Skip to content

Commit

Permalink
Fix editing maps that have public transit. #372
Browse files Browse the repository at this point in the history
Back in #819, I broke things by creating the sidewalk+transit graph
before transit routes had been set up. This causes immediate crashing
when editing the 2 maps with transit (Arboretum and SF).
  • Loading branch information
dabreegster committed Feb 17, 2022
1 parent c750493 commit 0dc8972
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
12 changes: 6 additions & 6 deletions data/MANIFEST.json
Original file line number Diff line number Diff line change
Expand Up @@ -4856,19 +4856,19 @@
"compressed_size_bytes": 5791660
},
"data/system/us/san_francisco/maps/downtown.bin": {
"checksum": "795db5b07597936c2f3616164a8b23a2",
"uncompressed_size_bytes": 49950221,
"compressed_size_bytes": 19950106
"checksum": "d40e9b3669999d224d59511541e4f17c",
"uncompressed_size_bytes": 50025645,
"compressed_size_bytes": 19993123
},
"data/system/us/seattle/city.bin": {
"checksum": "5205f53fd0402a7e39bbcda758d7ef97",
"uncompressed_size_bytes": 326004,
"compressed_size_bytes": 169671
},
"data/system/us/seattle/maps/arboretum.bin": {
"checksum": "38fd5c4ddcb80f77e73406322a917b63",
"uncompressed_size_bytes": 5764659,
"compressed_size_bytes": 2239895
"checksum": "9769f87611ebb40122e6df672908073a",
"uncompressed_size_bytes": 5769223,
"compressed_size_bytes": 2241972
},
"data/system/us/seattle/maps/central_seattle.bin": {
"checksum": "e430bfe2084db852ad450f9f859cab57",
Expand Down
7 changes: 6 additions & 1 deletion map_model/src/make/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,15 @@ impl Map {
} else {
CreateEngine::CH
};
map.pathfinder = Pathfinder::new(&map, map.routing_params().clone(), engine, timer);
map.pathfinder = Pathfinder::new(&map, map.routing_params().clone(), &engine, timer);
timer.stop("setup pathfinding");

transit::finalize_transit(&mut map, &raw, timer);
timer.start("setup pathfinding for people using transit");
let mut pathfinder = std::mem::replace(&mut map.pathfinder, Pathfinder::empty());
pathfinder.finalize_transit(&map, &engine);
map.pathfinder = pathfinder;
timer.stop("setup pathfinding for people using transit");

map
}
Expand Down
19 changes: 11 additions & 8 deletions map_model/src/pathfind/pathfinder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,17 @@ impl Pathfinder {
pub fn new(
map: &Map,
params: RoutingParams,
engine: CreateEngine,
engine: &CreateEngine,
timer: &mut Timer,
) -> Pathfinder {
timer.start("prepare pathfinding for cars");
let car_graph = VehiclePathfinder::new(map, PathConstraints::Car, &params, &engine);
let car_graph = VehiclePathfinder::new(map, PathConstraints::Car, &params, engine);
timer.stop("prepare pathfinding for cars");

// The edge weights for bikes are so different from the driving graph that reusing the node
// ordering actually hurts!
timer.start("prepare pathfinding for bikes");
let bike_graph = VehiclePathfinder::new(map, PathConstraints::Bike, &params, &engine);
let bike_graph = VehiclePathfinder::new(map, PathConstraints::Bike, &params, engine);
timer.stop("prepare pathfinding for bikes");

timer.start("prepare pathfinding for buses");
Expand All @@ -116,13 +116,11 @@ impl Pathfinder {
timer.stop("prepare pathfinding for trains");

timer.start("prepare pathfinding for pedestrians");
let walking_graph = SidewalkPathfinder::new(map, None, &engine);
let walking_graph = SidewalkPathfinder::new(map, None, engine);
timer.stop("prepare pathfinding for pedestrians");

timer.start("prepare pathfinding for pedestrians using transit");
let walking_with_transit_graph =
SidewalkPathfinder::new(map, Some((&bus_graph, &train_graph)), &engine);
timer.stop("prepare pathfinding for pedestrians using transit");
// Transit routes haven't been created yet, so defer this step
let walking_with_transit_graph = SidewalkPathfinder::empty();

Pathfinder {
car_graph,
Expand Down Expand Up @@ -171,6 +169,11 @@ impl Pathfinder {
p
}

pub fn finalize_transit(&mut self, map: &Map, engine: &CreateEngine) {
self.walking_with_transit_graph =
SidewalkPathfinder::new(map, Some((&self.bus_graph, &self.train_graph)), engine);
}

/// Finds a path from a start to an end for a certain type of agent.
pub fn pathfind(&self, req: PathRequest, map: &Map) -> Option<PathV2> {
self.pathfind_with_params(req, map.routing_params(), PathfinderCaching::NoCache, map)
Expand Down

0 comments on commit 0dc8972

Please sign in to comment.