Changeset 16340 in josm for trunk


Ignore:
Timestamp:
2020-04-18T18:00:12+02:00 (4 years ago)
Author:
Klumbumbus
Message:

fix #11253 - require to add unit to maxstay tag, rework preset and add validator rules with autofixes for the most common cases (patch by skyper, modified)

Location:
trunk/resources/data
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/resources/data/defaultpresets.xml

    r16316 r16340  
    231231    </chunk>
    232232    <chunk id="maxstay">
    233         <combo key="maxstay" text="Time Limit (minutes)" values="0,30,60,90,120,180" />
     233        <combo key="maxstay" text="Time Limit" values="30 minutes,60 minutes,180 minutes,1 hour,1.5 hours,1 day,3 days,2 weeks,4 months,1.5 years,unlimited,no,load-unload" values_no_i18n="true" values_sort="false" />
    234234    </chunk>
    235235    <chunk id="supervised">
     
    24242424            <reference ref="parking_access_fee_operator_surface_smoothness" />
    24252425            <reference ref="supervised_lit_oh" />
     2426            <reference ref="maxstay" />
    24262427            <check key="covered" text="Covered (with roof)" />
    24272428        </item> <!-- Parking -->
  • trunk/resources/data/validator/numeric.mapcss

    r16316 r16340  
    415415  assertNoMatch: "node isced:level=0-3";
    416416}
     417
     418/* #11253, maxstay=0 is unclear. Was in presets. */
     419*[maxstay=0] {
     420  throwWarning: tr("Definition of {0} is unclear", "{0.tag}");
     421  assertMatch: "node maxstay=0";
     422  assertMatch: "way maxstay=0";
     423  assertNoMatch: "node maxstay=2";
     424  assertNoMatch: "way maxstay=no";
     425}
     426
     427/* #11253, maxstay needs unit. Was in presets without it. Autofixes for the most common cases. */
     428*[maxstay][maxstay =~ /^([1-9][0-9]*(\.[0-9]+)? min)$/][maxstay!="1 min"] {
     429  throwWarning: tr("unusual value of {0}: set unit e.g. {1} or {2}; only positive values; point is decimal separator; space between value and unit", "{0.key}", "minutes", "hours");
     430  fixAdd: concat("maxstay=", replace(tag("maxstay"), "min", "minutes"));
     431  set maxstay_autofix;
     432  assertMatch: "node maxstay=\"5 min\"";
     433  assertMatch: "node maxstay=\"15 min\"";
     434  assertNoMatch: "node maxstay=\"1 min\"";
     435  assertNoMatch: "node maxstay=\"02 minutes\"";
     436  assertNoMatch: "node maxstay=\"2 minutes\"";
     437}
     438*[maxstay="1h"],
     439*[maxstay="1 h"],
     440*[maxstay="1 hr"] {
     441  throwWarning: tr("unusual value of {0}: set unit e.g. {1} or {2}; only positive values; point is decimal separator; space between value and unit", "{0.key}", "minutes", "hours");
     442  fixAdd: "maxstay=1 hour";
     443  set maxstay_autofix;
     444  assertMatch: "node maxstay=1h";
     445  assertMatch: "node maxstay=\"1 h\"";
     446  assertMatch: "node maxstay=\"1 hr\"";
     447}
     448*[maxstay][maxstay =~ /^([1-9][0-9]*(\.[0-9]+)? h)$/][maxstay!="1 h"] {
     449  throwWarning: tr("unusual value of {0}: set unit e.g. {1} or {2}; only positive values; point is decimal separator; space between value and unit", "{0.key}", "minutes", "hours");
     450  fixAdd: concat("maxstay=", replace(tag("maxstay"), "h", "hours"));
     451  set maxstay_autofix;
     452  assertMatch: "node maxstay=\"5 h\"";
     453  assertMatch: "node maxstay=\"15 h\"";
     454  assertNoMatch: "node maxstay=\"1 h\"";
     455  assertNoMatch: "node maxstay=\"02 hours\"";
     456  assertNoMatch: "node maxstay=\"2 hours\"";
     457}
     458*[maxstay][maxstay =~ /^([1-9][0-9]*(\.[0-9]+)? hr)$/][maxstay!="1 hr"] {
     459  throwWarning: tr("unusual value of {0}: set unit e.g. {1} or {2}; only positive values; point is decimal separator; space between value and unit", "{0.key}", "minutes", "hours");
     460  fixAdd: concat("maxstay=", replace(tag("maxstay"), "hr", "hours"));
     461  set maxstay_autofix;
     462  assertMatch: "node maxstay=\"5 hr\"";
     463  assertMatch: "node maxstay=\"15 hr\"";
     464  assertNoMatch: "node maxstay=\"1 hr\"";
     465  assertNoMatch: "node maxstay=\"02 hours\"";
     466  assertNoMatch: "node maxstay=\"2 hours\"";
     467}
     468*[maxstay][maxstay =~ /^([1-9][0-9]*(\.[0-9]+)?h)$/][maxstay!="1h"] {
     469  throwWarning: tr("unusual value of {0}: set unit e.g. {1} or {2}; only positive values; point is decimal separator; space between value and unit", "{0.key}", "minutes", "hours");
     470  fixAdd: concat("maxstay=", replace(tag("maxstay"), "h", " hours"));
     471  set maxstay_autofix;
     472  assertMatch: "node maxstay=5h";
     473  assertMatch: "node maxstay=15h";
     474  assertNoMatch: "node maxstay=1h";
     475  assertNoMatch: "node maxstay=02hours";
     476  assertNoMatch: "node maxstay=2hours";
     477  assertNoMatch: "node maxstay=\"2 h\"";
     478  assertNoMatch: "node maxstay=\"2 hr\"";
     479}
     480/* the rest without autofix */
     481*[maxstay][maxstay !~ /^(([1-9][0-9]*(\.[0-9]+)?( (minute|minutes|hour|hours|day|days|week|weeks|month|months|year|years)))|(no|unlimited|0|load-unload))$/]!.maxstay_autofix {
     482  throwWarning: tr("unusual value of {0}: set unit e.g. {1} or {2}; only positive values; point is decimal separator; space between value and unit", "{0.key}", "minutes", "hours");
     483  assertMatch: "node maxstay=something";
     484  assertMatch: "node maxstay=-5";
     485  assertMatch: "node maxstay=180";
     486  assertMatch: "node maxstay=66minutes";
     487  assertMatch: "node maxstay=\"1. hours\"";
     488  assertMatch: "node maxstay=\"0 minutes\"";
     489  assertNoMatch: "node maxstay=0";
     490  assertNoMatch: "node maxstay=no";
     491  assertNoMatch: "node maxstay=\"7 h\"";
     492  assertNoMatch: "node maxstay=\"7 hr\"";
     493  assertNoMatch: "node maxstay=unlimited";
     494  assertNoMatch: "node maxstay=load-unload";
     495  assertNoMatch: "node maxstay=\"66 minutes\"";
     496  assertNoMatch: "node maxstay=\"2.5 hours\"";
     497}
Note: See TracChangeset for help on using the changeset viewer.