Skip to content

Commit

Permalink
Store lane_specs_ltr on RawRoad, instead of constantly recalculating. a…
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed May 1, 2022
1 parent 2c3157e commit f72dd62
Show file tree
Hide file tree
Showing 15 changed files with 1,257 additions and 1,256 deletions.
2 changes: 1 addition & 1 deletion apps/map_editor/src/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl EditRoad {
for (k, v) in road.osm_tags.inner() {
txt.add_line(Line(format!("{} = {}", k, v)).secondary());
}
if let Ok((pl, _)) = app.model.map.untrimmed_road_geometry(r) {
if let Ok((pl, _)) = road.untrimmed_road_geometry() {
txt.add_line(Line(format!("Length before trimming: {}", pl.length())));
}
if let Ok(pl) = app.model.map.trimmed_road_geometry(r) {
Expand Down
5 changes: 3 additions & 2 deletions apps/map_editor/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ impl Model {
// Roads
impl Model {
pub fn road_added(&mut self, ctx: &EventCtx, id: OriginalRoad) {
let (center, total_width) = self.map.untrimmed_road_geometry(id).unwrap();
let hitbox = center.make_polygons(total_width);
let road = &self.map.roads[&id];
let (center, total_width) = road.untrimmed_road_geometry().unwrap();
let hitbox = center.make_polygons(total_width);
let mut draw = GeomBatch::new();
draw.push(
if road.osm_tags.is("junction", "intersection") {
Expand Down Expand Up @@ -338,6 +338,7 @@ impl Model {
self.map.intersections[&i2].point,
],
osm_tags,
&self.map.config,
),
);
self.road_added(ctx, id);
Expand Down
6 changes: 4 additions & 2 deletions convert_osm/src/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ pub fn extract_osm(
way.tags.insert(osm::SIDEWALK, "right");
}

out.roads
.push((id, RawRoad::new(way.pts.clone(), way.tags.clone())));
out.roads.push((
id,
RawRoad::new(way.pts.clone(), way.tags.clone(), &opts.map_config),
));
continue;
} else if way.tags.is(osm::HIGHWAY, "service") {
// If we got here, is_road didn't interpret it as a normal road
Expand Down
5 changes: 5 additions & 0 deletions convert_osm/src/parking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ pub fn apply_parking(map: &mut RawMap, opts: &Options, timer: &mut Timer) {
} else {
r.osm_tags.insert(osm::PARKING_BOTH, "parallel");
}

r.lane_specs_ltr = raw_map::get_lane_specs_ltr(&r.osm_tags, &opts.map_config);
}
}
}
Expand Down Expand Up @@ -138,6 +140,9 @@ fn use_parking_hints(map: &mut RawMap, path: String, timer: &mut Timer) {
tags.remove(osm::PARKING_RIGHT).unwrap();
tags.insert(osm::PARKING_BOTH, value);
}

let lane_specs_ltr = raw_map::get_lane_specs_ltr(tags, &map.config);
map.roads.get_mut(&r).unwrap().lane_specs_ltr = lane_specs_ltr;
}
}
timer.stop("apply parking hints");
Expand Down
Loading

0 comments on commit f72dd62

Please sign in to comment.