- Timestamp:
- 2017-01-07T17:19:05+01:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/SelfIntersectingWay.java
r11149 r11441 31 31 @Override 32 32 public void visit(Way w) { 33 int last = w.getNodesCount(); 34 if (last < 2) 35 return; 33 36 Set<Node> nodes = new HashSet<>(); 34 for (int i = 1; i < w.getNodesCount() - 1; i++) { 37 nodes.add(w.firstNode()); 38 int countFirst = 0; 39 int countLast = 0; 40 for (int i = 1; i < last; i++) { 35 41 Node n = w.getNode(i); 36 42 if (nodes.contains(n)) { 37 errors.add(TestError.builder(this, Severity.WARNING, SELF_INTERSECT) 38 .message(tr("Self-intersecting ways")) 39 .primitives(w) 40 .highlight(n) 41 .build()); 42 break; 43 boolean ok = false; 44 if (n == w.firstNode()) { 45 if (countFirst++ == 0) 46 ok = true; 47 } else if (i + 1 == last) { 48 if (countLast++ == 0) 49 ok = true; 50 } 51 if (!ok || countFirst + countLast > 1) { 52 errors.add(TestError.builder(this, Severity.WARNING, SELF_INTERSECT) 53 .message(tr("Self-intersecting ways")) 54 .primitives(w) 55 .highlight(n) 56 .build()); 57 break; 58 } 43 59 } else { 44 60 nodes.add(n);
Note:
See TracChangeset
for help on using the changeset viewer.