Skip to content

Commit 52f6bf7

Browse files
committed
Fix routes incorrectly ending on a road with a modal filter
1 parent 00fb50b commit 52f6bf7

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

backend/src/map_model.rs

+3
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ impl Intersection {
158158
if to_road.id == from_road.id {
159159
return None;
160160
}
161+
if router_input.has_modal_filter(to_road.id) {
162+
return None;
163+
}
161164
if router_input
162165
.turn_restrictions(self.id)
163166
.contains(&(from_r, to_road.id))

backend/src/route.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ impl Route {
210210
#[cfg(test)]
211211
mod tests {
212212
use super::*;
213-
use crate::osm_tests::load_osm_xml;
213+
use crate::{osm_tests::load_osm_xml, FilterKind};
214214

215215
fn r(road_id: usize) -> RoadID {
216216
RoadID(road_id)
@@ -233,12 +233,24 @@ mod tests {
233233
// |
234234
// i0
235235
// ```
236-
let map = load_osm_xml("simple_four_way_intersection");
236+
let mut map = load_osm_xml("simple_four_way_intersection");
237237
let Route { steps } = map.router_before.route_from_roads(r(3), r(2)).unwrap();
238238
assert_eq!(
239239
steps,
240240
vec![(r(3), Direction::Backwards), (r(2), Direction::Backwards)]
241241
);
242+
243+
// Filter r2
244+
map.add_modal_filter(
245+
map.get_r(r(2)).linestring.0[0],
246+
Some(vec![r(2)]),
247+
FilterKind::NoEntry,
248+
);
249+
map.rebuild_router(1.0);
250+
let router_after = map.router_after.as_ref().unwrap();
251+
// A route starting or ending there should fail
252+
assert!(router_after.route_from_roads(r(2), r(3)).is_none());
253+
assert!(router_after.route_from_roads(r(3), r(2)).is_none());
242254
}
243255

244256
#[test]

0 commit comments

Comments
 (0)