Changeset 6579 in josm for trunk


Ignore:
Timestamp:
2013-12-31T13:18:44+01:00 (11 years ago)
Author:
simon04
Message:

fix #4280 - Validator, crossing ways: do not warn if layer is missing for simple, unambiguous cases (one way is bridge/tunnel and the other one is not)

Location:
trunk/src/org/openstreetmap/josm
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java

    r6246 r6579  
    603603    }
    604604
     605    /**
     606     * Returns true if the {@code key} corresponds to an OSM true value.
     607     * @see {@link OsmUtils#isTrue(String) }
     608     */
     609    public final boolean isKeyTrue(String key) {
     610        return OsmUtils.isTrue(get(key));
     611    }
     612
     613    /**
     614     * Returns true if the {@code key} corresponds to an OSM false value.
     615     * @see {@link OsmUtils#isFalse(String) }
     616     */
     617    public final boolean isKeyFalse(String key) {
     618        return OsmUtils.isFalse(get(key));
     619    }
     620
    605621    public final String getIgnoreCase(String key) {
    606622        String[] keys = this.keys;
  • trunk/src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java

    r6457 r6579  
    1515
    1616import org.openstreetmap.josm.data.osm.Node;
     17import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1718import org.openstreetmap.josm.data.osm.Way;
    1819import org.openstreetmap.josm.data.osm.WaySegment;
     
    6162        errorSegments = null;
    6263        seenWays = null;
     64    }
     65
     66    private String getLayer(OsmPrimitive w) {
     67        String layer1 = w.get("layer");
     68        if ("0".equals(layer1)) {
     69            layer1 = null; // 0 is default value for layer.
     70        } else if (layer1 == null && w.isKeyTrue("bridge")) {
     71            /* see #4280.
     72               In order to avoid a test error for simple settings (such as one way is a bridge, the other one isn't),
     73               set layer to a marker value <bridge>. Then, two crossing bridges w/o a layer set are still detected.
     74            */
     75            layer1 = "<bridge>";
     76        } else if (layer1 == null && w.isKeyTrue("tunnel")) {
     77            /* likewise for tunnels */
     78            layer1 = "<tunnel>";
     79        }
     80        return layer1;
    6381    }
    6482
     
    84102
    85103        String level1 = w.get("level");
    86         String layer1 = w.get("layer");
    87         if ("0".equals(layer1)) {
    88             layer1 = null; // 0 is default value for layer. Don't assume the same for levels
    89         }
     104        String layer1 = getLayer(w);
    90105
    91106        int nodesSize = w.getNodesCount();
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java

    r6556 r6579  
    130130                            || en.hasTag("amenity", "parking_entrance")
    131131                            || en.hasTag("railway", "buffer_stop")
    132                             || OsmUtils.isTrue(en.get("noexit"))
     132                            || en.isKeyTrue("noexit")
    133133                            || en.hasKey("entrance")
    134134                            || en.hasKey("barrier")) {
     
    235235            String railway = w.get("railway");
    236236            String highway = w.get("highway");
    237             this.isAbandoned = "abandoned".equals(railway) || OsmUtils.isTrue(w.get("disused"));
     237            this.isAbandoned = "abandoned".equals(railway) || w.isKeyTrue("disused");
    238238            this.highway = (highway != null || railway != null) && !isAbandoned;
    239239            this.isBoundary = !this.highway && "administrative".equals(w.get("boundary"));
     
    252252            if (w.containsNode(n))
    253253                return false;
    254             if (OsmUtils.isTrue(n.get("noexit")))
     254            if (n.isKeyTrue("noexit"))
    255255                return false;
    256256            EastNorth coord = n.getEastNorth();
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Condition.java

    r6560 r6579  
    255255            case PRIMITIVE:
    256256                if (KeyMatchType.TRUE.equals(matchType))
    257                     return OsmUtils.isTrue(e.osm.get(label)) ^ negateResult;
     257                    return e.osm.isKeyTrue(label) ^ negateResult;
    258258                else if (KeyMatchType.FALSE.equals(matchType))
    259                     return OsmUtils.isFalse(e.osm.get(label)) ^ negateResult;
     259                    return e.osm.isKeyFalse(label) ^ negateResult;
    260260                else if (KeyMatchType.REGEX.equals(matchType))
    261261                    return Utils.exists(e.osm.keySet(), Predicates.stringContainsPattern(Pattern.compile(label))) ^ negateResult;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/xml/XmlStyleSource.java

    r6316 r6579  
    177177        String lineIdx = null;
    178178        HashMap<String, LinemodPrototype> overlayMap = new HashMap<String, LinemodPrototype>();
    179         boolean isNotArea = OsmUtils.isFalse(primitive.get("area"));
     179        boolean isNotArea = primitive.isKeyFalse("area");
    180180        for (String key : primitive.keySet()) {
    181181            String val = primitive.get(key);
Note: See TracChangeset for help on using the changeset viewer.