Changeset 5490 in josm for trunk/src


Ignore:
Timestamp:
2012-09-01T19:01:03+02:00 (12 years ago)
Author:
Don-vip
Message:

fix #8015 - proper warnings for closed ways with area-style keys that do not denote an area

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

Legend:

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

    r5408 r5490  
    471471        return nodes.length >= 3 && nodes[nodes.length-1] == nodes[0];
    472472    }
     473   
     474    /**
     475     * Determines if this way denotes an area (closed way with at least three distinct nodes).
     476     * @return {@code true} if this way is closed and contains at least three distinct nodes
     477     * @see #isClosed
     478     * @since 5490
     479     */
     480    public boolean isArea() {
     481        if (this.nodes.length >= 4 && isClosed()) {
     482            Node distinctNode = null;
     483            for (int i=1; i<nodes.length-1; i++) {
     484                if (distinctNode == null && nodes[i] != nodes[0]) {
     485                    distinctNode = nodes[i];
     486                } else if (distinctNode != null && nodes[i] != nodes[0] && nodes[i] != distinctNode) {
     487                    return true;
     488                }
     489            }
     490        }
     491        return false;
     492    }
    473493
    474494    /**
     
    627647            if (lastN != null) {
    628648                LatLon lastNcoor = lastN.getCoor();
    629                 LatLon coor = n.getCoor();
     649                LatLon coor = n.getCoor();
    630650                if (lastNcoor != null && coor != null) {
    631651                    length += coor.greatCircleDistance(lastNcoor);
  • trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java

    r5488 r5490  
    177177            }
    178178            wNodesToUse.add(wNodes.get(lowestIndex));
     179        } else {
     180                wNodesToUse.addAll(wNodes);
    179181        }
    180182        // Build the list of lat/lon
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java

    r5012 r5490  
    116116    @Override
    117117    public void visit(Way w) {
    118         if (!w.isClosed() && ElemStyles.hasAreaElemStyle(w, false)) {
     118        if (!w.isArea() && ElemStyles.hasAreaElemStyle(w, false)) {
    119119            List<Node> nodes = w.getNodes();
    120120            if (nodes.size()<1) return; // fix zero nodes bug
  • trunk/src/org/openstreetmap/josm/data/validation/tests/OverlappingAreas.java

    r5269 r5490  
    2727    @Override
    2828    public void visit(Way w) {
    29         if (w.isUsable() && w.isClosed() && ElemStyles.hasAreaElemStyle(w, false)) {
     29        if (w.isUsable() && w.isArea() && ElemStyles.hasAreaElemStyle(w, false)) {
    3030            index.add(w);
    3131        }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UnclosedWays.java

    r4806 r5490  
    107107        }
    108108
    109         if (type != null && !w.isClosed()) {
     109        if (type != null && !w.isArea()) {
    110110            for (OsmPrimitive parent: w.getReferrers()) {
    111111                if (parent instanceof Relation && ((Relation)parent).isMultipolygon())
Note: See TracChangeset for help on using the changeset viewer.