Ticket #19163: josm_validator_numeric_unit_abb_v2.patch

File josm_validator_numeric_unit_abb_v2.patch, 13.0 KB (added by skyper, 6 years ago)

version 2: no combinations of test, no "weight" so far

  • src/org/openstreetmap/josm/resources/data/validator/numeric.mapcss

     
    5454  assertNoMatch: "node building:levels=0"; /* valid because there can be building:levels:underground > 0 or roof:levels > 0 */
    5555}
    5656
     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}
    5777*[height][height =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/] {
    5878  throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
    5979  fixAdd: concat("height=", replace(tag("height"), ",", "."));
     
    6686  assertNoMatch: "node height=3.5";
    6787  assertNoMatch: "node height=4";
    6888}
    69 *[height][height !~ /^(([0-9]+\.?[0-9]*( (m|ft))?)|([1-9][0-9]*\'((10|11|[0-9])((\.[0-9]+)?)\")?))$/]!.height_separator_autofix {
     89*[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 {
    7090  throwWarning: tr("unusual value of {0}: meters is default; point is decimal separator; if units, put space then unit", "{0.key}");
    7191  assertMatch: "node height=medium";
    7292  assertMatch: "node height=-5";
     
    7797  assertNoMatch: "node height=22'";
    7898}
    7999
     100*[maxheight][maxheight =~ /^[1-9][0-9]*\.?[0-9]*(( )*(metre|metres|meter|meters|Metre|Metres|Meter|Meters)|m)$/] {
     101  throwWarning: tr("Unit of {0} in long form: Use abbreviation for unit and space between value and unit", "{0.key}");
     102  set maxheight_meter_autofix;
     103  fixAdd: concat("maxheight=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxheight")),1)," m");
     104  assertMatch: "node maxheight=6.78 meters";
     105  assertMatch: "way maxheight=5  metre";
     106  assertMatch: "node maxheight=2m";
     107  assertNoMatch: "node maxheight=2 m";
     108  assertNoMatch: "relation maxheight=5";
     109}
     110*[maxheight][maxheight =~ /^[0-9]+\.?[0-9]*(( )*(foot|Foot|feet|Feet)|ft)$/] {
     111  throwWarning: tr("Unit of {0} in long form: Use abbreviation for unit and space between value and unit", "{0.key}");
     112  set maxheight_foot_autofix;
     113  fixAdd: concat("maxheight=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxheight")),1)," ft");
     114  assertMatch: "node maxheight=6.78 foot";
     115  assertMatch: "way maxheight=5  Feet";
     116  assertMatch: "node maxheight=2ft";
     117  assertNoMatch: "node maxheight=2 ft";
     118  assertNoMatch: "relation maxheight=5";
     119}
    80120*[maxheight][maxheight =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/] {
    81121  throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
    82122  fixAdd: concat("maxheight=", replace(tag("maxheight"), ",", "."));
    83123  set maxheight_separator_autofix;
    84124  assertMatch: "node maxheight=5,5";
    85125  assertMatch: "node maxheight=12,00";
    86   assertMatch: "node maxheight=12,5 ft";
     126  assertMatch: "way maxheight=12,5 ft";
    87127  assertNoMatch: "node maxheight=12,000";
    88128  assertNoMatch: "node maxheight=3,50,5";
    89   assertNoMatch: "node maxheight=3.5";
     129  assertNoMatch: "way maxheight=3.5";
    90130  assertNoMatch: "node maxheight=4";
    91131}
    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 {
     132*[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 {
    93133  throwWarning: tr("unusual value of {0}: meters is default; point is decimal separator; if units, put space then unit", "{0.key}");
    94134  assertMatch: "node maxheight=something";
    95   assertMatch: "node maxheight=-5";
     135  assertMatch: "way maxheight=-5";
    96136  assertMatch: "node maxheight=0";
    97137  assertNoMatch: "node maxheight=4";
    98138  assertNoMatch: "node maxheight=3.5";
    99   assertNoMatch: "node maxheight=2 m";
     139  assertNoMatch: "way maxheight=2 m";
    100140  assertNoMatch: "node maxheight=14 ft";
    101141  assertNoMatch: "node maxheight=10'";
    102142  assertNoMatch: "node maxheight=16'3\"";
    103143}
    104144
     145*[maxlength][maxlength =~ /^[1-9][0-9]*\.?[0-9]*(( )*(metre|metres|meter|meters|Metre|Metres|Meter|Meters)|m)$/] {
     146  throwWarning: tr("Unit of {0} in long form: Use abbreviation for unit and space between value and unit", "{0.key}");
     147  set maxlength_meter_autofix;
     148  fixAdd: concat("maxlength=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxlength")),1)," m");
     149  assertMatch: "node maxlength=6.78 meters";
     150  assertMatch: "way maxlength=5  metre";
     151  assertMatch: "node maxlength=2m";
     152  assertNoMatch: "node maxlength=2 m";
     153  assertNoMatch: "relation maxlength=5";
     154}
     155*[maxlength][maxlength =~ /^[0-9]+\.?[0-9]*(( )*(foot|Foot|feet|Feet)|ft)$/] {
     156  throwWarning: tr("Unit of {0} in long form: Use abbreviation for unit and space between value and unit", "{0.key}");
     157  set maxlength_foot_autofix;
     158  fixAdd: concat("maxlength=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxlength")),1)," ft");
     159  assertMatch: "node maxlength=6.78 foot";
     160  assertMatch: "way maxlength=5  Feet";
     161  assertMatch: "node maxlength=2ft";
     162  assertNoMatch: "node maxlength=2 ft";
     163  assertNoMatch: "relation maxlength=5";
     164}
     165*[maxlength][maxlength =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/] {
     166  throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
     167  fixAdd: concat("maxlength=", replace(tag("maxlength"), ",", "."));
     168  set maxlength_separator_autofix;
     169  assertMatch: "node maxlength=5,5";
     170  assertMatch: "node maxlength=12,00";
     171  assertMatch: "way maxlength=12,5 ft";
     172  assertNoMatch: "node maxlength=12,000";
     173  assertNoMatch: "node maxlength=3,50,5";
     174  assertNoMatch: "way maxlength=3.5";
     175  assertNoMatch: "node maxlength=4";
     176}
     177*[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 {
     178  throwWarning: tr("unusual value of {0}: meters is default; point is decimal separator; if units, put space then unit", "{0.key}");
     179  assertMatch: "node maxlength=something";
     180  assertMatch: "way maxlength=-5";
     181  assertMatch: "node maxlength=0";
     182  assertNoMatch: "node maxlength=4";
     183  assertNoMatch: "node maxlength=3.5";
     184  assertNoMatch: "way maxlength=2 m";
     185  assertNoMatch: "node maxlength=14 ft";
     186  assertNoMatch: "node maxlength=10'";
     187  assertNoMatch: "node maxlength=16'3\"";
     188}
     189
     190*[width][width =~ /^[0-9]*\.?[0-9]*(( )*(metre|metres|meter|meters|Metre|Metres|Meter|Meters)|m)$/] {
     191  throwWarning: tr("Unit of {0} in long form: Use abbreviation for unit and space between value and unit", "{0.key}");
     192  set width_meter_autofix;
     193  fixAdd: concat("width=", get(regexp_match("([0-9.]+)( )*(.+)",tag("width")),1)," m");
     194  assertMatch: "node width=6.78 meters";
     195  assertMatch: "way width=5  metre";
     196  assertMatch: "node width=2m";
     197  assertNoMatch: "node width=2 m";
     198  assertNoMatch: "relation width=5";
     199}
     200*[width][width =~ /^[0-9]+\.?[0-9]*(( )*(foot|Foot|feet|Feet)|ft)$/] {
     201  throwWarning: tr("Unit of {0} in long form: Use abbreviation for unit and space between value and unit", "{0.key}");
     202  set width_foot_autofix;
     203  fixAdd: concat("width=", get(regexp_match("([0-9.]+)( )*(.+)",tag("width")),1)," ft");
     204  assertMatch: "node width=6.78 foot";
     205  assertMatch: "way width=5  Feet";
     206  assertMatch: "node width=2ft";
     207  assertNoMatch: "node width=2 ft";
     208  assertNoMatch: "relation width=5";
     209}
    105210*[width][width =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/] {
    106211  throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
    107212  fixAdd: concat("width=", replace(tag("width"), ",", "."));
     
    113218  assertNoMatch: "node width=3.5";
    114219  assertNoMatch: "node width=4";
    115220}
    116 *[width][width !~ /^(([0-9]+\.?[0-9]*( [a-z]+)?)|([0-9]+\'([0-9]+\.?[0-9]*\")?))$/]!.width_separator_autofix {
     221*[width][width !~ /^(([0-9]+\.?[0-9]*( (m|ft))?)|([0-9]+\'([0-9]+\.?[0-9]*\")?))$/]!.width_separator_autofix!.width_meter_autofix!.width_foot_autofix {
    117222  throwWarning: tr("unusual value of {0}: meters is default; point is decimal separator; if units, put space then unit", "{0.key}");
    118223  assertMatch: "way width=something";
    119224  assertMatch: "way width=-5";
     
    125230  assertNoMatch: "way width=10'5\"";
    126231}
    127232
     233*[maxwidth][maxwidth=~ /^[0-9]*\.?[0-9]*(( )*(metre|metres|meter|meters|Metre|Metres|Meter|Meters)|m)$/] {
     234  throwWarning: tr("Unit of {0} in long form: Use abbreviation for unit and space between value and unit", "{0.key}");
     235  set maxwidth_meter_autofix;
     236  fixAdd: concat("maxwidth=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxwidth")),1)," m");
     237  assertMatch: "node maxwidth=6.78 meters";
     238  assertMatch: "way maxwidth=5  metre";
     239  assertMatch: "node maxwidth=2m";
     240  assertNoMatch: "node maxwidth=2 m";
     241  assertNoMatch: "relation maxwidth=5";
     242}
     243*[maxwidth][maxwidth =~ /^[0-9]+\.?[0-9]*(( )*(foot|Foot|feet|Feet)|ft)$/] {
     244  throwWarning: tr("Unit of {0} in long form: Use abbreviation for unit and space between value and unit", "{0.key}");
     245  set maxwidth_foot_autofix;
     246  fixAdd: concat("maxwidth=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxwidth")),1)," ft");
     247  assertMatch: "node maxwidth=6.78 foot";
     248  assertMatch: "way maxwidth=5  Feet";
     249  assertMatch: "node maxwidth=2ft";
     250  assertNoMatch: "node maxwidth=2 ft";
     251  assertNoMatch: "relation maxwidth=5";
     252}
    128253*[maxwidth][maxwidth =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/] {
    129254  throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
    130255  fixAdd: concat("maxwidth=", replace(tag("maxwidth"), ",", "."));
     
    136261  assertNoMatch: "node maxwidth=3.5";
    137262  assertNoMatch: "node maxwidth=4";
    138263}
    139 *[maxwidth][maxwidth !~ /^(([0-9]+\.?[0-9]*( (m|ft))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/]!.maxwidth_separator_autofix {
     264*[maxwidth][maxwidth !~ /^(([0-9]+\.?[0-9]*( (m|ft))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/]!.maxwidth_separator_autofix!.maxwidth_meter_autofix!.maxwidth_foot_autofix {
    140265  throwWarning: tr("unusual value of {0}: meters is default; point is decimal separator; if units, put space then unit", "{0.key}");
    141266  assertMatch: "way maxwidth=something";
    142267  assertMatch: "way maxwidth=-5";
     
    146271  assertNoMatch: "way maxwidth=7 ft";
    147272}
    148273
    149 *[maxweight][maxweight =~ /^[0-9]+,[0-9][0-9]?( (t|kg|lbs))?$/] {
     274*[maxaxleload][maxaxleload =~ /^[0-9]+,[0-9][0-9]?( (t|kg|st|lbs))?$/] {
     275  throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
     276  fixAdd: concat("maxaxleload=", replace(tag("maxaxleload"), ",", "."));
     277  set maxaxleload_separator_autofix;
     278  assertMatch: "node maxaxleload=5,5";
     279  assertMatch: "way maxaxleload=12,00";
     280  assertNoMatch: "node maxaxleload=12,000";
     281  assertNoMatch: "way maxaxleload=3,50,5";
     282  assertNoMatch: "node maxaxleload=3.5";
     283  assertNoMatch: "way maxaxleload=4";
     284}
     285*[maxaxleload][maxaxleload !~ /^(([0-9]+\.?[0-9]*( (t|kg|st|lbs))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/]!.maxaxleload_separator_autofix {
     286  throwWarning: tr("unusual value of {0}: tonne is default; point is decimal separator; if units, put space then unit", "{0.key}");
     287  assertMatch: "node maxaxleload=something";
     288  assertMatch: "way maxaxleload=-5";
     289  assertNoMatch: "node maxaxleload=2";
     290  assertNoMatch: "way maxaxleload=6'6\"";
     291  assertNoMatch: "node maxaxleload=2.5";
     292  assertNoMatch: "way maxaxleload=7 kg";
     293}
     294
     295*[maxweight][maxweight =~ /^[0-9]+,[0-9][0-9]?( (t|kg|st|lbs))?$/] {
    150296  throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
    151297  fixAdd: concat("maxweight=", replace(tag("maxweight"), ",", "."));
    152298  set maxweight_separator_autofix;
     
    157303  assertNoMatch: "node maxweight=3.5";
    158304  assertNoMatch: "node maxweight=4";
    159305}
    160 *[maxweight][maxweight !~ /^(([0-9]+\.?[0-9]*( (t|kg|lbs))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/]!.maxweight_separator_autofix {
     306*[maxweight][maxweight !~ /^(([0-9]+\.?[0-9]*( (t|kg|st|lbs))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/]!.maxweight_separator_autofix {
    161307  throwWarning: tr("unusual value of {0}: tonne is default; point is decimal separator; if units, put space then unit", "{0.key}");
    162308  assertMatch: "way maxweight=something";
    163309  assertMatch: "way maxweight=-5";