Skip to content

Commit

Permalink
It's not a "shortcut" unless it goes through the interior.
Browse files Browse the repository at this point in the history
Originally we talked about making this more sophisticated - looking for
including in "editable_roads" but I think *regardless* of if we're
letting the user edit the perimeter, we wouldn't include trips solely
along the perimeter as shortcuts.

== Perf

This is primarily a correctness fix, but it also substantially speeds up the
calculation of shortcuts. It's still 2x slower vs. "intersection" (pre
turn restriction) routing, but 2x is a lot better than 10x!

shortcuts in bristol_east
                        time:   [2.0087 ms 2.0097 ms 2.0108 ms]
                        change: [-81.521% -81.424% -81.332%] (p = 0.00 < 0.05)
                        Performance has improved.
shortcuts in bristol_west
                        time:   [5.7247 ms 5.7953 ms 5.8633 ms]
                        change: [-77.296% -76.972% -76.653%] (p = 0.00 < 0.05)
                        Performance has improved.
shortcuts in strasbourg time:   [24.363 ms 25.531 ms 26.718 ms]
                        change: [-79.893% -78.657% -77.258%] (p = 0.00 < 0.05)
                        Performance has improved.
  • Loading branch information
michaelkirk authored and dabreegster committed Feb 13, 2025
1 parent 5661e29 commit 5f1013d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions backend/src/shortcuts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,20 @@ impl Shortcuts {
for start_i in &neighbourhood.border_intersections {
let start_intersection = map.get_i(*start_i);
for start_r in &start_intersection.roads {
// It's not a "shortcut" unless it cuts through the interior.
if !neighbourhood.interior_roads.contains(start_r) {
continue;
}
for end_i in &neighbourhood.border_intersections {
if start_i == end_i {
continue;
}
let end_intersection = map.get_i(*end_i);
for end_r in &end_intersection.roads {
// It's not a "shortcut" unless it cuts through the interior.
if !neighbourhood.interior_roads.contains(end_r) {
continue;
}
let Some(route) = router.route_from_roads(*start_r, *end_r) else {
continue;
};
Expand Down
2 changes: 1 addition & 1 deletion tests/output/bristol_east.geojson

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/output/bristol_west.geojson

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/output/strasbourg.geojson

Large diffs are not rendered by default.

0 comments on commit 5f1013d

Please sign in to comment.