-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow u-turns only at dead ends #2883
Open
easbar
wants to merge
34
commits into
master
Choose a base branch
from
dead_end_u_turns
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
3af92a8
Allow u-turns only at deadends
easbar 0d8e956
unrelated to subnetworks since they are running afterwards (first the…
easbar caecb8f
Merge branch 'master' into dead_end_u_turns
easbar ee2b9bf
storedUTurnCostsAreDeadEndFlags... (sigh)
easbar 7e320bb
Disable failing tests.
easbar 8ba5040
tmp
easbar 1dfb794
Merge branch 'master' into dead_end_u_turns
easbar 6c3de4b
Merge branch 'master' into dead_end_u_turns
easbar 5d88e15
up
easbar 07bd1b5
Remove max_turn_costs encoder parameter
easbar e0b308f
tmp
easbar e9c8f2c
continue
easbar 564ab4d
update
easbar 01479d3
Merge branch 'master' into tctr
easbar ff9a8d8
Use boolean turn restriction enc instead of decimal turn cost enc
easbar 22e0d59
Merge branch 'turn_restriction_enc' into dead_end_enc
easbar b91304a
Merge branch 'dead_end_enc' into dead_end_u_turns
easbar 1a251bc
Use dead end enc
easbar fa3dc17
Merge branch 'master' into turn_restriction_enc
easbar 2544c6f
Merge branch 'turn_restriction_enc' into dead_end_u_turns
easbar ba08fea
Merge branch 'master' into dead_end_u_turns
easbar 60a6ba3
fix some tests
easbar 750388f
tmp
easbar 1b7ea5d
reverse order / green
easbar 103b098
green
easbar c6dd1d0
Fix dead ends at subnetwork boundaries
easbar 50a607b
move + test
easbar eadc81e
Try lower u-turn costs
easbar 6a2e143
Try higher u-turn costs
easbar ae0cf77
try zero u-turn costs
easbar 14ffa5b
Merge branch 'master' into dead_end_u_turns
karussell 8db91a7
minor fixes
karussell a733535
Merge branch 'master' into dead_end_u_turns
easbar efd095b
Merge branch 'master' into dead_end_u_turns
easbar File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
core/src/main/java/com/graphhopper/reader/osm/PrepareDeadEnds.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Licensed to GraphHopper GmbH under one or more contributor | ||
* license agreements. See the NOTICE file distributed with this work for | ||
* additional information regarding copyright ownership. | ||
* | ||
* GraphHopper GmbH licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except in | ||
* compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.graphhopper.reader.osm; | ||
|
||
import com.graphhopper.routing.ev.BooleanEncodedValue; | ||
import com.graphhopper.routing.weighting.Weighting; | ||
import com.graphhopper.storage.BaseGraph; | ||
import com.graphhopper.util.EdgeExplorer; | ||
import com.graphhopper.util.EdgeIterator; | ||
import com.graphhopper.util.GHUtility; | ||
|
||
public class PrepareDeadEnds { | ||
private final BaseGraph baseGraph; | ||
|
||
public PrepareDeadEnds(BaseGraph baseGraph) { | ||
this.baseGraph = baseGraph; | ||
} | ||
|
||
public void findDeadEndUTurns(Weighting weighting, BooleanEncodedValue deadEndEnc, BooleanEncodedValue subnetworkEnc) { | ||
EdgeExplorer inExplorer = baseGraph.createEdgeExplorer(); | ||
EdgeExplorer outExplorer = baseGraph.createEdgeExplorer(); | ||
for (int node = 0; node < baseGraph.getNodes(); node++) { | ||
EdgeIterator fromEdge = inExplorer.setBaseNode(node); | ||
OUTER: | ||
while (fromEdge.next()) { | ||
if (Double.isFinite(weighting.calcEdgeWeight(fromEdge, true))) { | ||
boolean subnetworkFrom = fromEdge.get(subnetworkEnc); | ||
EdgeIterator toEdge = outExplorer.setBaseNode(node); | ||
while (toEdge.next()) { | ||
if (toEdge.getEdge() != fromEdge.getEdge() | ||
&& Double.isFinite(GHUtility.calcWeightWithTurnWeight(weighting, toEdge, false, fromEdge.getEdge())) | ||
&& subnetworkFrom == toEdge.get(subnetworkEnc)) | ||
continue OUTER; | ||
} | ||
// the only way to continue from fromEdge is a u-turn. this is a dead-end u-turn | ||
setDeadEndUTurn(baseGraph, deadEndEnc, fromEdge.getEdge(), node); | ||
} | ||
} | ||
} | ||
} | ||
|
||
private void setDeadEndUTurn(BaseGraph baseGraph, BooleanEncodedValue deadEndEnc, int fromEdge, int viaNode) { | ||
baseGraph.getTurnCostStorage().set(deadEndEnc, fromEdge, viaNode, fromEdge, true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
core/src/main/java/com/graphhopper/routing/ev/DeadEnd.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Licensed to GraphHopper GmbH under one or more contributor | ||
* license agreements. See the NOTICE file distributed with this work for | ||
* additional information regarding copyright ownership. | ||
* | ||
* GraphHopper GmbH licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except in | ||
* compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.graphhopper.routing.ev; | ||
|
||
import static com.graphhopper.routing.util.EncodingManager.getKey; | ||
|
||
public class DeadEnd { | ||
|
||
public static String key(String prefix) { | ||
return getKey(prefix, "dead_end"); | ||
} | ||
|
||
public static BooleanEncodedValue create(String name) { | ||
return new SimpleBooleanEncodedValue(key(name), false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case there will be u-turns other than dead-ends that we want to explicitly allow in the future, maybe we should use a more general name(?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Information. Sorry as (non dev) GPS user I have to describe it less technically.
U-turns are sure very useful.
In the Kurviger and Cruiser app 180° u-turns are very usefully used.
See example in the image and attached gpx navigation track.
By Notepad++ or gpx editor, find turn instructions in trackpoints.
Cruiser_GraphHopper planning.
Cruiser_Brouter planning.
Same as above but with an extra.
A "correct misplaced via points" tool can presumably thus automatically prevent false out and return track glitches with 180° u-turn commands. The correction distance is adjustable between 0 and 100m (default 40m).
Provided additional shaping point, a 180° u-turn can still be enforced even in this correction range.
Cruiser_Brouter navigation.
If you ignore the u-turn command during navigation, the system does not insist on a 180° u-turn but suggests a forward alternative (large diversions if necessary). As a person, you can of course still turn back.
RouteYou website planner. (osrm router).
![Usefull u-turn example](https://private-user-images.githubusercontent.com/54167201/283891735-c8c8c882-0701-4660-8420-564bf7094917.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkxMjA3NjEsIm5iZiI6MTcxOTEyMDQ2MSwicGF0aCI6Ii81NDE2NzIwMS8yODM4OTE3MzUtYzhjOGM4ODItMDcwMS00NjYwLTg0MjAtNTY0YmY3MDk0OTE3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjIzVDA1Mjc0MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQ2MTlkMjQ4YWNlNGJjNzBhNjBmMjBiNzA4OWUxNmFiY2FhMWJlNzU4YzYzZThiNWYwYmEyYzMzNjFmMGUwZWImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.NdkV2MXTpz349S0u0UhLcA3q8zhonR9Uu8-ZRLkK8os)
Sure allows 180° U-turns. In addition, there is a "correct misplaced via points" tool. The correction distance at which the tool intervenes is 100m. Track glitches shorter than 100m are so automatically prevented.
Usefull u-turn navtrack.gpx.txt