(temporarily) filter out driveways too close to either end of the road.

get cars unparking from driveways properly.
This commit is contained in:
Dustin Carlino 2019-10-19 19:10:59 -07:00
parent 50728cf375
commit f78b11d633
6 changed files with 29 additions and 17 deletions

View File

@ -26,8 +26,6 @@ list.
- full PSRC day doesn't gridlock with freeform policy
- 23rd and madison traffic signal is the biggest problem, try manual traffic
signals
- sometimes crashes with queue spillover?!
- unparking from driveways has bugs
## caphill

View File

@ -28,6 +28,7 @@ pub struct OffstreetParking {
pub num_stalls: usize,
// Goes from the building to the driving lane
pub driveway_line: Line,
// Guaranteed to be at least 7m before the end of the lane
pub driving_pos: Position,
}

View File

@ -75,7 +75,6 @@ pub fn make_all_buildings(
// Make a driveway from the parking icon to the nearest road.
if let Some(ref mut p) = bldg.parking {
// TODO Is it a problem if the driveway is too close to the start/end of a lane?
let (driving_lane, driving_pt) = closest_driving
.closest_pt(bldg.label_center, Distance::meters(100.0))
.expect("Can't find driveway!");
@ -92,6 +91,13 @@ pub fn make_all_buildings(
));
}
p.driving_pos = Position::new(driving_lane, dist_along);
if lanes[driving_lane.0].length() - dist_along < Distance::meters(7.0) {
timer.warn(format!("Skipping driveway of {}, too close to the end of the road. Forfeiting {} stalls!", bldg.id, p.num_stalls));
bldg.parking = None;
} else if dist_along < Distance::meters(1.0) {
timer.warn(format!("Skipping driveway of {}, too close to the start of the road. Forfeiting {} stalls!", bldg.id, p.num_stalls));
bldg.parking = None;
}
}
results.push(bldg);

View File

@ -452,19 +452,17 @@ impl CreateCar {
}
}
// TODO Maybe inline in trips, the only caller.
pub fn for_parked_car(
parked_car: ParkedCar,
router: Router,
start_dist: Distance,
trip: TripID,
parking: &ParkingSimState,
map: &Map,
) -> CreateCar {
CreateCar {
vehicle: parked_car.vehicle.clone(),
router,
start_dist: parking
.spot_to_driving_pos(parked_car.spot, &parked_car.vehicle, map)
.dist_along(),
start_dist,
maybe_parked_car: Some(parked_car),
trip,
}

View File

@ -63,6 +63,7 @@ impl Car {
transit: &TransitSimState,
) -> DrawCarInput {
assert!(front >= Distance::ZERO);
// This goes from back to front
let raw_body = if front >= self.vehicle.length {
self.router
.head()
@ -101,9 +102,9 @@ impl Car {
let body = match self.state {
CarState::Unparking(_, ref spot, ref time_int)
| CarState::Parking(_, ref spot, ref time_int) => {
let percent_time = match self.state {
CarState::Unparking(_, _, _) => 1.0 - time_int.percent(now),
CarState::Parking(_, _, _) => time_int.percent(now),
let (percent_time, is_parking) = match self.state {
CarState::Unparking(_, _, _) => (1.0 - time_int.percent(now), false),
CarState::Parking(_, _, _) => (time_int.percent(now), true),
_ => unreachable!(),
};
match spot {
@ -124,13 +125,17 @@ impl Car {
ParkingSpot::Offstreet(b, _) => {
// Append the car's polyline on the street with the driveway
let driveway = &map.get_b(*b).parking.as_ref().unwrap().driveway_line;
let full_piece = raw_body.extend(driveway.reverse().to_polyline());
let full_piece = if is_parking {
raw_body.extend(driveway.reverse().to_polyline())
} else {
driveway.to_polyline().extend(raw_body).reversed()
};
// Then make the car creep along the added length of the driveway (which could
// be really short)
let creep_along = driveway.length() * percent_time;
// TODO Ideally the car would slowly disappear into the building, but some
// stuff downstream needs to understand that the windows and such will get cut
// off. :)
// TODO Ideally the car would slowly (dis)appear into the building, but
// some stuff downstream needs to understand that the windows and such will
// get cut off. :)
full_piece.exact_slice(creep_along, creep_along + self.vehicle.length)
}
}

View File

@ -179,7 +179,11 @@ impl TripManager {
let parked_car = parking.get_car_at_spot(spot).unwrap();
assert_eq!(parked_car.vehicle.id, car);
let start = parking.spot_to_driving_pos(parked_car.spot, &parked_car.vehicle, map);
let mut start = parking.spot_to_driving_pos(parked_car.spot, &parked_car.vehicle, map);
if let ParkingSpot::Offstreet(_, _) = spot {
// Actually, to unpark, the car's front should be where it'll wind up at the end.
start = Position::new(start.lane(), start.dist_along() + parked_car.vehicle.length);
}
let end = drive_to.goal_pos(map);
let path = if let Some(p) = map.pathfind(PathRequest {
start,
@ -202,7 +206,7 @@ impl TripManager {
scheduler.push(
now,
Command::SpawnCar(
CreateCar::for_parked_car(parked_car.clone(), router, trip.id, parking, map),
CreateCar::for_parked_car(parked_car.clone(), router, start.dist_along(), trip.id),
true,
),
);