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

Last change on this file since 9737 was 9737, checked in by Klumbumbus, 9 years ago

add numerical test for building:levels

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