-
Notifications
You must be signed in to change notification settings - Fork 12
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
Cache roads per intersection. #93 #98
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ef623fb
WIP: Cache roads per intersection. #93
dabreegster e91e94b
Fix a bug with caching roads per intersection and clipping. Now just one
dabreegster f4b5f67
Rewrite the clipping logic entirely to manage road IDs more sanely.
dabreegster 9cb1679
Get rid of the over-complicated new_osm_node_id method; there's only …
dabreegster b16ca54
Start debugging the road sort order in the UI
dabreegster b888748
Actually sort roads, copying the approach from the intersection polygon
dabreegster 84db6c4
Fix a crash in clipping with the northgate test
dabreegster e6de03c
Accept changes in tests from #93
dabreegster 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,6 +138,7 @@ pub fn collapse_intersection(streets: &mut StreetNetwork, i: NodeID) { | |
assert_eq!(roads.len(), 2); | ||
let mut r1 = roads[0]; | ||
let mut r2 = roads[1]; | ||
assert_ne!(r1, r2); | ||
|
||
// We'll keep r1's way ID, so it's a little more convenient for debugging to guarantee r1 is | ||
// the longer piece. | ||
|
@@ -157,11 +158,11 @@ pub fn collapse_intersection(streets: &mut StreetNetwork, i: NodeID) { | |
} | ||
|
||
info!("Collapsing degenerate {}", i); | ||
streets.intersections.remove(&i).unwrap(); | ||
// We could be more careful merging percent_incline and osm_tags, but in practice, it doesn't | ||
// matter for the short segments we're merging. | ||
let mut new_road = streets.roads.remove(&r1).unwrap(); | ||
let mut road2 = streets.roads.remove(&r2).unwrap(); | ||
let mut new_road = streets.remove_road(&r1); | ||
let mut road2 = streets.remove_road(&r2); | ||
streets.intersections.remove(&i).unwrap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Order matters! |
||
|
||
// There are 4 cases, easy to understand on paper. Preserve the original direction of r1 | ||
let (new_i1, new_i2) = if r1.i2 == r2.i1 { | ||
|
@@ -195,7 +196,7 @@ pub fn collapse_intersection(streets: &mut StreetNetwork, i: NodeID) { | |
i1: new_i1, | ||
i2: new_i2, | ||
}; | ||
streets.roads.insert(new_r1, new_road); | ||
streets.insert_road(new_r1, new_road); | ||
|
||
// We may need to fix up turn restrictions. r1 and r2 both become new_r1. | ||
let rewrite = |x: &OriginalRoad| *x == r1 || *x == r2; | ||
|
@@ -242,7 +243,7 @@ pub fn trim_deadends(streets: &mut StreetNetwork) { | |
} | ||
|
||
for r in remove_roads { | ||
streets.roads.remove(&r).unwrap(); | ||
streets.remove_road(&r); | ||
} | ||
for i in remove_intersections { | ||
streets.delete_intersection(i); | ||
|
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
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
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.
Is there a good type that has an
insert_at
to take advantage of the fact that roads is already sorted?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.
Like https://doc.rust-lang.org/std/vec/struct.Vec.html#method.insert ? When we're adding a new road, we could calculate its position in the list and add it, or just recalculate the ordering for the intersection. It'll depend on the sorting algorithm
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.
Right. Performance doesn't really matter, so
Vec
works if we want to do it the "find and insert" way.