Routino SVN Repository Browser

Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino

ViewVC logotype

Contents of /trunk/web/bin/summarise-log.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1231 - (show annotations) (download) (as text)
Thu Dec 27 14:00:23 2012 UTC (12 years, 2 months ago) by amb
File MIME type: text/x-perl
File size: 8091 byte(s)
Don't append segments if they are duplicates within a way or have duplicated
nodes.  Log errors for middle nodes that repeat within a way (can be non-trivial
unintentional loops).

1 #!/usr/bin/perl
2
3 $verbose=0;
4 $verbose=1 if($#ARGV==0 && $ARGV[0] eq "-v");
5
6 $html=0;
7 $html=1 if($#ARGV==0 && $ARGV[0] eq "-html");
8
9 die "Usage: $0 [-v | -html] < <error-log-file>\n" if($#ARGV>0 || ($#ARGV==0 && !$verbose && !$html));
10
11
12 # Read in each line from the error log and store them
13
14 %errors=();
15 %errorids=();
16 %errortypes=();
17
18 while(<STDIN>)
19 {
20 s%\r*\n%%;
21
22 undef $errorid;
23
24 if(m%nodes ([0-9]+) and ([0-9]+) in way ([0-9]+)%i) # Special case pair of nodes and a way
25 {
26 $errorid="($1 $2 $3)";
27 $errortype="N2W";
28 s%nodes [0-9]+ and [0-9]+ in way [0-9]+%nodes <node-id1> and <node-id2> in way <way-id>%;
29 }
30
31 elsif(m%node ([0-9]+) in way ([0-9]+)%i) # Special case node and a way
32 {
33 $errorid="($1 $2)";
34 $errortype="NW";
35 s%Node [0-9]+ in way [0-9]+%Node <node-id> in way <way-id>%;
36 }
37
38 elsif(m%nodes ([0-9]+) and ([0-9]+)%i) # Special case pair of nodes
39 {
40 $errorid="($1 $2)";
41 $errortype="N2";
42 s%nodes [0-9]+ and [0-9]+%nodes <node-id1> and <node-id2>%;
43 }
44
45 elsif(m%Segment (contains|connects) node ([0-9]+)%) # Special case node
46 {
47 $errorid=$2;
48 $errortype="N";
49 s%node [0-9]+%node <node-id>%;
50 }
51
52 elsif(m%Relation ([0-9]+).* contains Node ([0-9]+)%) # Special case relation/node
53 {
54 $errorid="($1 $2)";
55 $errortype="RN";
56 s%Relation [0-9]+%Relation <relation-id>%;
57 s%Node [0-9]+%node <node-id>%;
58 }
59
60 elsif(m%Relation ([0-9]+).* contains Way ([0-9]+)%) # Generic case relation/way
61 {
62 $errorid="($1 $2)";
63 $errortype="RW";
64 s%Relation [0-9]+%Relation <relation-id>%;
65 s%Way [0-9]+%way <way-id>%;
66 }
67
68 elsif(!m%Way ([0-9]+)% && !m%Relation ([0-9]+)% && m%Node ([0-9]+)%) # Generic node
69 {
70 $errorid=$1;
71 $errortype="N";
72 s%Node [0-9]+%Node <node-id>%;
73 }
74
75 elsif(!m%Node ([0-9]+)% && !m%Relation ([0-9]+)% && m%Way ([0-9]+)%) # Generic way
76 {
77 $errorid=$1;
78 $errortype="W";
79 s%Way [0-9]+%Way <way-id>%;
80 }
81
82 elsif(!m%Node ([0-9]+)% && !m%Way ([0-9]+)% && m%Relation ([0-9]+)%) # Generic relation
83 {
84 $errorid=$1;
85 $errortype="R";
86 s%Relation [0-9]+%Relation <relation-id>%;
87 }
88
89 else
90 {
91 $errorid="ERROR";
92 $errortype="E";
93 warn "Unrecognised error message '$_'\n";
94 }
95
96 $errors{$_}++;
97
98 if($verbose || $html)
99 {
100 if(defined $errorids{$_})
101 {
102 $errorids{$_}.=",$errorid";
103 }
104 else
105 {
106 $errorids{$_}="$errorid";
107 }
108 }
109
110 if($html)
111 {
112 $errortypes{$_}=$errortype;
113 }
114 }
115
116
117 # Print out the results as text
118
119 if( ! $html )
120 {
121
122 foreach $error (sort { if ( $errors{$b} == $errors{$a} ) { return $errorids{$a} cmp $errorids{$b} }
123 else { return $errors{$b} <=> $errors{$a} } } (keys %errors))
124 {
125 printf "%9d : $error\n",$errors{$error};
126
127 if($verbose && defined $errorids{$error})
128 {
129 print " $errorids{$error}\n";
130 }
131 }
132
133 }
134
135 # Print out the results as HTML
136
137 else
138 {
139
140 print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n".
141 "<HTML>\n".
142 "\n".
143 "<HEAD>\n".
144 "<TITLE>Routino Error Log File Summary</TITLE>\n".
145 "<META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n".
146 "<STYLE type=\"text/css\">\n".
147 "<!--\n".
148 " body {font-family: sans-serif; font-size: 12px;}\n".
149 " h1 {font-family: sans-serif; font-size: 14px; font-style: bold;}\n".
150 " h2 {font-family: sans-serif; font-size: 13px; font-style: bold;}\n".
151 " h3 {font-family: sans-serif; font-size: 12px; font-style: bold;}\n".
152 "-->\n".
153 "</STYLE>\n".
154 "</HEAD>\n".
155 "\n".
156 "<BODY>\n".
157 "\n".
158 "<h1>Routino Error Log File Summary</h1>\n".
159 "\n".
160 "This HTML file contains a summary of the Routino OSM parser error log file with\n".
161 "links to the OSM website that allow browsing each of the nodes, ways or relations\n".
162 "that are responsible for the error messages.\n".
163 "\n";
164
165 %errortypeorder=(
166 "N" , 1,
167 "NW" , 2,
168 "N2W" , 3,
169 "N2" , 4,
170 "W" , 5,
171 "R" , 6,
172 "RN" , 7,
173 "RW" , 8,
174 "E" , 9
175 );
176
177 %errortypelabel=(
178 "N" , "Nodes",
179 "NW" , "Node in a Way",
180 "N2W" , "Node Pairs in a Way",
181 "N2" , "Node Pairs",
182 "W" , "Ways",
183 "R" , "Relations",
184 "RN" , "Relations/Nodes",
185 "RW" , "Relations/Ways",
186 "E" , "ERROR"
187 );
188
189 $lasterrortype="";
190
191 foreach $error (sort { if ( $errortypes{$b} ne $errortypes{$a} ) { return $errortypeorder{$errortypes{$a}} <=> $errortypeorder{$errortypes{$b}} }
192 elsif ( $errors{$b} == $errors{$a} ) { return $errorids{$a} cmp $errorids{$b} }
193 else { return $errors{$b} <=> $errors{$a} } } (keys %errors))
194 {
195 $errorhtml=$error;
196
197 $errorhtml =~ s/&/&amp;/g;
198 $errorhtml =~ s/</&lt;/g;
199 $errorhtml =~ s/>/&gt;/g;
200
201 if($errortypes{$error} ne $lasterrortype)
202 {
203 print "<h2>$errortypelabel{$errortypes{$error}}</h2>\n";
204 $lasterrortype=$errortypes{$error};
205 }
206
207 print "<h3>$errorhtml</h3>\n";
208
209 if($errors{$error}>100)
210 {
211 print "$errors{$error} occurences (not listed).\n";
212 }
213 else
214 {
215 @ids=split(",",$errorids{$error});
216
217 $first=1;
218
219 foreach $id (@ids)
220 {
221 if($first)
222 {
223 print "$errortypelabel{$errortypes{$error}}:\n";
224 }
225 else
226 {
227 print ",";
228 }
229
230 $first=0;
231
232 print "<a href=\"http://www.openstreetmap.org/browse/node/$id\">$id</a>" if($errortypes{$error} eq "N");
233 print "<a href=\"http://www.openstreetmap.org/browse/way/$id\">$id</a>" if($errortypes{$error} eq "W");
234 print "<a href=\"http://www.openstreetmap.org/browse/relation/$id\">$id</a>" if($errortypes{$error} eq "R");
235
236 if($errortypes{$error} eq "NW" || $errortypes{$error} eq "N2" || $errortypes{$error} eq "RN" || $errortypes{$error} eq "RW")
237 {
238 $id =~ m%\(([0-9]+) ([0-9]+)\)%;
239 print "(<a href=\"http://www.openstreetmap.org/browse/node/$1\">$1</a> <a href=\"http://www.openstreetmap.org/browse/way/$2\">$2</a>)" if($errortypes{$error} eq "NW");
240 print "(<a href=\"http://www.openstreetmap.org/browse/node/$1\">$1</a> <a href=\"http://www.openstreetmap.org/browse/node/$2\">$2</a>)" if($errortypes{$error} eq "N2");
241 print "(<a href=\"http://www.openstreetmap.org/browse/relation/$1\">$1</a> <a href=\"http://www.openstreetmap.org/browse/node/$2\">$2</a>)" if($errortypes{$error} eq "RN");
242 print "(<a href=\"http://www.openstreetmap.org/browse/relation/$1\">$1</a> <a href=\"http://www.openstreetmap.org/browse/way/$2\">$2</a>)" if($errortypes{$error} eq "RW");
243 }
244
245 if($errortypes{$error} eq "N2W")
246 {
247 $id =~ m%\(([0-9]+) ([0-9]+) ([0-9]+)\)%;
248 print "(<a href=\"http://www.openstreetmap.org/browse/node/$1\">$1</a> <a href=\"http://www.openstreetmap.org/browse/node/$2\">$2</a> <a href=\"http://www.openstreetmap.org/browse/way/$3\">$3</a>)" if($errortypes{$error} eq "N2W");
249 }
250
251 print "\n";
252 }
253 }
254 }
255
256 print "\n".
257 "</BODY>\n".
258 "\n".
259 "</HTML>\n";
260
261 }

Properties

Name Value
svn:executable *