Display for Traversable

This commit is contained in:
Dustin Carlino 2019-03-18 12:32:10 -07:00
parent 8bf8b958d7
commit c7dc028601
6 changed files with 54 additions and 5 deletions

View File

@ -190,6 +190,42 @@ so, I think the steps:
Cool, good enough to start. whew.
### Looking at this problem again
raw_map to map is expensive -- so much that we have to precompute it. For the simple edits (change lane type and modify intersection policy), can we do a cheap live update?
MAP LAYER:
- initial Road stores lane_specs, but doesnt use the lanetypes yet
- halfmap uses lane types: is_border, make_all_turns, turn lookup idx
- stop signs and traffic signals assigned last-minute, very easy to override in map layer
- pathfinder graph
SIM LAYER (ignore for now, just ban most live edits):
- parking sim needs to know about lane types
- block some edits
- cant modify turns while intersection has any requests or accepted
- cant change lane type while anybody is on it
- or if parking spot is reserved
- paths are also affected
EDITOR LAYER:
- ooh, luckily DrawLanes aren't batched! should be relatively easy.
equivalence test...
- option 1: load a map from scratch with edits, compare to making live edits, do PartialEq and meld
- option 2: always apply edits as last step of initial map loading. always reset map to canonical form before applying edits.
So how to structure things?
- dont ask for individual changes; mutate a MapEdits object and ask map, sim, editor layer to recalculate everything needed.
- lane IDs will never change; just store LaneID -> LaneType overrides.
- might have to figure out original OSM-based lanetype by recalculating
- applying map edits always takes a BEFORE (possibly empty) and AFTER set
## Notes on King County GIS datasets
- TODO: https://data-seattlecitygis.opendata.arcgis.com/datasets/channelization

View File

@ -55,6 +55,19 @@ pub enum Traversable {
Turn(TurnID),
}
impl fmt::Display for Traversable {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Traversable::Lane(id) => write!(f, "Traversable::Lane({})", id.0),
Traversable::Turn(id) => write!(
f,
"Traversable::Turn({}, {}, {})",
id.src, id.dst, id.parent
),
}
}
}
impl Traversable {
pub fn as_lane(&self) -> LaneID {
match *self {

View File

@ -17,7 +17,7 @@ pub struct TurnID {
impl fmt::Display for TurnID {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "TurnID({0}, {1}, {2})", self.parent, self.src, self.dst)
write!(f, "TurnID({}, {}, {})", self.src, self.dst, self.parent)
}
}

View File

@ -747,7 +747,7 @@ impl DrivingSimState {
pub fn tooltip_lines(&self, id: CarID) -> Option<Vec<String>> {
let car = self.cars.get(&id)?;
Some(vec![
format!("{} on {:?}", id, car.router.head()),
format!("{} on {}", id, car.router.head()),
format!("Owned by {:?}", car.vehicle.owner),
format!("{} lanes left", car.router.get_path().num_lanes()),
format!("{:?}", car.state),

View File

@ -199,7 +199,7 @@ impl State {
for req in &self.accepted {
if cycle.get_priority(req.turn) < TurnPriority::Yield {
/*println!(
"{:?} is still doing {:?} after the cycle is over",
"{:?} is still doing {} after the cycle is over",
req.agent, req.turn
);*/
return false;

View File

@ -83,7 +83,7 @@ impl Queue {
if bound < Distance::ZERO {
dump_cars(&result, cars, self.id, time);
panic!(
"Queue has spillover on {:?} at {} -- can't draw {}, bound is {}. Laggy head is {:?}",
"Queue has spillover on {} at {} -- can't draw {}, bound is {}. Laggy head is {:?}",
self.id, time, id, bound, self.laggy_head
);
}
@ -180,7 +180,7 @@ fn dump_cars(
id: Traversable,
time: Duration,
) {
println!("\nOn {:?} at {}...", id, time);
println!("\nOn {} at {}...", id, time);
for (id, dist) in dists {
let car = &cars[id];
println!("- {} @ {} (length {})", id, dist, car.vehicle.length);