make it a bit easier to jump to the time when trips are actually

starting. and prepping popdat for release
This commit is contained in:
Dustin Carlino 2019-05-26 18:22:46 -07:00
parent 40efcc7b05
commit 0e298c756f
7 changed files with 34 additions and 8 deletions

View File

@ -457,3 +457,11 @@ https://pdfs.semanticscholar.org/36d1/b4ec6a4a2823e9c875318f1952df4abf4876.pdf
- but will the better heuristic to the goal make us actually search those?
- or just use intersections between big roads as these landmarks, precompute paths between them
contraction hierarchies: https://github.com/cc-routing/routing/wiki/Contraction-Hierarchies
### OSRM notes
https://github.com/aquavit/Project-OSRM/wiki/OSRM-normalized-file-format
https://github.com/deliveroo/osrm-rs

View File

@ -21,7 +21,7 @@ impl TripsVisualizer {
let trips = ctx.loading_screen("load trip data", |_, mut timer| {
let popdat: PopDat = abstutil::read_binary("../data/shapes/popdat", &mut timer)
.expect("Couldn't load popdat");
let mut all_trips = clip_trips(&popdat, ui, 1_000, &mut timer);
let mut all_trips = clip_trips(&popdat, ui, 10_000, &mut timer);
let map = &ui.primary.map;
let routes = timer.parallelize(
"calculate paths with geometry",

View File

@ -256,7 +256,9 @@ fn instantiate_trips(ctx: &mut EventCtx, ui: &mut UI) {
let map = &ui.primary.map;
let mut rng = ui.primary.current_flags.sim_flags.make_rng();
for trip in clip_trips(&popdat, ui, 1_000, &mut timer) {
let mut min_time = Duration::parse("23:59:59.9").unwrap();
for trip in clip_trips(&popdat, ui, 10_000, &mut timer) {
ui.primary.sim.schedule_trip(
trip.depart_at,
match trip.mode {
@ -291,7 +293,9 @@ fn instantiate_trips(ctx: &mut EventCtx, ui: &mut UI) {
},
map,
);
min_time = min_time.min(trip.depart_at);
}
timer.note(format!("Expect the first trip to start at {}", min_time));
ui.primary.sim.spawn_all_trips(map, &mut timer, true);
});

View File

@ -62,6 +62,7 @@ impl SandboxMode {
(Some(Key::U), "load next sim state"),
(Some(Key::Space), "run/pause sim"),
(Some(Key::M), "step forwards 0.1s"),
(Some(Key::N), "step forwards 10 mins"),
(Some(Key::X), "reset sim"),
(Some(Key::S), "seed the sim with agents"),
// TODO Strange to always have this. Really it's a case of stacked modal?
@ -276,6 +277,13 @@ impl SandboxMode {
.sim
.step(&state.ui.primary.map, Duration::seconds(0.1));
//*ctx.recalculate_current_selection = true;
} else if mode.menu.action("step forwards 10 mins") {
state
.ui
.primary
.sim
.step(&state.ui.primary.map, Duration::minutes(10));
//*ctx.recalculate_current_selection = true;
}
EventLoopMode::InputOnly
}

View File

@ -18,6 +18,9 @@ for map in 23rd ballard caphill downtown montlake; do
cp -v data/maps/$map.abst $OUT/data/maps/
done
mkdir -p $OUT/data/shapes
cp -v data/shapes/popdat $OUT/data/shapes
mkdir $OUT/editor
cargo build --release --bin editor
cp target/release/editor $OUT/editor

View File

@ -14,6 +14,9 @@ for map in 23rd ballard caphill downtown montlake; do
cp -v data/maps/$map.abst $OUT/data/maps/
done
mkdir -p $OUT/data/shapes
cp -v data/shapes/popdat $OUT/data/shapes
mkdir $OUT/editor
cross build --release --target x86_64-pc-windows-gnu --bin editor
cp target/x86_64-pc-windows-gnu/release/editor.exe $OUT/editor

View File

@ -740,9 +740,10 @@ impl Sim {
let mut stats = SimStats::new(self.time);
for trip in self.trips.get_active_trips().into_iter() {
if let Some(agent) = self.trips.trip_to_agent(trip) {
// Active trips with an agent should have a canonical pt.
stats
.canonical_pt_per_trip
.insert(trip, self.canonical_pt_for_agent(agent, map));
.insert(trip, self.canonical_pt_for_agent(agent, map).unwrap());
}
}
@ -757,14 +758,13 @@ impl Sim {
pub fn get_canonical_pt_per_trip(&self, trip: TripID, map: &Map) -> Option<Pt2D> {
self.trips
.trip_to_agent(trip)
.map(|id| self.canonical_pt_for_agent(id, map))
.and_then(|id| self.canonical_pt_for_agent(id, map))
}
// Assumes agent does exist.
fn canonical_pt_for_agent(&self, id: AgentID, map: &Map) -> Pt2D {
fn canonical_pt_for_agent(&self, id: AgentID, map: &Map) -> Option<Pt2D> {
match id {
AgentID::Car(id) => self.get_draw_car(id, map).unwrap().body.last_pt(),
AgentID::Pedestrian(id) => self.get_draw_ped(id, map).unwrap().pos,
AgentID::Car(id) => Some(self.get_draw_car(id, map)?.body.last_pt()),
AgentID::Pedestrian(id) => Some(self.get_draw_ped(id, map)?.pos),
}
}