More intelligent searches in Geo::Coder::Free - part 2

Being lazy, I thought to myself, "when using the web interface, why should I need to add my country to the query?". So, using CGI::Lingua which is already available via the VWF system used to build the site, you longer need to do that. From the US, try this:

curl 'https://geocode.nigelhorne.com/cgi-bin/page.fcgi?page=query&q=Rock+Bottom,+Bethesda,+MD'

With VWF it was a minor change:

$rc = $geocoder->geocode(location => $q);

if(!defined($rc)) {

if(my $country = $self->{_lingua}->country()) {

$rc = $geocoder->geocode(location => "$q, $country");

}

return '{}' if(!defined($rc));

}

Leave a comment

About Nigel Horne

user-pic I blog about my projects.