Stories
Slash Boxes
Comments

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

acme (189)

acme
  (email not shown publicly)
http://www.astray.com/

Leon Brocard (aka acme) is an orange-loving Perl eurohacker with many varied contributions to the Perl community, including the GraphViz module on the CPAN. YAPC::Europe was all his fault. He is still looking for a Perl Monger group he can start which begins with the letter 'D'.

Journal of acme (189)

Sunday September 29, 2002
08:46 AM

WWW::Gazetteer

[ #8079 ]
To help me get location information for the Perl Monger groups I hacked up WWW::Gazetteer this morning, and it's on CPAN now...

NAME
    WWW::Gazetteer - Find location of world towns and cities

SYNOPSYS
      use WWW::Gazetteer;
      my $g = WWW::Gazetteer->new();
      my $london = $g->fetch("London", "United Kingdom");
      print $london->{longitude}, ", ", $london->{latitude}, "\n";
      my $nice = $g->fetch("Nice", "France");
      my @bactons = $g->fetch("Bacton", "United Kingdom");
      # note: more than one Bacton in the UK!

DESCRIPTION
    A gazetteer is a geographical dictionary (as at the back of an atlas).
    The `WWW::Gazetteer' module uses the information at
    http://www.calle.com/world/ to return geographical location (longitude,
    latitude) for towns and cities in countries in the world.

    Once you have imported the module and created a gazetteer object,
    calling fetch($town, $country) will return a list of hashrefs with
    longitude and latitude information.

      my $london = $g->fetch("London", "United Kingdom");
      print $london->{longitude}, ", ", $london->{latitude}, "\n";
      # prints -0.1167, 51.5000

    Note that there may be more than one town or city with that name in the
    country. In that case, you will get a list of hashrefs for each
    town/city.

    The following countries are valid: ...

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I noticed a distinct lack of the US among the available cities list. (presumably because the nima.mil isn't supplying the info?) Do you have a hybrid solution for also getting lat/longs for US cities?

    thanks
    kellan
  • Here's another database, that has lots of cities and aliases, with longitude, latitude and elevation: http://www.heavens-above.com/countries.asp [heavens-above.com].

    I've built a script that sucks the whole database (it was the subject of one of my lightning talks in Munich), but maybe it could be turned into a module, too. Is there room for this in the WWW::Gazetteer namespace?

    • Ah cool, I knew there was something like that. The Calle database also has elevation, it's just that I didn't find it useful ;-) Well, maybe we need a WWW::Gazetteer::Calle and a WWW::Gazetteer::HeavensAbove. What do you think?
      • Well, my script still needs to implement the optimisations I talked about in Munich... But if you provide a generic WWW::Gazetteer API, I can make WWW::Gazetteer::HeavensAbove follow it.

        If the module doesn't have to fetch the results of a request like "a*", and work around the 200+ answers limitation, that should be quick and easy (provided I find enough spare time to do it, obviously).

      • The Calle database also has elevation, it's just that I didn't find it useful ;-)

        Elevation is useful, if you want to produce a proper ICBM block [tuxedo.org] for each perl monger group.

        I'm not sure who this would be useful for - it seems that we know Saddam Hussein's favourite brand of chocolate (Quality Street [bbc.co.uk]) and computer manufacture (Sun [theregister.co.uk]) - but do we have any idea what his favourite programming language is, and hence if we should be afraid?