Revert "distinguish parked cars that have a trip scheduled or not"

This reverts commit dba7ced094.

Is slow, not so useful. Could implement more intelligently, but not
worthwhile yet.
This commit is contained in:
Dustin Carlino 2019-10-19 15:24:40 -07:00
parent a4b24c2643
commit f1f951fc1c
6 changed files with 20 additions and 40 deletions

View File

@ -27,6 +27,7 @@ list.
- 23rd and madison traffic signal is the biggest problem
- lots of unfinished trips, pedestrians waiting for missing buses
- sometimes crashes with queue spillover?!
- unparking from driveways has bugs
## caphill
@ -51,5 +52,4 @@ list.
- short roads: lake city, ne 115th
- 12th and ravenna seems stuck, not sure why
- running zoomed-in is super laggy
- Car with one-step route Router, crash around 6am

View File

@ -457,12 +457,7 @@ impl AgentColorScheme {
CarStatus::Debug => cs.get_def("debug car", Color::BLUE.alpha(0.8)),
CarStatus::Moving => cs.get_def("moving car", Color::CYAN),
CarStatus::Stuck => cs.get_def("stuck car", Color::rgb(222, 184, 135)),
CarStatus::ParkedWithoutTrip => {
cs.get_def("parked car without trip", Color::rgb(200, 233, 176))
}
CarStatus::ParkedWithTrip => {
cs.get_def("parked car with trip", Color::rgb(180, 233, 76))
}
CarStatus::Parked => cs.get_def("parked car", Color::rgb(180, 233, 76)),
}
}
}
@ -477,7 +472,7 @@ impl AgentColorScheme {
// TODO Hard to see on the greenish bike lanes? :P
CarStatus::Moving => cs.get_def("moving bike", Color::GREEN),
CarStatus::Stuck => cs.get_def("stuck bike", Color::RED),
CarStatus::ParkedWithoutTrip | CarStatus::ParkedWithTrip => unreachable!(),
CarStatus::Parked => unreachable!(),
},
_ => self.by_metadata(&input.metadata),
}

View File

@ -154,10 +154,10 @@ impl Car {
CarState::WaitingToAdvance => CarStatus::Stuck,
CarState::Crossing(_, _) => CarStatus::Moving,
// Eh they're technically moving, but this is a bit easier to spot
CarState::Unparking(_, _, _) => CarStatus::ParkedWithTrip,
CarState::Parking(_, _, _) => CarStatus::ParkedWithTrip,
CarState::Unparking(_, _, _) => CarStatus::Parked,
CarState::Parking(_, _, _) => CarStatus::Parked,
// Changing color for idling buses is helpful
CarState::Idling(_, _) => CarStatus::ParkedWithTrip,
CarState::Idling(_, _) => CarStatus::Parked,
},
on: self.router.head(),
label: if self.vehicle.vehicle_type == VehicleType::Bus {

View File

@ -1,6 +1,4 @@
use crate::{
AgentMetadata, CarID, CarStatus, DrawCarInput, ParkedCar, ParkingSpot, TripManager, Vehicle,
};
use crate::{AgentMetadata, CarID, CarStatus, DrawCarInput, ParkedCar, ParkingSpot, Vehicle};
use abstutil::{
deserialize_btreemap, deserialize_multimap, serialize_btreemap, serialize_multimap, MultiMap,
};
@ -144,37 +142,27 @@ impl ParkingSimState {
self.dynamically_reserved_cars.remove(&p.vehicle.id);
}
pub fn get_draw_cars(&self, id: LaneID, map: &Map, trips: &TripManager) -> Vec<DrawCarInput> {
pub fn get_draw_cars(&self, id: LaneID, map: &Map) -> Vec<DrawCarInput> {
let mut cars = Vec::new();
if let Some(ref lane) = self.onstreet_lanes.get(&id) {
for spot in lane.spots() {
if let Some(car) = self.occupants.get(&spot) {
cars.push(self.get_draw_car(*car, map, trips).unwrap());
cars.push(self.get_draw_car(*car, map).unwrap());
}
}
}
cars
}
pub fn get_draw_car(&self, id: CarID, map: &Map, trips: &TripManager) -> Option<DrawCarInput> {
pub fn get_draw_car(&self, id: CarID, map: &Map) -> Option<DrawCarInput> {
let p = self.parked_cars.get(&id)?;
match p.spot {
ParkingSpot::Onstreet(lane, idx) => {
let front_dist = self.onstreet_lanes[&lane].dist_along_for_car(idx, &p.vehicle);
// TODO Is this expensive to do constantly?
let status = if let Some(b) = p.vehicle.owner {
if trips.find_trip_using_car(id, b).is_some() {
CarStatus::ParkedWithTrip
} else {
CarStatus::ParkedWithoutTrip
}
} else {
CarStatus::ParkedWithoutTrip
};
Some(DrawCarInput {
id: p.vehicle.id,
waiting_for_turn: None,
status,
status: CarStatus::Parked,
on: Traversable::Lane(lane),
label: None,
metadata: AgentMetadata {
@ -194,20 +182,18 @@ impl ParkingSimState {
}
// There's no DrawCarInput for cars parked offstreet, so we need this.
pub fn canonical_pt(&self, id: CarID, map: &Map, trips: &TripManager) -> Option<Pt2D> {
pub fn canonical_pt(&self, id: CarID, map: &Map) -> Option<Pt2D> {
let p = self.parked_cars.get(&id)?;
match p.spot {
ParkingSpot::Onstreet(_, _) => {
self.get_draw_car(id, map, trips).map(|c| c.body.last_pt())
}
ParkingSpot::Onstreet(_, _) => self.get_draw_car(id, map).map(|c| c.body.last_pt()),
ParkingSpot::Offstreet(b, _) => Some(map.get_b(b).label_center),
}
}
pub fn get_all_draw_cars(&self, map: &Map, trips: &TripManager) -> Vec<DrawCarInput> {
pub fn get_all_draw_cars(&self, map: &Map) -> Vec<DrawCarInput> {
self.parked_cars
.keys()
.filter_map(|id| self.get_draw_car(*id, map, trips))
.filter_map(|id| self.get_draw_car(*id, map))
.collect()
}

View File

@ -46,8 +46,7 @@ pub struct DrawCarInput {
pub enum CarStatus {
Moving,
Stuck,
ParkedWithoutTrip,
ParkedWithTrip,
Parked,
Debug,
}

View File

@ -288,7 +288,7 @@ impl GetDrawAgents for Sim {
}
fn get_draw_car(&self, id: CarID, map: &Map) -> Option<DrawCarInput> {
self.parking.get_draw_car(id, map, &self.trips).or_else(|| {
self.parking.get_draw_car(id, map).or_else(|| {
self.driving
.get_single_draw_car(id, self.time, map, &self.transit)
})
@ -301,7 +301,7 @@ impl GetDrawAgents for Sim {
fn get_draw_cars(&self, on: Traversable, map: &Map) -> Vec<DrawCarInput> {
if let Traversable::Lane(l) = on {
if map.get_l(l).is_parking() {
return self.parking.get_draw_cars(l, map, &self.trips);
return self.parking.get_draw_cars(l, map);
}
}
self.driving
@ -320,7 +320,7 @@ impl GetDrawAgents for Sim {
let mut result = self
.driving
.get_all_draw_cars(self.time, map, &self.transit);
result.extend(self.parking.get_all_draw_cars(map, &self.trips));
result.extend(self.parking.get_all_draw_cars(map));
result
}
@ -889,7 +889,7 @@ impl Sim {
match id {
AgentID::Car(id) => self
.parking
.canonical_pt(id, map, &self.trips)
.canonical_pt(id, map)
.or_else(|| Some(self.get_draw_car(id, map)?.body.last_pt())),
AgentID::Pedestrian(id) => Some(self.get_draw_ped(id, map)?.pos),
}