From 04c3add1b6a4dd16c909f72825f0f903e5320cb6 Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Fri, 4 Mar 2022 14:02:26 +0000 Subject: [PATCH] Option A: filter out rat-runs using perimeter roads. #839 --- apps/ltn/src/rat_runs.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/ltn/src/rat_runs.rs b/apps/ltn/src/rat_runs.rs index d93eab8473..bc89871fa0 100644 --- a/apps/ltn/src/rat_runs.rs +++ b/apps/ltn/src/rat_runs.rs @@ -58,7 +58,7 @@ pub fn find_rat_runs(app: &App, neighborhood: &Neighborhood, timer: &mut Timer) let mut params = map.routing_params().clone(); modal_filters.update_routing_params(&mut params); - let paths: Vec = timer + let mut paths: Vec = timer .parallelize( "calculate paths between entrances and exits", requests, @@ -68,6 +68,18 @@ pub fn find_rat_runs(app: &App, neighborhood: &Neighborhood, timer: &mut Timer) .flatten() .collect(); + // Some paths dip out of the neighborhood. Even though the entrance and exit is in the same + // cell, the optimal path is to use a boundary road. Filter those out. + paths.retain(|path| { + path.get_steps().iter().all(|step| { + if let PathStep::Lane(l) = step { + neighborhood.orig_perimeter.interior.contains(&l.road) + } else { + true + } + }) + }); + // TODO Rank the likeliness of each rat run by // 1) Calculating a path between similar start/endpoints -- travelling along the perimeter, // starting and ending on a specific road that makes sense. (We have to pick the 'direction'