Ticket #13086: 13086_mod.patch

File 13086_mod.patch, 3.3 KB (added by GerdP, 3 years ago)
  • test/unit/org/openstreetmap/josm/data/validation/tests/SelfIntersectingWayTest.java

     
    4343
    4444    /**
    4545     * Self-Intersection at first (+ last) node of closed way
     46     * This is considered okay
    4647     */
    4748    @Test
    4849    public void TestClosedWay() {
     
    6061        w.setNodes(wayNodes);
    6162        SelfIntersectingWay test = new SelfIntersectingWay();
    6263        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());
    6565    }
    6666
    6767    /**
    6868     * Self-Intersection at first node of unclosed way
     69     * This is considered okay
    6970     */
    7071    @Test
    7172    public void TestUnclosedWayFirst() {
     
    8283        w.setNodes(wayNodes);
    8384        SelfIntersectingWay test = new SelfIntersectingWay();
    8485        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());
    8787    }
    8888
    8989    /**
    90      * Self-Intersection at first node of unclosed way
     90     * Self-Intersection at last node of unclosed way
     91     * This is considered okay
    9192     */
    9293    @Test
    9394    public void TestUnclosedWayLast() {
     
    9697        Way w = (Way) OsmUtils.createPrimitive("way ");
    9798        List<Node> wayNodes = new ArrayList<>();
    9899        wayNodes.add(nodes.get(0));
    99         wayNodes.add(nodes.get(1)); // problem
     100        wayNodes.add(nodes.get(1)); // problem node
    100101        wayNodes.add(nodes.get(2));
    101102        wayNodes.add(nodes.get(3));
    102103        wayNodes.add(nodes.get(4));
     
    104105        w.setNodes(wayNodes);
    105106        SelfIntersectingWay test = new SelfIntersectingWay();
    106107        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());
    109109    }
    110110
    111111    /**
  • src/org/openstreetmap/josm/data/validation/tests/SelfIntersectingWay.java

     
    3131    @Override
    3232    public void visit(Way w) {
    3333        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++) {
    4135            Node n = w.getNode(i);
    4236            if (nodes.contains(n)) {
    4337                errors.add(TestError.builder(this, Severity.WARNING, SELF_INTERSECT)