Changeset 15732 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2020-01-19T18:57:26+01:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionType.java
r15696 r15732 80 80 */ 81 81 public WayConnectionType(boolean invalid) { 82 this.linkPrev = false; 83 this.linkNext = false; 84 this.isLoop = false; 85 this.direction = NONE; 82 86 this.invalid = invalid; 83 87 } … … 85 89 /** construct invalid instance */ 86 90 public WayConnectionType() { 87 this.linkPrev = false; 88 this.linkNext = false; 89 this.isLoop = false; 90 this.direction = NONE; 91 invalid = true; 91 this(true); 92 92 } 93 93 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculator.java
r15700 r15732 8 8 import java.util.ArrayList; 9 9 import java.util.List; 10 import java.util.stream.Collectors; 10 11 11 12 import org.openstreetmap.josm.data.osm.Node; … … 14 15 import org.openstreetmap.josm.data.osm.Way; 15 16 import org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionType.Direction; 17 import org.openstreetmap.josm.tools.StreamUtils; 16 18 import org.openstreetmap.josm.tools.bugreport.BugReport; 17 19 … … 43 45 public List<WayConnectionType> updateLinks(Relation r, List<RelationMember> members) { 44 46 this.members = members; 45 final List<WayConnectionType> con = new ArrayList<>(); 46 47 for (int i = 0; i < members.size(); ++i) { 48 con.add(null); 49 } 47 final List<WayConnectionType> con = members.stream() 48 .map(ignore -> (WayConnectionType) null) 49 .collect(Collectors.toList()); 50 50 51 51 firstGroupIdx = 0; … … 65 65 } 66 66 } 67 makeLoopIfNeeded(con, members.size()-1); 67 if (!isSuperRoute(r)) { 68 makeLoopIfNeeded(con, members.size() - 1); 69 } 68 70 69 71 return con; … … 72 74 private WayConnectionType updateLinksFor(Relation r, List<WayConnectionType> con, WayConnectionType lastWct, int i) { 73 75 final RelationMember m = members.get(i); 74 if (isNoHandleableWay(m)) { 76 if (isSuperRoute(r)) { 77 final WayConnectionType wct; 78 if (!members.get(i).isRelation()) { 79 return new WayConnectionType(true); 80 } else if (i == 0) { 81 return new WayConnectionType(false); 82 } else { 83 final List<RelationMember> previousMembers = members.get(i - 1).getRelation().getMembers(); 84 final Way previousLastWay = StreamUtils.reversedStream(previousMembers) 85 .filter(x -> x.isWay() && !x.hasRole()) 86 .map(RelationMember::getWay) 87 .findFirst().orElse(null); 88 final Way currentFirstWay = m.getRelation().getMembers().stream() 89 .filter(x -> x.isWay() && !x.hasRole()) 90 .map(RelationMember::getWay) 91 .findFirst().orElse(null); 92 final boolean isConnected = isConnected(previousLastWay, currentFirstWay); 93 wct = new WayConnectionType(false); 94 lastWct.linkNext = wct.linkPrev = isConnected; 95 } 96 con.set(i, wct); 97 return wct; 98 } else if (isNoHandleableWay(m)) { 75 99 if (i > 0) { 76 100 makeLoopIfNeeded(con, i-1); … … 139 163 con.set(i, wct); 140 164 return wct; 165 } 166 167 private boolean isSuperRoute(Relation r) { 168 return r != null && r.hasTag("type", "superroute"); 141 169 } 142 170 … … 372 400 members = null; 373 401 } 402 403 private boolean isConnected(Way way1, Way way2) { 404 return way1 != null && way2 != null && way1.isUsable() && way2.isUsable() 405 && (way1.isFirstLastNode(way2.firstNode()) || way1.isFirstLastNode(way2.lastNode())); 406 } 374 407 }
Note:
See TracChangeset
for help on using the changeset viewer.