Ticket #19163: josm_validator_numeric_unit_abb_v3.patch
| File josm_validator_numeric_unit_abb_v3.patch, 13.2 KB (added by , 6 years ago) |
|---|
-
src/org/openstreetmap/josm/resources/data/validator/numeric.mapcss
54 54 assertNoMatch: "node building:levels=0"; /* valid because there can be building:levels:underground > 0 or roof:levels > 0 */ 55 55 } 56 56 57 *[height][height =~ /^[0-9]+\.?[0-9]*(( )*(metre|metres|meter|meters|Metre|Metres|Meter|Meters)|m)$/] { 58 throwWarning: tr("Unit of {0} in long form: Use abbreviation for unit and space between value and unit", "{0.key}"); 59 set height_meter_autofix; 60 fixAdd: concat("height=", get(regexp_match("([0-9.]+)( )*(.+)",tag("height")),1)," m"); 61 assertMatch: "node height=6.78 meters"; 62 assertMatch: "way height=5 metre"; 63 assertMatch: "node height=2m"; 64 assertNoMatch: "node height=2 m"; 65 assertNoMatch: "relation height=5"; 66 } 67 *[height][height =~ /^[0-9]+\.?[0-9]*(( )*(foot|Foot|feet|Feet)|ft)$/] { 68 throwWarning: tr("Unit of {0} in long form: Use abbreviation for unit and space between value and unit", "{0.key}"); 69 set height_foot_autofix; 70 fixAdd: concat("height=", get(regexp_match("([0-9.]+)( )*(.+)",tag("height")),1)," ft"); 71 assertMatch: "node height=6.78 foot"; 72 assertMatch: "way height=5 Feet"; 73 assertMatch: "node height=2ft"; 74 assertNoMatch: "node height=2 ft"; 75 assertNoMatch: "relation height=5"; 76 } 57 77 *[height][height =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/] { 58 78 throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}"); 59 79 fixAdd: concat("height=", replace(tag("height"), ",", ".")); … … 66 86 assertNoMatch: "node height=3.5"; 67 87 assertNoMatch: "node height=4"; 68 88 } 69 *[height][height !~ /^(([0-9]+\.?[0-9]*( (m|ft))?)|([1-9][0-9]*\'((10|11|[0-9])((\.[0-9]+)?)\")?))$/]!.height_separator_autofix {70 throwWarning: tr("unusual value of {0}: meters is default; point is decimal separator; if units, put space then unit", "{0.key}");71 assertMatch: "node height=medium";72 assertMatch: "node height=-5";73 assertNoMatch: "node height=2 m";74 assertNoMatch: "node height=5";75 assertNoMatch: "node height=7.8";76 assertNoMatch: "node height=20 ft";77 assertNoMatch: "node height=22'";78 }79 89 90 *[maxheight][maxheight =~ /^[1-9][0-9]*\.?[0-9]*(( )*(metre|metres|meter|meters|Metre|Metres|Meter|Meters)|m)$/] { 91 throwWarning: tr("Unit of {0} in long form: Use abbreviation for unit and space between value and unit", "{0.key}"); 92 set maxheight_meter_autofix; 93 fixAdd: concat("maxheight=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxheight")),1)," m"); 94 assertMatch: "node maxheight=6.78 meters"; 95 assertMatch: "way maxheight=5 metre"; 96 assertMatch: "node maxheight=2m"; 97 assertNoMatch: "node maxheight=2 m"; 98 assertNoMatch: "relation maxheight=5"; 99 } 100 *[maxheight][maxheight =~ /^[0-9]+\.?[0-9]*(( )*(foot|Foot|feet|Feet)|ft)$/] { 101 throwWarning: tr("Unit of {0} in long form: Use abbreviation for unit and space between value and unit", "{0.key}"); 102 set maxheight_foot_autofix; 103 fixAdd: concat("maxheight=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxheight")),1)," ft"); 104 assertMatch: "node maxheight=6.78 foot"; 105 assertMatch: "way maxheight=5 Feet"; 106 assertMatch: "node maxheight=2ft"; 107 assertNoMatch: "node maxheight=2 ft"; 108 assertNoMatch: "relation maxheight=5"; 109 } 80 110 *[maxheight][maxheight =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/] { 81 111 throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}"); 82 112 fixAdd: concat("maxheight=", replace(tag("maxheight"), ",", ".")); 83 113 set maxheight_separator_autofix; 84 114 assertMatch: "node maxheight=5,5"; 85 115 assertMatch: "node maxheight=12,00"; 86 assertMatch: " nodemaxheight=12,5 ft";116 assertMatch: "way maxheight=12,5 ft"; 87 117 assertNoMatch: "node maxheight=12,000"; 88 118 assertNoMatch: "node maxheight=3,50,5"; 89 assertNoMatch: "node maxheight=3.5"; 90 assertNoMatch: "node maxheight=4"; 91 } 92 *[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 { 93 throwWarning: tr("unusual value of {0}: meters is default; point is decimal separator; if units, put space then unit", "{0.key}"); 94 assertMatch: "node maxheight=something"; 95 assertMatch: "node maxheight=-5"; 96 assertMatch: "node maxheight=0"; 119 assertNoMatch: "way maxheight=3.5"; 97 120 assertNoMatch: "node maxheight=4"; 98 assertNoMatch: "node maxheight=3.5";99 assertNoMatch: "node maxheight=2 m";100 assertNoMatch: "node maxheight=14 ft";101 assertNoMatch: "node maxheight=10'";102 assertNoMatch: "node maxheight=16'3\"";103 121 } 104 122 123 *[maxlength][maxlength =~ /^[1-9][0-9]*\.?[0-9]*(( )*(metre|metres|meter|meters|Metre|Metres|Meter|Meters)|m)$/] { 124 throwWarning: tr("Unit of {0} in long form: Use abbreviation for unit and space between value and unit", "{0.key}"); 125 set maxlength_meter_autofix; 126 fixAdd: concat("maxlength=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxlength")),1)," m"); 127 assertMatch: "node maxlength=6.78 meters"; 128 assertMatch: "way maxlength=5 metre"; 129 assertMatch: "node maxlength=2m"; 130 assertNoMatch: "node maxlength=2 m"; 131 assertNoMatch: "relation maxlength=5"; 132 } 133 *[maxlength][maxlength =~ /^[0-9]+\.?[0-9]*(( )*(foot|Foot|feet|Feet)|ft)$/] { 134 throwWarning: tr("Unit of {0} in long form: Use abbreviation for unit and space between value and unit", "{0.key}"); 135 set maxlength_foot_autofix; 136 fixAdd: concat("maxlength=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxlength")),1)," ft"); 137 assertMatch: "node maxlength=6.78 foot"; 138 assertMatch: "way maxlength=5 Feet"; 139 assertMatch: "node maxlength=2ft"; 140 assertNoMatch: "node maxlength=2 ft"; 141 assertNoMatch: "relation maxlength=5"; 142 } 143 *[maxlength][maxlength =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/] { 144 throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}"); 145 fixAdd: concat("maxlength=", replace(tag("maxlength"), ",", ".")); 146 set maxlength_separator_autofix; 147 assertMatch: "node maxlength=5,5"; 148 assertMatch: "node maxlength=12,00"; 149 assertMatch: "way maxlength=12,5 ft"; 150 assertNoMatch: "node maxlength=12,000"; 151 assertNoMatch: "node maxlength=3,50,5"; 152 assertNoMatch: "way maxlength=3.5"; 153 assertNoMatch: "node maxlength=4"; 154 } 155 156 *[width][width =~ /^[0-9]*\.?[0-9]*(( )*(metre|metres|meter|meters|Metre|Metres|Meter|Meters)|m)$/] { 157 throwWarning: tr("Unit of {0} in long form: Use abbreviation for unit and space between value and unit", "{0.key}"); 158 set width_meter_autofix; 159 fixAdd: concat("width=", get(regexp_match("([0-9.]+)( )*(.+)",tag("width")),1)," m"); 160 assertMatch: "node width=6.78 meters"; 161 assertMatch: "way width=5 metre"; 162 assertMatch: "node width=2m"; 163 assertNoMatch: "node width=2 m"; 164 assertNoMatch: "relation width=5"; 165 } 166 *[width][width =~ /^[0-9]+\.?[0-9]*(( )*(foot|Foot|feet|Feet)|ft)$/] { 167 throwWarning: tr("Unit of {0} in long form: Use abbreviation for unit and space between value and unit", "{0.key}"); 168 set width_foot_autofix; 169 fixAdd: concat("width=", get(regexp_match("([0-9.]+)( )*(.+)",tag("width")),1)," ft"); 170 assertMatch: "node width=6.78 foot"; 171 assertMatch: "way width=5 Feet"; 172 assertMatch: "node width=2ft"; 173 assertNoMatch: "node width=2 ft"; 174 assertNoMatch: "relation width=5"; 175 } 105 176 *[width][width =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/] { 106 177 throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}"); 107 178 fixAdd: concat("width=", replace(tag("width"), ",", ".")); … … 113 184 assertNoMatch: "node width=3.5"; 114 185 assertNoMatch: "node width=4"; 115 186 } 116 *[width][width !~ /^(([0-9]+\.?[0-9]*( [a-z]+)?)|([0-9]+\'([0-9]+\.?[0-9]*\")?))$/]!.width_separator_autofix {117 throwWarning: tr("unusual value of {0}: meters is default; point is decimal separator; if units, put space then unit", "{0.key}");118 assertMatch: "way width=something";119 assertMatch: "way width=-5";120 assertNoMatch: "way width=3";121 assertNoMatch: "way width=0.5";122 assertNoMatch: "way width=1 m";123 assertNoMatch: "way width=10 ft";124 assertNoMatch: "way width=1'";125 assertNoMatch: "way width=10'5\"";126 }127 187 188 *[maxwidth][maxwidth=~ /^[0-9]*\.?[0-9]*(( )*(metre|metres|meter|meters|Metre|Metres|Meter|Meters)|m)$/] { 189 throwWarning: tr("Unit of {0} in long form: Use abbreviation for unit and space between value and unit", "{0.key}"); 190 set maxwidth_meter_autofix; 191 fixAdd: concat("maxwidth=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxwidth")),1)," m"); 192 assertMatch: "node maxwidth=6.78 meters"; 193 assertMatch: "way maxwidth=5 metre"; 194 assertMatch: "node maxwidth=2m"; 195 assertNoMatch: "node maxwidth=2 m"; 196 assertNoMatch: "relation maxwidth=5"; 197 } 198 *[maxwidth][maxwidth =~ /^[0-9]+\.?[0-9]*(( )*(foot|Foot|feet|Feet)|ft)$/] { 199 throwWarning: tr("Unit of {0} in long form: Use abbreviation for unit and space between value and unit", "{0.key}"); 200 set maxwidth_foot_autofix; 201 fixAdd: concat("maxwidth=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxwidth")),1)," ft"); 202 assertMatch: "node maxwidth=6.78 foot"; 203 assertMatch: "way maxwidth=5 Feet"; 204 assertMatch: "node maxwidth=2ft"; 205 assertNoMatch: "node maxwidth=2 ft"; 206 assertNoMatch: "relation maxwidth=5"; 207 } 128 208 *[maxwidth][maxwidth =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/] { 129 209 throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}"); 130 210 fixAdd: concat("maxwidth=", replace(tag("maxwidth"), ",", ".")); … … 136 216 assertNoMatch: "node maxwidth=3.5"; 137 217 assertNoMatch: "node maxwidth=4"; 138 218 } 139 *[maxwidth][maxwidth !~ /^(([0-9]+\.?[0-9]*( (m|ft))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/]!.maxwidth_separator_autofix { 219 220 *[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, 221 *[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, 222 *[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, 223 *[width][width !~ /^(([0-9]+\.?[0-9]*( (m|ft))?)|([0-9]+\'([0-9]+\.?[0-9]*\")?))$/]!.width_separator_autofix!.width_meter_autofix!.width_foot_autofix, 224 *[maxwidth][maxwidth !~ /^(([0-9]+\.?[0-9]*( (m|ft))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/]!.maxwidth_separator_autofix!.maxwidth_meter_autofix!.maxwidth_foot_autofix { 140 225 throwWarning: tr("unusual value of {0}: meters is default; point is decimal separator; if units, put space then unit", "{0.key}"); 141 assertMatch: "way maxwidth=something"; 142 assertMatch: "way maxwidth=-5"; 143 assertNoMatch: "way maxwidth=2"; 144 assertNoMatch: "way maxwidth=6'6\""; 145 assertNoMatch: "way maxwidth=2.5"; 226 assertMatch: "node height=medium"; 227 assertMatch: "way maxheight=-5"; 228 assertMatch: "node maxlength=0"; 229 assertNoMatch: "way width=3"; 230 assertNoMatch: "node height=2.22 m"; 231 assertNoMatch: "node height=7.8"; 146 232 assertNoMatch: "way maxwidth=7 ft"; 233 assertNoMatch: "node height=22'"; 234 assertNoMatch: "way width=10'5\""; 147 235 } 148 236 149 *[maxweight][maxweight =~ /^[0-9]+,[0-9][0-9]?( (t|kg|lbs))?$/] { 237 *[maxaxleload][maxaxleload =~ /^[0-9]+,[0-9][0-9]?( (t|kg|st|lbs))?$/] { 238 throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}"); 239 fixAdd: concat("maxaxleload=", replace(tag("maxaxleload"), ",", ".")); 240 set maxaxleload_separator_autofix; 241 assertMatch: "node maxaxleload=5,5"; 242 assertMatch: "way maxaxleload=12,00"; 243 assertNoMatch: "node maxaxleload=12,000"; 244 assertNoMatch: "way maxaxleload=3,50,5"; 245 assertNoMatch: "node maxaxleload=3.5"; 246 assertNoMatch: "way maxaxleload=4"; 247 } 248 249 *[maxweight][maxweight =~ /^[0-9]+,[0-9][0-9]?( (t|kg|st|lbs))?$/] { 150 250 throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}"); 151 251 fixAdd: concat("maxweight=", replace(tag("maxweight"), ",", ".")); 152 252 set maxweight_separator_autofix; … … 157 257 assertNoMatch: "node maxweight=3.5"; 158 258 assertNoMatch: "node maxweight=4"; 159 259 } 160 *[maxweight][maxweight !~ /^(([0-9]+\.?[0-9]*( (t|kg|lbs))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/]!.maxweight_separator_autofix { 260 261 *[maxaxleload][maxaxleload !~ /^(([0-9]+\.?[0-9]*( (t|kg|st|lbs))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/]!.maxaxleload_separator_autofix, 262 *[maxweight][maxweight !~ /^(([0-9]+\.?[0-9]*( (t|kg|st|lbs))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/]!.maxweight_separator_autofix { 161 263 throwWarning: tr("unusual value of {0}: tonne is default; point is decimal separator; if units, put space then unit", "{0.key}"); 162 assertMatch: " way maxweight=something";264 assertMatch: "node maxaxleload=something"; 163 265 assertMatch: "way maxweight=-5"; 164 assertNoMatch: " way maxweight=2";266 assertNoMatch: "node maxaxleload=2"; 165 267 assertNoMatch: "way maxweight=6'6\""; 166 assertNoMatch: " way maxweight=2.5";167 assertNoMatch: "way max weight=7 kg";268 assertNoMatch: "node maxaxleload=2.5"; 269 assertNoMatch: "way maxaxleload=7 kg"; 168 270 } 169 271 170 272 way[maxspeed][maxspeed !~ /^(signals|none|unposted|variable|walk|[1-9][0-9]*( [a-z]+)?|[A-Z][A-Z]:(urban|rural|living_street|motorway))$/],
