NAME
Geo::Coder::Many::Util
DESCRIPTION
Miscellaneous routines that are convenient for, for example, generating commonly used callback methods to be used with Geo::Coder::Many.
SUBROUTINES
min_precision_filter
Constructs a result filter callback which only passes results which exceed the specified precision.
country_filter
Constructs a result filter callback which only passes results with the specified 'country' value.
max_precision_picker
A picker callback that requests all available results, and then picks the one with the highest precision. Note that querying all available geocoders may take a comparatively long time.
Example:
$geo_multiple->set_picker_callback( \&max_precision_picker );
consensus_picker
Returns a picker callback that requires at least 'required_consensus' separate geocoder results to be within a bounding square of side-length 'nearness'. If this can be satisfied, the result from that square which has the highest precision will be returned. Otherwise, asks for more/returns undef.
WARNING: quadratic time in length of @$ra_results - could be improved if necessary.
Example:
$geo_multiple->set_picker_callback( &consensus_picker({nearness => 0.1, required_consensus => 2}) );
INTERNAL ROUTINES
_in_box
Used by consensus_picker - returns true iff ($lat, $lon) is inside the square with centre ($centre_lat, $centre_lon) and side length 2*$half_width.
_find_max_precision
Given a reference to an array of result hashes, returns the one with the highest precision value