diff --git a/docs/TODO_phase1.md b/docs/TODO_phase1.md index 5c5c215be6..61168f9670 100644 --- a/docs/TODO_phase1.md +++ b/docs/TODO_phase1.md @@ -5,8 +5,10 @@ - trim buidings and parcels that're nowhere near roads (aka, the bbox is kinda wrong) - road with many lanes - - make/turns can use this especially. intersections should refer to different things. - - this will clean up other_side and siblings + - make road know about children in each direction + - make intersection know about roads, not lanes + - make/turns can use this especially. intersections should refer to different things. + - clean up all state in lane - maybe also the time to split into different lane types? what's similar/not between them? diff --git a/editor/src/render/lane.rs b/editor/src/render/lane.rs index 3543a44130..45e15280bd 100644 --- a/editor/src/render/lane.rs +++ b/editor/src/render/lane.rs @@ -40,7 +40,8 @@ impl DrawLane { let mut markings: Vec = Vec::new(); if lane.use_yellow_center_lines { markings.push(Marking { - lines: lane.unshifted_pts + lines: map.get_r(lane.parent) + .center_pts .points() .windows(2) .map(|pair| [pair[0].x(), pair[0].y(), pair[1].x(), pair[1].y()]) diff --git a/map_model/src/lane.rs b/map_model/src/lane.rs index 077c75ec82..81426713ea 100644 --- a/map_model/src/lane.rs +++ b/map_model/src/lane.rs @@ -43,7 +43,6 @@ pub struct Lane { pub probably_broken: bool, // TODO i think everything else should be moved to road, honestly. - pub src_i: IntersectionID, pub dst_i: IntersectionID, @@ -59,10 +58,6 @@ pub struct Lane { pub other_side: Option, // TODO alright, we might need a Road-vs-Lanes distinction pub siblings: Vec, - - // Unshifted center points. consider computing these twice or otherwise not storing them - // Order implies road orientation. - pub unshifted_pts: PolyLine, } impl PartialEq for Lane { @@ -120,10 +115,6 @@ impl Lane { "\nlet lane_center_r{}_pts = {}", self.id.0, self.lane_center_pts ); - println!( - "\nlet unshifted_r{}_pts = {}", - self.id.0, self.unshifted_pts - ); } // TODO different types for each lane type might be reasonable diff --git a/map_model/src/map.rs b/map_model/src/map.rs index ddf272154c..9697ee1714 100644 --- a/map_model/src/map.rs +++ b/map_model/src/map.rs @@ -62,10 +62,18 @@ impl Map { let mut counter = 0; for (idx, r) in data.roads.iter().enumerate() { let road_id = RoadID(idx); + let road_center_pts = PolyLine::new( + r.points + .iter() + .map(|coord| Pt2D::from_gps(coord, &bounds)) + .collect(), + ); + m.roads.push(Road { id: road_id, osm_tags: r.osm_tags.clone(), osm_way_id: r.osm_way_id, + center_pts: road_center_pts.clone(), }); // TODO move this to make/lanes.rs too @@ -79,12 +87,7 @@ impl Map { .map(|offset| LaneID(((id.0 as isize) + offset) as usize)) .collect(); - let mut unshifted_pts = PolyLine::new( - r.points - .iter() - .map(|coord| Pt2D::from_gps(coord, &bounds)) - .collect(), - ); + let mut unshifted_pts = road_center_pts.clone(); if lane.reverse_pts { unshifted_pts = unshifted_pts.reversed(); } @@ -118,7 +121,6 @@ impl Map { use_yellow_center_lines, lane_center_pts, probably_broken, - unshifted_pts, offset: lane.offset, src_i: i1, dst_i: i2, diff --git a/map_model/src/road.rs b/map_model/src/road.rs index 8a4453ec57..2bc35f0311 100644 --- a/map_model/src/road.rs +++ b/map_model/src/road.rs @@ -1,3 +1,4 @@ +use geom::PolyLine; use std::collections::BTreeMap; use std::fmt; @@ -17,4 +18,7 @@ pub struct Road { pub id: RoadID, pub osm_tags: BTreeMap, pub osm_way_id: i64, + + // Unshifted center points. Order implies road orientation. + pub center_pts: PolyLine, }