Geo::Coder::Postcodes - Provides a geocoding functionality using https://postcodes.io.
Version 0.01
use Geo::Coder::Postcodes; my $geocoder = Geo::Coder::Postcodes->new(); my $location = $geocoder->geocode(location => 'Margate');
Geo::Coder::Postcodes provides an interface to postcodes.io, a free geocode database covering the towns in the UK.
$geocoder = Geo::Coder::Postcodes->new(); my $ua = LWP::UserAgent->new(); $ua->env_proxy(1); $geocoder = Geo::Coder::Postcodes->new(ua => $ua);
$location = $geocoder->geocode(location => $location); print 'Latitude: ', $location->{'latitude'}, "\n"; print 'Longitude: ', $location->{'logitude'}, "\n";
Accessor method to get and set UserAgent object used internally. You can call env_proxy for example, to get the proxy information from environment variables:
$geocoder->ua()->env_proxy(1);
You can also set your own User-Agent object:
use LWP::UserAgent::Throttled; $geocoder->ua(LWP::UserAgent::Throttled->new());
$location = $geocoder->reverse_geocode(latlng => '37.778907,-122.39732');
Similar to geocode except it expects a latitude/longitude parameter.
Note that this most only works on towns and cities, some searches such as "Margate, Kent, UK" may work, but you're best to search only for "Margate".
Looking for "Sheffield, South Yorkshire, UK" matches "Sheffield Green, East Sussex, UK", because it currently only uses the first result - it doesn't iterate through them all yet.
Nigel Horne <njh@bandsman.co.uk>
Based on Geo::Coder::Coder::Googleplaces.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Lots of thanks to the folks at postcodes.io.
Geo::Coder::GooglePlaces, HTML::GoogleMaps::V3
Copyright 2017 Nigel Horne.
This program is released under the following licence: GPL2
To install Geo::Coder::Postcodes, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Geo::Coder::Postcodes
CPAN shell
perl -MCPAN -e shell install Geo::Coder::Postcodes
For more information on module installation, please visit the detailed CPAN module installation guide.