dont reach into DrawRoad's polygon directly from DrawIntersection

This commit is contained in:
Dustin Carlino 2018-06-18 14:46:11 -07:00
parent 40ec99592d
commit 91920c3e1d
6 changed files with 54 additions and 10 deletions

View File

@ -45,6 +45,14 @@
- https://gis-kingcounty.opendata.arcgis.com/datasets/traffic-signs--sign-point/
- multiple lanes
- prep: get rid of other_side
- display + mouseover parking lane and sidewalk
- all roads have sidewalk on both sides, oneways only have parking lane on one side
- model bikes in driving lanes (as slow cars)
- add random bike lanes, figure out how turns would work
- be able to convert between parking and bike lanes, recompute the turns
- when rendering sidewalks, have an option for a grass buffer
## Code cleanup

View File

@ -34,3 +34,22 @@ Some modeling questions:
- maintaining directional sanity could be useful
- what's the UI for changing lane types?
- it's a bit arbitrary which lane should draw the yellow center lines
Initial design:
- "Road" becomes "Lane" with a type
- don't need to know sibling lanes yet
- arbitrarily, one lane might have extra bits/geometry for yellow center line markings
- ideally, get rid of one-wayness and original center points, and plumb along pre-shifted lines
- but due to the polyline problem (affecting both geom center line layer that agents follow, and polygons for drawing), can't do this. encapsulate the messiness at least.
- so, store one way and orig points and index, but have an accessor
- as a compromise, dont interpet OSM points on a one-way road as the center, but as the edge.
The polyline problem:
- https://www.codeproject.com/Articles/226569/Drawing-polylines-by-tessellation
- https://stackoverflow.com/questions/36475254/polylines-outline-construction-drawing-thick-polylines
- Will lengths change? Is this a problem?
- Drawing cars as rectangles is funky, because if their front is aligned to a new line segment, their back juts into the center of the road

View File

@ -29,16 +29,15 @@ impl DrawIntersection {
bounds: &Bounds,
) -> DrawIntersection {
let mut pts: Vec<Vec2d> = Vec::new();
// TODO this smashes encapsulation to bits :D
for r in &map.get_roads_to_intersection(inter.id) {
let dr = &roads[r.id.0];
pts.push(dr.polygons.last().unwrap()[2]);
pts.push(dr.polygons.last().unwrap()[3]);
let (pt1, pt2) = roads[r.id.0].get_end_crossing();
pts.push(pt1);
pts.push(pt2);
}
for r in &map.get_roads_from_intersection(inter.id) {
let dr = &roads[r.id.0];
pts.push(dr.polygons[0][0]);
pts.push(dr.polygons[0][1]);
let (pt1, pt2) = roads[r.id.0].get_start_crossing();
pts.push(pt1);
pts.push(pt2);
}
let center = geometry::gps_to_screen_space(&inter.point, bounds);

View File

@ -129,4 +129,16 @@ impl DrawRoad {
lines.extend(r.osm_tags.iter().cloned());
lines
}
// Get the line marking the end of the road, perpendicular to the direction of the road
pub(crate) fn get_end_crossing(&self) -> (Vec2d, Vec2d) {
(
self.polygons.last().unwrap()[2],
self.polygons.last().unwrap()[3],
)
}
pub(crate) fn get_start_crossing(&self) -> (Vec2d, Vec2d) {
(self.polygons[0][0], self.polygons[0][1])
}
}

View File

@ -67,7 +67,8 @@ pub fn thick_multiline(style: &ThickLine, pts: &[Pt2D]) -> Vec<Vec<Vec2d>> {
let quad2 = thick_line(style, pt2, pt3);
// Of course, the original quad
polygons.push(quad1.clone());
// Add some triangles to fill in the gaps.
// Add some triangles to fill in the gaps. Comment this out to see part of the polyline
// problem more clearly.
polygons.push(vec![
[pt2.x(), pt2.y()],
quad1[3],

View File

@ -151,11 +151,16 @@ pub struct Map {
#[derive(Debug)]
pub struct Road {
pub id: RoadID,
// The orientation is implied by the order of these points
pub points: Vec<Pt2D>,
pub osm_tags: Vec<String>,
pub osm_way_id: i64,
// Ideally all of these would just become translated center points immediately, but this is
// hard due to the polyline problem.
// The orientation is implied by the order of these points
pub points: Vec<Pt2D>,
pub other_side: Option<RoadID>,
//offset: u8,
}
impl PartialEq for Road {