WWW::Gazetteer::HeavensAbove

Find location of world towns and cities
Download

WWW::Gazetteer::HeavensAbove Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Philippe Bruhat
  • Publisher web site:
  • http://search.cpan.org/~book/

WWW::Gazetteer::HeavensAbove Tags


WWW::Gazetteer::HeavensAbove Description

Find location of world towns and cities A gazetteer is a geographical dictionary (as at the back of an atlas). The WWW::Gazetteer::HeavensAbove Perl module uses the information athttp://www.heavens-above.com/countries.asp to return geographical location (longitude, latitude, elevation) for towns and cities in countries in the world.Once a WWW::Gazetteer::HeavensAbove objects is created, use the find() method to return lists of hashrefs holding all the information for the matching cities.A city tructure looks like this: $lesparis = { iso => 'FR', latitude => '45.633', regionname => 'Region', region => 'Rhône-Alpes', alias => 'Les Paris', elevation => '508', # meters longitude => '5.733', name => 'Paris', };Note: the 'regioname' attribute is the local name of a region (this can change from country to country).Due to the way heavens-above.com's database was created, cities from the U.S.A. are handled as a special case. The region field is the state, and a special field named county holds the county name.Here is an example of an American city: $newyork = { iso => 'US', latitude => '39.685', regionname => 'State', region => 'Missouri', county => 'Caldwell', # this is only for US cities alias => '', elevation => '244', longitude => '-93.927', name => 'New York' };SYNOPSIS use WWW::Gazetteer::HeavensAbove; my $atlas = WWW::Gazetteer::HeavensAbove->new; # simple query using ISO 3166 codes my @towns = $atlas->find( 'Bacton', 'GB' ); print $_->{name}, ", ", $_->{elevation}, $/ for @towns; # simple query using heavens-above.com codes my @towns = $atlas->query( 'Bacton', 'UK' ); print $_->{name}, ", ", $_->{elevation}, $/ for @towns; # big queries can use a callback (and return nothing) $atlas->find( 'Bacton', 'GB', sub { print $_->{name}, ", ", $_->{elevation}, $/ for @_ } ); # find() returns an arrayref in scalar context $cities = $atlas->find( 'Paris', 'FR' ); print $cities->{name}; # the heavens-above.com site supports complicated queries my @az = $atlas->find( 'a*z', 'FR' ); # and you can naturally use callbacks for those! my ($c, n); $atlas->find( 'N*', 'US', sub { $c++; $n += @_ } ); print "$c web requests needed for finding $n cities"; # or use your own UserAgent my $ua = LWP::UserAgent->new; $atlas = WWW::Gazetteer::HeavensAbove->new( ua => $ua ); # another way to create a new object use WWW::Gazetteer; my $g = WWW::Gazetteer->new('HeavensAbove'); Requirements: · Perl


WWW::Gazetteer::HeavensAbove Related Software