Changeset 12032 in josm for trunk/src


Ignore:
Timestamp:
2017-04-30T23:24:11+02:00 (8 years ago)
Author:
Don-vip
Message:

fix #14708 - no warning about potentially erroneous movement of existing nodes

File:
1 edited

Legend:

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

    r11608 r12032  
    55import static org.openstreetmap.josm.tools.I18n.tr;
    66
     7import java.util.HashSet;
     8import java.util.Set;
     9
    710import org.openstreetmap.josm.Main;
     11import org.openstreetmap.josm.data.osm.Node;
    812import org.openstreetmap.josm.data.osm.OsmPrimitive;
    913import org.openstreetmap.josm.data.osm.Way;
     
    1418
    1519/**
    16  * Checks for untagged ways
     20 * Checks for very long segments.
    1721 *
    1822 * @since 8320
     
    2428    /** Maximum segment length for this test */
    2529    protected int maxlength;
     30    /** set of visited ways */
     31    private final Set<Way> visitedWays = new HashSet<>();
    2632
    2733    /**
     
    3440
    3541    @Override
     42    public void visit(Node n) {
     43        for (Way w : n.getParentWays()) {
     44            if (isPrimitiveUsable(w)) {
     45                testWay(w);
     46            }
     47        }
     48    }
     49
     50    @Override
    3651    public void visit(Way w) {
    37         if (w.hasTag("route", "ferry")) {
     52        testWay(w);
     53    }
     54
     55    private void testWay(Way w) {
     56        if (visitedWays.contains(w) || w.hasTag("route", "ferry")) {
    3857            return;
    3958        }
     59        visitedWays.add(w);
    4060        Double length = w.getLongestSegmentLength();
    4161        if (length > maxlength) {
     
    5272        super.startTest(monitor);
    5373        maxlength = Main.pref.getInteger("validator.maximum.segment.length", 15_000);
     74        visitedWays.clear();
     75    }
     76
     77    @Override
     78    public void endTest() {
     79        visitedWays.clear();
     80        super.endTest();
    5481    }
    5582
    5683    @Override
    5784    public boolean isPrimitiveUsable(OsmPrimitive p) {
    58         return p.isUsable() && p instanceof Way && ((Way) p).getNodesCount() > 1; // test only Ways with at least 2 nodes
     85        // test only nodes and Ways with at least 2 nodes
     86        return p.isUsable() && ((p instanceof Node && p.isDrawable()) || (p instanceof Way && ((Way) p).getNodesCount() > 1));
    5987    }
    6088}
Note: See TracChangeset for help on using the changeset viewer.