Skip to content
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

Make LTN cell calculations account for one-way roads #1043

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions apps/ltn/src/neighbourhood.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ fn floodfill(
},
);

let current_oneway_dir = current.oneway_for_driving();

for i in [current.src_i, current.dst_i] {
// It's possible for one border intersection to have two roads in the interior of the
// neighbourhood. Don't consider a turn between those roads through this intersection as
Expand All @@ -253,13 +255,34 @@ fn floodfill(
continue;
}

// TODO This seems redundant given below. Maybe only do this when we happen to start on
// a one-way?
// Don't search against the one-way direction
if (current_oneway_dir == Some(Direction::Fwd) && i == current.src_i)
|| (current_oneway_dir == Some(Direction::Back) && i == current.dst_i)
{
continue;
}

for next in &map.get_i(i).roads {
let next_road = map.get_r(*next);
if let Some(filter) = edits.intersections.get(&i) {
if !filter.allows_turn(current.id, *next) {
continue;
}
}

// TODO It might be simpler to search by intersections and start from borders?
// TODO More generally, is it possible to turn into the road this way?
if let Some(dir) = next_road.oneway_for_driving() {
if dir == Direction::Fwd && i == next_road.dst_i {
continue;
}
if dir == Direction::Back && i == next_road.src_i {
continue;
}
}

if let Some(filter) = edits.roads.get(next) {
// Which ends of the filtered road have we reached?
let mut visited_start = next_road.src_i == i;
Expand Down