Ticket #18137: 18137.3.patch

File 18137.3.patch, 1.9 KB (added by taylor.smock, 6 years ago)

Try to find the next node in each direction when one is null or we don't know the LatLon (needs testing)

  • src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java

     
    445445                visited.add(node);
    446446                for (final Way way : node.getParentWays()) {
    447447                    if (isCandidate(way)) {
    448                         List<Node> nextNodes = new ArrayList<>();
    449448                        int pos = way.getNodes().indexOf(node);
     449                        Node[] nextNodes = new Node[2];
    450450                        if (pos > 0) {
    451                             nextNodes.add(way.getNode(pos - 1));
     451                            nextNodes[0] = way.getNode(pos - 1);
    452452                        }
    453453                        if (pos + 1 < way.getNodesCount()) {
    454                             nextNodes.add(way.getNode(pos + 1));
     454                            nextNodes[1] = way.getNode(pos + 1);
    455455                        }
     456
     457                        // Don't try to use nodes that are null (there shouldn't be any) or where we don't know the LatLon.
     458                        int i = 1;
     459                        while (pos - i >= 0 && (nextNodes[0] == null || !nextNodes[0].isLatLonKnown())) {
     460                            nextNodes[0] = way.getNode(pos - i);
     461                            i++;
     462                        }
     463                        i = 2;
     464                        while (pos + i < way.getNodesCount() && (nextNodes[1] == null || !nextNodes[1].isLatLonKnown())) {
     465                            nextNodes[1] = way.getNode(pos + i);
     466                            i++;
     467                        }
    456468                        for (Node next : nextNodes) {
    457469                            final boolean containsN = visited.contains(next);
    458470                            visited.add(next);