Ignore:
Timestamp:
2017-02-25T03:14:20+01:00 (8 years ago)
Author:
Don-vip
Message:

fix #14402 - add blacklist for leisure area values to avoid false positives - improve globally the detection of keys/tags

Location:
trunk/src/org/openstreetmap/josm/data/validation
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/Test.java

    r11553 r11608  
    342342     */
    343343    protected static final boolean isBuilding(OsmPrimitive p) {
    344         String v = p.get("building");
    345         return v != null && !"no".equals(v) && !"entrance".equals(v);
     344        return p.hasTagDifferent("building", "no", "entrance");
    346345    }
    347346
     
    357356        Test test = (Test) obj;
    358357        return Objects.equals(name, test.name) &&
    359                 Objects.equals(description, test.description);
     358               Objects.equals(description, test.description);
    360359    }
    361360}
  • trunk/src/org/openstreetmap/josm/data/validation/tests/Addresses.java

    r11339 r11608  
    6363            // warning level only if several relations have different names, see #10945
    6464            final String name = list.get(0).get("name");
    65             if (name == null || SubclassFilteredCollection.filter(list, r -> name.equals(r.get("name"))).size() < list.size()) {
     65            if (name == null || SubclassFilteredCollection.filter(list, r -> r.hasTag("name", name)).size() < list.size()) {
    6666                level = Severity.WARNING;
    6767            } else {
     
    147147                        street.add((Way) p);
    148148                    }
    149                     if (relationName != null && p.hasKey("name") && !relationName.equals(p.get("name"))) {
     149                    if (relationName != null && p.hasTagDifferent("name", relationName)) {
    150150                        if (wrongStreetNames.isEmpty()) {
    151151                            wrongStreetNames.add(r);
  • trunk/src/org/openstreetmap/josm/data/validation/tests/Coastlines.java

    r11129 r11608  
    251251
    252252    private static boolean isCoastline(OsmPrimitive osm) {
    253         return osm instanceof Way && "coastline".equals(osm.get("natural"));
     253        return osm instanceof Way && osm.hasTag("natural", "coastline");
    254254    }
    255255
  • trunk/src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java

    r11587 r11608  
    241241
    242242    static boolean isHighway(OsmPrimitive w) {
    243         return w.hasKey(HIGHWAY) && !w.hasTag(HIGHWAY, "rest_area", "services");
     243        return w.hasTagDifferent(HIGHWAY, "rest_area", "services");
    244244    }
    245245
  • trunk/src/org/openstreetmap/josm/data/validation/tests/Highways.java

    r11129 r11608  
    9292    public void visit(Way w) {
    9393        if (w.isUsable()) {
    94             if (w.isClosed() && w.hasKey("highway") && CLASSIFIED_HIGHWAYS.contains(w.get("highway"))
    95                     && w.hasKey("junction") && "roundabout".equals(w.get("junction"))) {
     94            if (w.isClosed() && w.hasTag("highway", CLASSIFIED_HIGHWAYS) && w.hasTag("junction", "roundabout")) {
    9695                // TODO: find out how to handle splitted roundabouts (see #12841)
    9796                testWrongRoundabout(w);
     
    131130                if (list.size() > 2 || oneway1 == null || oneway2 == null || !oneway1 || !oneway2) {
    132131                    // Error when the highway tags do not match
    133                     if (!w.get("highway").equals(s)) {
     132                    String value = w.get("highway");
     133                    if (!value.equals(s)) {
    134134                        errors.add(TestError.builder(this, Severity.WARNING, WRONG_ROUNDABOUT_HIGHWAY)
    135                                 .message(tr("Incorrect roundabout (highway: {0} instead of {1})", w.get("highway"), s))
     135                                .message(tr("Incorrect roundabout (highway: {0} instead of {1})", value, s))
    136136                                .primitives(w)
    137137                                .fix(() -> new ChangePropertyCommand(w, "highway", s))
  • trunk/src/org/openstreetmap/josm/data/validation/tests/LongSegment.java

    r11129 r11608  
    3535    @Override
    3636    public void visit(Way w) {
    37         if ("ferry".equals(w.get("route"))) {
     37        if (w.hasTag("route", "ferry")) {
    3838            return;
    3939        }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java

    r11590 r11608  
    175175    private void checkStyleConsistency(Relation r, Multipolygon polygon) {
    176176        ElemStyles styles = MapPaintStyles.getStyles();
    177         if (styles != null && !"boundary".equals(r.get("type"))) {
     177        if (styles != null && !r.hasTag("type", "boundary")) {
    178178            AreaElement area = ElemStyles.getAreaElemStyle(r, false);
    179179            boolean areaStyle = area != null;
  • trunk/src/org/openstreetmap/josm/data/validation/tests/OverlappingWays.java

    r11129 r11608  
    9090
    9191                for (WaySegment ws : duplicated) {
    92                     if (ws.way.get("highway") != null) {
     92                    if (ws.way.hasKey("highway")) {
    9393                        highway++;
    94                     } else if (ws.way.get("railway") != null) {
     94                    } else if (ws.way.hasKey("railway")) {
    9595                        railway++;
    9696                    }
     
    107107                    currentWays.add(ws.way);
    108108                }
    109                 /* These ways not seen before
    110                  * If two or more of the overlapping ways are
    111                  * highways or railways mark a separate error
    112                  */
     109                // These ways not seen before
     110                // If two or more of the overlapping ways are highways or railways mark a separate error
    113111                if ((highlight = seenWays.get(currentWays)) == null) {
    114112                    String errortype;
  • trunk/src/org/openstreetmap/josm/data/validation/tests/PowerLines.java

    r11432 r11608  
    165165     */
    166166    private static boolean isPowerIn(OsmPrimitive p, Collection<String> values) {
    167         String v = p.get("power");
    168         return v != null && values != null && values.contains(v);
     167        return p.hasTag("power", values);
    169168    }
    170169
     
    176175     */
    177176    private static boolean isBuildingIn(OsmPrimitive p, Collection<String> values) {
    178         String v = p.get("building");
    179         return v != null && values != null && values.contains(v);
     177        return p.hasTag("building", values);
    180178    }
    181179}
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TurnrestrictionTest.java

    r11129 r11608  
    4848    @Override
    4949    public void visit(Relation r) {
    50         if (!"restriction".equals(r.get("type")))
     50        if (!r.hasTag("type", "restriction"))
    5151            return;
    5252
     
    224224
    225225    private static boolean isFullOneway(Way w) {
    226         return w.isOneway() != 0 && !"no".equals(w.get("oneway:bicycle"));
     226        return w.isOneway() != 0 && !w.hasTag("oneway:bicycle", "no");
    227227    }
    228228
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java

    r11587 r11608  
    306306            this.isAbandoned = "abandoned".equals(railway) || w.isKeyTrue("disused");
    307307            this.highway = (highway != null || railway != null) && !isAbandoned;
    308             this.isBoundary = !this.highway && "administrative".equals(w.get("boundary"));
     308            this.isBoundary = !this.highway && w.hasTag("boundary", "administrative");
    309309            line = new Line2D.Double(n1.getEastNorth().east(), n1.getEastNorth().north(),
    310310                    n2.getEastNorth().east(), n2.getEastNorth().north());
Note: See TracChangeset for help on using the changeset viewer.