make sure sidewalk corner polygons dont explode out of the original intersection polygon
@@ -123,9 +123,7 @@ fn calculate_corners(i: IntersectionID, map: &Map) -> Vec<Polygon> {
let src_line = l1.last_line().shift_left(LANE_THICKNESS / 2.0);
let dst_line = l2.first_line().shift_left(LANE_THICKNESS / 2.0);
- // TODO Could assert this is in the intersection.
- // TODO How do we handle parallel lines?
- let pt_in_intersection = src_line
+ let pt_maybe_in_intersection = src_line
.intersection_two_infinite_lines(&dst_line)
.expect("SharedSidewalkCorner between parallel sidewalks");
@@ -138,7 +136,14 @@ fn calculate_corners(i: IntersectionID, map: &Map) -> Vec<Polygon> {
{
//.expect("SharedSidewalkCorner couldn't find intersection points");
pts_between.push(src_line.pt2());
- pts_between.push(pt_in_intersection);
+ // If the intersection of the two lines isn't actually inside, then just exclude
+ // this point.
+ // TODO Argh, this is inefficient.
+ if map.get_i(i).polygon.len() >= 3
+ && Polygon::new(&map.get_i(i).polygon).contains_pt(pt_maybe_in_intersection)
+ {
+ pts_between.push(pt_maybe_in_intersection);
+ }
pts_between.push(dst_line.pt1());
corners.push(Polygon::new(&pts_between));
}
@@ -299,7 +304,7 @@ fn find_pts_between(pts: &Vec<Pt2D>, start: Pt2D, end: Pt2D) -> Option<Vec<Pt2D>
result.push(*pt);
}
// start and end might be the same.
- if pt.approx_eq(end) {
+ if !result.is_empty() && pt.approx_eq(end) {
return Some(result);
}
}
