mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-28 08:53:26 +03:00
making sure we only consider appropriate lane types for parking searches
This commit is contained in:
parent
fa898a9c70
commit
8d8237a40e
@ -1,4 +1,4 @@
|
||||
use crate::{LaneID, Map};
|
||||
use crate::{LaneID, LaneType, Map};
|
||||
use abstutil::Timer;
|
||||
use petgraph::graphmap::DiGraphMap;
|
||||
use std::collections::{HashSet, VecDeque};
|
||||
@ -68,11 +68,9 @@ fn bidi_flood(map: &Map, start: LaneID, largest_group: &HashSet<LaneID>) -> Opti
|
||||
queue.push_back(turn.id.src);
|
||||
}
|
||||
}
|
||||
for turn in map.get_turns_from_lane(current) {
|
||||
if map.is_turn_allowed(turn.id) {
|
||||
for turn in map.get_legal_turns(current, vec![LaneType::Driving]) {
|
||||
queue.push_back(turn.id.dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
@ -369,6 +369,15 @@ impl Map {
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn get_legal_turns(&self, from: LaneID, lane_types: Vec<LaneType>) -> Vec<&Turn> {
|
||||
let valid_types: HashSet<LaneType> = lane_types.into_iter().collect();
|
||||
self.get_next_turns_and_lanes(from, self.get_l(from).dst_i)
|
||||
.into_iter()
|
||||
.filter(|(t, l)| self.is_turn_allowed(t.id) && valid_types.contains(&l.lane_type))
|
||||
.map(|(t, _)| t)
|
||||
.collect()
|
||||
}
|
||||
|
||||
// These come back sorted
|
||||
pub fn get_next_roads(&self, from: RoadID) -> Vec<RoadID> {
|
||||
let mut roads: BTreeSet<RoadID> = BTreeSet::new();
|
||||
|
@ -263,8 +263,8 @@ fn path_to_free_parking_spot(
|
||||
current = turn.src;
|
||||
}
|
||||
}
|
||||
for turn in map.get_turns_from_lane(current) {
|
||||
if map.is_turn_allowed(turn.id) && !backrefs.contains_key(&turn.id.dst) {
|
||||
for turn in map.get_legal_turns(current, vec![LaneType::Driving]) {
|
||||
if !backrefs.contains_key(&turn.id.dst) {
|
||||
backrefs.insert(turn.id.dst, turn.id);
|
||||
queue.push_back(turn.id.dst);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user