eliminate bus stops that dont line up with short driving lanes

This commit is contained in:
Dustin Carlino 2018-10-24 14:54:07 -07:00
parent 86d578f4f8
commit 45bd7ee128
2 changed files with 15 additions and 2 deletions

View File

@ -36,8 +36,19 @@ pub fn make_bus_stops(
for (id, dists) in stops_per_sidewalk.iter_all_mut() {
let road = &roads[lanes[id.0].parent.0];
if let Ok(driving_lane) = road.find_driving_lane_from_sidewalk(*id) {
let driving_len = lanes[driving_lane.0].length();
dists.sort_by_key(|(dist, _)| NotNaN::new(dist.value_unsafe).unwrap());
for (idx, (dist_along, orig_pt)) in dists.iter().enumerate() {
// TODO Should project perpendicular line to find equivalent dist_along for
// different lanes. Till then, just skip this.
if *dist_along > driving_len {
warn!(
"Skipping bus stop at {} along {}, because driving lane {} is only {} long",
dist_along, id, driving_lane, driving_len
);
continue;
}
let stop_id = BusStopID { sidewalk: *id, idx };
point_to_stop_id.insert(*orig_pt, stop_id);
lanes[id.0].bus_stops.push(stop_id);

View File

@ -127,8 +127,8 @@ impl Car {
loop {
if self.debug {
debug!(
" -- {} looking ahead to {:?} with {} left to scan",
self.id, current_on, dist_to_lookahead
" -- At {}, {} looking ahead to {:?} with {} left to scan",
time, self.id, current_on, dist_to_lookahead
);
}
@ -704,6 +704,8 @@ impl DrivingSimState {
params: CreateCar,
) -> bool {
{
// TODO Should filter out this parking spot to begin with, or even better, match up
// dist_along between different lanes using perpendicular lines.
let start_length = map.get_l(params.start).length();
if params.dist_along > start_length {
panic!("Can't start car at {} along {}; it's only {}. Parking lane or sidewalk (with bus stop) must be much longer.", params.dist_along, params.start, start_length);