-
Notifications
You must be signed in to change notification settings - Fork 3.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
Add functionality to write turn lookups and read turn penalty files #2306
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
@routing @speed @traffic | ||
Feature: Traffic - turn penalties | ||
|
||
Background: Evenly spaced grid with multiple intersections | ||
Given the node map | ||
| | a | | b | | | ||
| c | d | e | f | g | | ||
| | h | | i | | | ||
| j | k | l | m | n | | ||
| | o | | p | | | ||
And the ways | ||
| nodes | highway | | ||
| ad | primary | | ||
| cd | primary | | ||
| de | primary | | ||
| dhk | primary | | ||
|
||
| bf | primary | | ||
| ef | primary | | ||
| fg | primary | | ||
| fim | primary | | ||
|
||
| jk | primary | | ||
| kl | primary | | ||
| ko | primary | | ||
|
||
| lm | primary | | ||
| mn | primary | | ||
| mp | primary | | ||
And the profile "car" | ||
And the extract extra arguments "--generate-edge-lookup" | ||
|
||
Scenario: Weighting not based on turn penalty file | ||
When I route I should get | ||
| from | to | route | speed | time | | ||
| a | h | ad,dhk,dhk | 63 km/h | 11.5s +-1 | | ||
# straight | ||
| i | g | fim,fg,fg | 59 km/h | 12s +-1 | | ||
# right | ||
| a | e | ad,de,de | 57 km/h | 12.5s +-1 | | ||
# left | ||
| c | g | cd,de,ef,fg,fg | 63 km/h | 23s +-1 | | ||
# double straight | ||
| p | g | mp,fim,fg,fg | 61 km/h | 23.5s +-1 | | ||
# straight-right | ||
| a | l | ad,dhk,kl,kl | 60 km/h | 24s +-1 | | ||
# straight-left | ||
| l | e | kl,dhk,de,de | 59 km/h | 24.5s +-1 | | ||
# double right | ||
| g | n | fg,fim,mn,mn | 57 km/h | 25s +-1 | | ||
# double left | ||
|
||
Scenario: Weighting based on turn penalty file | ||
Given the turn penalty file | ||
""" | ||
9,6,7,1.8 | ||
9,13,14,24.5 | ||
8,4,3,26 | ||
12,11,8,9 | ||
8,11,12,13 | ||
1,4,5,-0.2 | ||
""" | ||
And the contract extra arguments "--turn-penalty-file penalties.csv" | ||
When I route I should get | ||
| from | to | route | speed | time | | ||
| a | h | ad,dhk,dhk | 63 km/h | 11.5s +-1 | | ||
# straight | ||
| i | g | fim,fg,fg | 55 km/h | 13s +-1 | | ||
# right - ifg penalty | ||
| a | e | ad,de,de | 64 km/h | 11s +-1 | | ||
# left - faster because of negative ade penalty | ||
| c | g | cd,de,ef,fg,fg | 63 km/h | 23s +-1 | | ||
# double straight | ||
| p | g | mp,fim,fg,fg | 59 km/h | 24.5s +-1 | | ||
# straight-right - ifg penalty | ||
| a | l | ad,de,ef,fim,lm,lm | 61 km/h | 35.5s +-1 | | ||
# was straight-left - forced around by hkl penalty | ||
| l | e | lm,fim,ef,ef | 57 km/h | 25s +-1 | | ||
# double right - forced left by lkh penalty | ||
| g | n | fg,fim,mn,mn | 30 km/h | 47.5s +-1 | | ||
# double left - imn penalty | ||
| j | c | jk,kl,lm,fim,ef,de,cd,cd | 60 km/h | 48s +-1 | | ||
# double left - hdc penalty ever so slightly higher than imn; forces all the way around | ||
|
||
Scenario: Too-negative penalty clamps, but does not fail | ||
Given the contract extra arguments "--turn-penalty-file penalties.csv" | ||
And the profile "testbot" | ||
And the turn penalty file | ||
""" | ||
1,4,5,-10 | ||
""" | ||
When I route I should get | ||
| from | to | route | time | | ||
| a | d | ad,ad | 10s +-1 | | ||
| a | e | ad,de,de | 10s +-1 | | ||
| b | f | bf,bf | 10s +-1 | | ||
| b | g | bf,fg,fg | 20s +-1 | |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
@routing @speed @traffic | ||
Feature: Traffic - turn penalties applied to turn onto which a phantom node snaps | ||
|
||
Background: Simple map with phantom nodes | ||
Given the node map | ||
| | 1 | | 2 | | 3 | | | ||
| a | | b | | c | | d | | ||
| | | | | | | | | ||
| | | e | | f | | g | | ||
And the ways | ||
| nodes | highway | | ||
| ab | primary | | ||
| bc | primary | | ||
| cd | primary | | ||
|
||
| be | primary | | ||
| cf | primary | | ||
| dg | primary | | ||
And the profile "testbot" | ||
# Since testbot doesn't have turn penalties, a penalty from file of 0 should produce a neutral effect | ||
And the extract extra arguments "--generate-edge-lookup" | ||
|
||
Scenario: Weighting based on turn penalty file, with an extreme negative value -- clamps and does not fail | ||
Given the turn penalty file | ||
""" | ||
1,2,5,0 | ||
3,4,7,-20 | ||
""" | ||
And the contract extra arguments "--turn-penalty-file penalties.csv" | ||
When I route I should get | ||
| from | to | route | speed | time | | ||
| a | e | ab,be,be | 36 km/h | 40s +-1 | | ||
| 1 | e | ab,be,be | 36 km/h | 30s +-1 | | ||
| b | f | bc,cf,cf | 36 km/h | 40s +-1 | | ||
| 2 | f | bc,cf,cf | 36 km/h | 30s +-1 | | ||
| c | g | cd,dg,dg | 71 km/h | 20s +-1 | | ||
| 3 | g | cd,dg,dg | 54 km/h | 20s +-1 | |
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
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.
Why was this assertion removed? I don't see why this should be wrong unless there are negative penalties?
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.
@TheMarex yes, that's exactly the case this was removed to support.
The situation where this might arise would be where segment speeds are being calculated using GPS probe data. At an intersection where the majority of the traffic makes a turn, the average speed will be primarily that of turning traffic. However, if the intersection also allows unimpeded straight-through movements, a negative "turn" value can be used to correct traversal time for traffic that proceeds straight and unimpeded. This type of situation is reasonably common on the outskirts of urban areas across the US, example: http://www.openstreetmap.org/#map=18/38.79196/-121.35847
Really though, it would apply in any situation where an average measurement does not represent the fastest traffic through an intersection, and a "speedup" needs to be applied for some movements.