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: ...
Re:and US cities?
acme on 2002-10-03T06:43:58
Yes, I noticed that too. I put it down to the US not being very important... Oh, okay then: patches welcome;-) Re:and US cities?
jhi on 2002-10-03T17:24:13
The US info is available from the US Census Bureau website either as a database or a query form.
Here's another database, that has lots of cities and aliases, with longitude, latitude and elevation: http://www.heavens-above.com/countries.asp.
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?
Re:Another database of geographical data
acme on 2002-10-08T08:36:06
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? Re:Another database of geographical data
BooK on 2002-10-08T09:54:30
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).
Re:Another database of geographical data
nicholas on 2002-10-11T11:16:48
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 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) and computer manufacture (Sun) - but do we have any idea what his favourite programming language is, and hence if we should be afraid?