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

Last change on this file since 17941 was 17939, checked in by Klumbumbus, 4 years ago

See #21026, see #14532 - Fix unit test

  • Property svn:eol-style set to native
File size: 29.8 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
43*[building:levels][building:levels !~ /^(([0-9]|[1-9][0-9]*)(\.5)?)$/]!.negative_value,
44*[level][level !~ /^((((-*[1-9]|[0-9])|-*[1-9][0-9]*)(\.5)?)|-0\.5)(;((((-*[1-9]|[0-9])|-*[1-9][0-9]*)(\.5)?)|-0\.5))*$/] { /* all numbers from -∞ to ∞ in 0.5 steps, optional multiple values separated by a ; */
45 throwWarning: tr("{0} should have numbers only with optional .5 increments", "{0.key}");
46 assertMatch: "node level=one";
47 assertMatch: "node level=01";
48 assertMatch: "node level=-03";
49 assertMatch: "node level=-01.5";
50 assertMatch: "node level=2.3";
51 assertMatch: "node level=-0";
52 assertNoMatch: "node level=0";
53 assertNoMatch: "node level=1";
54 assertNoMatch: "node level=-1";
55 assertNoMatch: "node level=-0.5";
56 assertNoMatch: "node level=1.5";
57 assertNoMatch: "node level=12";
58 assertNoMatch: "node level=0;1";
59 assertNoMatch: "node level=1;1.5";
60 assertNoMatch: "node level=1;0.5";
61 assertNoMatch: "node level=0;-0.5";
62 assertNoMatch: "node level=-0.5;0";
63 assertNoMatch: "node level=-1;-0.5";
64 assertNoMatch: "node building:levels=1.5";
65 assertNoMatch: "node building:levels=-1"; /* tested already by rule above "negative values" and excluded here via !.negative_value in selector */
66 assertMatch: "node building:levels=1A";
67 assertNoMatch: "node building:levels=0"; /* valid because there can be building:levels:underground > 0 or roof:levels > 0 */
68}
69
70*[height][height =~ /^[0-9]+(\.[0-9]+)?(( )*(metre|metres|meter|meters|Metre|Metres|Meter|Meters)|m)$/] {
71 throwWarning: tr("unusual value of {0}: use abbreviation for unit and space between value and unit", "{0.key}");
72 set height_meter_autofix;
73 fixAdd: concat("height=", get(regexp_match("([0-9.]+)( )*(.+)",tag("height")),1)," m");
74 assertMatch: "node height=6.78 meters";
75 assertMatch: "node height=5 metre";
76 assertMatch: "node height=2m";
77 assertNoMatch: "node height=2 m";
78 assertNoMatch: "node height=5";
79}
80*[height][height =~ /^[0-9]+(\.[0-9]+)?(( )*(foot|Foot|feet|Feet)|ft)$/] {
81 throwWarning: tr("unusual value of {0}: use abbreviation for unit and space between value and unit", "{0.key}");
82 set height_foot_autofix;
83 fixAdd: concat("height=", get(regexp_match("([0-9.]+)( )*(.+)",tag("height")),1)," ft");
84 assertMatch: "node height=6.78 foot";
85 assertMatch: "node height=5 Feet";
86 assertMatch: "node height=2ft";
87 assertNoMatch: "node height=2 ft";
88 assertNoMatch: "node height=5";
89}
90*[height][height =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/] {
91 throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
92 fixAdd: concat("height=", replace(tag("height"), ",", "."));
93 set height_separator_autofix;
94 assertMatch: "node height=5,5";
95 assertMatch: "node height=12,00";
96 assertMatch: "node height=12,5 ft";
97 assertNoMatch: "node height=12,000";
98 assertNoMatch: "node height=3,50,5";
99 assertNoMatch: "node height=3.5";
100 assertNoMatch: "node height=4";
101}
102
103*[maxheight][maxheight =~ /^[1-9][0-9]*(\.[0-9]+)?(( )*(metre|metres|meter|meters|Metre|Metres|Meter|Meters)|m)$/] {
104 throwWarning: tr("unusual value of {0}: use abbreviation for unit and space between value and unit", "{0.key}");
105 set maxheight_meter_autofix;
106 fixAdd: concat("maxheight=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxheight")),1)," m");
107 assertMatch: "node maxheight=6.78 meters";
108 assertMatch: "node maxheight=5 metre";
109 assertMatch: "node maxheight=2m";
110 assertNoMatch: "node maxheight=2 m";
111 assertNoMatch: "node maxheight=5";
112}
113*[maxheight][maxheight =~ /^[0-9]+(\.[0-9]+)?(( )*(foot|Foot|feet|Feet)|ft)$/] {
114 throwWarning: tr("unusual value of {0}: use abbreviation for unit and space between value and unit", "{0.key}");
115 set maxheight_foot_autofix;
116 fixAdd: concat("maxheight=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxheight")),1)," ft");
117 assertMatch: "node maxheight=6.78 foot";
118 assertMatch: "node maxheight=5 Feet";
119 assertMatch: "node maxheight=2ft";
120 assertNoMatch: "node maxheight=2 ft";
121 assertNoMatch: "node maxheight=5";
122}
123*[maxheight][maxheight =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/] {
124 throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
125 fixAdd: concat("maxheight=", replace(tag("maxheight"), ",", "."));
126 set maxheight_separator_autofix;
127 assertMatch: "node maxheight=5,5";
128 assertMatch: "node maxheight=12,00";
129 assertMatch: "node maxheight=12,5 ft";
130 assertNoMatch: "node maxheight=12,000";
131 assertNoMatch: "node maxheight=3,50,5";
132 assertNoMatch: "node maxheight=3.5";
133 assertNoMatch: "node maxheight=4";
134}
135
136*[maxlength][maxlength =~ /^[1-9][0-9]*(\.[0-9]+)?(( )*(metre|metres|meter|meters|Metre|Metres|Meter|Meters)|m)$/] {
137 throwWarning: tr("unusual value of {0}: use abbreviation for unit and space between value and unit", "{0.key}");
138 set maxlength_meter_autofix;
139 fixAdd: concat("maxlength=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxlength")),1)," m");
140 assertMatch: "node maxlength=6.78 meters";
141 assertMatch: "node maxlength=5 metre";
142 assertMatch: "node maxlength=2m";
143 assertNoMatch: "node maxlength=2 m";
144 assertNoMatch: "node maxlength=5";
145}
146*[maxlength][maxlength =~ /^[0-9]+(\.[0-9]+)?(( )*(foot|Foot|feet|Feet)|ft)$/] {
147 throwWarning: tr("unusual value of {0}: use abbreviation for unit and space between value and unit", "{0.key}");
148 set maxlength_foot_autofix;
149 fixAdd: concat("maxlength=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxlength")),1)," ft");
150 assertMatch: "node maxlength=6.78 foot";
151 assertMatch: "node maxlength=5 Feet";
152 assertMatch: "node maxlength=2ft";
153 assertNoMatch: "node maxlength=2 ft";
154 assertNoMatch: "node maxlength=5";
155}
156*[maxlength][maxlength =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/] {
157 throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
158 fixAdd: concat("maxlength=", replace(tag("maxlength"), ",", "."));
159 set maxlength_separator_autofix;
160 assertMatch: "node maxlength=5,5";
161 assertMatch: "node maxlength=12,00";
162 assertMatch: "node maxlength=12,5 ft";
163 assertNoMatch: "node maxlength=12,000";
164 assertNoMatch: "node maxlength=3,50,5";
165 assertNoMatch: "node maxlength=3.5";
166 assertNoMatch: "node maxlength=4";
167}
168
169*[width][width =~ /^[0-9]+(\.[0-9]+)?(( )*(metre|metres|meter|meters|Metre|Metres|Meter|Meters)|m)$/] {
170 throwWarning: tr("unusual value of {0}: use abbreviation for unit and space between value and unit", "{0.key}");
171 set width_meter_autofix;
172 fixAdd: concat("width=", get(regexp_match("([0-9.]+)( )*(.+)",tag("width")),1)," m");
173 assertMatch: "node width=6.78 meters";
174 assertMatch: "node width=5 metre";
175 assertMatch: "node width=2m";
176 assertNoMatch: "node width=2 m";
177 assertNoMatch: "node width=5";
178}
179*[width][width =~ /^[0-9]+(\.[0-9]+)?(( )*(foot|Foot|feet|Feet)|ft)$/] {
180 throwWarning: tr("unusual value of {0}: use abbreviation for unit and space between value and unit", "{0.key}");
181 set width_foot_autofix;
182 fixAdd: concat("width=", get(regexp_match("([0-9.]+)( )*(.+)",tag("width")),1)," ft");
183 assertMatch: "node width=6.78 foot";
184 assertMatch: "node width=5 Feet";
185 assertMatch: "node width=2ft";
186 assertNoMatch: "node width=2 ft";
187 assertNoMatch: "node width=5";
188}
189*[width][width =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/] {
190 throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
191 fixAdd: concat("width=", replace(tag("width"), ",", "."));
192 set width_separator_autofix;
193 assertMatch: "node width=5,5";
194 assertMatch: "node width=12,00";
195 assertNoMatch: "node width=12,000";
196 assertNoMatch: "node width=3,50,5";
197 assertNoMatch: "node width=3.5";
198 assertNoMatch: "node width=4";
199}
200
201*[maxwidth][maxwidth=~ /^[0-9]+(\.[0-9]+)?(( )*(metre|metres|meter|meters|Metre|Metres|Meter|Meters)|m)$/] {
202 throwWarning: tr("unusual value of {0}: use abbreviation for unit and space between value and unit", "{0.key}");
203 set maxwidth_meter_autofix;
204 fixAdd: concat("maxwidth=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxwidth")),1)," m");
205 assertMatch: "node maxwidth=6.78 meters";
206 assertMatch: "node maxwidth=5 metre";
207 assertMatch: "node maxwidth=2m";
208 assertNoMatch: "node maxwidth=2 m";
209 assertNoMatch: "node maxwidth=5";
210}
211*[maxwidth][maxwidth =~ /^[0-9]+(\.[0-9]+)?(( )*(foot|Foot|feet|Feet)|ft)$/] {
212 throwWarning: tr("unusual value of {0}: use abbreviation for unit and space between value and unit", "{0.key}");
213 set maxwidth_foot_autofix;
214 fixAdd: concat("maxwidth=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxwidth")),1)," ft");
215 assertMatch: "node maxwidth=6.78 foot";
216 assertMatch: "node maxwidth=5 Feet";
217 assertMatch: "node maxwidth=2ft";
218 assertNoMatch: "node maxwidth=2 ft";
219 assertNoMatch: "node maxwidth=5";
220}
221*[maxwidth][maxwidth =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/] {
222 throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
223 fixAdd: concat("maxwidth=", replace(tag("maxwidth"), ",", "."));
224 set maxwidth_separator_autofix;
225 assertMatch: "node maxwidth=5,5";
226 assertMatch: "node maxwidth=12,00";
227 assertNoMatch: "node maxwidth=12,000";
228 assertNoMatch: "node maxwidth=3,50,5";
229 assertNoMatch: "node maxwidth=3.5";
230 assertNoMatch: "node maxwidth=4";
231}
232
233*[height ][height !~ /^(([0-9]+(\.[0-9]+)?( (m|ft))?)|([1-9][0-9]*\'((10|11|[0-9])((\.[0-9]+)?)\")?))$/]!.height_separator_autofix!.height_meter_autofix!.height_foot_autofix,
234*[maxheight][maxheight !~ /^(([1-9][0-9]*(\.[0-9]+)?( (m|ft))?)|([0-9]+\'(([0-9]|10|11)(\.[0-9]*)?\")?)|none|default|below_default)$/]!.maxheight_separator_autofix!.maxheight_meter_autofix!.maxheight_foot_autofix,
235*[maxlength][maxlength !~ /^(([1-9][0-9]*(\.[0-9]+)?( (m|ft))?)|([0-9]+\'(([0-9]|10|11)(\.[0-9]*)?\")?)|none|default|below_default)$/]!.maxlength_separator_autofix!.maxlength_meter_autofix!.maxlength_foot_autofix,
236*[width ][width !~ /^(([0-9]+(\.[0-9]+)?( (m|ft))?)|([0-9]+\'([0-9]+(\.[0-9]+)?\")?))$/]!.width_separator_autofix!.width_meter_autofix!.width_foot_autofix,
237*[maxwidth ][maxwidth !~ /^(([0-9]+(\.[0-9]+)?( (m|ft))?)|([0-9]+\'([0-9]+(\.[0-9]+)?\")?))$/]!.maxwidth_separator_autofix!.maxwidth_meter_autofix!.maxwidth_foot_autofix {
238 throwWarning: tr("unusual value of {0}: {1} is default; only positive values; point is decimal separator; if units, put space then unit", "{0.key}", "meters");
239 assertMatch: "node height=medium";
240 assertMatch: "node maxheight=-5";
241 assertMatch: "node maxlength=0";
242 assertMatch: "node maxlength=10'13\"";
243 assertMatch: "node width=10'2.\"";
244 assertMatch: "node maxheight=\"2. m\"";
245 assertMatch: "node height=\"12. m\"";
246 assertNoMatch: "node height=6.78 meters";
247 assertNoMatch: "node height=5 metre";
248 assertNoMatch: "node height=2m";
249 assertNoMatch: "node height=3";
250 assertNoMatch: "node height=2.22 m";
251 assertNoMatch: "node height=7.8";
252 assertNoMatch: "node maxwidth=7 ft";
253 assertNoMatch: "node height=22'";
254 assertNoMatch: "node width=10'5\"";
255 assertNoMatch: "node width=10'";
256}
257
258*[maxaxleload][maxaxleload =~ /^[0-9]+,[0-9][0-9]?( (t|kg|st|lbs))?$/] {
259 throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
260 fixAdd: concat("maxaxleload=", replace(tag("maxaxleload"), ",", "."));
261 set maxaxleload_separator_autofix;
262 assertMatch: "node maxaxleload=5,5";
263 assertMatch: "node maxaxleload=12,00";
264 assertNoMatch: "node maxaxleload=12,000";
265 assertNoMatch: "node maxaxleload=3,50,5";
266 assertNoMatch: "node maxaxleload=3.5";
267 assertNoMatch: "node maxaxleload=4";
268}
269
270*[maxweight][maxweight =~ /^[0-9]+,[0-9][0-9]?( (t|kg|st|lbs))?$/] {
271 throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
272 fixAdd: concat("maxweight=", replace(tag("maxweight"), ",", "."));
273 set maxweight_separator_autofix;
274 assertMatch: "node maxweight=5,5";
275 assertMatch: "node maxweight=12,00";
276 assertNoMatch: "node maxweight=12,000";
277 assertNoMatch: "node maxweight=3,50,5";
278 assertNoMatch: "node maxweight=3.5";
279 assertNoMatch: "node maxweight=4";
280}
281
282*[maxaxleload][maxaxleload !~ /^([0-9]+(\.[0-9]+)?( (t|kg|st|lbs))?)$/]!.maxaxleload_separator_autofix,
283*[maxweight][maxweight !~ /^([0-9]+(\.[0-9]+)?( (t|kg|st|lbs))?)$/]!.maxweight_separator_autofix {
284 throwWarning: tr("unusual value of {0}: {1} is default; only positive values; point is decimal separator; if units, put space then unit", "{0.key}", "tonne");
285 assertMatch: "node maxaxleload=something";
286 assertMatch: "node maxweight=-5";
287 assertNoMatch: "node maxaxleload=2";
288 assertNoMatch: "node maxaxleload=2.5";
289 assertNoMatch: "node maxaxleload=7 kg";
290}
291
292way[maxspeed][maxspeed !~ /^(signals|none|unposted|variable|walk|[1-9][0-9]*( [a-z]+)?|[A-Z][A-Z]:(urban|rural|living_street|motorway))$/],
293way[maxspeed:forward][maxspeed:forward !~ /^(signals|none|unposted|variable|walk|[1-9][0-9]*( [a-z]+)?|[A-Z][A-Z]:(urban|rural|living_street|motorway))$/],
294way[maxspeed:backward][maxspeed:backward !~ /^(signals|none|unposted|variable|walk|[1-9][0-9]*( [a-z]+)?|[A-Z][A-Z]:(urban|rural|living_street|motorway))$/] {
295 throwWarning: tr("unusual value of {0}: {1} is default; only positive values; point is decimal separator; if units, put space then unit", "{0.key}", "km/h");
296 assertMatch: "way maxspeed=something";
297 assertMatch: "way maxspeed=-50";
298 assertMatch: "way maxspeed=0";
299 assertNoMatch: "way maxspeed=50";
300 assertNoMatch: "way maxspeed=30 mph";
301 assertNoMatch: "way maxspeed=RO:urban";
302 assertNoMatch: "way maxspeed=RU:rural";
303 assertNoMatch: "way maxspeed=RU:living_street";
304 assertNoMatch: "way maxspeed=DE:motorway";
305 assertNoMatch: "way maxspeed=signals";
306 assertNoMatch: "way maxspeed=none";
307 assertNoMatch: "way maxspeed=variable";
308}
309
310*[distance][distance =~ /^[0-9]+,[0-9][0-9]?( (m|km|mi|nmi))?$/] {
311 throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
312 fixAdd: concat("distance=", replace(tag("distance"), ",", "."));
313 set distance_separator_autofix;
314 assertMatch: "node distance=5,5";
315 assertMatch: "node distance=12,00";
316 assertNoMatch: "node distance=12,000";
317 assertNoMatch: "node distance=3,50,5";
318 assertNoMatch: "node distance=3.5";
319 assertNoMatch: "node distance=4";
320}
321*[distance][distance !~ /^(([0-9]+(\.[0-9]+)?( (m|km|mi|nmi))?)|([0-9]+\'([0-9]+(\.[0-9]+)?\")?))$/]!.distance_separator_autofix {
322 throwWarning: tr("unusual value of {0}: {1} is default; only positive values; point is decimal separator; if units, put space then unit", "{0.key}", "kilometers");
323 assertMatch: "way distance=something";
324 assertMatch: "way distance=-5";
325 assertMatch: "way distance=5.";
326 assertNoMatch: "way distance=2";
327 assertNoMatch: "way distance=2.5";
328 assertNoMatch: "way distance=7 mi";
329}
330
331way[voltage][voltage =~ /(.*[A-Za-z].*)|.*,.*|.*( ).*/] {
332 throwWarning: tr("voltage should be in volts with no units/delimiter/spaces");
333 assertMatch: "way voltage=medium";
334 assertNoMatch: "way voltage=15000";
335}
336
337/* some users are using frequency for other purposes (not electromagnetic)
338 with the values 'perennial' and 'intermittent'; the vast majority are 0, 16.7, 50 and 60 */
339way[frequency][frequency !~ /^(0|[1-9][0-9]*(\.[0-9]+)?)( (kHz|MHz|GHz|THz))?$/] {
340 throwWarning: tr("unusual value of {0}", "{0.key}");
341 assertMatch: "way frequency=something";
342 assertNoMatch: "way frequency=0"; /* DC */
343 assertNoMatch: "way frequency=16.7";
344 assertNoMatch: "way frequency=50";
345 assertNoMatch: "way frequency=680 kHz";
346 assertNoMatch: "way frequency=123.5 MHz";
347}
348
349way[gauge][gauge !~ /^([1-9][0-9]{1,3}(;[1-9][0-9]{1,3})*|broad|standard|narrow)$/] {
350 throwWarning: tr("unusual value of {0}", "{0.key}");
351 assertMatch: "way gauge=something";
352 assertNoMatch: "way gauge=1435";
353 assertNoMatch: "way gauge=1000;1435";
354 assertNoMatch: "way gauge=standard";
355 assertNoMatch: "way gauge=narrow";
356}
357
358/* the numbers for percentage and degrees include could probably be bracketed a bit more precisely */
359way[incline][incline !~ /^(up|down|-?([0-9]+?(\.[1-9]%)?|100)[%°]?)$/] {
360 throwWarning: tr("unusual value of {0}", "{0.key}");
361 suggestAlternative: "x%";
362 suggestAlternative: "x°";
363 suggestAlternative: "up";
364 suggestAlternative: "down";
365 assertMatch: "way incline=extreme";
366 assertNoMatch: "way incline=up";
367 assertNoMatch: "way incline=down";
368 assertNoMatch: "way incline=10%";
369 assertNoMatch: "way incline=-5%";
370 assertNoMatch: "way incline=10°";
371}
372
373/* see ticket #9631 */
374*[population][population !~ /^[0-9]+$/ ] {
375 throwWarning: tr("{0} must be a numeric value", "{0.key}");
376}
377
378/* must be an integer positive number only and not 0, see #10837 (lanes), #11055 (screen) */
379node[seats][seats !~ /^[1-9]([0-9]*)$/][amenity=bench],
380way[seats][seats !~ /^[1-9]([0-9]*)$/][amenity=bench],
381way[lanes][lanes !~ /^[1-9]([0-9]*)$/][highway],
382way["lanes:backward"]["lanes:backward" !~ /^[1-9]([0-9]*)$/][highway],
383way["lanes:forward"]["lanes:forward" !~ /^[1-9]([0-9]*)$/][highway],
384*[screen][screen !~ /^[1-9]([0-9]*)$/][amenity=cinema] {
385 throwError: tr("{0} must be a positive integer number", "{0.key}");
386 assertMatch: "way highway=residential lanes=-1";
387 assertMatch: "way highway=residential lanes=5.5";
388 assertMatch: "way highway=residential lanes=1;2";
389 assertMatch: "way highway=residential lanes:forward=-1";
390 assertMatch: "way highway=residential lanes:backward=-1";
391 assertNoMatch: "way highway=residential lanes=1";
392 assertMatch: "node amenity=cinema screen=led";
393 assertNoMatch: "node amenity=cinema screen=8";
394}
395*[admin_level][admin_level !~ /^(1|2|3|4|5|6|7|8|9|10|11|12)$/] {
396 throwWarning: tr("unusual value of {0}", "{0.key}");
397 assertMatch: "node admin_level=0";
398 assertMatch: "node admin_level=-1";
399 assertMatch: "node admin_level=13";
400 assertNoMatch: "node admin_level=5";
401}
402
403/* #14989 */
404*[direction][direction<0],
405*[direction][direction>=360],
406*[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))*$/] {
407 throwWarning: tr("unusual value of {0}", "{0.key}");
408 assertMatch: "node direction=north-down";
409 assertMatch: "node direction=rome";
410 assertMatch: "node direction=C";
411 assertMatch: "node direction=NNNE";
412 assertMatch: "node direction=1360";
413 assertNoMatch: "node direction=NE-S"; /* ranges are used at tourism=viewpoint*/
414 assertMatch: "node direction=north-south"; /* ranges only in numbers or short NESW form */
415 assertMatch: "node direction=north-east"; /* if range use N-E, if single direcion use NE */
416 assertNoMatch: "node direction=0-360"; /* complete panorama view */
417 assertNoMatch: "node direction=45-100;190-250;300-360";
418 assertMatch: "node direction=45-100;190-250;300-";
419 assertNoMatch: "node direction=45-100;190-250;300";
420 assertNoMatch: "node direction=90;270";
421 assertNoMatch: "node direction=up";
422 assertNoMatch: "node direction=down"; /* up/down are replaced by incline tag, has separate warning */
423 assertMatch: "node direction=-10";
424 assertNoMatch: "node direction=0";
425 assertNoMatch: "node direction=45";
426 assertMatch: "node direction=360";
427 assertNoMatch: "node direction=N";
428 assertNoMatch: "node direction=NNE";
429 assertNoMatch: "node direction=west";
430 assertNoMatch: "node direction=forward";
431 assertNoMatch: "node direction=anti-clockwise";
432 assertNoMatch: "node direction=anticlockwise"; /* both spellings are in use and even wiki uses both */
433}
434
435/* #14786 (should be safe to just remove the meters unit from the value) */
436*[ele][ele =~ /^-?[0-9]+(\.[0-9]+)? ?m$/] {
437 throwWarning: tr("{0} must be a numeric value, in meters and without units", "{0.key}");
438 fixAdd: concat("ele=", trim(replace(tag("ele"), "m", "")));
439 set ele_meter_remove_autofix;
440 assertMatch: "node ele=12m";
441 assertMatch: "node ele=12 m";
442 assertNoMatch: "node ele=12km";
443 assertMatch: "node ele=12.1m";
444 assertMatch: "node ele=-12.1 m";
445 assertNoMatch: "node ele=12";
446 assertNoMatch: "node ele=high";
447}
448*[ele][ele =~ /^[0-9]+,[0-9][0-9]?$/] {
449 throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
450 fixAdd: concat("ele=", replace(tag("ele"), ",", "."));
451 set ele_separator_autofix;
452 assertMatch: "node ele=5,5";
453 assertMatch: "node ele=12,00";
454 assertNoMatch: "node ele=8,848"; /* wrongly used thousands separator */
455 assertNoMatch: "node ele=3,50,5";
456 assertNoMatch: "node ele=3.5";
457 assertNoMatch: "node ele=4";
458}
459*[ele][ele !~ /^-?[0-9]+(\.[0-9]+)?$/]!.ele_meter_remove_autofix!.ele_separator_autofix {
460 throwWarning: tr("{0} must be a numeric value, in meters and without units", "{0.key}");
461 assertNoMatch: "node ele=12m";
462 assertNoMatch: "node ele=12 m";
463 assertMatch: "node ele=12km";
464 assertNoMatch: "node ele=12.1m";
465 assertNoMatch: "node ele=-12.1 m";
466 assertNoMatch: "node ele=12";
467 assertMatch: "node ele=high";
468}
469
470/* #17530 */
471*[ele][ele =~ /^-?[0-9]+\.[0-9][0-9][0-9]+$/] {
472 throwWarning: tr("{0}", "{0.tag}");
473 group: tr("Unnecessary amount of decimal places");
474 fixAdd: concat("ele=", round(tag("ele")*100)/100);
475 assertNoMatch: "node ele=12";
476 assertNoMatch: "node ele=1.12";
477 assertMatch: "node ele=12.123";
478 assertMatch: "node ele=12.1234";
479 assertMatch: "node ele=-12.6789";
480 assertNoMatch: "node ele=12.123 m";
481 assertNoMatch: "node ele=high";
482}
483
484/* #15774 */
485node[fire_hydrant:pressure="#"] {
486 throwError: tr("unusual value of {0}", "{0.key}");
487}
488
489*[interval][interval !~ /^([0-9][0-9]?|[0-9][0-9]:[0-5][0-9](:[0-9][0-9])?)$/] {
490 throwWarning: tr("unusual value of {0}", "{0.key}");
491 assertNoMatch: "way interval=5";
492 assertNoMatch: "way interval=20";
493 assertNoMatch: "way interval=00:05";
494 assertNoMatch: "way interval=00:05:00";
495 assertNoMatch: "way interval=03:00:00";
496 assertMatch: "way interval=123";
497 assertMatch: "way interval=0:5:0";
498 assertMatch: "way interval=00:65:00";
499}
500
501/* #15107 */
502*[aeroway=helipad ][iata][iata!~/^[A-Z]{3}$/],
503*[aeroway=aerodrome][iata][iata!~/^[A-Z]{3}$/] {
504 throwWarning: tr("wrong value: {0}", "{1.tag}");
505 group: tr("Airport tagging");
506 assertNoMatch: "way aeroway=aerodrome iata=BER";
507 assertMatch: "way aeroway=aerodrome iata=BERL";
508 assertMatch: "way aeroway=aerodrome iata=BE";
509 assertMatch: "way aeroway=aerodrome iata=ber";
510}
511*[aeroway=helipad ][icao][icao!~/^[A-Z]{4}$/],
512*[aeroway=aerodrome][icao][icao!~/^[A-Z]{4}$/] {
513 throwWarning: tr("wrong value: {0}", "{1.tag}");
514 group: tr("Airport tagging");
515 assertNoMatch: "way aeroway=aerodrome icao=EDDB";
516 assertMatch: "way aeroway=aerodrome icao=EDDBA";
517 assertMatch: "way aeroway=aerodrome icao=EDD";
518 assertMatch: "way aeroway=aerodrome icao=eddb";
519}
520*[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)/],
521*[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)/] {
522 throwWarning: tr("wrong value: {0}", "{1.tag}");
523 group: tr("Airport tagging");
524 assertNoMatch: "way aeroway=aerodrome icao=EDDB";
525 assertMatch: "way aeroway=aerodrome icao=EQQQ";
526}
527
528/* #18573 */
529*[isced:level][isced:level !~ /^(0|1|2|3|4|5|6|7|8)((;|-)(1|2|3|4|5|6|7|8))*$/] {
530 throwWarning: tr("unusual value of {0}", "{0.key}");
531 assertMatch: "node isced:level=secondary";
532 assertMatch: "node isced:level=0,1,2,3";
533 assertMatch: "node isced:level=9";
534 assertMatch: "node isced:level=10";
535 assertNoMatch: "node isced:level=0;1;2;3";
536 assertNoMatch: "node isced:level=0";
537 assertNoMatch: "node isced:level=5";
538 assertNoMatch: "node isced:level=0-3";
539}
540
541/* #11253, maxstay=0 is unclear. Was in presets. */
542*[maxstay=0] {
543 throwWarning: tr("Definition of {0} is unclear", "{0.tag}");
544 assertMatch: "node maxstay=0";
545 assertMatch: "way maxstay=0";
546 assertNoMatch: "node maxstay=2";
547 assertNoMatch: "way maxstay=no";
548}
549
550/* #11253, maxstay needs unit. Was in presets without it. Autofixes for the most common cases. */
551*[maxstay][maxstay =~ /^([1-9][0-9]*(\.[0-9]+)? min)$/][maxstay!="1 min"] {
552 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");
553 fixAdd: concat("maxstay=", replace(tag("maxstay"), "min", "minutes"));
554 set maxstay_autofix;
555 assertMatch: "node maxstay=\"5 min\"";
556 assertMatch: "node maxstay=\"15 min\"";
557 assertNoMatch: "node maxstay=\"1 min\"";
558 assertNoMatch: "node maxstay=\"02 minutes\"";
559 assertNoMatch: "node maxstay=\"2 minutes\"";
560}
561*[maxstay="1h"],
562*[maxstay="1 h"],
563*[maxstay="1 hr"] {
564 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");
565 fixAdd: "maxstay=1 hour";
566 set maxstay_autofix;
567 assertMatch: "node maxstay=1h";
568 assertMatch: "node maxstay=\"1 h\"";
569 assertMatch: "node maxstay=\"1 hr\"";
570}
571*[maxstay][maxstay =~ /^([1-9][0-9]*(\.[0-9]+)? h)$/][maxstay!="1 h"] {
572 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");
573 fixAdd: concat("maxstay=", replace(tag("maxstay"), "h", "hours"));
574 set maxstay_autofix;
575 assertMatch: "node maxstay=\"5 h\"";
576 assertMatch: "node maxstay=\"15 h\"";
577 assertNoMatch: "node maxstay=\"1 h\"";
578 assertNoMatch: "node maxstay=\"02 hours\"";
579 assertNoMatch: "node maxstay=\"2 hours\"";
580}
581*[maxstay][maxstay =~ /^([1-9][0-9]*(\.[0-9]+)? hr)$/][maxstay!="1 hr"] {
582 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");
583 fixAdd: concat("maxstay=", replace(tag("maxstay"), "hr", "hours"));
584 set maxstay_autofix;
585 assertMatch: "node maxstay=\"5 hr\"";
586 assertMatch: "node maxstay=\"15 hr\"";
587 assertNoMatch: "node maxstay=\"1 hr\"";
588 assertNoMatch: "node maxstay=\"02 hours\"";
589 assertNoMatch: "node maxstay=\"2 hours\"";
590}
591*[maxstay][maxstay =~ /^([1-9][0-9]*(\.[0-9]+)?h)$/][maxstay!="1h"] {
592 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");
593 fixAdd: concat("maxstay=", replace(tag("maxstay"), "h", " hours"));
594 set maxstay_autofix;
595 assertMatch: "node maxstay=5h";
596 assertMatch: "node maxstay=15h";
597 assertNoMatch: "node maxstay=1h";
598 assertNoMatch: "node maxstay=02hours";
599 assertNoMatch: "node maxstay=2hours";
600 assertNoMatch: "node maxstay=\"2 h\"";
601 assertNoMatch: "node maxstay=\"2 hr\"";
602}
603/* the rest without autofix */
604*[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 {
605 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");
606 assertMatch: "node maxstay=something";
607 assertMatch: "node maxstay=-5";
608 assertMatch: "node maxstay=180";
609 assertMatch: "node maxstay=66minutes";
610 assertMatch: "node maxstay=\"1. hours\"";
611 assertMatch: "node maxstay=\"0 minutes\"";
612 assertNoMatch: "node maxstay=0";
613 assertNoMatch: "node maxstay=no";
614 assertNoMatch: "node maxstay=\"7 h\"";
615 assertNoMatch: "node maxstay=\"7 hr\"";
616 assertNoMatch: "node maxstay=unlimited";
617 assertNoMatch: "node maxstay=load-unload";
618 assertNoMatch: "node maxstay=\"66 minutes\"";
619 assertNoMatch: "node maxstay=\"2.5 hours\"";
620}
621
622/* #19536 */
623*[name][name =~ /^([0-9.,]+)$/] {
624 throwOther: tr("Numeric name: {0}. Maybe {1} or {2} is meant.", "{0.value}", "ref", "addr:housenumber");
625 assertMatch: "node name=12";
626 assertMatch: "node name=3.5";
627 assertNoMatch: "node name=\"1. Chemnitzer Billardclub 1952 e.V.\"";
628}
Note: See TracBrowser for help on using the repository browser.