/* measurement values and units warnings (ticket #8687) */ *[/^[0-9]+$/] { throwWarning: tr("numerical key"); assertMatch: "way 123=foo"; assertNoMatch: "way ref.1=foo"; } *[layer =~ /\+.*/] { throwWarning: tr("layer tag with + sign"); fixAdd: concat("layer=", replace(tag("layer"), "+", "")); assertMatch: "node layer=+1"; assertNoMatch: "node layer=1"; assertNoMatch: "node layer=-1"; } *[layer][layer !~ /^0$|^(-|\+)?[1-5]$/] { throwWarning: tr("layer should be between -5 and 5"); assertMatch: "node layer=-50"; assertMatch: "node layer=6"; assertMatch: "node layer=+100"; assertNoMatch: "node layer=-5"; assertNoMatch: "node layer=0"; assertNoMatch: "node layer=2"; assertNoMatch: "node layer=+5"; /* this is an invalid value, but this case is already covered by the previous rule */ } *[building:levels][building:levels !~ /^(([0-9]|[1-9][0-9]*)(\.5)?)$/], *[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 seperated by a ; */ throwWarning: tr("{0} should have numbers only with optional .5 increments", "{0.key}"); assertMatch: "node level=one"; assertMatch: "node level=01"; assertMatch: "node level=-03"; assertMatch: "node level=-01.5"; assertMatch: "node level=2.3"; assertMatch: "node level=-0"; assertNoMatch: "node level=0"; assertNoMatch: "node level=1"; assertNoMatch: "node level=-1"; assertNoMatch: "node level=-0.5"; assertNoMatch: "node level=1.5"; assertNoMatch: "node level=12"; assertNoMatch: "node level=0;1"; assertNoMatch: "node level=1;1.5"; assertNoMatch: "node level=1;0.5"; assertNoMatch: "node level=0;-0.5"; assertNoMatch: "node level=-0.5;0"; assertNoMatch: "node level=-1;-0.5"; assertNoMatch: "node building:levels=1.5"; assertMatch: "node building:levels=-1"; assertNoMatch: "node building:levels=0"; /* valid because there can be building:levels:underground > 0 or roof:levels > 0 */ } *[height][height !~ /^(([0-9]+\.?[0-9]*( (m|ft))?)|([1-9][0-9]*\'((10|11|[0-9])((\.[0-9]+)?)\")?))$/] { throwWarning: tr("{0}: meters is default; period is separator; if units, put space then unit", "height"); assertMatch: "node height=medium"; assertMatch: "node height=-5"; assertNoMatch: "node height=2 m"; assertNoMatch: "node height=5"; assertNoMatch: "node height=7.8"; assertNoMatch: "node height=20 ft"; assertNoMatch: "node height=22'"; } *[maxheight][maxheight !~ /^(([1-9][0-9]*(\.[0-9]+)?( (m|ft))?)|([0-9]+\'(([0-9]|10|11)(\.[0-9]*)?\")?)|none|default)$/] { throwWarning: tr("{0}: meters is default; period is separator; if units, put space then unit", "maxheight"); assertMatch: "node maxheight=something"; assertMatch: "node maxheight=-5"; assertMatch: "node maxheight=0"; assertNoMatch: "node maxheight=4"; assertNoMatch: "node maxheight=3.5"; assertNoMatch: "node maxheight=2 m"; assertNoMatch: "node maxheight=14 ft"; assertNoMatch: "node maxheight=10'"; assertNoMatch: "node maxheight=16'3\""; } way[width][width !~ /^(([0-9]+\.?[0-9]*( [a-z]+)?)|([0-9]+\'([0-9]+\.?[0-9]*\")?))$/] { throwWarning: tr("{0}: meters is default; period is separator; if units, put space then unit", "width"); assertMatch: "way width=something"; assertMatch: "way width=-5"; assertNoMatch: "way width=3"; assertNoMatch: "way width=0.5"; assertNoMatch: "way width=1 m"; assertNoMatch: "way width=10 ft"; assertNoMatch: "way width=1'"; assertNoMatch: "way width=10'5\""; } *[maxwidth][maxwidth !~ /^(([0-9]+\.?[0-9]*( (m|ft))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/] { throwWarning: tr("{0}: meters is default; period is separator; if units, put space then unit", "maxwidth"); assertMatch: "way maxwidth=something"; assertMatch: "way maxwidth=-5"; assertNoMatch: "way maxwidth=2"; assertNoMatch: "way maxwidth=6'6\""; assertNoMatch: "way maxwidth=2.5"; assertNoMatch: "way maxwidth=7 ft"; } *[maxweight][maxweight !~ /^(([0-9]+\.?[0-9]*( (t|kg|lbs))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/] { throwWarning: tr("{0}: tonne is default; period is separator; if units, put space then unit", "maxweight"); assertMatch: "way maxweight=something"; assertMatch: "way maxweight=-5"; assertNoMatch: "way maxweight=2"; assertNoMatch: "way maxweight=6'6\""; assertNoMatch: "way maxweight=2.5"; assertNoMatch: "way maxweight=7 kg"; } way[maxspeed][maxspeed !~ /^(signals|none|unposted|variable|walk|[1-9][0-9]*( [a-z]+)?|[A-Z][A-Z]:(urban|rural|living_street|motorway))$/], way[maxspeed:forward][maxspeed:forward !~ /^(signals|none|unposted|variable|walk|[1-9][0-9]*( [a-z]+)?|[A-Z][A-Z]:(urban|rural|living_street|motorway))$/], way[maxspeed:backward][maxspeed:backward !~ /^(signals|none|unposted|variable|walk|[1-9][0-9]*( [a-z]+)?|[A-Z][A-Z]:(urban|rural|living_street|motorway))$/] { throwWarning: tr("unusual {0} format", "maxspeed"); assertMatch: "way maxspeed=something"; assertMatch: "way maxspeed=-50"; assertMatch: "way maxspeed=0"; assertNoMatch: "way maxspeed=50"; assertNoMatch: "way maxspeed=30 mph"; assertNoMatch: "way maxspeed=RO:urban"; assertNoMatch: "way maxspeed=RU:rural"; assertNoMatch: "way maxspeed=RU:living_street"; assertNoMatch: "way maxspeed=DE:motorway"; assertNoMatch: "way maxspeed=signals"; assertNoMatch: "way maxspeed=none"; assertNoMatch: "way maxspeed=variable"; } *[distance][distance !~ /^(([0-9]+\.?[0-9]*( (km|mi|nmi))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/] { throwWarning: tr("{0}: kilometers is default; period is separator; if units, put space then unit", "distance"); assertMatch: "way distance=something"; assertMatch: "way distance=-5"; assertNoMatch: "way distance=2"; assertNoMatch: "way distance=2.5"; assertNoMatch: "way distance=7 mi"; } way[voltage][voltage =~ /(.*[A-Za-z].*)|.*,.*|.*( ).*/] { throwWarning: tr("voltage should be in volts with no units/delimiter/spaces"); assertMatch: "way voltage=medium"; assertNoMatch: "way voltage=15000"; } /* some users are using frequency for other purposes (not electromagnetic) with the values 'perennial' and 'intermittent'; the vast majority are 0, 16.7, 50 and 60 */ way[frequency][frequency !~ /^(0|[1-9][0-9]*(\.[0-9]+)?)( (kHz|MHz|GHz|THz))?$/] { throwWarning: tr("unusual {0} specification", "frequency"); assertMatch: "way frequency=something"; assertNoMatch: "way frequency=0"; /* DC */ assertNoMatch: "way frequency=16.7"; assertNoMatch: "way frequency=50"; assertNoMatch: "way frequency=680 kHz"; assertNoMatch: "way frequency=123.5 MHz"; } way[gauge][gauge !~ /^([1-9][0-9]{1,3}(;[1-9][0-9]{1,3})*|broad|standard|narrow)$/] { throwWarning: tr("unusual train track gauge; use mm with no separator"); assertMatch: "way gauge=something"; assertNoMatch: "way gauge=1435"; assertNoMatch: "way gauge=1000;1435"; assertNoMatch: "way gauge=standard"; assertNoMatch: "way gauge=narrow"; } /* the numbers for percentage and degrees include could probably be bracketed a bit more precisely */ way[incline][incline !~ /^(up|down|-?([0-9]+?(\.[1-9]%)?|100)[%°]?)$/] { throwWarning: tr("unusual incline; use percentages/degrees or up/down"); assertMatch: "way incline=extreme"; assertNoMatch: "way incline=up"; assertNoMatch: "way incline=down"; assertNoMatch: "way incline=10%"; assertNoMatch: "way incline=-5%"; assertNoMatch: "way incline=10°"; } /* see ticket #9631 */ *[population][population !~ /^[0-9]+$/ ] { throwWarning: tr("{0} must be a numeric value", "{0.key}"); } /* must be an integer positive number only and not 0, see #10837 (lanes), #11055 (screen) */ way[lanes][lanes !~ /^[1-9]([0-9]*)$/][highway], way["lanes:backward"]["lanes:backward" !~ /^[1-9]([0-9]*)$/][highway], way["lanes:forward"]["lanes:forward" !~ /^[1-9]([0-9]*)$/][highway], *[screen][screen !~ /^[1-9]([0-9]*)$/][amenity=cinema] { throwError: tr("{0} must be a positive integer number", "{0.key}"); assertMatch: "way highway=residential lanes=-1"; assertMatch: "way highway=residential lanes=5.5"; assertMatch: "way highway=residential lanes=1;2"; assertMatch: "way highway=residential lanes:forward=-1"; assertMatch: "way highway=residential lanes:backward=-1"; assertNoMatch: "way highway=residential lanes=1"; assertMatch: "node amenity=cinema screen=led"; assertNoMatch: "node amenity=cinema screen=8"; } *[admin_level][admin_level !~ /^(1|2|3|4|5|6|7|8|9|10|11|12)$/] { throwWarning: tr("unusual value of {0}", "{1.key}"); assertMatch: "node admin_level=0"; assertMatch: "node admin_level=-1"; assertMatch: "node admin_level=13"; assertNoMatch: "node admin_level=5"; } *[direction][direction>=0][direction<360] { set correct_direction_degree; } *[direction][direction !~ /^(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)$/]!.correct_direction_degree { throwWarning: tr("unusual value of {0}", "{1.key}"); assertMatch: "node direction=360"; assertMatch: "node direction=-10"; assertMatch: "node direction=north-east"; assertNoMatch: "node direction=up"; assertNoMatch: "node direction=down"; /* up/down are replaced by incline tag, has separate warning */ assertNoMatch: "node direction=0"; assertNoMatch: "node direction=45"; assertNoMatch: "node direction=N"; assertNoMatch: "node direction=NNE"; assertNoMatch: "node direction=west"; assertNoMatch: "node direction=forward"; assertNoMatch: "node direction=anti-clockwise"; assertNoMatch: "node direction=anticlockwise"; /* both spellings are in use and even wiki uses both */ } /* #14786 (should be safe to just remove the meters unit from the value) */ *[ele][ele =~ /^-?[0-9]+(\.[0-9]+)? ?m$/] { throwWarning: tr("{0} must be a numeric value, in meters and without units", "{0.key}"); fixAdd: concat("ele=", trim(replace(tag("ele"), "m", ""))); set .ele_is_fixable; assertMatch: "node ele=12m"; assertMatch: "node ele=12 m"; assertNoMatch: "node ele=12km"; assertMatch: "node ele=12.1m"; assertMatch: "node ele=-12.1 m"; assertNoMatch: "node ele=12"; assertNoMatch: "node ele=high"; } *[ele][ele !~ /^-?[0-9]+(\.[0-9]+)?$/]!.ele_is_fixable{ throwWarning: tr("{0} must be a numeric value, in meters and without units", "{0.key}"); assertNoMatch: "node ele=12m"; assertNoMatch: "node ele=12 m"; assertMatch: "node ele=12km"; assertNoMatch: "node ele=12.1m"; assertNoMatch: "node ele=-12.1 m"; assertNoMatch: "node ele=12"; assertMatch: "node ele=high"; }