Ignore:
Timestamp:
2020-01-13T00:11:29+01:00 (4 years ago)
Author:
Don-vip
Message:

fix #18020 - don't show way directions for boundary relations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculator.java

    r15586 r15696  
    1010
    1111import org.openstreetmap.josm.data.osm.Node;
     12import org.openstreetmap.josm.data.osm.Relation;
    1213import org.openstreetmap.josm.data.osm.RelationMember;
    1314import org.openstreetmap.josm.data.osm.Way;
     
    3031     */
    3132    public List<WayConnectionType> updateLinks(List<RelationMember> members) {
     33        return updateLinks(null, members);
     34    }
     35
     36    /**
     37     * refresh the cache of member WayConnectionTypes
     38     * @param r relation. Can be null, for plugins compatibility, but really shouldn't
     39     * @param members relation members
     40     * @return way connections
     41     * @since 15696
     42     */
     43    public List<WayConnectionType> updateLinks(Relation r, List<RelationMember> members) {
    3244        this.members = members;
    3345        final List<WayConnectionType> con = new ArrayList<>();
     
    4658        for (int i = 0; i < members.size(); ++i) {
    4759            try {
    48                 lastWct = updateLinksFor(con, lastWct, i);
     60                lastWct = updateLinksFor(r, con, lastWct, i);
    4961            } catch (RuntimeException e) {
    5062                int index = i;
     
    5870    }
    5971
    60     private WayConnectionType updateLinksFor(final List<WayConnectionType> con, WayConnectionType lastWct, int i) {
     72    private WayConnectionType updateLinksFor(Relation r, List<WayConnectionType> con, WayConnectionType lastWct, int i) {
    6173        final RelationMember m = members.get(i);
    6274        if (isNoHandleableWay(m)) {
     
    6779            firstGroupIdx = i;
    6880        } else {
    69             WayConnectionType wct = computeNextWayConnection(con, lastWct, i, m);
     81            WayConnectionType wct = computeNextWayConnection(r, con, lastWct, i, m);
    7082
    7183            if (!wct.linkPrev) {
     
    8496    }
    8597
    86     private WayConnectionType computeNextWayConnection(final List<WayConnectionType> con, WayConnectionType lastWct, int i,
     98    private WayConnectionType computeNextWayConnection(Relation r, List<WayConnectionType> con, WayConnectionType lastWct, int i,
    8799            final RelationMember m) {
    88100        WayConnectionType wct = new WayConnectionType(false);
    89101        wct.linkPrev = i > 0 && con.get(i-1) != null && con.get(i-1).isValid();
    90102        wct.direction = NONE;
    91 
    92         if (RelationSortUtils.isOneway(m)) {
     103        wct.ignoreOneway = isOnewayIgnored(r);
     104
     105        if (!wct.ignoreOneway && RelationSortUtils.isOneway(m)) {
    93106            handleOneway(lastWct, i, wct);
    94107        }
     
    121134        }
    122135
     136        if (!wct.ignoreOneway) {
     137            handleOnewayFollows(lastWct, i, m, wct);
     138        }
     139        con.set(i, wct);
     140        return wct;
     141    }
     142
     143    private static boolean isOnewayIgnored(Relation r) {
     144        return r != null && "boundary".equals(r.get("type"));
     145    }
     146
     147    protected void handleOnewayFollows(WayConnectionType lastWct, int i, final RelationMember m,
     148            WayConnectionType wct) {
    123149        if (lastWct != null && i > 0 && m.getMember() instanceof Way && members.get(i - 1).getMember() instanceof Way
    124150                && (m.getWay().isOneway() != 0 || members.get(i - 1).getWay().isOneway() != 0)) {
     
    135161            }
    136162        }
    137         con.set(i, wct);
    138         return wct;
    139163    }
    140164
Note: See TracChangeset for help on using the changeset viewer.