Changeset 7121 in josm


Ignore:
Timestamp:
2014-05-14T09:05:56+02:00 (6 years ago)
Author:
simon04
Message:

fix #9889 - Follow line should stop on ambiguous junctions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/FollowLineAction.java

    r6142 r7121  
    1515import org.openstreetmap.josm.data.osm.Node;
    1616import org.openstreetmap.josm.data.osm.OsmPrimitive;
    17 import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    1817import org.openstreetmap.josm.data.osm.Way;
    1918import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2019import org.openstreetmap.josm.tools.Shortcut;
     20import org.openstreetmap.josm.tools.Utils;
    2121
    2222/**
     
    8484
    8585        Node newPoint = null;
    86         for (OsmPrimitive referrer : referrers) {
    87             if (!referrer.getType().equals(OsmPrimitiveType.WAY)) { // Can't follow points or relations
    88                 continue;
    89             }
    90             Way toFollow = (Way) referrer;
     86        for (final Way toFollow : Utils.filteredCollection(referrers, Way.class)) {
    9187            if (toFollow.equals(follower)) {
    9288                continue;
    9389            }
    9490            Set<Node> points = toFollow.getNeighbours(last);
    95             if (!points.remove(prev) || points.isEmpty())
     91            points.remove(prev);
     92            if (points.isEmpty())     // No candidate -> consider next way
    9693                continue;
    9794            if (points.size() > 1)    // Ambiguous junction?
    9895                return;
    9996
     97            // points contains exactly one element
    10098            Node newPointCandidate = points.iterator().next();
    10199
Note: See TracChangeset for help on using the changeset viewer.