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

Last change on this file since 17937 was 17934, checked in by Klumbumbus, 5 years ago

Fix #21026, see #14532 - Better warnings for negative numeric values

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