make some more pedestrian paths possible by forcing turns even when line trimming fails

This commit is contained in:
Dustin Carlino 2018-07-23 08:39:58 -07:00
parent 14eac3c486
commit a52b966b03
3 changed files with 17 additions and 3 deletions

View File

@ -28,8 +28,6 @@
## pedestrians
- why so many impossible paths? r350 to r41
- UI: draw cars and peds in intersections, even at lower zoom levels, just like on roads
- make them obey intersections (deterministically!)
- make them start and end at buildings

View File

@ -180,6 +180,20 @@ impl PolyLine {
.map(|pts| pts.iter().map(|pt| pt.to_vec()).collect())
.collect()
}
pub fn intersects(&self, other: &PolyLine) -> bool {
// Quadratic
for pair1 in self.pts.windows(2) {
let l1 = Line::new(pair1[0], pair1[1]);
for pair2 in other.pts.windows(2) {
let l2 = Line::new(pair2[0], pair2[1]);
if l1.intersects(&l2) {
return true;
}
}
}
false
}
}
impl fmt::Display for PolyLine {

View File

@ -99,7 +99,9 @@ pub(crate) fn make_crosswalks(i: &Intersection, m: &Map, mut turn_id_start: usiz
}
let dst_pt = dst.endpoint(i.id);
if src_pt != dst_pt {
// TODO Just the first check ideally, but until line trimming handles polylines, we
// should also do the second check.
if src_pt != dst_pt && !src.lane_center_pts.intersects(&dst.lane_center_pts) {
continue;
}