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

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

see #19907 - Avoid that the fix button of some numeric tests produces a still wrong value

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