WWW::Gazetteer API

acme on 2002-10-25T11:58:23

After a little work figuring out the simplest API, Philippe "BooK" Bruhat and I have a generic gazetteer API: WWW::Gazetteer. It's a factory class, so you need to install ::Calle or ::HeavensAbove, but is dead easy to use. The following code uses both modules:

#!/usr/bin/perl -w

use strict;
use WWW::Gazetteer;
use YAML;

my $g1 = WWW::Gazetteer->new('calle');
my $g2 = WWW::Gazetteer->new('heavensabove');
print Dump($g1->find("Bath", "GB"));
print Dump($g2->find("Bath", "GB"));
and it prints out:
--- #YAML:1.0
city: Bath
country: GB
elevation: 132
latitude: 51.3833
longitude: -2.3500
--- #YAML:1.0
alias: ''
elevation: 74
latitude: 51.378
longitude: -2.366
name: Bath
region: Avon
regionname: county

Now how many subclasses are we going to have? ;-)

PS: Don't use this for navigation!


Avon?

2shortplanks on 2002-10-25T12:21:58

Oh well, the quality of the data is not really your fault ;-)

Nicely done.