Ticket #18137: 18137.4.patch

File 18137.4.patch, 1.9 KB (added by taylor.smock, 7 years ago)

Iterate through nodes until we find one that has a good LatLon, needs a check in the for (Node next : nextNodes) block since we may only find nodes with no known latlon (and that will be what is assigned to the array) or no nodes (in which case we have null in the array).

  • 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 = {null, null};
    450450                        if (pos > 0) {
    451                             nextNodes.add(way.getNode(pos - 1));
     451                            int i = 1;
     452                            while (pos - i >= 0 && (nextNodes[0] == null || !nextNodes[0].isLatLonKnown())) {
     453                                nextNodes[0] = way.getNode(pos - i);
     454                                i++;
     455                            }
    452456                        }
    453457                        if (pos + 1 < way.getNodesCount()) {
    454                             nextNodes.add(way.getNode(pos + 1));
     458                            int i = 1;
     459                            while (pos + i < way.getNodesCount() - 1 && (nextNodes[1] == null || !nextNodes[1].isLatLonKnown())) {
     460                                nextNodes[1] = way.getNode(pos + i);
     461                                i++;
     462                            }
    455463                        }
    456464                        for (Node next : nextNodes) {
     465                            if (next == null || !next.isLatLonKnown()) continue;
    457466                            final boolean containsN = visited.contains(next);
    458467                            visited.add(next);
    459468                            if (!containsN && isConnectedTo(next, way, visited,