-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfindnames2.pl
75 lines (61 loc) · 1.1 KB
/
findnames2.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use strict;
use warnings;
use Data::Dumper;
# temp variables
my %f;
my %seen;
sub process {
my $d="";
my $url="";
my $mode ='';
while (<>) {
chomp;
if (/<modify>/){$mode="m";}
if (/<delete>/){$mode="d";}
if (/<create>/){$mode="c";}
if ($mode eq 'c' || $mode eq 'm') {
if (/\s+<(way|node|relation) id=\"(\d+)\"/)
{
$url = "https://www.openstreetmap.org/$1/$2";
$d=$_;
}
if (/k=\"name\"\s+v=\"(.+)\"/) {
my $name =$1;
for my $c (split(//,$name)) {
my $a = ord($c);
if ($a > 127 ) {
push @{$f{$a}},[$url, $d, $_];
#print $c, ord($c);
#print $d;
}
}
}
}
}
}
sub report {
print "<html>";
foreach my $name2 (sort keys %seen) {
my $u = $seen{$name2};
print "<p>$name2\t$u</p>\n";
}
print "</html>";
}
sub prepare {
for my $x (keys %f)
{
my $v = $f{$x};
for my $z (@{$v}) {
my $url = $z->[0];
my $node = $z->[1];
my $name = $z->[2];
if ($name =~/v=\"(.+)\"/) {
$name = $1;
}
$seen{$name}=$url;
}
};
};
process();
prepare();
report();