Changeset 6548 in josm


Ignore:
Timestamp:
2013-12-27T17:14:34+01:00 (6 years ago)
Author:
simon04
Message:

see #9414 - MapCSS-based tagchecker: migrate remaining tagchecks

All former tagchecker.cfg checks are now located in data/validator/*mapcss :-)

Location:
trunk
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/data/validator/deprecated.mapcss

    r6527 r6548  
    177177  fixChangeKey: "monitoring:river_level => monitoring:water_level";
    178178}
    179 
    180 *[layer=0] {
    181   /* see #9365 - Useless tag layer=0 */
    182   throwWarning: tr("{0}={1} is unnecessary", "layer", "0");
    183   fixRemove: "layer";
    184 }
    185 
    186 *[emergency=permissive] {
    187   /* see #9458 - emergency=permissive makes no sense */
    188   throwWarning: tr("{0}={1} makes no sense", "emergency", "permissive");
    189   fixAdd: "emergency=yes";
    190   assertMatch: "way emergency=permissive";
    191   assertNoMatch: "way emergency=designated";
    192 }
  • trunk/data/validator/numeric.mapcss

    r6534 r6548  
    11/* measurement values and units warnings (ticket #8687) */
     2
     3*[/^[0-9]+$/] {
     4  throwWarning: tr("numerical key");
     5  assertMatch: "way 123=foo";
     6  assertNoMatch: "way ref.1=foo";
     7}
    28
    39*[layer =~ /\+.*/] {
  • trunk/data/validator/tagchecker.cfg

    r6537 r6548  
    3737# Empty lines and space signs are ignored
    3838
    39 *    : W : / *name */i == * && name != *                                       # misspelled key name
    40 
    4139# The following could replace unnamed way check. Still at the moment we keep it as it is
    4240#way  : W : junction == roundabout && highway == /motorway|trunk|primary|secondary|tertiary|residential|pedestrian/ && /name|ref|(name:.*)|(.*_name)|(.*_ref)/ != * # Unnamed junction
     
    4644#way  : W : oneway != BOOLEAN_FALSE && /.*:(backward|forward)/ == *    # oneway combined with *:backward/forward
    4745
    48 node : I : amenity == /restaurant|cafe|fast_food/ && name != * # restaurant without name
    49 #way  : I : highway != * && railway != * && waterway != * && name == * # unusual named way type
    50 #*    : W : natural == water && waterway == *                   # unusual tag combination (natural=water & waterway)
    51 *    : W : highway == * && waterway == * && waterway != dam    # unusual tag combination (highway & waterway)
    52 *    : W : highway == * && natural == *                        # unusual tag combination (highway & natural)
    53 *    : W : landuse == * && building == *                       # unusual tag combination (landuse & building)
    5446
    55 *    : W : highway == proposed && access == *                  # unnecessary access key
    56 *    : W : highway == /motorway*|trunk*|primary*|secondary*|tertiary*|unclassified|residential|service|living_street/ && motor_vehicle == BOOLEAN_TRUE # unnecessary motor_vehicle=yes
    57 
    58 *    : W : natural == water && leisure == swimming_pool        # natural water used for swimming pool
    59 *    : W : natural == water && amenity == swimming_pool        # natural water used for swimming pool
    60 
    61 *    : W : /\d+/ == *                                          # numerical key
    62 
    63 # power related stuff (incomplete)
    64 *    : W : power == /line|minor_line|cable/ && voltage != *    # power line without voltage
    65 *    : W : substation == * && power != substation              # substation key without power=substation
    66 *    : W : transformer == * && power != *                      # transformer key without power
    67 *    : I : power == substation && substation != *              # missing substation=*
    68 *    : I : power == transformer && transformer != *            # missing transformer=*
    69 
    70 
    71 ########################################
    72 # Rules derived from Taginfo statistics
    73 ########################################
    74 
    75 # see ticket #5017
    76 # Taginfo query: select keypairs.key1, keypairs.key2, keypairs.count_all, keys.count_all, cast(keypairs.count_all as real)/keys.count_all as from_fraction_all from keys, keypairs where key1='waterway' and keys.key=keypairs.key2 and (key1<>'highway' or keypairs.count_all>12000) and (key1<>'railway' or keypairs.count_all>3000) and (key1<>'waterway' or keypairs.count_all>800) and key2 not like '%:%' and from_fraction_all>0.97 and 1 union select keypairs.key2, keypairs.key1, keypairs.count_all, keys.count_all, cast(keypairs.count_all as real)/keys.count_all as from_fraction_all from keys, keypairs where key2='waterway' and keys.key=keypairs.key1 and (key2<>'highway' or keypairs.count_all>12000) and (key2<>'railway' or keypairs.count_all>3000) and (key2<>'waterway' or keypairs.count_all>800) and key1 not like '%:%' and from_fraction_all>0.97 and 1 order by keypairs.count_all desc limit 1000;
    77 *    : W : incline              == * && highway != * && railway != *                   # incline without highway or railway
    78 way  : W : junction             == * && highway != *                                   # junction without highway
    79 *    : W : lanes                == * && highway != *                                   # lanes without highway
    80 *    : W : lcn                  == * && highway != *                                   # lcn without highway
    81 *    : W : lit                  == * && highway != * && railway != * && piste:type != * && amenity != /parking.*/ && public_transport != platform && advertising != billboard && leisure != pitch # lit on suspicious object
    82 *    : W : living_street        == * && highway != *                                   # living_street without highway
    83 *    : W : maintenance          == * && highway != *                                   # maintenance without highway
    84 *    : W : median               == * && highway != *                                   # median without highway
    85 *    : W : motorroad            == * && highway != *                                   # motorroad without highway
    86 *    : W : ntd_id               == * && highway != *                                   # ntd_id without highway
    87 *    : W : oneway               == * && highway != * && railway != *                   # oneway without highway or railway
    88 *    : W : sac_scale            == * && highway != *                                   # sac_scale without highway
    89 *    : W : segregated           == * && highway != * && railway != crossing            # segregated without highway
    90 *    : W : sidewalk             == * && highway != *                                   # sidewalk without highway
    91 *    : W : smoothness           == * && highway != *                                   # smoothness without highway
    92 *    : W : snowplowing          == * && highway != *                                   # snowplowing without highway
    93 *    : W : step_count           == * && highway != *                                   # step_count without highway
    94 *    : W : toll                 == * && highway != * && route != ferry                 # toll without highway
    95 *    : W : tracktype            == * && highway != *                                   # tracktype without highway
    96 *    : W : trail_visibility     == * && highway != *                                   # trail_visibility without highway
    97 *    : W : trolley_wire         == * && highway != *                                   # trolley_wire without highway
    98 *    : W : zip_left             == * && highway != *                                   # zip_left without highway
    99 *    : W : zip_right            == * && highway != *                                   # zip_right without highway
    100 *    : W : detail               == * && railway != *                                   # detail without railway
    101 *    : W : eddy_current_brake   == * && railway != *                                   # eddy_current_brake without railway
    102 *    : W : electrified          == * && railway != *                                   # electrified without railway
    103 *    : W : etcs                 == * && railway != *                                   # etcs without railway
    104 *    : W : gauge                == * && railway != *                                   # gauge without railway
    105 *    : W : grade_of_track       == * && railway != *                                   # grade_of_track without railway
    106 *    : W : kursbuchstrecke      == * && railway != *                                   # kursbuchstrecke without railway
    107 *    : W : lzb                  == * && railway != *                                   # lzb without railway
    108 *    : W : old_railway_operator == * && railway != *                                   # old_railway_operator without railway
    109 *    : W : operating_procedure  == * && railway != *                                   # operating_procedure without railway
    110 *    : W : pzb                  == * && railway != *                                   # pzb without railway
    111 *    : W : radio                == * && railway != *                                   # radio without railway
    112 *    : W : structure_gauge      == * && railway != *                                   # structure_gauge without railway
    113 *    : W : tilting_technology   == * && railway != *                                   # tilting_technologie without railway
    114 *    : W : track_class          == * && railway != *                                   # track_class without railway
    115 *    : W : tracks               == * && railway != *                                   # tracks without railway
    116 *    : W : traffic_mode         == * && railway != *                                   # traffic_mode without railway
    117 *    : W : usage                == * && railway != *                                   # usage without railway
    118 *    : W : workrules            == * && railway != *                                   # workrules without railway
    119 *    : W : stream               == * && waterway != *                                  # stream without waterway
    120 *    : W : intermittent         == * && waterway != *                                  # intermittent without waterway
    121 *    : W : boat                 == * && waterway != * && natural != water              # boat without waterway / natural=water
    122 *    : W : length_unit          == * && waterway != *                                  # length_unit without waterway
    123 *    : W : llid                 == * && waterway != *                                  # llid without waterway
    124 *    : W : canal                == * && waterway != *                                  # canal without waterway
    125 *    : W : have_riverbank       == * && waterway != *                                  # have_riverbank without waterway
    126 *    : W : tunnel               == * && highway != * && railway != * && waterway != * && public_transport != platform && man_made != pipeline  # tunnel without highway/railway/waterway/platform/pipeline
    127 *    : W : bridge               == * && highway != * && railway != * && waterway != * && piste:type != * && public_transport != platform && man_made != /bridge|pipeline/ && building != bridge  # bridge without highway/railway/waterway/platform/piste/pipeline
    128 *    : W : psv                  == * && highway != * && railway != * && waterway != * && amenity != /parking.*/  # psv without highway/railway/waterway/parking
    129 *    : W : width                == * && highway != * && railway != * && waterway != * && aeroway != * && cycleway != * && footway != * && barrier != * && man_made != * && entrance != *  # width without physical linear feature
    130 *    : W : maxspeed             == * && highway != * && railway != * && traffic_sign != /(.*;)?maxspeed(;.*)?/ && type != enforcement  # maxspeed without highway/railway/traffic_sign/enforcement
    131 *    : W : fence_type           == * && barrier != fence                               # fence_type without barrier=fence
    132 *    : W : border_type          == * && boundary != *                                  # border_type without boundary
    133 *    : W : recycling_type       == * && amenity != recycling                           # recycling_type without amenity=recycling
    134 *    : W : board_type           == * && information != board                           # board_type without information=board
    135 *    : W : shelter_type         == * && amenity != shelter                             # shelter_type without amenity=shelter
    136 *    : W : lamp_type            == * && highway != street_lamp                         # lamp_type without highway=street_lamp
    137 *    : W : map_type             == * && information != map                             # map_type without information=map
    138 *    : W : site_type            == * && historic != archaeological_site                # site_type without historic=archaeological_site
    139 *    : W : artwork_type         == * && tourism != artwork                             # artwork_type without tourism=artwork
    140 *    : W : castle_type          == * && historic != castle                             # castle_type without historic=castle
    141 *    : W : reservoir_type       == * && landuse != reservoir && water != reservoir     # reservoir_type without landuse/water=reservoir
    142 *    : W : bunker_type          == * && military != bunker                             # bunker_type without military=bunker
    143 *    : W : source:addr                  == * && /addr:.*/                != *          # source:addr without addr:*
    144 *    : W : source:date                  == * && source                   != *          # source:date without source
    145 *    : W : source:name                  == * && name                     != *          # source:name without name
    146 *    : W : source:maxspeed              == * && /maxspeed(:.*)?/         != *          # source:maxspeed without maxspeed
    147 *    : W : source:maxspeed:forward      == * && maxspeed:forward         != *          # source:maxspeed:forward without maxspeed:forward
    148 *    : W : source:maxspeed:backward     == * && maxspeed:backward        != *          # source:maxspeed:backward without maxspeed:backward
    149 *    : W : source:maxspeed:forward      == * && source:maxspeed:backward != *          # source:maxspeed:forward without source:maxspeed:backward
    150 *    : W : source:maxspeed:backward     == * && source:maxspeed:forward  != *          # source:maxspeed:backward without source:maxspeed:forward
    151 *    : W : source:building              == * && building                 != *          # source:building without building
    152 *    : W : source:ref                   == * && ref                      != *          # source:ref without ref
    153 *    : W : source:population            == * && population               != *          # source:population without population
    154 node : W : source:geometry              == *                                           # source:geometry on a node
    155 *    : W : /source:(addr:)?postcode/    == * && addr:postcode            != *          # source:[addr:]postcode without addr:postcode
    156 *    : W : source:postal_code           == * && postal_code              != *          # source:postal_code without postal_code
    157 *    : W : source:ele                   == * && ele                      != *          # source:ele without ele
    158 *    : W : source:ref:INSEE             == * && ref:INSEE                != *          # source:ref:INSEE without ref:INSEE
    159 *    : W : source:lit                   == * && lit                      != *          # source:lit without lit
    160 *    : W : source:hgv                   == * && hgv                      != *          # source:hgv without hgv
    161 node : W : source:outline               == *                                           # source:outline on a node
    162 *    : W : source:highway               == * && highway                  != *          # source:highway without highway
    163 *    : W : source:maxaxleload           == * && maxaxleload              != *          # source:maxaxleload without maxaxleload
    164 *    : W : source:surface               == * && surface                  != *          # source:surface without surface
    165 *    : W : source:bridge                == * && bridge                   != *          # source:bridge without bridge
    166 *    : W : source:old_name              == * && old_name                 != *          # source:old_name without old_name
    167 *    : W : source:bicycle               == * && bicycle                  != *          # source:bicycle without bicycle
    168 *    : W : source:designation           == * && designation              != *          # source:designation without designation
    169 *    : W : /source:(addr:)?housenumber/ == * && addr:housenumber         != *          # source:[addr:]housenumber without addr:housenumber
    170 *    : W : source:height                == * && height                   != *          # source:height without height
    171 *    : W : source:lanes                 == * && lanes                    != *          # source:lanes without lanes
    172 
    173 
    174 #####################################
    175 # validation for the wikipedia=* tag
    176 #####################################
    177 
    178 # see ticket #8383
    179 # If there is no language at all, this is broken. Also catches 'wikipedia' used as 'email', 'website', 'ele' [sic!] ...
    180 * : E : wikipedia == * && wikipedia != /[a-zA-Z_-]{2,12}:.*/ # no wikipedia-language given, use ''wikipedia''=''language:page title''
    181 # Valid languages are extracted from <http://de.wikipedia.org/w/api.php?action=sitematrix&format=xml>, which may change, so this is a warning only.
    182 * : W : wikipedia == /[a-zA-Z_-]{2,12}:.*/ && wikipedia != /(aa|ab|ace|af|ak|als|am|an|ang|ar|arc|arz|as|ast|av|ay|az|ba|bar|bat-smg|bcl|be|be-x-old|bg|bh|bi|bjn|bm|bn|bo|bpy|br|bs|bug|bxr|ca|cbk-zam|cdo|ce|ceb|ch|cho|chr|chy|ckb|co|cr|crh|cs|csb|cu|cv|cy|cz|da|de|diq|dk|dsb|dv|dz|ee|el|eml|en|eo|epo|es|et|eu|ext|fa|ff|fi|fiu-vro|fj|fo|fr|frp|frr|fur|fy|ga|gag|gan|gd|gl|glk|gn|got|gu|gv|ha|hak|haw|he|hi|hif|ho|hr|hsb|ht|hu|hy|hz|ia|id|ie|ig|ii|ik|ilo|io|is|it|iu|ja|jbo|jp|jv|ka|kaa|kab|kbd|kg|ki|kj|kk|kl|km|kn|ko|koi|kr|krc|ks|ksh|ku|kv|kw|ky|la|lad|lb|lbe|lez|lg|li|lij|lmo|ln|lo|lt|ltg|lv|map-bms|mdf|mg|mh|mhr|mi|minnan|mk|ml|mn|mo|mr|mrj|ms|mt|mus|mwl|my|myv|mzn|na|nah|nan|nap|nb|nds|nds-nl|ne|new|ng|nl|nn|no|nov|nrm|nso|nv|ny|oc|om|or|os|pa|pag|pam|pap|pcd|pdc|pfl|pi|pih|pl|pms|pnb|pnt|ps|pt|qu|rm|rmy|rn|ro|roa-rup|roa-tara|ru|rue|rw|sa|sah|sc|scn|sco|sd|se|sg|sh|si|simple|sk|sl|sm|sn|so|sq|sr|srn|ss|st|stq|su|sv|sw|szl|ta|te|tet|tg|th|ti|tk|tl|tn|to|tpi|tr|ts|tt|tum|tw|ty|udm|ug|uk|ur|uz|ve|vec|vep|vi|vls|vo|wa|war|wo|wuu|xal|xh|xmf|yi|yo|za|zea|zh|zh-cfr|zh-classical|zh-min-nan|zh-yue|zu):.*/  # unknown language prefix in wikipedia tag
     47# all former checks are now located in data/validator/*mapcss :-)
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r6538 r6548  
    255255                cmds.add(new ChangePropertyKeyCommand(p, oldKey, newKey));
    256256            }
    257             return new SequenceCommand(tr("Fix of {0}", getDescription()), cmds);
     257            return new SequenceCommand(tr("Fix of {0}", getDescriptionForMatchingSelector(matchingSelector)), cmds);
    258258        }
    259259
     
    271271         *
    272272         * @return a description (possibly with alternative suggestions)
     273         * @see {@link #getDescriptionForMatchingSelector(Selector)}
    273274         */
    274275        String getDescription() {
     
    281282        }
    282283
     284        /**
     285         * Constructs a (localized) description for this deprecation check
     286         * where any placeholders are replaced by values of the matched selector.
     287         *
     288         * @return a description (possibly with alternative suggestions)
     289         */
     290        String getDescriptionForMatchingSelector(Selector matchingSelector) {
     291            return insertArguments(matchingSelector, getDescription());
     292        }
     293
    283294        Severity getSeverity() {
    284295            return errors.values().iterator().next();
     296        }
     297
     298        @Override
     299        public String toString() {
     300            return getDescription();
    285301        }
    286302
     
    295311            if (matchingSelector != null) {
    296312                final Command fix = fixPrimitive(p);
    297                 final String description = TagCheck.insertArguments(matchingSelector, getDescription());
     313                final String description = getDescriptionForMatchingSelector(matchingSelector);
    298314                if (fix != null) {
    299315                    return new FixableTestError(null, getSeverity(), description, 3000, p, fix);
     
    363379        addMapCSS("religion.mapcss");
    364380        addMapCSS("relation.mapcss");
     381        addMapCSS("combinations.mapcss");
     382        addMapCSS("unnecessary.mapcss");
     383        addMapCSS("wikipedia.mapcss");
     384        addMapCSS("power.mapcss");
    365385    }
    366386}
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java

    r6538 r6548  
    5555        assertThat(check.getErrorForPrimitive(n1).getMessage(), is("natural=marsh is deprecated"));
    5656        assertThat(check.getErrorForPrimitive(n1).getSeverity(), is(Severity.WARNING));
     57        assertThat(check.fixPrimitive(n1).getDescriptionText(), is("Sequence: Fix of natural=marsh is deprecated"));
    5758        assertThat(((ChangePropertyCommand) check.fixPrimitive(n1).getChildren().iterator().next()).getTags().toString(),
    5859                is("{natural=}"));
     
    7677            throw new IllegalArgumentException("Expecting n/node/w/way/r/relation, but got " + x[0]);
    7778        }
    78         for (final Map.Entry<String, String> i : TextTagParser.getValidatedTagsFromText(x[1]).entrySet()) {
     79        for (final Map.Entry<String, String> i : TextTagParser.readTagsFromText(x[1]).entrySet()) {
    7980            p.put(i.getKey(), i.getValue());
    8081        }
Note: See TracChangeset for help on using the changeset viewer.