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

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

fix #19163 - Adjust units validator tests: add autofixes for missing or multiple spaces and long forms of units, validate maxaxleload and maxlength too (patch by skyper, modified)

  • Property svn:eol-style set to native
File size: 28.6 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 assertNoMatch: "node height=6.78 meters";
231 assertNoMatch: "node height=5 metre";
232 assertNoMatch: "node height=2m";
233 assertNoMatch: "node height=3";
234 assertNoMatch: "node height=2.22 m";
235 assertNoMatch: "node height=7.8";
236 assertNoMatch: "node maxwidth=7 ft";
237 assertNoMatch: "node height=22'";
238 assertNoMatch: "node width=10'5\"";
239}
240
241*[maxaxleload][maxaxleload =~ /^[0-9]+,[0-9][0-9]?( (t|kg|st|lbs))?$/] {
242 throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
243 fixAdd: concat("maxaxleload=", replace(tag("maxaxleload"), ",", "."));
244 set maxaxleload_separator_autofix;
245 assertMatch: "node maxaxleload=5,5";
246 assertMatch: "node maxaxleload=12,00";
247 assertNoMatch: "node maxaxleload=12,000";
248 assertNoMatch: "node maxaxleload=3,50,5";
249 assertNoMatch: "node maxaxleload=3.5";
250 assertNoMatch: "node maxaxleload=4";
251}
252
253*[maxweight][maxweight =~ /^[0-9]+,[0-9][0-9]?( (t|kg|st|lbs))?$/] {
254 throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
255 fixAdd: concat("maxweight=", replace(tag("maxweight"), ",", "."));
256 set maxweight_separator_autofix;
257 assertMatch: "node maxweight=5,5";
258 assertMatch: "node maxweight=12,00";
259 assertNoMatch: "node maxweight=12,000";
260 assertNoMatch: "node maxweight=3,50,5";
261 assertNoMatch: "node maxweight=3.5";
262 assertNoMatch: "node maxweight=4";
263}
264
265*[maxaxleload][maxaxleload !~ /^(([0-9]+\.?[0-9]*( (t|kg|st|lbs))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/]!.maxaxleload_separator_autofix,
266*[maxweight][maxweight !~ /^(([0-9]+\.?[0-9]*( (t|kg|st|lbs))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/]!.maxweight_separator_autofix {
267 throwWarning: tr("unusual value of {0}: tonne is default; point is decimal separator; if units, put space then unit", "{0.key}");
268 assertMatch: "node maxaxleload=something";
269 assertMatch: "node maxweight=-5";
270 assertNoMatch: "node maxaxleload=2";
271 assertNoMatch: "node maxweight=6'6\"";
272 assertNoMatch: "node maxaxleload=2.5";
273 assertNoMatch: "node maxaxleload=7 kg";
274}
275
276way[maxspeed][maxspeed !~ /^(signals|none|unposted|variable|walk|[1-9][0-9]*( [a-z]+)?|[A-Z][A-Z]:(urban|rural|living_street|motorway))$/],
277way[maxspeed:forward][maxspeed:forward !~ /^(signals|none|unposted|variable|walk|[1-9][0-9]*( [a-z]+)?|[A-Z][A-Z]:(urban|rural|living_street|motorway))$/],
278way[maxspeed:backward][maxspeed:backward !~ /^(signals|none|unposted|variable|walk|[1-9][0-9]*( [a-z]+)?|[A-Z][A-Z]:(urban|rural|living_street|motorway))$/] {
279 throwWarning: tr("unusual value of {0}", "{0.key}");
280 assertMatch: "way maxspeed=something";
281 assertMatch: "way maxspeed=-50";
282 assertMatch: "way maxspeed=0";
283 assertNoMatch: "way maxspeed=50";
284 assertNoMatch: "way maxspeed=30 mph";
285 assertNoMatch: "way maxspeed=RO:urban";
286 assertNoMatch: "way maxspeed=RU:rural";
287 assertNoMatch: "way maxspeed=RU:living_street";
288 assertNoMatch: "way maxspeed=DE:motorway";
289 assertNoMatch: "way maxspeed=signals";
290 assertNoMatch: "way maxspeed=none";
291 assertNoMatch: "way maxspeed=variable";
292}
293
294*[distance][distance =~ /^[0-9]+,[0-9][0-9]?( (m|km|mi|nmi))?$/] {
295 throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
296 fixAdd: concat("distance=", replace(tag("distance"), ",", "."));
297 set distance_separator_autofix;
298 assertMatch: "node distance=5,5";
299 assertMatch: "node distance=12,00";
300 assertNoMatch: "node distance=12,000";
301 assertNoMatch: "node distance=3,50,5";
302 assertNoMatch: "node distance=3.5";
303 assertNoMatch: "node distance=4";
304}
305*[distance][distance !~ /^(([0-9]+\.?[0-9]*( (m|km|mi|nmi))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/]!.distance_separator_autofix {
306 throwWarning: tr("unusual value of {0}: kilometers is default; point is decimal separator; if units, put space then unit", "{0.key}");
307 assertMatch: "way distance=something";
308 assertMatch: "way distance=-5";
309 assertNoMatch: "way distance=2";
310 assertNoMatch: "way distance=2.5";
311 assertNoMatch: "way distance=7 mi";
312}
313
314way[voltage][voltage =~ /(.*[A-Za-z].*)|.*,.*|.*( ).*/] {
315 throwWarning: tr("voltage should be in volts with no units/delimiter/spaces");
316 assertMatch: "way voltage=medium";
317 assertNoMatch: "way voltage=15000";
318}
319
320/* some users are using frequency for other purposes (not electromagnetic)
321 with the values 'perennial' and 'intermittent'; the vast majority are 0, 16.7, 50 and 60 */
322way[frequency][frequency !~ /^(0|[1-9][0-9]*(\.[0-9]+)?)( (kHz|MHz|GHz|THz))?$/] {
323 throwWarning: tr("unusual value of {0}", "{0.key}");
324 assertMatch: "way frequency=something";
325 assertNoMatch: "way frequency=0"; /* DC */
326 assertNoMatch: "way frequency=16.7";
327 assertNoMatch: "way frequency=50";
328 assertNoMatch: "way frequency=680 kHz";
329 assertNoMatch: "way frequency=123.5 MHz";
330}
331
332way[gauge][gauge !~ /^([1-9][0-9]{1,3}(;[1-9][0-9]{1,3})*|broad|standard|narrow)$/] {
333 throwWarning: tr("unusual value of {0}", "{0.key}");
334 assertMatch: "way gauge=something";
335 assertNoMatch: "way gauge=1435";
336 assertNoMatch: "way gauge=1000;1435";
337 assertNoMatch: "way gauge=standard";
338 assertNoMatch: "way gauge=narrow";
339}
340
341/* the numbers for percentage and degrees include could probably be bracketed a bit more precisely */
342way[incline][incline !~ /^(up|down|-?([0-9]+?(\.[1-9]%)?|100)[%°]?)$/] {
343 throwWarning: tr("unusual value of {0}", "{0.key}");
344 suggestAlternative: "x%";
345 suggestAlternative: "x°";
346 suggestAlternative: "up";
347 suggestAlternative: "down";
348 assertMatch: "way incline=extreme";
349 assertNoMatch: "way incline=up";
350 assertNoMatch: "way incline=down";
351 assertNoMatch: "way incline=10%";
352 assertNoMatch: "way incline=-5%";
353 assertNoMatch: "way incline=10°";
354}
355
356/* see ticket #9631 */
357*[population][population !~ /^[0-9]+$/ ] {
358 throwWarning: tr("{0} must be a numeric value", "{0.key}");
359}
360
361/* must be an integer positive number only and not 0, see #10837 (lanes), #11055 (screen) */
362node[seats][seats !~ /^[1-9]([0-9]*)$/][amenity=bench],
363way[seats][seats !~ /^[1-9]([0-9]*)$/][amenity=bench],
364way[lanes][lanes !~ /^[1-9]([0-9]*)$/][highway],
365way["lanes:backward"]["lanes:backward" !~ /^[1-9]([0-9]*)$/][highway],
366way["lanes:forward"]["lanes:forward" !~ /^[1-9]([0-9]*)$/][highway],
367*[screen][screen !~ /^[1-9]([0-9]*)$/][amenity=cinema] {
368 throwError: tr("{0} must be a positive integer number", "{0.key}");
369 assertMatch: "way highway=residential lanes=-1";
370 assertMatch: "way highway=residential lanes=5.5";
371 assertMatch: "way highway=residential lanes=1;2";
372 assertMatch: "way highway=residential lanes:forward=-1";
373 assertMatch: "way highway=residential lanes:backward=-1";
374 assertNoMatch: "way highway=residential lanes=1";
375 assertMatch: "node amenity=cinema screen=led";
376 assertNoMatch: "node amenity=cinema screen=8";
377}
378*[admin_level][admin_level !~ /^(1|2|3|4|5|6|7|8|9|10|11|12)$/] {
379 throwWarning: tr("unusual value of {0}", "{0.key}");
380 assertMatch: "node admin_level=0";
381 assertMatch: "node admin_level=-1";
382 assertMatch: "node admin_level=13";
383 assertNoMatch: "node admin_level=5";
384}
385
386/* #14989 */
387*[direction][direction<0],
388*[direction][direction>=360],
389*[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))*$/] {
390 throwWarning: tr("unusual value of {0}", "{0.key}");
391 assertMatch: "node direction=north-down";
392 assertMatch: "node direction=rome";
393 assertMatch: "node direction=C";
394 assertMatch: "node direction=NNNE";
395 assertMatch: "node direction=1360";
396 assertNoMatch: "node direction=NE-S"; /* ranges are used at tourism=viewpoint*/
397 assertMatch: "node direction=north-south"; /* ranges only in numbers or short NESW form */
398 assertMatch: "node direction=north-east"; /* if range use N-E, if single direcion use NE */
399 assertNoMatch: "node direction=0-360"; /* complete panorama view */
400 assertNoMatch: "node direction=45-100;190-250;300-360";
401 assertMatch: "node direction=45-100;190-250;300-";
402 assertNoMatch: "node direction=45-100;190-250;300";
403 assertNoMatch: "node direction=90;270";
404 assertNoMatch: "node direction=up";
405 assertNoMatch: "node direction=down"; /* up/down are replaced by incline tag, has separate warning */
406 assertMatch: "node direction=-10";
407 assertNoMatch: "node direction=0";
408 assertNoMatch: "node direction=45";
409 assertMatch: "node direction=360";
410 assertNoMatch: "node direction=N";
411 assertNoMatch: "node direction=NNE";
412 assertNoMatch: "node direction=west";
413 assertNoMatch: "node direction=forward";
414 assertNoMatch: "node direction=anti-clockwise";
415 assertNoMatch: "node direction=anticlockwise"; /* both spellings are in use and even wiki uses both */
416}
417
418/* #14786 (should be safe to just remove the meters unit from the value) */
419*[ele][ele =~ /^-?[0-9]+(\.[0-9]+)? ?m$/] {
420 throwWarning: tr("{0} must be a numeric value, in meters and without units", "{0.key}");
421 fixAdd: concat("ele=", trim(replace(tag("ele"), "m", "")));
422 set ele_meter_remove_autofix;
423 assertMatch: "node ele=12m";
424 assertMatch: "node ele=12 m";
425 assertNoMatch: "node ele=12km";
426 assertMatch: "node ele=12.1m";
427 assertMatch: "node ele=-12.1 m";
428 assertNoMatch: "node ele=12";
429 assertNoMatch: "node ele=high";
430}
431*[ele][ele =~ /^[0-9]+,[0-9][0-9]?$/] {
432 throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
433 fixAdd: concat("ele=", replace(tag("ele"), ",", "."));
434 set ele_separator_autofix;
435 assertMatch: "node ele=5,5";
436 assertMatch: "node ele=12,00";
437 assertNoMatch: "node ele=8,848"; /* wrongly used thousands separator */
438 assertNoMatch: "node ele=3,50,5";
439 assertNoMatch: "node ele=3.5";
440 assertNoMatch: "node ele=4";
441}
442*[ele][ele !~ /^-?[0-9]+(\.[0-9]+)?$/]!.ele_meter_remove_autofix!.ele_separator_autofix {
443 throwWarning: tr("{0} must be a numeric value, in meters and without units", "{0.key}");
444 assertNoMatch: "node ele=12m";
445 assertNoMatch: "node ele=12 m";
446 assertMatch: "node ele=12km";
447 assertNoMatch: "node ele=12.1m";
448 assertNoMatch: "node ele=-12.1 m";
449 assertNoMatch: "node ele=12";
450 assertMatch: "node ele=high";
451}
452
453/* #17530 */
454*[ele][ele =~ /^-?[0-9]+\.[0-9][0-9][0-9]+$/] {
455 throwWarning: tr("{0}", "{0.tag}");
456 group: tr("Unnecessary amount of decimal places");
457 fixAdd: concat("ele=", round(tag("ele")*100)/100);
458 assertNoMatch: "node ele=12";
459 assertNoMatch: "node ele=1.12";
460 assertMatch: "node ele=12.123";
461 assertMatch: "node ele=12.1234";
462 assertMatch: "node ele=-12.6789";
463 assertNoMatch: "node ele=12.123 m";
464 assertNoMatch: "node ele=high";
465}
466
467/* #15774 */
468node[fire_hydrant:pressure="#"] {
469 throwError: tr("unusual value of {0}", "{0.key}");
470}
471
472*[interval][interval !~ /^([0-9][0-9]?|[0-9][0-9]:[0-5][0-9](:[0-9][0-9])?)$/] {
473 throwWarning: tr("unusual value of {0}", "{0.key}");
474 assertNoMatch: "way interval=5";
475 assertNoMatch: "way interval=20";
476 assertNoMatch: "way interval=00:05";
477 assertNoMatch: "way interval=00:05:00";
478 assertNoMatch: "way interval=03:00:00";
479 assertMatch: "way interval=123";
480 assertMatch: "way interval=0:5:0";
481 assertMatch: "way interval=00:65:00";
482}
483
484/* #15107 */
485*[aeroway=helipad ][iata][iata!~/^[A-Z]{3}$/],
486*[aeroway=aerodrome][iata][iata!~/^[A-Z]{3}$/] {
487 throwWarning: tr("wrong value: {0}", "{1.tag}");
488 group: tr("Airport tagging");
489 assertNoMatch: "way aeroway=aerodrome iata=BER";
490 assertMatch: "way aeroway=aerodrome iata=BERL";
491 assertMatch: "way aeroway=aerodrome iata=BE";
492 assertMatch: "way aeroway=aerodrome iata=ber";
493}
494*[aeroway=helipad ][icao][icao!~/^[A-Z]{4}$/],
495*[aeroway=aerodrome][icao][icao!~/^[A-Z]{4}$/] {
496 throwWarning: tr("wrong value: {0}", "{1.tag}");
497 group: tr("Airport tagging");
498 assertNoMatch: "way aeroway=aerodrome icao=EDDB";
499 assertMatch: "way aeroway=aerodrome icao=EDDBA";
500 assertMatch: "way aeroway=aerodrome icao=EDD";
501 assertMatch: "way aeroway=aerodrome icao=eddb";
502}
503*[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)/],
504*[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)/] {
505 throwWarning: tr("wrong value: {0}", "{1.tag}");
506 group: tr("Airport tagging");
507 assertNoMatch: "way aeroway=aerodrome icao=EDDB";
508 assertMatch: "way aeroway=aerodrome icao=EQQQ";
509}
510
511/* #18573 */
512*[isced:level][isced:level !~ /^(0|1|2|3|4|5|6|7|8)((;|-)(1|2|3|4|5|6|7|8))*$/] {
513 throwWarning: tr("unusual value of {0}", "{0.key}");
514 assertMatch: "node isced:level=secondary";
515 assertMatch: "node isced:level=0,1,2,3";
516 assertMatch: "node isced:level=9";
517 assertMatch: "node isced:level=10";
518 assertNoMatch: "node isced:level=0;1;2;3";
519 assertNoMatch: "node isced:level=0";
520 assertNoMatch: "node isced:level=5";
521 assertNoMatch: "node isced:level=0-3";
522}
523
524/* #11253, maxstay=0 is unclear. Was in presets. */
525*[maxstay=0] {
526 throwWarning: tr("Definition of {0} is unclear", "{0.tag}");
527 assertMatch: "node maxstay=0";
528 assertMatch: "way maxstay=0";
529 assertNoMatch: "node maxstay=2";
530 assertNoMatch: "way maxstay=no";
531}
532
533/* #11253, maxstay needs unit. Was in presets without it. Autofixes for the most common cases. */
534*[maxstay][maxstay =~ /^([1-9][0-9]*(\.[0-9]+)? min)$/][maxstay!="1 min"] {
535 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");
536 fixAdd: concat("maxstay=", replace(tag("maxstay"), "min", "minutes"));
537 set maxstay_autofix;
538 assertMatch: "node maxstay=\"5 min\"";
539 assertMatch: "node maxstay=\"15 min\"";
540 assertNoMatch: "node maxstay=\"1 min\"";
541 assertNoMatch: "node maxstay=\"02 minutes\"";
542 assertNoMatch: "node maxstay=\"2 minutes\"";
543}
544*[maxstay="1h"],
545*[maxstay="1 h"],
546*[maxstay="1 hr"] {
547 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");
548 fixAdd: "maxstay=1 hour";
549 set maxstay_autofix;
550 assertMatch: "node maxstay=1h";
551 assertMatch: "node maxstay=\"1 h\"";
552 assertMatch: "node maxstay=\"1 hr\"";
553}
554*[maxstay][maxstay =~ /^([1-9][0-9]*(\.[0-9]+)? h)$/][maxstay!="1 h"] {
555 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");
556 fixAdd: concat("maxstay=", replace(tag("maxstay"), "h", "hours"));
557 set maxstay_autofix;
558 assertMatch: "node maxstay=\"5 h\"";
559 assertMatch: "node maxstay=\"15 h\"";
560 assertNoMatch: "node maxstay=\"1 h\"";
561 assertNoMatch: "node maxstay=\"02 hours\"";
562 assertNoMatch: "node maxstay=\"2 hours\"";
563}
564*[maxstay][maxstay =~ /^([1-9][0-9]*(\.[0-9]+)? hr)$/][maxstay!="1 hr"] {
565 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");
566 fixAdd: concat("maxstay=", replace(tag("maxstay"), "hr", "hours"));
567 set maxstay_autofix;
568 assertMatch: "node maxstay=\"5 hr\"";
569 assertMatch: "node maxstay=\"15 hr\"";
570 assertNoMatch: "node maxstay=\"1 hr\"";
571 assertNoMatch: "node maxstay=\"02 hours\"";
572 assertNoMatch: "node maxstay=\"2 hours\"";
573}
574*[maxstay][maxstay =~ /^([1-9][0-9]*(\.[0-9]+)?h)$/][maxstay!="1h"] {
575 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");
576 fixAdd: concat("maxstay=", replace(tag("maxstay"), "h", " hours"));
577 set maxstay_autofix;
578 assertMatch: "node maxstay=5h";
579 assertMatch: "node maxstay=15h";
580 assertNoMatch: "node maxstay=1h";
581 assertNoMatch: "node maxstay=02hours";
582 assertNoMatch: "node maxstay=2hours";
583 assertNoMatch: "node maxstay=\"2 h\"";
584 assertNoMatch: "node maxstay=\"2 hr\"";
585}
586/* the rest without autofix */
587*[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 {
588 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");
589 assertMatch: "node maxstay=something";
590 assertMatch: "node maxstay=-5";
591 assertMatch: "node maxstay=180";
592 assertMatch: "node maxstay=66minutes";
593 assertMatch: "node maxstay=\"1. hours\"";
594 assertMatch: "node maxstay=\"0 minutes\"";
595 assertNoMatch: "node maxstay=0";
596 assertNoMatch: "node maxstay=no";
597 assertNoMatch: "node maxstay=\"7 h\"";
598 assertNoMatch: "node maxstay=\"7 hr\"";
599 assertNoMatch: "node maxstay=unlimited";
600 assertNoMatch: "node maxstay=load-unload";
601 assertNoMatch: "node maxstay=\"66 minutes\"";
602 assertNoMatch: "node maxstay=\"2.5 hours\"";
603}
Note: See TracBrowser for help on using the repository browser.