Ticket #19163: josm_validator_numeric_unit_abb.patch

File josm_validator_numeric_unit_abb.patch, 11.3 KB (added by skyper, 6 years ago)

patch file

  • 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][0-9]?( (m|ft))?$/] {
     57*[height][height =~ /^[0-9]+\.?[0-9]*(( )*(metre|metres|meter|meters|Metre|Metres|Meter|Meters)|m)$/],
     58*[maxheight][maxheight =~ /^[1-9][0-9]*\.?[0-9]*(( )*(metre|metres|meter|meters|Metre|Metres|Meter|Meters)|m)$/],
     59*[maxlength][maxlength =~ /^[1-9][0-9]*\.?[0-9]*(( )*(metre|metres|meter|meters|Metre|Metres|Meter|Meters)|m)$/],
     60*[width][width=~ /^[0-9]*\.?[0-9]*(( )*(metre|metres|meter|meters|Metre|Metres|Meter|Meters)|m)$/],
     61*[maxwidth][maxwidth=~ /^[0-9]*\.?[0-9]*(( )*(metre|metres|meter|meters|Metre|Metres|Meter|Meters)|m)$/] {
     62  throwWarning: tr("Unit of {0} in long form: Use abbreviation for unit and space between value and unit", "{0.key}");
     63  set meter_abb_autofix;
     64  fixAdd: concat("height=", get(regexp_match("([0-9.]+)( )*(.+)",tag("height")),1)," m");
     65  fixAdd: concat("maxheight=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxheight")),1)," m");
     66  fixAdd: concat("maxlength=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxlength")),1)," m");
     67  fixAdd: concat("width=", get(regexp_match("([0-9.]+)( )*(.+)",tag("width")),1)," m");
     68  fixAdd: concat("maxwidth=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxwidth")),1)," m");
     69  assertMatch: "node maxlength=6.78 meters";
     70  assertMatch: "way maxheight=5  metre";
     71  assertMatch: "node width=2m";
     72  assertNoMatch: "node maxwidth=2 m";
     73  assertNoMatch: "relation height=5";
     74}
     75*[height][height =~ /^[0-9]+\.?[0-9]*(( )*(foot|Foot|feet|Feet)|ft)$/],
     76*[maxheight][maxheight =~ /^[1-9][0-9]*\.?[0-9]*(( )*(foot|Foot|feet|Feet)|ft)$/],
     77*[maxlength][maxlength =~ /^[1-9][0-9]*\.?[0-9]*(( )*(foot|Foot|feet|Feet)|ft)$/],
     78*[width][width =~ /^[0-9]*\.?[0-9]*(( )*(foot|Foot|feet|Feet)|ft)$/],
     79*[maxwidth][maxwidth =~ /^[0-9]*\.?[0-9]*(( )*(foot|Foot|feet|Feet)|ft)$/] {
     80  throwWarning: tr("Unit of {0} in long form: Use abbreviation for unit and space between value and unit", "{0.key}");
     81  set foot_abb_autofix;
     82  fixAdd: concat("height=", get(regexp_match("([0-9.]+)( )*(.+)",tag("height")),1)," ft");
     83  fixAdd: concat("maxheight=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxheight")),1)," ft");
     84  fixAdd: concat("maxlength=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxlength")),1)," ft");
     85  fixAdd: concat("width=", get(regexp_match("([0-9.]+)( )*(.+)",tag("width")),1)," ft");
     86  fixAdd: concat("maxwidth=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxwidth")),1)," ft");
     87  assertMatch: "node maxlength=6.78 foot";
     88  assertMatch: "way maxheight=5  Feet";
     89  assertMatch: "node width=2ft";
     90  assertNoMatch: "node maxwidth=2 ft";
     91  assertNoMatch: "relation height=5";
     92}
     93*[height][height =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/],
     94*[maxheight][maxheight =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/],
     95*[maxlength][maxlength =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/],
     96*[width][width =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/],
     97*[maxwidth][maxwidth =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/] {
    5898  throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
    5999  fixAdd: concat("height=", replace(tag("height"), ",", "."));
     100  fixAdd: concat("maxheight=", replace(tag("maxheight"), ",", "."));
     101  fixAdd: concat("maxlength=", replace(tag("maxlength"), ",", "."));
     102  fixAdd: concat("width=", replace(tag("width"), ",", "."));
     103  fixAdd: concat("maxwidth=", replace(tag("maxwidth"), ",", "."));
    60104  set height_separator_autofix;
    61105  assertMatch: "node height=5,5";
    62   assertMatch: "node height=12,00";
     106  assertMatch: "way maxlength=12,00";
    63107  assertMatch: "node height=12,5 ft";
    64   assertNoMatch: "node height=12,000";
    65   assertNoMatch: "node height=3,50,5";
    66   assertNoMatch: "node height=3.5";
    67   assertNoMatch: "node height=4";
    68 }
    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 
    80 *[maxheight][maxheight =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/] {
    81   throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
    82   fixAdd: concat("maxheight=", replace(tag("maxheight"), ",", "."));
    83   set maxheight_separator_autofix;
    84   assertMatch: "node maxheight=5,5";
    85   assertMatch: "node maxheight=12,00";
    86   assertMatch: "node maxheight=12,5 ft";
    87   assertNoMatch: "node maxheight=12,000";
    88   assertNoMatch: "node maxheight=3,50,5";
     108  assertNoMatch: "way height=12,000";
     109  assertNoMatch: "node width=3,50,5";
    89110  assertNoMatch: "node maxheight=3.5";
    90   assertNoMatch: "node maxheight=4";
     111  assertNoMatch: "node maxwidth=4";
    91112}
    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 {
     113*[height][height !~ /^(([0-9]+\.?[0-9]*( (m|ft))?)|([1-9][0-9]*\'((10|11|[0-9])((\.[0-9]+)?)\")?))$/]!.height_separator_autofix!.meter_abb_autofix!.foot_abb_autofix,
     114*[maxheight][maxheight !~ /^(([1-9][0-9]*(\.[0-9]+)?( (m|ft))?)|([0-9]+\'(([0-9]|10|11)(\.[0-9]*)?\")?)|none|default|below_default)$/]!.height_separator_autofix!.meter_abb_autofix!.foot_abb_autofix,
     115*[maxlength][maxlength !~ /^(([1-9][0-9]*(\.[0-9]+)?( (m|ft))?)|([0-9]+\'(([0-9]|10|11)(\.[0-9]*)?\")?))$/]!.height_separator_autofix!.meter_abb_autofix!.foot_abb_autofix,
     116*[width][width !~ /^(([0-9]+\.?[0-9]*( [a-z]+)?)|([0-9]+\'([0-9]+\.?[0-9]*\")?))$/]!.height_separator_autofix!.meter_abb_autofix!.foot_abb_autofix,
     117*[maxwidth][maxwidth !~ /^(([0-9]+\.?[0-9]*( (m|ft))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/]!.height_separator_autofix!.meter_abb_autofix!.foot_abb_autofix {
    93118  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";
     119  assertMatch: "node height=medium";
     120  assertMatch: "way width=-5";
    96121  assertMatch: "node maxheight=0";
    97122  assertNoMatch: "node maxheight=4";
    98   assertNoMatch: "node maxheight=3.5";
    99   assertNoMatch: "node maxheight=2 m";
    100   assertNoMatch: "node maxheight=14 ft";
     123  assertNoMatch: "node height=2 m";
     124  assertNoMatch: "node maxlength=7.8";
     125  assertNoMatch: "way maxwidth=7 ft";
    101126  assertNoMatch: "node maxheight=10'";
    102   assertNoMatch: "node maxheight=16'3\"";
    103 }
    104 
    105 *[width][width =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/] {
    106   throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
    107   fixAdd: concat("width=", replace(tag("width"), ",", "."));
    108   set width_separator_autofix;
    109   assertMatch: "node width=5,5";
    110   assertMatch: "node width=12,00";
    111   assertNoMatch: "node width=12,000";
    112   assertNoMatch: "node width=3,50,5";
    113   assertNoMatch: "node width=3.5";
    114   assertNoMatch: "node width=4";
    115 }
    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'";
    125127  assertNoMatch: "way width=10'5\"";
    126128}
    127129
    128 *[maxwidth][maxwidth =~ /^[0-9]+,[0-9][0-9]?( (m|ft))?$/] {
    129   throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
    130   fixAdd: concat("maxwidth=", replace(tag("maxwidth"), ",", "."));
    131   set maxwidth_separator_autofix;
    132   assertMatch: "node maxwidth=5,5";
    133   assertMatch: "node maxwidth=12,00";
    134   assertNoMatch: "node maxwidth=12,000";
    135   assertNoMatch: "node maxwidth=3,50,5";
    136   assertNoMatch: "node maxwidth=3.5";
    137   assertNoMatch: "node maxwidth=4";
     130*[maxweight][maxweight =~ /^[0-9]*\.?[0-9]*(( )*(T|ton|tons|Ton|Tons)|t)$/],
     131*[maxaxleload][maxaxleload =~ /^[0-9]*\.?[0-9]*(( )*(T|ton|tons|Ton|Tons)|t)$/] {
     132  throwWarning: tr("Unit of {0} in long form: Use abbreviation for unit and space between value and unit", "{0.key}");
     133  set ton_abb_autofix;
     134  fixAdd: concat("maxweight=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxweight")),1)," t");
     135  fixAdd: concat("maxaxleload=", get(regexp_match("([0-9.]+)( )*(.+)",tag("maxaxleload")),1)," t");
     136  assertMatch: "node maxaxleload=6.78 Tons";
     137  assertMatch: "way maxweight=5ton";
     138  assertMatch: "node maxweight=2     T";
     139  assertMatch: "node maxweight=2t";
     140  assertNoMatch: "node maxaxleload=2 t";
     141  assertNoMatch: "relation maxweight=5";
     142  assertNoMatch: "way maxweight=5,7";
    138143}
    139 *[maxwidth][maxwidth !~ /^(([0-9]+\.?[0-9]*( (m|ft))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/]!.maxwidth_separator_autofix {
    140   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))?$/] {
     144*[maxweight][maxweight =~ /^[0-9]+,[0-9][0-9]?( (t|kg|st|lbs))?$/],
     145*[maxaxleload][maxaxleload =~ /^[0-9]+,[0-9][0-9]?( (t|kg|st|lbs))?$/] {
    150146  throwWarning: tr("unusual value of {0}: use . instead of , as decimal separator", "{0.key}");
    151147  fixAdd: concat("maxweight=", replace(tag("maxweight"), ",", "."));
    152   set maxweight_separator_autofix;
     148  fixAdd: concat("maxaxleload=", replace(tag("maxaxleload"), ",", "."));
     149  set weight_separator_autofix;
    153150  assertMatch: "node maxweight=5,5";
    154   assertMatch: "node maxweight=12,00";
     151  assertMatch: "way maxaxleload=12,00";
    155152  assertNoMatch: "node maxweight=12,000";
    156   assertNoMatch: "node maxweight=3,50,5";
     153  assertNoMatch: "way maxaxleload=3,50,5";
    157154  assertNoMatch: "node maxweight=3.5";
    158155  assertNoMatch: "node maxweight=4";
    159156}
    160 *[maxweight][maxweight !~ /^(([0-9]+\.?[0-9]*( (t|kg|lbs))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/]!.maxweight_separator_autofix {
     157*[maxweight][maxweight !~ /^(([0-9]+\.?[0-9]*( (t|kg|st|lbs))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/]!.weight_separator_autofix!.ton_abb_autofix,
     158*[maxaxleload][maxaxleload !~ /^(([0-9]+\.?[0-9]*( (t|kg|st|lbs))?)|([0-9]+\'[0-9]+\.?[0-9]*\"))$/]!.weight_separator_autofix!.ton_abb_autofix {
    161159  throwWarning: tr("unusual value of {0}: tonne is default; point is decimal separator; if units, put space then unit", "{0.key}");
    162160  assertMatch: "way maxweight=something";
    163161  assertMatch: "way maxweight=-5";
    164   assertNoMatch: "way maxweight=2";
     162  assertNoMatch: "node maxaxleload=2";
    165163  assertNoMatch: "way maxweight=6'6\"";
    166   assertNoMatch: "way maxweight=2.5";
     164  assertNoMatch: "node maxaxleload=2.5";
    167165  assertNoMatch: "way maxweight=7 kg";
    168166}
    169167