Changeset 16685 in josm for trunk/resources


Ignore:
Timestamp:
2020-06-20T21:56:27+02:00 (4 years ago)
Author:
Klumbumbus
Message:

fix #19163 - Adjust units validator tests: add autofixes for missing or multiple spaces and long forms of units, validate maxaxleload and maxlength too (patch by skyper, modified)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/resources/data/validator/numeric.mapcss

    r16340 r16685  
    5555}
    5656
     57*[height][height =~ /^[0-9]+\.?[0-9]*(( )*(metre|metres|meter|meters|Metre|Metres|Meter|Meters)|m)$/] {
     58  throwWarning: tr("unusual value of {0}: 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: "node height=5  metre";
     63  assertMatch: "node height=2m";
     64  assertNoMatch: "node height=2 m";
     65  assertNoMatch: "node height=5";
     66}
     67*[height][height =~ /^[0-9]+\.?[0-9]*(( )*(foot|Foot|feet|Feet)|ft)$/] {
     68  throwWarning: tr("unusual value of {0}: 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: "node height=5  Feet";
     73  assertMatch: "node height=2ft";
     74  assertNoMatch: "node height=2 ft";
     75  assertNoMatch: "node 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}");
     
    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 {
    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("unusual value of {0}: 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: "node maxheight=5  metre";
     96  assertMatch: "node maxheight=2m";
     97  assertNoMatch: "node maxheight=2 m";
     98  assertNoMatch: "node maxheight=5";
     99}
     100*[maxheight][maxheight =~ /^[0-9]+\.?[0-9]*(( )*(foot|Foot|feet|Feet)|ft)$/] {
     101  throwWarning: tr("unusual value of {0}: 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: "node maxheight=5  Feet";
     106  assertMatch: "node maxheight=2ft";
     107  assertNoMatch: "node maxheight=2 ft";
     108  assertNoMatch: "node maxheight=5";
     109}
    80110*[maxheight][maxheight =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/] {
    81111  throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
     
    90120  assertNoMatch: "node maxheight=4";
    91121}
    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";
    97   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 }
    104 
     122
     123*[maxlength][maxlength =~ /^[1-9][0-9]*\.?[0-9]*(( )*(metre|metres|meter|meters|Metre|Metres|Meter|Meters)|m)$/] {
     124  throwWarning: tr("unusual value of {0}: 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: "node maxlength=5  metre";
     129  assertMatch: "node maxlength=2m";
     130  assertNoMatch: "node maxlength=2 m";
     131  assertNoMatch: "node maxlength=5";
     132}
     133*[maxlength][maxlength =~ /^[0-9]+\.?[0-9]*(( )*(foot|Foot|feet|Feet)|ft)$/] {
     134  throwWarning: tr("unusual value of {0}: 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: "node maxlength=5  Feet";
     139  assertMatch: "node maxlength=2ft";
     140  assertNoMatch: "node maxlength=2 ft";
     141  assertNoMatch: "node 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: "node maxlength=12,5 ft";
     150  assertNoMatch: "node maxlength=12,000";
     151  assertNoMatch: "node maxlength=3,50,5";
     152  assertNoMatch: "node 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("unusual value of {0}: 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: "node width=5  metre";
     162  assertMatch: "node width=2m";
     163  assertNoMatch: "node width=2 m";
     164  assertNoMatch: "node width=5";
     165}
     166*[width][width =~ /^[0-9]+\.?[0-9]*(( )*(foot|Foot|feet|Feet)|ft)$/] {
     167  throwWarning: tr("unusual value of {0}: 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: "node width=5  Feet";
     172  assertMatch: "node width=2ft";
     173  assertNoMatch: "node width=2 ft";
     174  assertNoMatch: "node width=5";
     175}
    105176*[width][width =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/] {
    106177  throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
     
    114185  assertNoMatch: "node width=4";
    115186}
    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("unusual value of {0}: 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: "node maxwidth=5  metre";
     194  assertMatch: "node maxwidth=2m";
     195  assertNoMatch: "node maxwidth=2 m";
     196  assertNoMatch: "node maxwidth=5";
     197}
     198*[maxwidth][maxwidth =~ /^[0-9]+\.?[0-9]*(( )*(foot|Foot|feet|Feet)|ft)$/] {
     199  throwWarning: tr("unusual value of {0}: 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: "node maxwidth=5  Feet";
     204  assertMatch: "node maxwidth=2ft";
     205  assertNoMatch: "node maxwidth=2 ft";
     206  assertNoMatch: "node maxwidth=5";
     207}
    128208*[maxwidth][maxwidth =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/] {
    129209  throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
     
    137217  assertNoMatch: "node maxwidth=4";
    138218}
    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 {
    140225  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";
    146   assertNoMatch: "way maxwidth=7 ft";
    147 }
    148 
    149 *[maxweight][maxweight =~ /^[0-9]+,[0-9][0-9]?( (t|kg|lbs))?$/] {
     226  assertMatch: "node height=medium";
     227  assertMatch: "node maxheight=-5";
     228  assertMatch: "node maxlength=0";
     229  assertMatch: "node maxlength=10'13\"";
     230  assertNoMatch: "node height=6.78 meters";
     231  assertNoMatch: "node height=5  metre";
     232  assertNoMatch: "node height=2m";
     233  assertNoMatch: "node height=3";
     234  assertNoMatch: "node height=2.22 m";
     235  assertNoMatch: "node height=7.8";
     236  assertNoMatch: "node maxwidth=7 ft";
     237  assertNoMatch: "node height=22'";
     238  assertNoMatch: "node width=10'5\"";
     239}
     240
     241*[maxaxleload][maxaxleload =~ /^[0-9]+,[0-9][0-9]?( (t|kg|st|lbs))?$/] {
     242  throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
     243  fixAdd: concat("maxaxleload=", replace(tag("maxaxleload"), ",", "."));
     244  set maxaxleload_separator_autofix;
     245  assertMatch: "node maxaxleload=5,5";
     246  assertMatch: "node maxaxleload=12,00";
     247  assertNoMatch: "node maxaxleload=12,000";
     248  assertNoMatch: "node maxaxleload=3,50,5";
     249  assertNoMatch: "node maxaxleload=3.5";
     250  assertNoMatch: "node maxaxleload=4";
     251}
     252
     253*[maxweight][maxweight =~ /^[0-9]+,[0-9][0-9]?( (t|kg|st|lbs))?$/] {
    150254  throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
    151255  fixAdd: concat("maxweight=", replace(tag("maxweight"), ",", "."));
     
    158262  assertNoMatch: "node maxweight=4";
    159263}
    160 *[maxweight][maxweight !~ /^(([0-9]+\.?[0-9]*( (t|kg|lbs))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/]!.maxweight_separator_autofix {
     264
     265*[maxaxleload][maxaxleload !~ /^(([0-9]+\.?[0-9]*( (t|kg|st|lbs))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/]!.maxaxleload_separator_autofix,
     266*[maxweight][maxweight !~ /^(([0-9]+\.?[0-9]*( (t|kg|st|lbs))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/]!.maxweight_separator_autofix {
    161267  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";
    163   assertMatch: "way maxweight=-5";
    164   assertNoMatch: "way maxweight=2";
    165   assertNoMatch: "way maxweight=6'6\"";
    166   assertNoMatch: "way maxweight=2.5";
    167   assertNoMatch: "way maxweight=7 kg";
     268  assertMatch: "node maxaxleload=something";
     269  assertMatch: "node maxweight=-5";
     270  assertNoMatch: "node maxaxleload=2";
     271  assertNoMatch: "node maxweight=6'6\"";
     272  assertNoMatch: "node maxaxleload=2.5";
     273  assertNoMatch: "node maxaxleload=7 kg";
    168274}
    169275
Note: See TracChangeset for help on using the changeset viewer.