A gazetteer is a geographical dictionary (as at the back of an atlas). The WWW::Gazetteer::Getty module uses the information at http://www.getty.edu/research/conducting_research/vocabularies/tgn/ to return geographical location (longitude, latitude) for towns and cities in countries in the world.
WWW::Gazetteer::Getty is a subclass of WWW::Gazetteer, so you must use that to create a WWW::Gazetteer::Getty object. Once you have imported the module and created a gazetteer object, calling find($country => $town) will return a list of hashrefs with longitude and latitude information.
my @londons = $g->find('London', 'UK');
my $london = $londons[0];
print $london->{longitude}, ", ", $london->{latitude}, "
";
# prints -0.1167, 51.5000
The hashref for London actually looks like this:
$london = {
longitude => "-0.167",
latitude => "51.500",
city => 'London',
country => 'United Kingdom',
};
The city and country values are the same as the ones you used. The longitude and latitude are in degrees, ranging from -180 to 180 where (0, 0) is on the Prime Meridian and the equator.
SYNOPSYS
use WWW::Gazetteer;
my $g = WWW::Gazetteer::Getty->new('getty');
my @londons = $g->find('London', 'UK');
my $london = $londons[0];
print $london->{longitude}, ", ", $london->{latitude}, "
";
my $nice = $g->find("Nice", "France")->[0];
print $nice->{city}, ", ", $nice->{elevation}, "
";
Product's homepage
Requirements:
· Perl