Start a tool to compress Map files by removing information unnecessary to the bike network tool. #746

Just a modest start, switching from CHs to Dijkstra's for pathfinding. Not uploading the minified result yet.
This commit is contained in:
Dustin Carlino 2021-09-01 19:02:42 -07:00
parent 1c756befa8
commit f83168184d
2 changed files with 29 additions and 0 deletions

View File

@ -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();
}

View File

@ -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,
);
}
}