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

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

fix #19907 - Adjust some numeric regular expessions to warn about cases with missing numbers after decimal separator (width=10'2." or maxheight=2. m), don't warn about values without inch (feet only)

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