Skip to content

Commit

Permalink
Start a tool to compress Map files by removing information unnecessar…
Browse files Browse the repository at this point in the history
…y to the bike network tool. #746

Just a modest start, switching from CHs to Dijkstra's for pathfinding. Not uploading the minified result yet.
  • Loading branch information
dabreegster committed Sep 2, 2021
1 parent 1c756be commit f831681
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
15 changes: 15 additions & 0 deletions importer/src/bin/minify_map.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//! Removes nonessential parts of a Map, for the bike network tool.
use abstutil::{CmdArgs, Timer};
use map_model::Map;

fn main() {
let mut args = CmdArgs::new();
let mut timer = Timer::new("minify map");
let mut map = Map::load_synchronously(args.required_free(), &mut timer);
args.done();

map.minify(&mut timer);
// This also changes the name, so this won't overwrite anything
map.save();
}
14 changes: 14 additions & 0 deletions map_model/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -818,4 +818,18 @@ impl Map {
&& from.get_detailed_rank() < to.get_detailed_rank()
&& self.get_i(from.common_endpt(to)).is_stop_sign()
}

/// Modifies the map in-place, removing parts not essential for the bike network tool. Also
/// modifies the name.
pub fn minify(&mut self, timer: &mut Timer) {
self.name.map = format!("minified_{}", self.name.map);

// Don't need CHs
self.pathfinder = Pathfinder::new(
self,
self.routing_params().clone(),
crate::pathfind::CreateEngine::Dijkstra,
timer,
);
}
}

0 comments on commit f831681

Please sign in to comment.