- Timestamp:
- 2020-08-12T22:17:36+02:00 (4 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/RelationNodeMap.java
r16630 r16886 177 177 private Integer popForwardOnewayPart(Integer way) { 178 178 if (onewayMap.ways.containsKey(way)) { 179 for (Node n : onewayMap.ways.get(way)) { 180 Integer i = findAdjacentWay(onewayMap, n); 181 if (i == null) { 182 continue; 183 } 184 185 lastOnewayNode = processBackwardIfEndOfLoopReached(i); 186 if (lastOnewayNode != null) 187 return popBackwardOnewayPart(firstOneway); 188 189 deleteWayNode(onewayMap, i, n); 190 return i; 191 } 179 Node exitNode = onewayMap.ways.get(way).iterator().next(); 180 181 if (checkIfEndOfLoopReached(exitNode)) { 182 lastOnewayNode = exitNode; 183 return popBackwardOnewayPart(firstOneway); 184 } 185 186 Integer i = deleteAndGetAdjacentNode(onewayMap, exitNode); 187 if (i != null) return i; 188 189 // When our forward route ends in a dead end try to start 190 // the backward route anyway from the split point 191 // (firstOneWay), to support routes with split a split start 192 // or end. 193 lastOnewayNode = exitNode; 194 return popBackwardOnewayPart(firstOneway); 192 195 } 193 196 … … 196 199 } 197 200 198 private Node processBackwardIfEndOfLoopReached(Integer way) { //find if we didn't reach end of the loop (and process backward part) 199 if (onewayReverseMap.ways.containsKey(way)) { 200 for (Node n : onewayReverseMap.ways.get(way)) { 201 if (map.nodes.containsKey(n) 202 || (onewayMap.nodes.containsKey(n) && onewayMap.nodes.get(n).size() > 1)) 203 return n; 204 if (firstCircular != null && firstCircular == n) 205 return firstCircular; 206 } 207 } 208 return null; 201 // Check if the given node can be the end of the loop (i.e. it has 202 // an outgoing bidirectional or multiple outgoing oneways, or we 203 // looped back to our first circular node) 204 private boolean checkIfEndOfLoopReached(Node n) { 205 if (map.nodes.containsKey(n) 206 || (onewayMap.nodes.containsKey(n) && onewayMap.nodes.get(n).size() > 1)) 207 return true; 208 if (firstCircular != null && firstCircular == n) 209 return true; 210 return false; 209 211 } 210 212 … … 267 269 } else { 268 270 done(way); 269 } 270 nw.ways.get(way).remove(n); 271 // For bidirectional ways, remove the entry node, so 272 // subsequent lookups will only return the other node(s) as 273 // valid exit nodes. 274 nw.ways.get(way).remove(n); 275 } 271 276 } 272 277 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculator.java
r15747 r16886 146 146 147 147 if (!wct.linkPrev) { 148 wct.direction = determineDirectionOfFirst(i, m );148 wct.direction = determineDirectionOfFirst(i, m, false); 149 149 if (RelationSortUtils.isOneway(m)) { 150 150 wct.isOnewayLoopForwardPart = true; … … 218 218 } 219 219 220 private Direction determineDirectionOfFirst(final int i, final RelationMember m ) {220 private Direction determineDirectionOfFirst(final int i, final RelationMember m, boolean reversed) { 221 221 Direction result = RelationSortUtils.roundaboutType(m); 222 222 if (result != NONE) … … 224 224 225 225 if (RelationSortUtils.isOneway(m)) { 226 if (RelationSortUtils.isBackward(m) ) return BACKWARD;226 if (RelationSortUtils.isBackward(m) != reversed) return BACKWARD; 227 227 else return FORWARD; 228 228 } else { /** guess the direction and see if it fits with the next member */ … … 248 248 } 249 249 250 // Support split-start routes. When the current way does 251 // not fit as forward or backward and we have no backward 252 // ways yet (onewayBeginning) and the most recent oneway 253 // head starts a new segment (!linkPrev), instead of 254 // disconnecting the current way, make it the start of the 255 // backward route. To render properly, unset isOnewayHead on 256 // the most recent head (since the current backward way does 257 // no longer start there). 258 if (dirFW == NONE && dirBW == NONE && RelationSortUtils.isOneway(m) && !wct.isOnewayHead) { 259 WayConnectionType prevHead = null; 260 for (int j = i - 1; j >= 0; --j) { 261 if (con.get(j).isOnewayHead) { 262 prevHead = con.get(j); 263 break; 264 } 265 } 266 267 if (prevHead != null && !prevHead.linkPrev) { 268 dirBW = determineDirectionOfFirst(i, m, true); 269 prevHead.isOnewayHead = false; 270 } 271 } 272 250 273 if (dirBW != NONE) { 251 274 onewayBeginning = false; … … 269 292 if (dirFW == NONE && dirBW == NONE) { 270 293 wct.linkPrev = false; 271 if (RelationSortUtils.isOneway(m)) { 272 wct.isOnewayHead = true; 273 lastForwardWay = i-1; 274 lastBackwardWay = i-1; 275 } else { 276 lastForwardWay = UNCONNECTED; 277 lastBackwardWay = UNCONNECTED; 278 } 294 wct.isOnewayHead = true; 295 lastForwardWay = i-1; 296 lastBackwardWay = i-1; 279 297 onewayBeginning = true; 280 298 }
Note:
See TracChangeset
for help on using the changeset viewer.