mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-29 01:13:53 +03:00
the parking redirects dont have to be before the lane... they can also be after. just nearby is the goal. this fixes a few more aborted trips
This commit is contained in:
parent
b644f1d86d
commit
17136509cf
@ -1,4 +1,4 @@
|
||||
use crate::{IntersectionType, LaneID, Map};
|
||||
use crate::{LaneID, Map};
|
||||
use abstutil::Timer;
|
||||
use petgraph::graphmap::DiGraphMap;
|
||||
use std::collections::{HashSet, VecDeque};
|
||||
@ -30,17 +30,16 @@ pub fn redirect_parking_blackholes(map: &Map, timer: &mut Timer) -> Vec<(LaneID,
|
||||
continue;
|
||||
}
|
||||
|
||||
// Search backwards for the nearest driving lane belonging to largest_group.
|
||||
if let Some(redirect) = reverse_flood(map, l.id, &largest_group) {
|
||||
// Search forwards and backwards for the nearest driving lane belonging to largest_group.
|
||||
if let Some(redirect) = bidi_flood(map, l.id, &largest_group) {
|
||||
redirects.push((l.id, redirect));
|
||||
} else {
|
||||
// If the lane starts at a border, totally expected to have no possible redirect.
|
||||
if map.get_i(l.src_i).intersection_type != IntersectionType::Border {
|
||||
timer.warn(format!(
|
||||
"{} is a parking blackhole with no reasonable redirect!",
|
||||
l.id
|
||||
));
|
||||
}
|
||||
// TODO Make this an error after dealing with places like Austin without much parking
|
||||
// in the first place.
|
||||
timer.warn(format!(
|
||||
"{} is a parking blackhole with no reasonable redirect!",
|
||||
l.id
|
||||
));
|
||||
}
|
||||
}
|
||||
timer.note(format!(
|
||||
@ -50,7 +49,7 @@ pub fn redirect_parking_blackholes(map: &Map, timer: &mut Timer) -> Vec<(LaneID,
|
||||
redirects
|
||||
}
|
||||
|
||||
fn reverse_flood(map: &Map, start: LaneID, largest_group: &HashSet<LaneID>) -> Option<LaneID> {
|
||||
fn bidi_flood(map: &Map, start: LaneID, largest_group: &HashSet<LaneID>) -> Option<LaneID> {
|
||||
let mut queue = VecDeque::new();
|
||||
queue.push_back(start);
|
||||
let mut visisted = HashSet::new();
|
||||
@ -69,6 +68,11 @@ fn reverse_flood(map: &Map, start: LaneID, largest_group: &HashSet<LaneID>) -> O
|
||||
queue.push_back(turn.id.src);
|
||||
}
|
||||
}
|
||||
for turn in map.get_turns_from_lane(current) {
|
||||
if map.is_turn_allowed(turn.id) {
|
||||
queue.push_back(turn.id.dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
@ -150,8 +150,8 @@ impl TripManager {
|
||||
p
|
||||
} else {
|
||||
println!(
|
||||
"Aborting a trip because no path for the car portion! {:?} to {:?}",
|
||||
start, end
|
||||
"Aborting {} at {} because no path for the car portion! {:?} to {:?}",
|
||||
trip.id, now, start, end
|
||||
);
|
||||
self.unfinished_trips -= 1;
|
||||
trip.aborted = true;
|
||||
@ -202,8 +202,8 @@ impl TripManager {
|
||||
p
|
||||
} else {
|
||||
println!(
|
||||
"Aborting a trip because no path for the bike portion! {:?} to {:?}",
|
||||
driving_pos, end
|
||||
"Aborting {} at {} because no path for the bike portion! {:?} to {:?}",
|
||||
trip.id, now, driving_pos, end
|
||||
);
|
||||
self.unfinished_trips -= 1;
|
||||
trip.aborted = true;
|
||||
@ -351,8 +351,8 @@ impl TripManager {
|
||||
_ => {
|
||||
// TODO Should be unreachable
|
||||
println!(
|
||||
"At {}: Aborting trip {}, because {} couldn't find parking and got stuck",
|
||||
now, trip.id, car
|
||||
"Aborting {} at {} because {} couldn't find parking and got stuck",
|
||||
trip.id, now, car
|
||||
);
|
||||
self.unfinished_trips -= 1;
|
||||
trip.aborted = true;
|
||||
@ -503,8 +503,8 @@ impl Trip {
|
||||
p
|
||||
} else {
|
||||
println!(
|
||||
"Aborting a trip because no path for the walking portion! {:?} to {:?}",
|
||||
start, walk_to
|
||||
"Aborting {} at {} because no path for the walking portion! {:?} to {:?}",
|
||||
self.id, now, start, walk_to
|
||||
);
|
||||
return false;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user