source: josm/trunk/resources/data/validator/numeric.mapcss

Last change on this file was 19453, checked in by stoecker, 12 days ago

Improve validator for level tag (patch by tordanik), fix #22427

  • Property svn:eol-style set to native
File size: 32.2 KB
Line 
1/* measurement values and units warnings (tickets #8687, #15719) */
2
3*[/^[0-9]+$/] {
4 throwWarning: tr("numerical key");
5 assertMatch: "way 123=foo";
6 assertNoMatch: "way ref.1=foo";
7}
8
9*[layer =~ /^\+\d/] {
10 throwWarning: tr("{0} value with + sign", "{0.key}");
11 fixAdd: concat("layer=", replace(tag("layer"), "+", ""));
12 assertMatch: "node layer=+1";
13 assertNoMatch: "node layer=1";
14 assertNoMatch: "node layer=-1";
15 assertNoMatch: "node layer=+foo";
16}
17
18*[layer][layer !~ /^0$|^(-|\+)?[1-5]$/] {
19 throwWarning: tr("{0} should be an integer value between -5 and 5", "{0.key}");
20 assertMatch: "node layer=-50";
21 assertMatch: "node layer=6";
22 assertMatch: "node layer=+10";
23 assertMatch: "node layer=0.5";
24 assertMatch: "node layer=0;1";
25 assertNoMatch: "node layer=-5";
26 assertNoMatch: "node layer=0";
27 assertNoMatch: "node layer=2";
28 assertNoMatch: "node layer=+5"; /* this is an invalid value, but this case is already covered by the previous rule */
29}
30
31/* negative values, #21026 */
32*[building:levels^="-"] {
33 throwError: tr("negative {0} value", "{0.key}");
34 set negative_value;
35 assertMatch: "node building:levels=-1";
36 assertNoMatch: "node building:levels=+1";
37 assertNoMatch: "node building:levels=1";
38 assertNoMatch: "node building:levels=foo";
39 assertMatch: "node building:levels=-foo";
40 assertNoMatch: "node level=-1";
41}
42*[building:levels][building:levels !~ /^(([0-9]|[1-9][0-9]*)(\.5)?)$/]!.negative_value {
43 throwWarning: tr("{0} should have numbers only with optional .5 increments", "{0.key}");
44 assertNoMatch: "node building:levels=1.5";
45 assertNoMatch: "node building:levels=-1"; /* excluded here via !.negative_value in selector */
46 assertMatch: "node building:levels=1A";
47 assertNoMatch: "node building:levels=0"; /* valid because there can be building:levels:underground > 0 or roof:levels > 0 */
48}
49
50/* level values: all numbers from -∞ to ∞ in 0.5 steps, optional multiple values separated by a ;, optional second value separated by a - */
51*[level][level !~ /^((((-?[1-9]|[0-9])|-?[1-9][0-9]*)(\.5)?)|-0\.5)(?:(;((((-?[1-9]|[0-9])|-?[1-9][0-9]*)(\.5)?)|-0\.5))*|(-((((-?[1-9]|[0-9])|-?[1-9][0-9]*)(\.5)?)|-0\.5)))$/] {
52 throwWarning: tr("{0} should have numbers only with optional .5 increments", "{0.key}");
53 assertMatch: "node level=one";
54 assertMatch: "node level=01";
55 assertMatch: "node level=-03";
56 assertMatch: "node level=-01.5";
57 assertMatch: "node level=2.3";
58 assertMatch: "node level=-0";
59 assertMatch: "node level=1-2-3";
60 assertMatch: "way level=--5";
61 assertMatch: "way level=--5-4";
62 assertMatch: "way level=-5---4";
63 assertNoMatch: "node level=0";
64 assertNoMatch: "node level=1";
65 assertNoMatch: "node level=-1";
66 assertNoMatch: "node level=-0.5";
67 assertNoMatch: "node level=1.5";
68 assertNoMatch: "node level=12";
69 assertNoMatch: "node level=0;1";
70 assertNoMatch: "node level=1;1.5";
71 assertNoMatch: "node level=1;0.5";
72 assertNoMatch: "node level=0;-0.5";
73 assertNoMatch: "node level=-0.5;0";
74 assertNoMatch: "node level=-1;-0.5";
75 assertNoMatch: "node level=0-3";
76 assertNoMatch: "node level=-1-100";
77 assertNoMatch: "node level=-10--5";
78 assertNoMatch: "node level=0--1";
79}
80
81*[roof:height][siunit_length(tag("roof:height")) == 0][roof:shape=flat] {
82 throwWarning: tr("{0} is unnecessary for {1}", "{0.tag}", "{2.tag}");
83 group: tr("unnecessary tag");
84 fixRemove: "{0.key}";
85 set zero_roof_height_flat;
86 assertMatch: "node roof:height=0 roof:shape=flat";
87 assertMatch: "node roof:shape=flat roof:height=\"00.00000 ft\" roof:shape=flat";
88 assertNoMatch: "node roof:shape=flat roof:height=2 m roof:shape=flat";
89 assertNoMatch: "node roof:height=0 roof:shape=gabled";
90}
91
92/*********************
93 * Begin Unit checks *
94 *********************/
95/* See https://wiki.openstreetmap.org/wiki/Map_features/Units */
96/* 1. Replace aliases to make the rest of the checks easier to implement */
97/* Distance measurements, note that these should look also match `,` separators to ensure that at least one error is matched */
98/* Meters; Note that we cannot assertMatch "2 m" since we replace the double space with a single space */
99*[height][height =~ /^(?i)[0-9]+([.,][0-9]+)?( *(metres?|meters?)|m| {2,}m)$/],
100*[roof:height][roof:height =~ /^(?i)[0-9]+([.,][0-9]+)?( *(metres?|meters?)|m| {2,}m)$/]!.zero_roof_height_flat,
101*[width][width =~ /^(?i)[0-9]+([.,][0-9]+)?( *(metres?|meters?)|m| {2,}m)$/],
102*[maxwidth][maxwidth =~ /^(?i)[0-9]+([.,][0-9]+)?( *(metres?|meters?)|m| {2,}m)$/],
103*[min_height][min_height =~ /^(?i)-?[0-9]+([.,][0-9]+)?( *(metres?|meters?)|m| {2,}m)$/],
104*[maxheight][maxheight =~ /^(?i)[1-9][0-9]*([.,][0-9]+)?( *(metres?|meters?)|m| {2,}m)$/],
105*[maxlength][maxlength =~ /^(?i)[1-9][0-9]*([.,][0-9]+)?( *(metres?|meters?)|m| {2,}m)$/] {
106 set _unit_auto_fix;
107 throwWarning: tr("unusual value of {0}: use abbreviation for unit and space between value and unit", "{0.key}");
108 fixAdd: concat("{0.key}", "=", get(regexp_match("([0-9.,]+) *.+", "{0.value}"), 1), " m");
109 assertMatch: "node height=6.78 meters";
110 assertMatch: "node height=6,78 meters";
111 assertMatch: "node height=5 metre";
112 assertMatch: "node height=2m";
113 assertNoMatch: "node height=2 m";
114 assertNoMatch: "node height=5";
115 assertMatch: "node maxheight=6.78 meters";
116 assertMatch: "node maxheight=5 metre";
117 assertMatch: "node maxheight=2m";
118 assertNoMatch: "node maxheight=2 m";
119 assertNoMatch: "node maxheight=5";
120 assertMatch: "node roof:height=6.78 meters";
121 assertMatch: "node roof:height=5 metre";
122 assertMatch: "node roof:height=2m";
123 assertNoMatch: "node roof:height=2 m";
124 assertNoMatch: "node roof:height=5";
125 assertMatch: "node maxlength=6.78 meters";
126 assertMatch: "node maxlength=5 metre";
127 assertMatch: "node maxlength=2m";
128 assertNoMatch: "node maxlength=2 m";
129 assertNoMatch: "node maxlength=5";
130 assertMatch: "node width=6.78 meters";
131 assertMatch: "node width=5 metre";
132 assertMatch: "node width=2m";
133 assertNoMatch: "node width=2 m";
134 assertNoMatch: "node width=5";
135 assertMatch: "node maxwidth=6.78 meters";
136 assertMatch: "node maxwidth=5 metre";
137 assertMatch: "node maxwidth=2m";
138 assertNoMatch: "node maxwidth=2 m";
139 assertNoMatch: "node maxwidth=5";
140 assertMatch: "node min_height=6.78 meters";
141 assertMatch: "node min_height=5 metre";
142 assertMatch: "node min_height=2m";
143 assertNoMatch: "node min_height=2 m";
144 assertNoMatch: "node min_height=5";
145}
146
147/* Foot inches */
148*[height][height =~ /^(?i)[0-9]+([.,][0-9]+)?( *(foot|feet|ft)| +\')$/],
149*[maxheight][maxheight =~ /^(?i)[0-9]+([.,][0-9]+)?( *(foot|feet|ft)| +\')$/],
150*[roof:height][roof:height =~ /^(?i)[0-9]+([.,][0-9]+)?( *(foot|feet|ft)| +\')$/]!.zero_roof_height_flat,
151*[maxlength][maxlength =~ /^(?i)[0-9]+([.,][0-9]+)?( *(foot|feet|ft)| +\')$/],
152*[width][width =~ /^(?i)[0-9]+([.,][0-9]+)?( *(foot|feet|ft)| +\')$/],
153*[maxwidth][maxwidth =~ /^(?i)[0-9]+([.,][0-9]+)?( *(foot|feet|ft)| +\')$/] {
154 set _unit_auto_fix;
155 throwWarning: tr("unusual value of {0}: use '' for foot and \" for inches, no spaces", "{0.key}");
156 fixAdd: concat("{0.key}", "=", get(regexp_match("([0-9.,]+) *.+", "{0.value}"), 1), "'");
157 assertMatch: "node height=6.78 foot";
158 assertMatch: "node height=5 Feet";
159 assertMatch: "node height=2 '";
160 assertNoMatch: "node height=2'";
161 assertNoMatch: "node height=5";
162 assertMatch: "node maxheight=6.78 foot";
163 assertMatch: "node maxheight=5 Feet";
164 assertMatch: "node maxheight=2 '";
165 assertNoMatch: "node maxheight=2'";
166 assertNoMatch: "node maxheight=5";
167 assertMatch: "node roof:height=6.78 foot";
168 assertMatch: "node roof:height=5 Feet";
169 assertMatch: "node roof:height=2 '";
170 assertNoMatch: "node roof:height=2'";
171 assertNoMatch: "node roof:height=5";
172 assertMatch: "node maxlength=6.78 foot";
173 assertMatch: "node maxlength=5 Feet";
174 assertMatch: "node maxlength=2 '";
175 assertNoMatch: "node maxlength=2'";
176 assertNoMatch: "node maxlength=5";
177 assertMatch: "node width=6.78 foot";
178 assertMatch: "node width=5 Feet";
179 assertMatch: "node width=2 '";
180 assertNoMatch: "node width=2'";
181 assertNoMatch: "node width=5";
182 assertMatch: "node maxwidth=6.78 foot";
183 assertMatch: "node maxwidth=5 Feet";
184 assertMatch: "node maxwidth=2 '";
185 assertNoMatch: "node maxwidth=2'";
186 assertNoMatch: "node maxwidth=5";
187}
188
189/* 2. Convert `,` to `.` */
190*[height][height =~ /^[0-9]+,[0-9][0-9]?( m|\')?$/],
191*[maxheight][maxheight =~ /^[0-9]+,[0-9][0-9]?( m|\')?$/],
192*[roof:height][roof:height =~ /^[0-9]+,[0-9][0-9]?( m|\')?$/],
193*[maxlength][maxlength =~ /^[0-9]+,[0-9][0-9]?( m|\')?$/],
194*[width][width =~ /^[0-9]+,[0-9][0-9]?( m|\')?$/],
195*[maxwidth][maxwidth =~ /^[0-9]+,[0-9][0-9]?( m|\')?$/],
196*[min_height][min_height =~ /^-?[0-9]+,[0-9][0-9]?( m|\')?$/],
197*[maxaxleload][maxaxleload =~ /^[0-9]+,[0-9][0-9]?( (t|kg|st|lbs))?$/],
198*[maxweight][maxweight =~ /^[0-9]+,[0-9][0-9]?( (t|kg|st|lbs))?$/],
199*[distance][distance =~ /^[0-9]+,[0-9][0-9]?( (m|km|mi|nmi))?$/] {
200 set _unit_auto_fix;
201 throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
202 fixAdd: concat("{0.key}", "=", replace(tag("{0.key}"), ",", "."));
203 assertMatch: "node height=5,5";
204 assertMatch: "node height=12,00";
205 assertMatch: "node height=12,5'";
206 assertNoMatch: "node height=12,000";
207 assertNoMatch: "node height=3,50,5";
208 assertNoMatch: "node height=3.5";
209 assertNoMatch: "node height=4";
210 assertMatch: "node maxheight=5,5";
211 assertMatch: "node maxheight=12,00";
212 assertMatch: "node maxheight=12,5'";
213 assertNoMatch: "node maxheight=12,000";
214 assertNoMatch: "node maxheight=3,50,5";
215 assertNoMatch: "node maxheight=3.5";
216 assertNoMatch: "node maxheight=4";
217 assertMatch: "node roof:height=5,5";
218 assertMatch: "node roof:height=12,00";
219 assertMatch: "node roof:height=12,5'";
220 assertNoMatch: "node roof:height=12,000";
221 assertNoMatch: "node roof:height=3,50,5";
222 assertNoMatch: "node roof:height=3.5";
223 assertNoMatch: "node roof:height=4";
224 assertMatch: "node maxlength=5,5";
225 assertMatch: "node maxlength=12,00";
226 assertMatch: "node maxlength=12,5'";
227 assertNoMatch: "node maxlength=12,000";
228 assertNoMatch: "node maxlength=3,50,5";
229 assertNoMatch: "node maxlength=3.5";
230 assertNoMatch: "node maxlength=4";
231 assertMatch: "node width=5,5";
232 assertMatch: "node width=12,00";
233 assertNoMatch: "node width=12,000";
234 assertNoMatch: "node width=3,50,5";
235 assertNoMatch: "node width=3.5";
236 assertNoMatch: "node width=4";
237 assertMatch: "node maxwidth=5,5";
238 assertMatch: "node maxwidth=12,00";
239 assertNoMatch: "node maxwidth=12,000";
240 assertNoMatch: "node maxwidth=3,50,5";
241 assertNoMatch: "node maxwidth=3.5";
242 assertNoMatch: "node maxwidth=4";
243 assertMatch: "node min_height=5,5";
244 assertMatch: "node min_height=12,00";
245 assertMatch: "node min_height=12,5'";
246 assertNoMatch: "node min_height=12,000";
247 assertNoMatch: "node min_height=3,50,5";
248 assertNoMatch: "node min_height=3.5";
249 assertNoMatch: "node min_height=4";
250 assertMatch: "node maxaxleload=5,5";
251 assertMatch: "node maxaxleload=12,00";
252 assertNoMatch: "node maxaxleload=12,000";
253 assertNoMatch: "node maxaxleload=3,50,5";
254 assertNoMatch: "node maxaxleload=3.5";
255 assertNoMatch: "node maxaxleload=4";
256 assertMatch: "node maxweight=5,5";
257 assertMatch: "node maxweight=12,00";
258 assertNoMatch: "node maxweight=12,000";
259 assertNoMatch: "node maxweight=3,50,5";
260 assertNoMatch: "node maxweight=3.5";
261 assertNoMatch: "node maxweight=4";
262 assertMatch: "node distance=5,5";
263 assertMatch: "node distance=12,00";
264 assertNoMatch: "node distance=12,000";
265 assertNoMatch: "node distance=3,50,5";
266 assertNoMatch: "node distance=3.5";
267 assertNoMatch: "node distance=4";
268}
269/* 3. Convert to the default unit for usage later. Use the tag prefixed with _. */
270/* 4. Start doing comparison checks. */
271
272*[height ][height !~ /^(([0-9]+(\.[0-9]+)?( m)?)|([1-9][0-9]*\'((10|11|[0-9])((\.[0-9]+)?)\")?))$/]!._unit_auto_fix,
273*[maxheight ][maxheight !~ /^(([1-9][0-9]*(\.[0-9]+)?( m)?)|([0-9]+\'(([0-9]|10|11)(\.[0-9]*)?\")?)|none|default|below_default)$/]!._unit_auto_fix,
274*[min_height ][min_height !~ /^(-?([0-9]+(\.[0-9]+)?( m)?)|(-?[1-9][0-9]*\'((10|11|[0-9])((\.[0-9]+)?)\")?))$/]!._unit_auto_fix,
275*[roof:height][roof:height !~ /^(([0-9]+(\.[0-9]+)?( m)?)|([1-9][0-9]*\'((10|11|[0-9])((\.[0-9]+)?)\")?))$/]!.zero_roof_height_flat!._unit_auto_fix,
276*[maxlength ][maxlength !~ /^(([1-9][0-9]*(\.[0-9]+)?( m)?)|([0-9]+\'(([0-9]|10|11)(\.[0-9]*)?\")?)|none|default|below_default)$/]!._unit_auto_fix,
277*[width ][width !~ /^(([0-9]+(\.[0-9]+)?( m)?)|([0-9]+\'([0-9]+(\.[0-9]+)?\")?))$/]!._unit_auto_fix,
278*[maxwidth ][maxwidth !~ /^(([0-9]+(\.[0-9]+)?( m)?)|([0-9]+\'([0-9]+(\.[0-9]+)?\")?))$/]!._unit_auto_fix {
279 throwWarning: tr("unusual value of {0}: meters is default; only positive values; point is decimal separator; if units, put space then unit", "{0.key}");
280 assertMatch: "node height=medium";
281 assertMatch: "node maxheight=-5";
282 assertMatch: "node maxlength=0";
283 assertMatch: "node maxlength=10'13\"";
284 assertMatch: "node width=10'2.\"";
285 assertMatch: "node maxheight=\"2. m\"";
286 assertMatch: "node height=\"12. m\"";
287 assertNoMatch: "node height=6.78 m";
288 assertNoMatch: "node height=5 m";
289 assertNoMatch: "node height=2 m";
290 assertNoMatch: "node height=3";
291 assertNoMatch: "node height=2.22 m";
292 assertNoMatch: "node height=7.8";
293 assertMatch: "node min_height=\"12. m\"";
294 assertNoMatch: "node min_height=-5";
295 assertNoMatch: "node maxwidth=7'";
296 assertNoMatch: "node height=22'";
297 assertNoMatch: "node width=10'5\"";
298 assertNoMatch: "node width=10'";
299}
300
301*[maxaxleload][maxaxleload !~ /^([0-9]+(\.[0-9]+)?( (t|kg|st|lbs))?)$/],
302*[maxweight][maxweight !~ /^([0-9]+(\.[0-9]+)?( (t|kg|st|lbs))?)$/] {
303 throwWarning: tr("unusual value of {0}: {1} is default; only positive values; point is decimal separator; if units, put space then unit", "{0.key}", tr("tonne"));
304 assertMatch: "node maxaxleload=something";
305 assertMatch: "node maxweight=-5";
306 assertNoMatch: "node maxaxleload=2";
307 assertNoMatch: "node maxaxleload=2.5";
308 assertNoMatch: "node maxaxleload=7 kg";
309}
310
311way[maxspeed][maxspeed !~ /^(signals|none|unposted|variable|walk|[1-9][0-9]*( [a-z]+)?|[A-Z][A-Z]:(urban|rural|living_street|motorway))$/],
312way[maxspeed:forward][maxspeed:forward !~ /^(signals|none|unposted|variable|walk|[1-9][0-9]*( [a-z]+)?|[A-Z][A-Z]:(urban|rural|living_street|motorway))$/],
313way[maxspeed:backward][maxspeed:backward !~ /^(signals|none|unposted|variable|walk|[1-9][0-9]*( [a-z]+)?|[A-Z][A-Z]:(urban|rural|living_street|motorway))$/] {
314 throwWarning: tr("unusual value of {0}: {1} is default; only positive values; point is decimal separator; if units, put space then unit", "{0.key}", tr("km/h"));
315 assertMatch: "way maxspeed=something";
316 assertMatch: "way maxspeed=-50";
317 assertMatch: "way maxspeed=0";
318 assertNoMatch: "way maxspeed=50";
319 assertNoMatch: "way maxspeed=30 mph";
320 assertNoMatch: "way maxspeed=RO:urban";
321 assertNoMatch: "way maxspeed=RU:rural";
322 assertNoMatch: "way maxspeed=RU:living_street";
323 assertNoMatch: "way maxspeed=DE:motorway";
324 assertNoMatch: "way maxspeed=signals";
325 assertNoMatch: "way maxspeed=none";
326 assertNoMatch: "way maxspeed=variable";
327}
328
329*[distance][distance !~ /^(([0-9]+(\.[0-9]+)?( (m|km|mi|nmi))?)|([0-9]+\'([0-9]+(\.[0-9]+)?\")?))$/] {
330 throwWarning: tr("unusual value of {0}: {1} is default; only positive values; point is decimal separator; if units, put space then unit", "{0.key}", tr("kilometers"));
331 assertMatch: "way distance=something";
332 assertMatch: "way distance=-5";
333 assertMatch: "way distance=5.";
334 assertNoMatch: "way distance=2";
335 assertNoMatch: "way distance=2.5";
336 assertNoMatch: "way distance=7 mi";
337}
338
339way[voltage][voltage =~ /(.*[A-Za-z].*)|.*,.*|.*( ).*/],
340way[voltage:primary][voltage:primary =~ /(.*[A-Za-z].*)|.*,.*|.*( ).*/],
341way[voltage:secondary][voltage:secondary =~ /(.*[A-Za-z].*)|.*,.*|.*( ).*/],
342way[voltage:tertiary][voltage:tertiary =~ /(.*[A-Za-z].*)|.*,.*|.*( ).*/] {
343 throwWarning: tr("voltage should be in volts with no units/delimiter/spaces");
344 assertMatch: "way voltage=medium";
345 assertNoMatch: "way voltage=15000";
346}
347
348/* some users are using frequency for other purposes (not electromagnetic)
349 with the values 'perennial' and 'intermittent'; the vast majority are 0, 16.7, 50 and 60 */
350way[frequency][frequency !~ /^(0|[1-9][0-9]*(\.[0-9]+)?)( (kHz|MHz|GHz|THz))?$/] {
351 throwWarning: tr("unusual value of {0}", "{0.key}");
352 assertMatch: "way frequency=something";
353 assertNoMatch: "way frequency=0"; /* DC */
354 assertNoMatch: "way frequency=16.7";
355 assertNoMatch: "way frequency=50";
356 assertNoMatch: "way frequency=680 kHz";
357 assertNoMatch: "way frequency=123.5 MHz";
358}
359
360/*******************
361 * End Unit checks *
362 *******************/
363
364way[gauge][gauge =~ /^(broad|standard|narrow)$/],
365relation[gauge][gauge =~ /^(broad|standard|narrow)$/] {
366 throwWarning: tr("imprecise value of {0}", "{0.tag}");
367 suggestAlternative: tr("an integer value in millimeters, without unit");
368 set imprecise_gauge;
369 assertNoMatch: "way gauge=something";
370 assertNoMatch: "way gauge=1435";
371 assertNoMatch: "way gauge=1000;1435";
372 assertNoMatch: "way gauge=2''10'";
373 assertMatch: "way gauge=standard";
374 assertMatch: "way gauge=narrow";
375}
376way[gauge][gauge !~ /^([1-9][0-9]{1,3}(;[1-9][0-9]{1,3})*)$/]!.imprecise_gauge,
377relation[gauge][gauge !~ /^([1-9][0-9]{1,3}(;[1-9][0-9]{1,3})*)$/]!.imprecise_gauge {
378 throwWarning: tr("unusual value of {0}", "{0.key}");
379 set unusual_gauge;
380 assertMatch: "way gauge=something";
381 assertMatch: "way gauge=2''10'";
382 assertNoMatch: "way gauge=1435";
383 assertNoMatch: "way gauge=1000;1435";
384 assertNoMatch: "way gauge=standard";
385 assertNoMatch: "way gauge=narrow";
386}
387/* #21866 - warn on narrow_railway gauge values outside 89..1434 range, including multi values */
388way[/railway$/ =~ /^narrow_gauge$/][gauge][gauge !~ /^((14(?:3[0-4]|[4-9])|(?:14[0-2]|(?:1[0-3]|9)[0-9])[0-9]?|143|(?:[2-7][0-9]|1[5-9])[0-9]|8(?:[0-8][0-9]|9[0-9]?));?)+$/]!.imprecise_gauge!.unusual_gauge,
389relation[/railway$/ =~ /^narrow_gauge$/][gauge][gauge !~ /^((14(?:3[0-4]|[4-9])|(?:14[0-2]|(?:1[0-3]|9)[0-9])[0-9]?|143|(?:[2-7][0-9]|1[5-9])[0-9]|8(?:[0-8][0-9]|9[0-9]?));?)+$/]!.imprecise_gauge!.unusual_gauge[type=route]{
390 group: tr("suspicious tag combination");
391 throwWarning: tr("unusual {0} value on narrow gauge railway", "{1.key}");
392 assertMatch: "way railway=narrow_gauge gauge=88";
393 assertNoMatch: "way railway=narrow_gauge gauge=89";
394 assertNoMatch: "way railway=narrow_gauge gauge=1434";
395 assertMatch: "way railway=narrow_gauge gauge=1435";
396 assertMatch: "way railway=narrow_gauge gauge=1435;1500";
397 assertMatch: "way railway=narrow_gauge gauge=60;600";
398 assertNoMatch: "way railway=narrow_gauge gauge=2''10'";
399 assertNoMatch: "way railway=narrow_gauge gauge=something";
400 assertNoMatch: "way railway=narrow_gauge gauge=narrow";
401}
402
403/* the numbers for percentage and degrees include could probably be bracketed a bit more precisely */
404way[incline][incline !~ /^(up|down|-?([0-9]+?(\.[1-9]%)?|100)[%°]?)$/] {
405 throwWarning: tr("unusual value of {0}", "{0.key}");
406 suggestAlternative: "x%";
407 suggestAlternative: "x°";
408 suggestAlternative: "up";
409 suggestAlternative: "down";
410 assertMatch: "way incline=extreme";
411 assertNoMatch: "way incline=up";
412 assertNoMatch: "way incline=down";
413 assertNoMatch: "way incline=10%";
414 assertNoMatch: "way incline=-5%";
415 assertNoMatch: "way incline=10°";
416}
417
418/* see ticket #9631 */
419*[population][population !~ /^[0-9]+$/ ] {
420 throwWarning: tr("{0} must be a numeric value", "{0.key}");
421}
422
423/* must be an integer positive number only and not 0, see #10837 (lanes), #11055 (screen) */
424node[seats][seats !~ /^[1-9]([0-9]*)$/][amenity=bench],
425way[seats][seats !~ /^[1-9]([0-9]*)$/][amenity=bench],
426way[lanes][lanes !~ /^[1-9]([0-9]*)$/][highway],
427way["lanes:backward"]["lanes:backward" !~ /^[1-9]([0-9]*)$/][highway],
428way["lanes:forward"]["lanes:forward" !~ /^[1-9]([0-9]*)$/][highway],
429*[screen][screen !~ /^[1-9]([0-9]*)$/][amenity=cinema] {
430 throwError: tr("{0} must be a positive integer number", "{0.key}");
431 assertMatch: "way highway=residential lanes=-1";
432 assertMatch: "way highway=residential lanes=5.5";
433 assertMatch: "way highway=residential lanes=1;2";
434 assertMatch: "way highway=residential lanes:forward=-1";
435 assertMatch: "way highway=residential lanes:backward=-1";
436 assertNoMatch: "way highway=residential lanes=1";
437 assertMatch: "node amenity=cinema screen=led";
438 assertNoMatch: "node amenity=cinema screen=8";
439}
440*[admin_level][admin_level !~ /^(1|2|3|4|5|6|7|8|9|10|11|12)$/] {
441 throwWarning: tr("unusual value of {0}", "{0.key}");
442 assertMatch: "node admin_level=0";
443 assertMatch: "node admin_level=-1";
444 assertMatch: "node admin_level=13";
445 assertNoMatch: "node admin_level=5";
446}
447
448/* #14989 */
449*[direction][direction<0],
450*[direction][direction>=360],
451*[direction][direction !~ /^([0-9][0-9]?[0-9]?|north|east|south|west|N|E|S|W|NE|SE|SW|NW|NNE|ENE|ESE|SSE|SSW|WSW|WNW|NNW|forward|backward|both|clockwise|anti-clockwise|anticlockwise|up|down)((-|;)([0-9][0-9]?[0-9]?|N|E|S|W|NE|SE|SW|NW|NNE|ENE|ESE|SSE|SSW|WSW|WNW|NNW))*$/] {
452 throwWarning: tr("unusual value of {0}", "{0.key}");
453 assertMatch: "node direction=north-down";
454 assertMatch: "node direction=rome";
455 assertMatch: "node direction=C";
456 assertMatch: "node direction=NNNE";
457 assertMatch: "node direction=1360";
458 assertNoMatch: "node direction=NE-S"; /* ranges are used at tourism=viewpoint*/
459 assertMatch: "node direction=north-south"; /* ranges only in numbers or short NESW form */
460 assertMatch: "node direction=north-east"; /* if range use N-E, if single direcion use NE */
461 assertNoMatch: "node direction=0-360"; /* complete panorama view */
462 assertNoMatch: "node direction=45-100;190-250;300-360";
463 assertMatch: "node direction=45-100;190-250;300-";
464 assertNoMatch: "node direction=45-100;190-250;300";
465 assertNoMatch: "node direction=90;270";
466 assertNoMatch: "node direction=up";
467 assertNoMatch: "node direction=down"; /* up/down are replaced by incline tag, has separate warning */
468 assertMatch: "node direction=-10";
469 assertNoMatch: "node direction=0";
470 assertNoMatch: "node direction=45";
471 assertMatch: "node direction=360";
472 assertNoMatch: "node direction=N";
473 assertNoMatch: "node direction=NNE";
474 assertNoMatch: "node direction=west";
475 assertNoMatch: "node direction=forward";
476 assertNoMatch: "node direction=anti-clockwise";
477 assertNoMatch: "node direction=anticlockwise"; /* both spellings are in use and even wiki uses both */
478}
479
480/* #14786 (should be safe to just remove the meters unit from the value) */
481*[ele][ele =~ /^-?[0-9]+(\.[0-9]+)? ?m$/] {
482 throwWarning: tr("{0} must be a numeric value, in meters and without units", "{0.key}");
483 fixAdd: concat("ele=", trim(replace(tag("ele"), "m", "")));
484 set ele_meter_remove_autofix;
485 assertMatch: "node ele=12m";
486 assertMatch: "node ele=12 m";
487 assertNoMatch: "node ele=12km";
488 assertMatch: "node ele=12.1m";
489 assertMatch: "node ele=-12.1 m";
490 assertNoMatch: "node ele=12";
491 assertNoMatch: "node ele=high";
492}
493*[ele][ele =~ /^[0-9]+,[0-9][0-9]?$/] {
494 throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
495 fixAdd: concat("ele=", replace(tag("ele"), ",", "."));
496 set ele_separator_autofix;
497 assertMatch: "node ele=5,5";
498 assertMatch: "node ele=12,00";
499 assertNoMatch: "node ele=8,848"; /* wrongly used thousands separator */
500 assertNoMatch: "node ele=3,50,5";
501 assertNoMatch: "node ele=3.5";
502 assertNoMatch: "node ele=4";
503}
504*[ele][ele !~ /^-?[0-9]+(\.[0-9]+)?$/]!.ele_meter_remove_autofix!.ele_separator_autofix {
505 throwWarning: tr("{0} must be a numeric value, in meters and without units", "{0.key}");
506 assertNoMatch: "node ele=12m";
507 assertNoMatch: "node ele=12 m";
508 assertMatch: "node ele=12km";
509 assertNoMatch: "node ele=12.1m";
510 assertNoMatch: "node ele=-12.1 m";
511 assertNoMatch: "node ele=12";
512 assertMatch: "node ele=high";
513}
514
515/* #17530 */
516*[ele][ele =~ /^-?[0-9]+\.[0-9][0-9][0-9]+$/] {
517 throwWarning: tr("{0}", "{0.tag}");
518 group: tr("Unnecessary amount of decimal places");
519 fixAdd: concat("ele=", round(tag("ele")*100)/100);
520 assertNoMatch: "node ele=12";
521 assertNoMatch: "node ele=1.12";
522 assertMatch: "node ele=12.123";
523 assertMatch: "node ele=12.1234";
524 assertMatch: "node ele=-12.6789";
525 assertNoMatch: "node ele=12.123 m";
526 assertNoMatch: "node ele=high";
527}
528
529/* #15774 */
530node[fire_hydrant:pressure="#"] {
531 throwError: tr("unusual value of {0}", "{0.key}");
532}
533
534*[interval][interval !~ /^([0-9][0-9]?[0-9]?|[0-9]+[0-9]:[0-5][0-9](:[0-5][0-9])?)$/] {
535 throwWarning: tr("unusual value of {0}", "{0.key}");
536 assertNoMatch: "way interval=5";
537 assertNoMatch: "way interval=20";
538 assertNoMatch: "way interval=00:05";
539 assertNoMatch: "way interval=00:05:00";
540 assertNoMatch: "way interval=03:00:00";
541 assertNoMatch: "relation interval=168:00:00";
542 assertNoMatch: "relation interval=120";
543 assertMatch: "way interval=0:5:0";
544 assertMatch: "way interval=00:65:00";
545 assertMatch: "way interval=00:15:90";
546}
547
548/* #15107 */
549*[aeroway=helipad ][iata][iata!~/^[A-Z]{3}$/],
550*[aeroway=aerodrome][iata][iata!~/^[A-Z]{3}$/] {
551 throwWarning: tr("wrong value: {0}", "{1.tag}");
552 group: tr("Airport tagging");
553 assertNoMatch: "way aeroway=aerodrome iata=BER";
554 assertMatch: "way aeroway=aerodrome iata=BERL";
555 assertMatch: "way aeroway=aerodrome iata=BE";
556 assertMatch: "way aeroway=aerodrome iata=ber";
557}
558*[aeroway=helipad ][icao][icao!~/^[A-Z]{4}$/],
559*[aeroway=aerodrome][icao][icao!~/^[A-Z]{4}$/] {
560 throwWarning: tr("wrong value: {0}", "{1.tag}");
561 group: tr("Airport tagging");
562 assertNoMatch: "way aeroway=aerodrome icao=EDDB";
563 assertMatch: "way aeroway=aerodrome icao=EDDBA";
564 assertMatch: "way aeroway=aerodrome icao=EDD";
565 assertMatch: "way aeroway=aerodrome icao=eddb";
566}
567*[aeroway=helipad ][icao][icao!~/^(AG|AN|AY|BG|BI|BK|C|DA|DB|DF|DG|DI|DN|DR|DT|DX|EB|ED|EE|EF|EG|EH|EI|EK|EL|EN|EP|ES|ET|EV|EY|FA|FB|FC|FD|FE|FG|FH|FI|FJ|FK|FL|FM|FN|FO|FP|FQ|FS|FT|FV|FW|FX|FY|FZ|GA|GB|GC|GE|GF|GG|GL|GM|GO|GQ|GS|GU|GV|HA|HB|HC|HD|HE|HH|HK|HL|HR|HS|HT|HU|K|LA|LB|LC|LD|LE|LF|LG|LH|LI|LJ|LK|LL|LM|LN|LO|LP|LQ|LR|LS|LT|LU|LV|LW|LX|LY|LZ|MB|MD|MG|MH|MK|MM|MN|MP|MR|MS|MT|MU|MW|MY|MZ|NC|NF|NG|NI|NL|NS|NT|NV|NW|NZ|OA|OB|OE|OI|OJ|OK|OL|OM|OO|OP|OR|OS|OT|OY|PA|PB|PC|PF|PG|PH|PJ|PK|PL|PM|PO|PP|PT|PW|RC|RJ|RK|RO|RP|SA|SB|SC|SD|SE|SF|SG|SH|SI|SJ|SK|SL|SM|SN|SO|SP|SS|SU|SV|SW|SY|TA|TB|TD|TF|TG|TI|TJ|TK|TL|TN|TQ|TR|TT|TU|TV|TX|U|UA|UB|UC|UD|UG|UK|UM|UT|VA|VC|VD|VE|VG|VH|VI|VL|VM|VN|VO|VQ|VR|VT|VV|VY|WA|WB|WI|WM|WP|WQ|WR|WS|Y|Z|ZK|ZM)/],
568*[aeroway=aerodrome][icao][icao!~/^(AG|AN|AY|BG|BI|BK|C|DA|DB|DF|DG|DI|DN|DR|DT|DX|EB|ED|EE|EF|EG|EH|EI|EK|EL|EN|EP|ES|ET|EV|EY|FA|FB|FC|FD|FE|FG|FH|FI|FJ|FK|FL|FM|FN|FO|FP|FQ|FS|FT|FV|FW|FX|FY|FZ|GA|GB|GC|GE|GF|GG|GL|GM|GO|GQ|GS|GU|GV|HA|HB|HC|HD|HE|HH|HK|HL|HR|HS|HT|HU|K|LA|LB|LC|LD|LE|LF|LG|LH|LI|LJ|LK|LL|LM|LN|LO|LP|LQ|LR|LS|LT|LU|LV|LW|LX|LY|LZ|MB|MD|MG|MH|MK|MM|MN|MP|MR|MS|MT|MU|MW|MY|MZ|NC|NF|NG|NI|NL|NS|NT|NV|NW|NZ|OA|OB|OE|OI|OJ|OK|OL|OM|OO|OP|OR|OS|OT|OY|PA|PB|PC|PF|PG|PH|PJ|PK|PL|PM|PO|PP|PT|PW|RC|RJ|RK|RO|RP|SA|SB|SC|SD|SE|SF|SG|SH|SI|SJ|SK|SL|SM|SN|SO|SP|SS|SU|SV|SW|SY|TA|TB|TD|TF|TG|TI|TJ|TK|TL|TN|TQ|TR|TT|TU|TV|TX|U|UA|UB|UC|UD|UG|UK|UM|UT|VA|VC|VD|VE|VG|VH|VI|VL|VM|VN|VO|VQ|VR|VT|VV|VY|WA|WB|WI|WM|WP|WQ|WR|WS|Y|Z|ZK|ZM)/] {
569 throwWarning: tr("wrong value: {0}", "{1.tag}");
570 group: tr("Airport tagging");
571 assertNoMatch: "way aeroway=aerodrome icao=EDDB";
572 assertMatch: "way aeroway=aerodrome icao=EQQQ";
573}
574
575/* #18573 */
576*[isced:level][isced:level !~ /^(0|1|2|3|4|5|6|7|8)((;|-)(1|2|3|4|5|6|7|8))*$/] {
577 throwWarning: tr("unusual value of {0}", "{0.key}");
578 assertMatch: "node isced:level=secondary";
579 assertMatch: "node isced:level=0,1,2,3";
580 assertMatch: "node isced:level=9";
581 assertMatch: "node isced:level=10";
582 assertNoMatch: "node isced:level=0;1;2;3";
583 assertNoMatch: "node isced:level=0";
584 assertNoMatch: "node isced:level=5";
585 assertNoMatch: "node isced:level=0-3";
586}
587
588/* #11253, maxstay=0 is unclear. Was in presets. */
589*[maxstay=0] {
590 throwWarning: tr("Definition of {0} is unclear", "{0.tag}");
591 assertMatch: "node maxstay=0";
592 assertMatch: "way maxstay=0";
593 assertNoMatch: "node maxstay=2";
594 assertNoMatch: "way maxstay=no";
595}
596
597/* #11253, maxstay needs unit. Was in presets without it. Autofixes for the most common cases. */
598*[maxstay][maxstay =~ /^([1-9][0-9]*(\.[0-9]+)? min)$/][maxstay!="1 min"] {
599 throwWarning: tr("unusual value of {0}: set unit e.g. {1} or {2}; only positive values; point is decimal separator; space between value and unit", "{0.key}", "minutes", "hours");
600 fixAdd: concat("maxstay=", replace(tag("maxstay"), "min", "minutes"));
601 set maxstay_autofix;
602 assertMatch: "node maxstay=\"5 min\"";
603 assertMatch: "node maxstay=\"15 min\"";
604 assertNoMatch: "node maxstay=\"1 min\"";
605 assertNoMatch: "node maxstay=\"02 minutes\"";
606 assertNoMatch: "node maxstay=\"2 minutes\"";
607}
608*[maxstay="1h"],
609*[maxstay="1 h"],
610*[maxstay="1 hr"] {
611 throwWarning: tr("unusual value of {0}: set unit e.g. {1} or {2}; only positive values; point is decimal separator; space between value and unit", "{0.key}", "minutes", "hours");
612 fixAdd: "maxstay=1 hour";
613 set maxstay_autofix;
614 assertMatch: "node maxstay=1h";
615 assertMatch: "node maxstay=\"1 h\"";
616 assertMatch: "node maxstay=\"1 hr\"";
617}
618*[maxstay][maxstay =~ /^([1-9][0-9]*(\.[0-9]+)? h)$/][maxstay!="1 h"] {
619 throwWarning: tr("unusual value of {0}: set unit e.g. {1} or {2}; only positive values; point is decimal separator; space between value and unit", "{0.key}", "minutes", "hours");
620 fixAdd: concat("maxstay=", replace(tag("maxstay"), "h", "hours"));
621 set maxstay_autofix;
622 assertMatch: "node maxstay=\"5 h\"";
623 assertMatch: "node maxstay=\"15 h\"";
624 assertNoMatch: "node maxstay=\"1 h\"";
625 assertNoMatch: "node maxstay=\"02 hours\"";
626 assertNoMatch: "node maxstay=\"2 hours\"";
627}
628*[maxstay][maxstay =~ /^([1-9][0-9]*(\.[0-9]+)? hr)$/][maxstay!="1 hr"] {
629 throwWarning: tr("unusual value of {0}: set unit e.g. {1} or {2}; only positive values; point is decimal separator; space between value and unit", "{0.key}", "minutes", "hours");
630 fixAdd: concat("maxstay=", replace(tag("maxstay"), "hr", "hours"));
631 set maxstay_autofix;
632 assertMatch: "node maxstay=\"5 hr\"";
633 assertMatch: "node maxstay=\"15 hr\"";
634 assertNoMatch: "node maxstay=\"1 hr\"";
635 assertNoMatch: "node maxstay=\"02 hours\"";
636 assertNoMatch: "node maxstay=\"2 hours\"";
637}
638*[maxstay][maxstay =~ /^([1-9][0-9]*(\.[0-9]+)?h)$/][maxstay!="1h"] {
639 throwWarning: tr("unusual value of {0}: set unit e.g. {1} or {2}; only positive values; point is decimal separator; space between value and unit", "{0.key}", "minutes", "hours");
640 fixAdd: concat("maxstay=", replace(tag("maxstay"), "h", " hours"));
641 set maxstay_autofix;
642 assertMatch: "node maxstay=5h";
643 assertMatch: "node maxstay=15h";
644 assertNoMatch: "node maxstay=1h";
645 assertNoMatch: "node maxstay=02hours";
646 assertNoMatch: "node maxstay=2hours";
647 assertNoMatch: "node maxstay=\"2 h\"";
648 assertNoMatch: "node maxstay=\"2 hr\"";
649}
650/* the rest without autofix */
651*[maxstay][maxstay !~ /^(([1-9][0-9]*(\.[0-9]+)?( (minute|minutes|hour|hours|day|days|week|weeks|month|months|year|years)))|(no|unlimited|0|load-unload))$/]!.maxstay_autofix {
652 throwWarning: tr("unusual value of {0}: set unit e.g. {1} or {2}; only positive values; point is decimal separator; space between value and unit", "{0.key}", "minutes", "hours");
653 assertMatch: "node maxstay=something";
654 assertMatch: "node maxstay=-5";
655 assertMatch: "node maxstay=180";
656 assertMatch: "node maxstay=66minutes";
657 assertMatch: "node maxstay=\"1. hours\"";
658 assertMatch: "node maxstay=\"0 minutes\"";
659 assertNoMatch: "node maxstay=0";
660 assertNoMatch: "node maxstay=no";
661 assertNoMatch: "node maxstay=\"7 h\"";
662 assertNoMatch: "node maxstay=\"7 hr\"";
663 assertNoMatch: "node maxstay=unlimited";
664 assertNoMatch: "node maxstay=load-unload";
665 assertNoMatch: "node maxstay=\"66 minutes\"";
666 assertNoMatch: "node maxstay=\"2.5 hours\"";
667}
668
669/* #19536 */
670*[name][name =~ /^([0-9.,]+)$/] {
671 throwOther: tr("Numeric name: {0}. Maybe {1} or {2} is meant.", "{0.value}", "ref", "addr:housenumber");
672 assertMatch: "node name=12";
673 assertMatch: "node name=3.5";
674 assertNoMatch: "node name=\"1. Chemnitzer Billardclub 1952 e.V.\"";
675}
676
677/* #23621 */
678node[natural=tree][circumference][siunit_length(tag(circumference)) > 45] {
679 throwWarning: tr("Unusually large value of {0}, possibly centimeter units are meant?", "{1.key}");
680 assertMatch: "node natural=tree circumference=200";
681 assertMatch: "node natural=tree circumference=82.4";
682 assertNoMatch: "node natural=tree circumference=18.4";
683 assertNoMatch: "node natural=tree circumference=\"100 cm\"";
684 assertNoMatch: "node natural=tree circumference=43"; /* Current world record */
685}
Note: See TracBrowser for help on using the repository browser.