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

Last change on this file since 19140 was 19140, checked in by stoecker, 3 months ago

adapt height rules to use siunit_length - patch by gaben, fix #23781

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