Ticket #13086: 13086_mod.patch
| File 13086_mod.patch, 3.3 KB (added by , 9 years ago) |
|---|
-
test/unit/org/openstreetmap/josm/data/validation/tests/SelfIntersectingWayTest.java
43 43 44 44 /** 45 45 * Self-Intersection at first (+ last) node of closed way 46 * This is considered okay 46 47 */ 47 48 @Test 48 49 public void TestClosedWay() { … … 60 61 w.setNodes(wayNodes); 61 62 SelfIntersectingWay test = new SelfIntersectingWay(); 62 63 test.visit(w); 63 Assert.assertEquals(1, test.getErrors().size()); 64 Assert.assertTrue(test.getErrors().iterator().next().getHighlighted().contains(nodes.get(0))); 64 Assert.assertEquals(0, test.getErrors().size()); 65 65 } 66 66 67 67 /** 68 68 * Self-Intersection at first node of unclosed way 69 * This is considered okay 69 70 */ 70 71 @Test 71 72 public void TestUnclosedWayFirst() { … … 82 83 w.setNodes(wayNodes); 83 84 SelfIntersectingWay test = new SelfIntersectingWay(); 84 85 test.visit(w); 85 Assert.assertEquals(1, test.getErrors().size()); 86 Assert.assertTrue(test.getErrors().iterator().next().getHighlighted().contains(nodes.get(0))); 86 Assert.assertEquals(0, test.getErrors().size()); 87 87 } 88 88 89 89 /** 90 * Self-Intersection at first node of unclosed way 90 * Self-Intersection at last node of unclosed way 91 * This is considered okay 91 92 */ 92 93 @Test 93 94 public void TestUnclosedWayLast() { … … 96 97 Way w = (Way) OsmUtils.createPrimitive("way "); 97 98 List<Node> wayNodes = new ArrayList<>(); 98 99 wayNodes.add(nodes.get(0)); 99 wayNodes.add(nodes.get(1)); // problem 100 wayNodes.add(nodes.get(1)); // problem node 100 101 wayNodes.add(nodes.get(2)); 101 102 wayNodes.add(nodes.get(3)); 102 103 wayNodes.add(nodes.get(4)); … … 104 105 w.setNodes(wayNodes); 105 106 SelfIntersectingWay test = new SelfIntersectingWay(); 106 107 test.visit(w); 107 Assert.assertEquals(1, test.getErrors().size()); 108 Assert.assertTrue(test.getErrors().iterator().next().getHighlighted().contains(nodes.get(1))); 108 Assert.assertEquals(0, test.getErrors().size()); 109 109 } 110 110 111 111 /** -
src/org/openstreetmap/josm/data/validation/tests/SelfIntersectingWay.java
31 31 @Override 32 32 public void visit(Way w) { 33 33 Set<Node> nodes = new HashSet<>(); 34 int last = w.getNodesCount(); 35 if (last < 2) 36 return; 37 if (w.firstNode() == w.lastNode()) 38 last--; // closed way, ignore last node 39 nodes.add(w.firstNode()); 40 for (int i = 1; i < last; i++) { 34 for (int i = 1; i < w.getNodesCount() - 1; i++) { 41 35 Node n = w.getNode(i); 42 36 if (nodes.contains(n)) { 43 37 errors.add(TestError.builder(this, Severity.WARNING, SELF_INTERSECT)
