Changeset 15696 in josm for trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculator.java
- Timestamp:
- 2020-01-13T00:11:29+01:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculator.java
r15586 r15696 10 10 11 11 import org.openstreetmap.josm.data.osm.Node; 12 import org.openstreetmap.josm.data.osm.Relation; 12 13 import org.openstreetmap.josm.data.osm.RelationMember; 13 14 import org.openstreetmap.josm.data.osm.Way; … … 30 31 */ 31 32 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) { 32 44 this.members = members; 33 45 final List<WayConnectionType> con = new ArrayList<>(); … … 46 58 for (int i = 0; i < members.size(); ++i) { 47 59 try { 48 lastWct = updateLinksFor( con, lastWct, i);60 lastWct = updateLinksFor(r, con, lastWct, i); 49 61 } catch (RuntimeException e) { 50 62 int index = i; … … 58 70 } 59 71 60 private WayConnectionType updateLinksFor( finalList<WayConnectionType> con, WayConnectionType lastWct, int i) {72 private WayConnectionType updateLinksFor(Relation r, List<WayConnectionType> con, WayConnectionType lastWct, int i) { 61 73 final RelationMember m = members.get(i); 62 74 if (isNoHandleableWay(m)) { … … 67 79 firstGroupIdx = i; 68 80 } else { 69 WayConnectionType wct = computeNextWayConnection( con, lastWct, i, m);81 WayConnectionType wct = computeNextWayConnection(r, con, lastWct, i, m); 70 82 71 83 if (!wct.linkPrev) { … … 84 96 } 85 97 86 private WayConnectionType computeNextWayConnection( finalList<WayConnectionType> con, WayConnectionType lastWct, int i,98 private WayConnectionType computeNextWayConnection(Relation r, List<WayConnectionType> con, WayConnectionType lastWct, int i, 87 99 final RelationMember m) { 88 100 WayConnectionType wct = new WayConnectionType(false); 89 101 wct.linkPrev = i > 0 && con.get(i-1) != null && con.get(i-1).isValid(); 90 102 wct.direction = NONE; 91 92 if (RelationSortUtils.isOneway(m)) { 103 wct.ignoreOneway = isOnewayIgnored(r); 104 105 if (!wct.ignoreOneway && RelationSortUtils.isOneway(m)) { 93 106 handleOneway(lastWct, i, wct); 94 107 } … … 121 134 } 122 135 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) { 123 149 if (lastWct != null && i > 0 && m.getMember() instanceof Way && members.get(i - 1).getMember() instanceof Way 124 150 && (m.getWay().isOneway() != 0 || members.get(i - 1).getWay().isOneway() != 0)) { … … 135 161 } 136 162 } 137 con.set(i, wct);138 return wct;139 163 } 140 164
Note:
See TracChangeset
for help on using the changeset viewer.