OpenStreetMap

Usage: perl relhistory.pl

content of file relhistory.pl:

use strict;

use LWP::Simple;

my $rel = get "http://www.openstreetmap.org/browse/relation/$ARGV[0]/history";
my %hist;
my %user;
while ($rel =~ m#\s*Edited by:\s*<a href="/user/.*?">(.*?)\s*\s*\s*Version:\s*(.*?)\s*.*?Members:\s*(.*?).*?<hr />#smg) {
my ($user, $v, $html) = ($1, $2, $3);
$user{$v} = $user;
while ($html =~ m#(.*?)(.*?)#smg) {
$hist{$v}->{$1} = $2;
$hist{$v}->{$1} =~ s/^ as //;
}
}

foreach my $v (sort {$b <=> $a} keys %hist) {
print "v=$v user=$user{$v}\n";
foreach my $e (sort keys %{$hist{$v}}) {
my $st = " ";
my $st2;
if (exists $hist{$v-1}->{$e}) {
if ($hist{$v}->{$e} ne $hist{$v-1}->{$e}) {
$st = "*";
$st2 = " was role $hist{$v-1}->{$e} now is $hist{$v}->{$e}";
}
} else {
$st = "+";
}
print "$st $e$st2\n";
}
foreach my $e (sort keys %{$hist{$v-1}}) {
print "- $e\n" if not exists $hist{$v}->{$e};
}
print "\n";
}

Discussion

Log in to leave a comment