1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use anyhow::Result;
use abstutil::Timer;
use map_model::{EditCmd, Map, MapEdits};
pub fn override_sidewalk_widths(map: &mut Map, path: String, timer: &mut Timer) -> Result<()> {
let edits = MapEdits::load_from_file(map, path, timer)?;
for cmd in &edits.commands {
if let EditCmd::ChangeRoad { r, new, .. } = cmd {
let left = &new.lanes_ltr[0];
if left.lt.is_walkable() {
map.mut_road(*r)
.osm_tags
.insert("sidewalk:left:width", left.width.inner_meters().to_string());
}
let right = new.lanes_ltr.last().unwrap();
if right.lt.is_walkable() {
map.mut_road(*r).osm_tags.insert(
"sidewalk:right:width",
right.width.inner_meters().to_string(),
);
}
}
}
map.must_apply_edits(edits, timer);
map.recalculate_pathfinding_after_edits(timer);
map.clear_edits_before_save();
Ok(())
}