The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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:

$GCMU->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:

$GCMU->set_picker_callback( consensus_picker({nearness => 0.1, required_consensus => 2}) );

determine_precision_from_bbox

    my $precision = Geo::Coder::Many::Util->determine_precision_from_bbox({
                       'lon1' => $sw_lon,
                       'lat1' => $sw_lat,
                       'lon2' => $ne_lon,
                       'lat2' => $ne_lat,
                    });

returns a precison between 0 (unknown) and 1 (highly precise) based on the size of the box supplied

INTERNAL ROUTINES

_in_box

Used by consensus_picker - returns true if ($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