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

Last change on this file was 18535, checked in by Klumbumbus, 4 months ago

see #21836 - Add some power/voltage validation rules:

  • voltage:primary/secondary/tertiary without transformer
  • voltage:primary/secondary/tertiary on a way
  • voltage:primary/secondary/tertiary not in correct number format (should be in volts with no units/delimiter/spaces)
  • don't warn about unknown numeric values of voltage:primary/secondary/tertiary
  • transformer together with voltage on nodes
  • voltage:secondary is lower than voltage:primary on transformer=generator
  • deprecate voltage-high and voltage-low in favor of voltage:primary/secondary
  • Property svn:eol-style set to native
File size: 34.3 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].*)|.*,.*|.*( ).*/],
376way[voltage:primary][voltage:primary =~ /(.*[A-Za-z].*)|.*,.*|.*( ).*/],
377way[voltage:secondary][voltage:secondary =~ /(.*[A-Za-z].*)|.*,.*|.*( ).*/],
378way[voltage:tertiary][voltage:tertiary =~ /(.*[A-Za-z].*)|.*,.*|.*( ).*/] {
379  throwWarning: tr("voltage should be in volts with no units/delimiter/spaces");
380  assertMatch: "way voltage=medium";
381  assertNoMatch: "way voltage=15000";
382}
383
384/* some users are using frequency for other purposes (not electromagnetic)
385   with the values 'perennial' and 'intermittent'; the vast majority are 0, 16.7, 50 and 60 */
386way[frequency][frequency !~ /^(0|[1-9][0-9]*(\.[0-9]+)?)( (kHz|MHz|GHz|THz))?$/] {
387  throwWarning: tr("unusual value of {0}", "{0.key}");
388  assertMatch: "way frequency=something";
389  assertNoMatch: "way frequency=0"; /* DC */
390  assertNoMatch: "way frequency=16.7";
391  assertNoMatch: "way frequency=50";
392  assertNoMatch: "way frequency=680 kHz";
393  assertNoMatch: "way frequency=123.5 MHz";
394}
395
396way[gauge][gauge      =~ /^(broad|standard|narrow)$/],
397relation[gauge][gauge =~ /^(broad|standard|narrow)$/] {
398  throwWarning: tr("imprecise value of {0}", "{0.tag}");
399  suggestAlternative: tr("an integer value in millimeters, without unit");
400  set imprecise_gauge;
401  assertNoMatch: "way gauge=something";
402  assertNoMatch: "way gauge=1435";
403  assertNoMatch: "way gauge=1000;1435";
404  assertNoMatch: "way gauge=2''10'";
405  assertMatch:   "way gauge=standard";
406  assertMatch:   "way gauge=narrow";
407}
408way[gauge][gauge      !~ /^([1-9][0-9]{1,3}(;[1-9][0-9]{1,3})*)$/]!.imprecise_gauge,
409relation[gauge][gauge !~ /^([1-9][0-9]{1,3}(;[1-9][0-9]{1,3})*)$/]!.imprecise_gauge {
410  throwWarning: tr("unusual value of {0}", "{0.key}");
411  set unusual_gauge;
412  assertMatch:   "way gauge=something";
413  assertMatch:   "way gauge=2''10'";
414  assertNoMatch: "way gauge=1435";
415  assertNoMatch: "way gauge=1000;1435";
416  assertNoMatch: "way gauge=standard";
417  assertNoMatch: "way gauge=narrow";
418}
419/* #21866 - warn on narrow_railway gauge values outside 89..1434 range, including multi values */
420way[/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,
421relation[/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]{
422  group: tr("suspicious tag combination");
423  throwWarning:  tr("unusual {0} value on narrow gauge railway", "{1.key}");
424  assertMatch:   "way railway=narrow_gauge gauge=88";
425  assertNoMatch: "way railway=narrow_gauge gauge=89";
426  assertNoMatch: "way railway=narrow_gauge gauge=1434";
427  assertMatch:   "way railway=narrow_gauge gauge=1435";
428  assertMatch:   "way railway=narrow_gauge gauge=1435;1500";
429  assertMatch:   "way railway=narrow_gauge gauge=60;600";
430  assertNoMatch: "way railway=narrow_gauge gauge=2''10'";
431  assertNoMatch: "way railway=narrow_gauge gauge=something";
432  assertNoMatch: "way railway=narrow_gauge gauge=narrow";
433}
434
435/* the numbers for percentage and degrees include could probably be bracketed a bit more precisely */
436way[incline][incline !~ /^(up|down|-?([0-9]+?(\.[1-9]%)?|100)[%°]?)$/] {
437  throwWarning: tr("unusual value of {0}", "{0.key}");
438  suggestAlternative: "x%";
439  suggestAlternative: "x°";
440  suggestAlternative: "up";
441  suggestAlternative: "down";
442  assertMatch: "way incline=extreme";
443  assertNoMatch: "way incline=up";
444  assertNoMatch: "way incline=down";
445  assertNoMatch: "way incline=10%";
446  assertNoMatch: "way incline=-5%";
447  assertNoMatch: "way incline=10°";
448}
449
450/* see ticket #9631 */
451*[population][population !~ /^[0-9]+$/ ] {
452  throwWarning: tr("{0} must be a numeric value", "{0.key}");
453}
454
455/* must be an integer positive number only and not 0, see #10837 (lanes), #11055 (screen) */
456node[seats][seats !~ /^[1-9]([0-9]*)$/][amenity=bench],
457way[seats][seats !~ /^[1-9]([0-9]*)$/][amenity=bench],
458way[lanes][lanes !~ /^[1-9]([0-9]*)$/][highway],
459way["lanes:backward"]["lanes:backward" !~ /^[1-9]([0-9]*)$/][highway],
460way["lanes:forward"]["lanes:forward" !~ /^[1-9]([0-9]*)$/][highway],
461*[screen][screen !~ /^[1-9]([0-9]*)$/][amenity=cinema] {
462  throwError: tr("{0} must be a positive integer number", "{0.key}");
463  assertMatch: "way highway=residential lanes=-1";
464  assertMatch: "way highway=residential lanes=5.5";
465  assertMatch: "way highway=residential lanes=1;2";
466  assertMatch: "way highway=residential lanes:forward=-1";
467  assertMatch: "way highway=residential lanes:backward=-1";
468  assertNoMatch: "way highway=residential lanes=1";
469  assertMatch: "node amenity=cinema screen=led";
470  assertNoMatch: "node amenity=cinema screen=8";
471}
472*[admin_level][admin_level !~ /^(1|2|3|4|5|6|7|8|9|10|11|12)$/] {
473  throwWarning: tr("unusual value of {0}", "{0.key}");
474  assertMatch: "node admin_level=0";
475  assertMatch: "node admin_level=-1";
476  assertMatch: "node admin_level=13";
477  assertNoMatch: "node admin_level=5";
478}
479
480/* #14989 */
481*[direction][direction<0],
482*[direction][direction>=360],
483*[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))*$/] {
484  throwWarning: tr("unusual value of {0}", "{0.key}");
485  assertMatch: "node direction=north-down";
486  assertMatch: "node direction=rome";
487  assertMatch: "node direction=C";
488  assertMatch: "node direction=NNNE";
489  assertMatch: "node direction=1360";
490  assertNoMatch: "node direction=NE-S"; /* ranges are used at tourism=viewpoint*/
491  assertMatch: "node direction=north-south"; /* ranges only in numbers or short NESW form */
492  assertMatch: "node direction=north-east"; /* if range use N-E, if single direcion use NE */
493  assertNoMatch: "node direction=0-360"; /* complete panorama view */
494  assertNoMatch: "node direction=45-100;190-250;300-360";
495  assertMatch: "node direction=45-100;190-250;300-";
496  assertNoMatch: "node direction=45-100;190-250;300";
497  assertNoMatch: "node direction=90;270";
498  assertNoMatch: "node direction=up";
499  assertNoMatch: "node direction=down"; /* up/down are replaced by incline tag, has separate warning */
500  assertMatch: "node direction=-10";
501  assertNoMatch: "node direction=0";
502  assertNoMatch: "node direction=45";
503  assertMatch: "node direction=360";
504  assertNoMatch: "node direction=N";
505  assertNoMatch: "node direction=NNE";
506  assertNoMatch: "node direction=west";
507  assertNoMatch: "node direction=forward";
508  assertNoMatch: "node direction=anti-clockwise";
509  assertNoMatch: "node direction=anticlockwise"; /* both spellings are in use and even wiki uses both */
510}
511
512/* #14786 (should be safe to just remove the meters unit from the value) */
513*[ele][ele =~ /^-?[0-9]+(\.[0-9]+)? ?m$/] {
514  throwWarning: tr("{0} must be a numeric value, in meters and without units", "{0.key}");
515  fixAdd: concat("ele=", trim(replace(tag("ele"), "m", "")));
516  set ele_meter_remove_autofix;
517  assertMatch: "node ele=12m";
518  assertMatch: "node ele=12 m";
519  assertNoMatch: "node ele=12km";
520  assertMatch: "node ele=12.1m";
521  assertMatch: "node ele=-12.1 m";
522  assertNoMatch: "node ele=12";
523  assertNoMatch: "node ele=high";
524}
525*[ele][ele =~ /^[0-9]+,[0-9][0-9]?$/] {
526  throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
527  fixAdd: concat("ele=", replace(tag("ele"), ",", "."));
528  set ele_separator_autofix;
529  assertMatch: "node ele=5,5";
530  assertMatch: "node ele=12,00";
531  assertNoMatch: "node ele=8,848"; /* wrongly used thousands separator */
532  assertNoMatch: "node ele=3,50,5";
533  assertNoMatch: "node ele=3.5";
534  assertNoMatch: "node ele=4";
535}
536*[ele][ele !~ /^-?[0-9]+(\.[0-9]+)?$/]!.ele_meter_remove_autofix!.ele_separator_autofix {
537  throwWarning: tr("{0} must be a numeric value, in meters and without units", "{0.key}");
538  assertNoMatch: "node ele=12m";
539  assertNoMatch: "node ele=12 m";
540  assertMatch: "node ele=12km";
541  assertNoMatch: "node ele=12.1m";
542  assertNoMatch: "node ele=-12.1 m";
543  assertNoMatch: "node ele=12";
544  assertMatch: "node ele=high";
545}
546
547/* #17530 */
548*[ele][ele =~ /^-?[0-9]+\.[0-9][0-9][0-9]+$/] {
549  throwWarning: tr("{0}", "{0.tag}");
550  group: tr("Unnecessary amount of decimal places");
551  fixAdd: concat("ele=", round(tag("ele")*100)/100);
552  assertNoMatch: "node ele=12";
553  assertNoMatch: "node ele=1.12";
554  assertMatch: "node ele=12.123";
555  assertMatch: "node ele=12.1234";
556  assertMatch: "node ele=-12.6789";
557  assertNoMatch: "node ele=12.123 m";
558  assertNoMatch: "node ele=high";
559}
560
561/* #15774 */
562node[fire_hydrant:pressure="#"] {
563  throwError: tr("unusual value of {0}", "{0.key}");
564}
565
566*[interval][interval !~ /^([0-9][0-9]?[0-9]?|[0-9]+[0-9]:[0-5][0-9](:[0-5][0-9])?)$/] {
567  throwWarning: tr("unusual value of {0}", "{0.key}");
568  assertNoMatch: "way interval=5";
569  assertNoMatch: "way interval=20";
570  assertNoMatch: "way interval=00:05";
571  assertNoMatch: "way interval=00:05:00";
572  assertNoMatch: "way interval=03:00:00";
573  assertNoMatch: "relation interval=168:00:00";
574  assertNoMatch: "relation interval=120";
575  assertMatch: "way interval=0:5:0";
576  assertMatch: "way interval=00:65:00";
577  assertMatch: "way interval=00:15:90";
578}
579
580/* #15107 */
581*[aeroway=helipad  ][iata][iata!~/^[A-Z]{3}$/],
582*[aeroway=aerodrome][iata][iata!~/^[A-Z]{3}$/] {
583  throwWarning: tr("wrong value: {0}", "{1.tag}");
584  group: tr("Airport tagging");
585  assertNoMatch: "way aeroway=aerodrome iata=BER";
586  assertMatch: "way aeroway=aerodrome iata=BERL";
587  assertMatch: "way aeroway=aerodrome iata=BE";
588  assertMatch: "way aeroway=aerodrome iata=ber";
589}
590*[aeroway=helipad  ][icao][icao!~/^[A-Z]{4}$/],
591*[aeroway=aerodrome][icao][icao!~/^[A-Z]{4}$/] {
592  throwWarning: tr("wrong value: {0}", "{1.tag}");
593  group: tr("Airport tagging");
594  assertNoMatch: "way aeroway=aerodrome icao=EDDB";
595  assertMatch: "way aeroway=aerodrome icao=EDDBA";
596  assertMatch: "way aeroway=aerodrome icao=EDD";
597  assertMatch: "way aeroway=aerodrome icao=eddb";
598}
599*[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)/],
600*[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)/] {
601  throwWarning: tr("wrong value: {0}", "{1.tag}");
602  group: tr("Airport tagging");
603  assertNoMatch: "way aeroway=aerodrome icao=EDDB";
604  assertMatch: "way aeroway=aerodrome icao=EQQQ";
605}
606
607/* #18573 */
608*[isced:level][isced:level !~ /^(0|1|2|3|4|5|6|7|8)((;|-)(1|2|3|4|5|6|7|8))*$/] {
609  throwWarning: tr("unusual value of {0}", "{0.key}");
610  assertMatch: "node isced:level=secondary";
611  assertMatch: "node isced:level=0,1,2,3";
612  assertMatch: "node isced:level=9";
613  assertMatch: "node isced:level=10";
614  assertNoMatch: "node isced:level=0;1;2;3";
615  assertNoMatch: "node isced:level=0";
616  assertNoMatch: "node isced:level=5";
617  assertNoMatch: "node isced:level=0-3";
618}
619
620/* #11253, maxstay=0 is unclear. Was in presets. */
621*[maxstay=0] {
622  throwWarning: tr("Definition of {0} is unclear", "{0.tag}");
623  assertMatch: "node maxstay=0";
624  assertMatch: "way maxstay=0";
625  assertNoMatch: "node maxstay=2";
626  assertNoMatch: "way maxstay=no";
627}
628
629/* #11253, maxstay needs unit. Was in presets without it. Autofixes for the most common cases. */
630*[maxstay][maxstay =~ /^([1-9][0-9]*(\.[0-9]+)? min)$/][maxstay!="1 min"] {
631  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");
632  fixAdd: concat("maxstay=", replace(tag("maxstay"), "min", "minutes"));
633  set maxstay_autofix;
634  assertMatch: "node maxstay=\"5 min\"";
635  assertMatch: "node maxstay=\"15 min\"";
636  assertNoMatch: "node maxstay=\"1 min\"";
637  assertNoMatch: "node maxstay=\"02 minutes\"";
638  assertNoMatch: "node maxstay=\"2 minutes\"";
639}
640*[maxstay="1h"],
641*[maxstay="1 h"],
642*[maxstay="1 hr"] {
643  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");
644  fixAdd: "maxstay=1 hour";
645  set maxstay_autofix;
646  assertMatch: "node maxstay=1h";
647  assertMatch: "node maxstay=\"1 h\"";
648  assertMatch: "node maxstay=\"1 hr\"";
649}
650*[maxstay][maxstay =~ /^([1-9][0-9]*(\.[0-9]+)? h)$/][maxstay!="1 h"] {
651  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");
652  fixAdd: concat("maxstay=", replace(tag("maxstay"), "h", "hours"));
653  set maxstay_autofix;
654  assertMatch: "node maxstay=\"5 h\"";
655  assertMatch: "node maxstay=\"15 h\"";
656  assertNoMatch: "node maxstay=\"1 h\"";
657  assertNoMatch: "node maxstay=\"02 hours\"";
658  assertNoMatch: "node maxstay=\"2 hours\"";
659}
660*[maxstay][maxstay =~ /^([1-9][0-9]*(\.[0-9]+)? hr)$/][maxstay!="1 hr"] {
661  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");
662  fixAdd: concat("maxstay=", replace(tag("maxstay"), "hr", "hours"));
663  set maxstay_autofix;
664  assertMatch: "node maxstay=\"5 hr\"";
665  assertMatch: "node maxstay=\"15 hr\"";
666  assertNoMatch: "node maxstay=\"1 hr\"";
667  assertNoMatch: "node maxstay=\"02 hours\"";
668  assertNoMatch: "node maxstay=\"2 hours\"";
669}
670*[maxstay][maxstay =~ /^([1-9][0-9]*(\.[0-9]+)?h)$/][maxstay!="1h"] {
671  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");
672  fixAdd: concat("maxstay=", replace(tag("maxstay"), "h", " hours"));
673  set maxstay_autofix;
674  assertMatch: "node maxstay=5h";
675  assertMatch: "node maxstay=15h";
676  assertNoMatch: "node maxstay=1h";
677  assertNoMatch: "node maxstay=02hours";
678  assertNoMatch: "node maxstay=2hours";
679  assertNoMatch: "node maxstay=\"2 h\"";
680  assertNoMatch: "node maxstay=\"2 hr\"";
681}
682/* the rest without autofix */
683*[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 {
684  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");
685  assertMatch: "node maxstay=something";
686  assertMatch: "node maxstay=-5";
687  assertMatch: "node maxstay=180";
688  assertMatch: "node maxstay=66minutes";
689  assertMatch: "node maxstay=\"1. hours\"";
690  assertMatch: "node maxstay=\"0 minutes\"";
691  assertNoMatch: "node maxstay=0";
692  assertNoMatch: "node maxstay=no";
693  assertNoMatch: "node maxstay=\"7 h\"";
694  assertNoMatch: "node maxstay=\"7 hr\"";
695  assertNoMatch: "node maxstay=unlimited";
696  assertNoMatch: "node maxstay=load-unload";
697  assertNoMatch: "node maxstay=\"66 minutes\"";
698  assertNoMatch: "node maxstay=\"2.5 hours\"";
699}
700
701/* #19536 */
702*[name][name =~ /^([0-9.,]+)$/] {
703  throwOther: tr("Numeric name: {0}. Maybe {1} or {2} is meant.", "{0.value}", "ref", "addr:housenumber");
704  assertMatch: "node name=12";
705  assertMatch: "node name=3.5";
706  assertNoMatch: "node name=\"1. Chemnitzer Billardclub 1952 e.V.\"";
707}
Note: See TracBrowser for help on using the repository browser.