Geo::Coder::List - Call many geocoders
Version 0.19
Geo::Coder::All and Geo::Coder::Many are great routines but neither quite does what I want. This module's primary use is to allow many backends to be used by HTML::GoogleMaps::V3
Creates a Geo::Coder::List object.
Add an encoder to list of encoders.
use Geo::Coder::List; use Geo::Coder::GooglePlaces; # ... my $list = Geo::Coder::List->new()->push(Geo::Coder::GooglePlaces->new());
Different encoders can be preferred for different locations. For example this code uses geocode.ca for Canada and US addresses, and OpenStreetMap for other places:
my $geocoderlist = Geo::Coder::List->new() ->push({ regex => qr/(Canada|USA|United States)$/, geocoder => new_ok('Geo::Coder::CA') }) ->push(new_ok('Geo::Coder::OSM')); # Uses Geo::Coder::CA, and if that fails uses Geo::Coder::OSM my $location = $geocoderlist->geocode(location => '1600 Pennsylvania Ave NW, Washington DC, USA'); # Only uses Geo::Coder::OSM if($location = $geocoderlist->geocode('10 Downing St, London, UK')) { print 'The prime minister lives at co-ordinates ', $location->{geometry}{location}{lat}, ',', $location->{geometry}{location}{lng}, "\n"; }
Runs geocode on all of the loaded drivers. See Geo::Coder::GooglePlaces::V3 for an explanation
The name of the geocoder that gave the result is put into the geocode element of the return value, if the value was retrieved from the cache the value will be undefined.
if(defined($location->{'geocoder'})) { print 'Location information retrieved using ', $location->{'geocoder'}, "\n"; }
Accessor method to set the UserAgent object used internally by each of the geocoders. You can call env_proxy for example, to get the proxy information from environment variables:
my $geocoderlist = Geo::Coder::List->new(); my $ua = LWP::UserAgent->new(); $ua->env_proxy(1); $geocoderlist->ua($ua);
Note that unlike Geo::Coders, there is no read method, since that would be pointless.
Returns the log of events to help you debug failures, optimize lookup order and fix quota breakage
my @log = @{$geocoderlist->log()};
Clear the log.
Nigel Horne, <njh at bandsman.co.uk>
<njh at bandsman.co.uk>
Please report any bugs or feature requests to bug-geo-coder-list at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Geo-Coder-List. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-geo-coder-list at rt.cpan.org
There is no reverse_geocode() yet.
Geo::Coder::Many Geo::Coder::All Geo::Coder::GooglePlaces
You can find documentation for this module with the perldoc command.
perldoc Geo::Coder::List
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Geo-Coder-List
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Geo-Coder-List
CPAN Ratings
http://cpanratings.perl.org/d/Geo-Coder-List
Search CPAN
http://search.cpan.org/dist/Geo-Coder-List/
Copyright 2016-2018 Nigel Horne.
This program is released under the following licence: GPL
To install Geo::Coder::List, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Geo::Coder::List
CPAN shell
perl -MCPAN -e shell install Geo::Coder::List
For more information on module installation, please visit the detailed CPAN module installation guide.