- Timestamp:
- 2017-04-30T23:24:11+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/LongSegment.java
r11608 r12032 5 5 import static org.openstreetmap.josm.tools.I18n.tr; 6 6 7 import java.util.HashSet; 8 import java.util.Set; 9 7 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.data.osm.Node; 8 12 import org.openstreetmap.josm.data.osm.OsmPrimitive; 9 13 import org.openstreetmap.josm.data.osm.Way; … … 14 18 15 19 /** 16 * Checks for untagged ways20 * Checks for very long segments. 17 21 * 18 22 * @since 8320 … … 24 28 /** Maximum segment length for this test */ 25 29 protected int maxlength; 30 /** set of visited ways */ 31 private final Set<Way> visitedWays = new HashSet<>(); 26 32 27 33 /** … … 34 40 35 41 @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 36 51 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")) { 38 57 return; 39 58 } 59 visitedWays.add(w); 40 60 Double length = w.getLongestSegmentLength(); 41 61 if (length > maxlength) { … … 52 72 super.startTest(monitor); 53 73 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(); 54 81 } 55 82 56 83 @Override 57 84 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)); 59 87 } 60 88 }
Note:
See TracChangeset
for help on using the changeset viewer.