/
map.xml.pl
executable file
·58 lines (44 loc) · 1.22 KB
/
map.xml.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/perl
# Read perl_mongers.xml and generate map.xml, which is much smaller and simpler.
# Where should this script live?
# -jhannah Jan 29, 2006
use strict;
use warnings;
use FindBin qw($Bin);
use XML::Twig;
open (OUT, ">$Bin/../www/groups/map.xml");
my $twig=XML::Twig->new(
twig_handlers =>
{ group => \&group }
);
print OUT <<EOT;
<?xml version="1.0" encoding="ISO-8859-1"?><markers>
EOT
$twig->parsefile("$Bin/../perl_mongers.xml");
print OUT <<EOT;
</markers>
EOT
close OUT;
sub group {
my ($twig, $group) = @_;
my $id = $group->{'att'}->{'id'};
my $status = $group->{'att'}->{'status'} || '';
my $name = $group->first_child('name');
my $web = $group->first_child('web');
my $location = $group->first_child('location') || return undef;
my $lat = $location->first_child('latitude');
my $long = $location->first_child('longitude');
$name = $name->text if $name;
$lat = $lat->text if $lat;
$long = $long->text if $long;
$web = $web->text if $web;
return unless ($status eq "active" and $lat and $long);
#print "$id $name $web $lat $long\n";
print OUT <<EOT
<marker lat="$lat"
lng="$long"
name="$name"
web="$web"
/>
EOT
}