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

Last change on this file was 17955, checked in by Klumbumbus, 7 months ago

see #21026, see #14532 - Fix i18n

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