[6532] | 1 | /* measurement values and units warnings (ticket #8687) */
|
---|
| 2 |
|
---|
| 3 | *[layer =~ /\+.*/] {
|
---|
| 4 | throwWarning: tr("layer tag with + sign");
|
---|
[6534] | 5 | fixAdd: concat("layer=", replace(tag("layer"), "+", ""));
|
---|
[6532] | 6 | assertMatch: "node layer=+1";
|
---|
| 7 | assertNoMatch: "node layer=1";
|
---|
| 8 | assertNoMatch: "node layer=-1";
|
---|
| 9 | }
|
---|
| 10 |
|
---|
| 11 | *[layer !~ /^0$|^(-|\+)?[1-5]$/] {
|
---|
| 12 | throwWarning: tr("layer should be between -5 and 5");
|
---|
| 13 | assertMatch: "node layer=-50";
|
---|
| 14 | assertMatch: "node layer=6";
|
---|
| 15 | assertMatch: "node layer=+100";
|
---|
| 16 | assertNoMatch: "node layer=-5";
|
---|
| 17 | assertNoMatch: "node layer=0";
|
---|
| 18 | assertNoMatch: "node layer=2";
|
---|
| 19 | assertNoMatch: "node layer=+5";
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | *[level !~ /^((([0-9]|-[1-9])|[1-9][0-9]*)(\.5)?)(;(([0-9]|-[1-9])|[1-9][0-9]*)(\.5)?)*$|^-0\.5$/] {
|
---|
| 23 | throwWarning: tr("level should be numbers with optional .5 increments");
|
---|
| 24 | assertMatch: "node level=one";
|
---|
| 25 | assertNoMatch: "node level=0";
|
---|
| 26 | assertNoMatch: "node level=1";
|
---|
| 27 | assertNoMatch: "node level=-1";
|
---|
| 28 | assertNoMatch: "node level=-0.5";
|
---|
| 29 | assertNoMatch: "node level=1.5";
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | *[height !~ /^(([0-9]+\.?[0-9]*( (m|ft))?)|([1-9][0-9]*\'((10|11|[0-9])((\.[0-9]+)?)\")?))$/] {
|
---|
| 33 | throwWarning: tr("{0}: meters is default; period is separator; if units, put space then unit", "height");
|
---|
| 34 | assertMatch: "node height=medium";
|
---|
| 35 | assertMatch: "node height=-5";
|
---|
| 36 | assertNoMatch: "node height=2 m";
|
---|
| 37 | assertNoMatch: "node height=5";
|
---|
| 38 | assertNoMatch: "node height=7.8";
|
---|
| 39 | assertNoMatch: "node height=20 ft";
|
---|
| 40 | assertNoMatch: "node height=22'";
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | *[maxheight !~ /^(([1-9][0-9]*(\.[0-9]+)?( (m|ft))?)|([0-9]+\'(([0-9]|10|11)(\.[0-9]*)?\")?))$/] {
|
---|
| 44 | throwWarning: tr("{0}: meters is default; period is separator; if units, put space then unit", "maxheight");
|
---|
| 45 | assertMatch: "node maxheight=something";
|
---|
| 46 | assertMatch: "node maxheight=-5";
|
---|
| 47 | assertMatch: "node maxheight=0";
|
---|
| 48 | assertNoMatch: "node maxheight=4";
|
---|
| 49 | assertNoMatch: "node maxheight=3.5";
|
---|
| 50 | assertNoMatch: "node maxheight=2 m";
|
---|
| 51 | assertNoMatch: "node maxheight=14 ft";
|
---|
| 52 | assertNoMatch: "node maxheight=10'";
|
---|
| 53 | assertNoMatch: "node maxheight=16'3\"";
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | way[width !~ /^(([0-9]+\.?[0-9]*( [a-z]+)?)|([0-9]+\'([0-9]+\.?[0-9]*\")?))$/] {
|
---|
| 57 | throwWarning: tr("{0}: meters is default; period is separator; if units, put space then unit", "width");
|
---|
| 58 | assertMatch: "way width=something";
|
---|
| 59 | assertMatch: "way width=-5";
|
---|
| 60 | assertNoMatch: "way width=3";
|
---|
| 61 | assertNoMatch: "way width=0.5";
|
---|
| 62 | assertNoMatch: "way width=1 m";
|
---|
| 63 | assertNoMatch: "way width=10 ft";
|
---|
| 64 | assertNoMatch: "way width=1'";
|
---|
| 65 | assertNoMatch: "way width=10'5\"";
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | *[maxwidth !~ /^(([0-9]+\.?[0-9]*( (m|ft))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/] {
|
---|
| 69 | throwWarning: tr("{0}: meters is default; period is separator; if units, put space then unit", "maxwidth");
|
---|
| 70 | assertMatch: "way maxwidth=something";
|
---|
| 71 | assertMatch: "way maxwidth=-5";
|
---|
| 72 | assertNoMatch: "way maxwidth=2";
|
---|
| 73 | assertNoMatch: "way maxwidth=6'6\"";
|
---|
| 74 | assertNoMatch: "way maxwidth=2.5";
|
---|
| 75 | assertNoMatch: "way maxwidth=7 ft";
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | way[maxspeed !~ /^(signals|none|unposted|unknown|variable|walk|[1-9][0-9]*( [a-z]+)?|[A-Z][A-Z]:(urban|rural|living_street|motorway))$/] {
|
---|
| 79 | throwWarning: tr("unusual {0} format", "maxspeed");
|
---|
| 80 | assertMatch: "way maxspeed=something";
|
---|
| 81 | assertMatch: "way maxspeed=-50";
|
---|
| 82 | assertMatch: "way maxspeed=0";
|
---|
| 83 | assertNoMatch: "way maxspeed=50";
|
---|
| 84 | assertNoMatch: "way maxspeed=30 mph";
|
---|
| 85 | assertNoMatch: "way maxspeed=RO:urban";
|
---|
| 86 | assertNoMatch: "way maxspeed=RU:rural";
|
---|
| 87 | assertNoMatch: "way maxspeed=RU:living_street";
|
---|
| 88 | assertNoMatch: "way maxspeed=DE:motorway";
|
---|
| 89 | assertNoMatch: "way maxspeed=signals";
|
---|
| 90 | assertNoMatch: "way maxspeed=none";
|
---|
| 91 | assertNoMatch: "way maxspeed=variable";
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | way[voltage =~ /(.*[A-Za-z].*)|.*,.*|.*( ).*/] {
|
---|
| 95 | throwWarning: tr("voltage should be in volts with no units/delimiter/spaces");
|
---|
| 96 | assertMatch: "way voltage=medium";
|
---|
| 97 | assertNoMatch: "way voltage=15000";
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 | /* some users are using frequency for other purposes (not electromagnetic)
|
---|
| 101 | with the values 'perennial' and 'intermittent'; the vast majority are 0, 16.7, 50 and 60 */
|
---|
| 102 | way[frequency !~ /^(0|[1-9][0-9]*(\.[0-9]+)?)( (kHz|MHz|GHz|THz))?$/] {
|
---|
| 103 | throwWarning: tr("unusual {0} specification", "frequency");
|
---|
| 104 | assertMatch: "way frequency=something";
|
---|
| 105 | assertNoMatch: "way frequency=0"; /* DC */
|
---|
| 106 | assertNoMatch: "way frequency=16.7";
|
---|
| 107 | assertNoMatch: "way frequency=50";
|
---|
| 108 | assertNoMatch: "way frequency=680 kHz";
|
---|
| 109 | assertNoMatch: "way frequency=123.5 MHz";
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | way[gauge !~ /^([1-9][0-9]{1,3}(;[1-9][0-9]{1,3})*|broad|standard|narrow)$/] {
|
---|
| 113 | throwWarning: tr("unusual train track gauge; use mm with no separator");
|
---|
| 114 | assertMatch: "way gauge=something";
|
---|
| 115 | assertNoMatch: "way gauge=1435";
|
---|
| 116 | assertNoMatch: "way gauge=1000;1435";
|
---|
| 117 | assertNoMatch: "way gauge=standard";
|
---|
| 118 | assertNoMatch: "way gauge=narrow";
|
---|
| 119 | }
|
---|
| 120 |
|
---|
| 121 | /* the numbers for percentage and degrees include could probably be bracketed a bit more precisely */
|
---|
| 122 | way[incline !~ /^(up|down|-?([0-9]+?(\.[1-9]%)?|100)[%°]?)$/] {
|
---|
| 123 | throwWarning: tr("unusual incline; use percentages/degrees or up/down");
|
---|
| 124 | assertMatch: "way incline=extreme";
|
---|
| 125 | assertNoMatch: "way incline=up";
|
---|
| 126 | assertNoMatch: "way incline=down";
|
---|
| 127 | assertNoMatch: "way incline=10%";
|
---|
| 128 | assertNoMatch: "way incline=-5%";
|
---|
| 129 | assertNoMatch: "way incline=10°";
|
---|
| 130 | }
|
---|