source: josm/trunk/data/validator/numeric.mapcss @ 9050

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

see #12102 - ignore man_made=petroleum_well, add validator warning for unusual value of admin_level

  • Property svn:eol-style set to native
File size: 7.6 KB
Line 
1/* measurement values and units warnings (ticket #8687) */
2
3*[/^[0-9]+$/] {
4  throwWarning: tr("numerical key");
5  assertMatch: "way 123=foo";
6  assertNoMatch: "way ref.1=foo";
7}
8
9*[layer =~ /\+.*/] {
10  throwWarning: tr("layer tag with + sign");
11  fixAdd: concat("layer=", replace(tag("layer"), "+", ""));
12  assertMatch: "node layer=+1";
13  assertNoMatch: "node layer=1";
14  assertNoMatch: "node layer=-1";
15}
16
17*[layer][layer !~ /^0$|^(-|\+)?[1-5]$/] {
18  throwWarning: tr("layer should be between -5 and 5");
19  assertMatch: "node layer=-50";
20  assertMatch: "node layer=6";
21  assertMatch: "node layer=+100";
22  assertNoMatch: "node layer=-5";
23  assertNoMatch: "node layer=0";
24  assertNoMatch: "node layer=2";
25  assertNoMatch: "node layer=+5";
26}
27
28*[level][level !~ /^((([0-9]|-[1-9])|[1-9][0-9]*)(\.5)?)(;(([0-9]|-[1-9])|[1-9][0-9]*)(\.5)?)*$|^-0\.5$/] {
29  throwWarning: tr("level should be numbers with optional .5 increments");
30  assertMatch: "node level=one";
31  assertNoMatch: "node level=0";
32  assertNoMatch: "node level=1";
33  assertNoMatch: "node level=-1";
34  assertNoMatch: "node level=-0.5";
35  assertNoMatch: "node level=1.5";
36}
37
38*[height][height !~ /^(([0-9]+\.?[0-9]*( (m|ft))?)|([1-9][0-9]*\'((10|11|[0-9])((\.[0-9]+)?)\")?))$/] {
39  throwWarning: tr("{0}: meters is default; period is separator; if units, put space then unit", "height");
40  assertMatch: "node height=medium";
41  assertMatch: "node height=-5";
42  assertNoMatch: "node height=2 m";
43  assertNoMatch: "node height=5";
44  assertNoMatch: "node height=7.8";
45  assertNoMatch: "node height=20 ft";
46  assertNoMatch: "node height=22'";
47}
48
49*[maxheight][maxheight !~ /^(([1-9][0-9]*(\.[0-9]+)?( (m|ft))?)|([0-9]+\'(([0-9]|10|11)(\.[0-9]*)?\")?))$/] {
50  throwWarning: tr("{0}: meters is default; period is separator; if units, put space then unit", "maxheight");
51  assertMatch: "node maxheight=something";
52  assertMatch: "node maxheight=-5";
53  assertMatch: "node maxheight=0";
54  assertNoMatch: "node maxheight=4";
55  assertNoMatch: "node maxheight=3.5";
56  assertNoMatch: "node maxheight=2 m";
57  assertNoMatch: "node maxheight=14 ft";
58  assertNoMatch: "node maxheight=10'";
59  assertNoMatch: "node maxheight=16'3\"";
60}
61
62way[width][width !~ /^(([0-9]+\.?[0-9]*( [a-z]+)?)|([0-9]+\'([0-9]+\.?[0-9]*\")?))$/] {
63  throwWarning: tr("{0}: meters is default; period is separator; if units, put space then unit", "width");
64  assertMatch: "way width=something";
65  assertMatch: "way width=-5";
66  assertNoMatch: "way width=3";
67  assertNoMatch: "way width=0.5";
68  assertNoMatch: "way width=1 m";
69  assertNoMatch: "way width=10 ft";
70  assertNoMatch: "way width=1'";
71  assertNoMatch: "way width=10'5\"";
72}
73
74*[maxwidth][maxwidth !~ /^(([0-9]+\.?[0-9]*( (m|ft))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/] {
75  throwWarning: tr("{0}: meters is default; period is separator; if units, put space then unit", "maxwidth");
76  assertMatch: "way maxwidth=something";
77  assertMatch: "way maxwidth=-5";
78  assertNoMatch: "way maxwidth=2";
79  assertNoMatch: "way maxwidth=6'6\"";
80  assertNoMatch: "way maxwidth=2.5";
81  assertNoMatch: "way maxwidth=7 ft";
82}
83*[maxweight][maxweight !~ /^(([0-9]+\.?[0-9]*( (t|kg|lbs))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/] {
84  throwWarning: tr("{0}: tonne is default; period is separator; if units, put space then unit", "maxweight");
85  assertMatch: "way maxweight=something";
86  assertMatch: "way maxweight=-5";
87  assertNoMatch: "way maxweight=2";
88  assertNoMatch: "way maxweight=6'6\"";
89  assertNoMatch: "way maxweight=2.5";
90  assertNoMatch: "way maxweight=7 kg";
91}
92way[maxspeed][maxspeed !~ /^(signals|none|unposted|variable|walk|[1-9][0-9]*( [a-z]+)?|[A-Z][A-Z]:(urban|rural|living_street|motorway))$/],
93way[maxspeed:forward][maxspeed:forward !~ /^(signals|none|unposted|variable|walk|[1-9][0-9]*( [a-z]+)?|[A-Z][A-Z]:(urban|rural|living_street|motorway))$/],
94way[maxspeed:backward][maxspeed:backward !~ /^(signals|none|unposted|variable|walk|[1-9][0-9]*( [a-z]+)?|[A-Z][A-Z]:(urban|rural|living_street|motorway))$/] {
95  throwWarning: tr("unusual {0} format", "maxspeed");
96  assertMatch: "way maxspeed=something";
97  assertMatch: "way maxspeed=-50";
98  assertMatch: "way maxspeed=0";
99  assertNoMatch: "way maxspeed=50";
100  assertNoMatch: "way maxspeed=30 mph";
101  assertNoMatch: "way maxspeed=RO:urban";
102  assertNoMatch: "way maxspeed=RU:rural";
103  assertNoMatch: "way maxspeed=RU:living_street";
104  assertNoMatch: "way maxspeed=DE:motorway";
105  assertNoMatch: "way maxspeed=signals";
106  assertNoMatch: "way maxspeed=none";
107  assertNoMatch: "way maxspeed=variable";
108}
109
110*[distance][distance !~ /^(([0-9]+\.?[0-9]*( (km|mi|nmi))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/] {
111  throwWarning: tr("{0}: kilometers is default; period is separator; if units, put space then unit", "distance");
112  assertMatch: "way distance=something";
113  assertMatch: "way distance=-5";
114  assertNoMatch: "way distance=2";
115  assertNoMatch: "way distance=2.5";
116  assertNoMatch: "way distance=7 mi";
117}
118
119way[voltage][voltage =~ /(.*[A-Za-z].*)|.*,.*|.*( ).*/] {
120  throwWarning: tr("voltage should be in volts with no units/delimiter/spaces");
121  assertMatch: "way voltage=medium";
122  assertNoMatch: "way voltage=15000";
123}
124
125/* some users are using frequency for other purposes (not electromagnetic)
126   with the values 'perennial' and 'intermittent'; the vast majority are 0, 16.7, 50 and 60 */
127way[frequency][frequency !~ /^(0|[1-9][0-9]*(\.[0-9]+)?)( (kHz|MHz|GHz|THz))?$/] {
128  throwWarning: tr("unusual {0} specification", "frequency");
129  assertMatch: "way frequency=something";
130  assertNoMatch: "way frequency=0"; /* DC */
131  assertNoMatch: "way frequency=16.7";
132  assertNoMatch: "way frequency=50";
133  assertNoMatch: "way frequency=680 kHz";
134  assertNoMatch: "way frequency=123.5 MHz";
135}
136
137way[gauge][gauge !~ /^([1-9][0-9]{1,3}(;[1-9][0-9]{1,3})*|broad|standard|narrow)$/] {
138  throwWarning: tr("unusual train track gauge; use mm with no separator");
139  assertMatch: "way gauge=something";
140  assertNoMatch: "way gauge=1435";
141  assertNoMatch: "way gauge=1000;1435";
142  assertNoMatch: "way gauge=standard";
143  assertNoMatch: "way gauge=narrow";
144}
145
146/* the numbers for percentage and degrees include could probably be bracketed a bit more precisely */
147way[incline][incline !~ /^(up|down|-?([0-9]+?(\.[1-9]%)?|100)[%°]?)$/] {
148  throwWarning: tr("unusual incline; use percentages/degrees or up/down");
149  assertMatch: "way incline=extreme";
150  assertNoMatch: "way incline=up";
151  assertNoMatch: "way incline=down";
152  assertNoMatch: "way incline=10%";
153  assertNoMatch: "way incline=-5%";
154  assertNoMatch: "way incline=10°";
155}
156
157/* see ticket #9631 */
158*[population][population !~ /^[0-9]+$/ ] {
159  throwWarning: tr("{0} must be a numeric value", "{0.key}");
160}
161
162/* must be an integer positive number only and not 0, see #10837 (lanes), #11055 (screen) */
163way[lanes][lanes !~ /^[1-9]([0-9]*)$/][highway],
164way["lanes:backward"]["lanes:backward" !~ /^[1-9]([0-9]*)$/][highway],
165way["lanes:forward"]["lanes:forward" !~ /^[1-9]([0-9]*)$/][highway],
166*[screen][screen !~ /^[1-9]([0-9]*)$/][amenity=cinema] {
167  throwError: tr("{0} must be a positive integer number", "{0.key}");
168  assertMatch: "way highway=residential lanes=-1";
169  assertMatch: "way highway=residential lanes=5.5";
170  assertMatch: "way highway=residential lanes=1;2";
171  assertMatch: "way highway=residential lanes:forward=-1";
172  assertMatch: "way highway=residential lanes:backward=-1";
173  assertNoMatch: "way highway=residential lanes=1";
174  assertMatch: "node amenity=cinema screen=led";
175  assertNoMatch: "node amenity=cinema screen=8";
176}
177*[admin_level][admin_level !~ /^(1|2|3|4|5|6|7|8|9|10|11|12)$/] {
178  throwWarning: tr("unusual value of {0}", "admin_level");
179  assertMatch: "node admin_level=0";
180  assertMatch: "node admin_level=-1";
181  assertMatch: "node admin_level=13";
182  assertNoMatch: "node admin_level=5";
183}
Note: See TracBrowser for help on using the repository browser.