
Set Up an OpenGuide for Your Hometown #97
Chapter 9, Mapping with Other People
|
495
HACK
my $rdf = get('http://london.openguides.org/index.
cgi?action=index&format=rdf');
$rdf =~ tr/\240/\040/; # XML-toxic characters
my @triples = $parser->parse_rdf($rdf);
# find all triples where the subject is of rdf:type geo:SpatialThing
my @spaces = grep {$_->[2] =~ /SpatialThing/} @triples;
my @points; # an empty list to hold our points
foreach my $s (@spaces) {
my $url = $s->[0]; # get the subject url of the triple
warn("reading $url");
my @t = $parser->parse_uri($url);
my ($lat) = grep {$_->[1] =~ /wgs84_pos\#lat/} @t;
next unless $lat; # don't bother if we can't find a latitude
next if $lat =~ m/0d/ or $lat !~ m/51/; # we know these are wrong
my ($lon) = grep {$_->[1] =~ /wgs84_pos\#long/} @t;
if ($lat =~ m/\d+d \d+m/) {
# this point is in DMS, not decimal, format
foreach ($lat,$lon) {
my ($direction,$d,$m,$s) = $_ =~ /(-?)([\d]+)d (\d+)m ([\d\.]+)s/;
$_ = $d + $m/60 + $s/3600;
$_ = 0-$_ if $direction;
}
}
push @points, { lat => $lat, long => $lon, url => $url};
}
Plotting Places over Open Space
Now that we have a list of points, we’re ready to roll! What we can do with
them, though, depends on where in the world we are. In London, bereft of
copyright-free, public domain base maps, the first visualization of Open-
Guides was just a plot of points on a blank white background.
The
SVG::Plot module, available ...