mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-29 17:34:58 +03:00
fix some epsilon issues with deadends and walking turns to get entire
krakow map to import. closes #143
This commit is contained in:
parent
cac35319b2
commit
fbff30a869
@ -311,6 +311,13 @@ pub fn make_crosswalk(batch: &mut GeomBatch, turn: &Turn, map: &Map, cs: &ColorS
|
||||
let line = {
|
||||
// The middle line in the crosswalk geometry is the main crossing line.
|
||||
let pts = turn.geom.points();
|
||||
if pts.len() < 3 {
|
||||
println!(
|
||||
"Not rendering crosswalk for {}; its geometry was squished earlier",
|
||||
turn.id
|
||||
);
|
||||
return;
|
||||
}
|
||||
Line::new(pts[1], pts[2])
|
||||
};
|
||||
|
||||
|
@ -89,6 +89,12 @@ impl PolyLine {
|
||||
PolyLine { pts, length }
|
||||
}
|
||||
|
||||
// First dedupes adjacent points. If the result is only 1 point, will panic.
|
||||
pub fn deduping_new(mut pts: Vec<Pt2D>) -> PolyLine {
|
||||
pts.dedup();
|
||||
PolyLine::new(pts)
|
||||
}
|
||||
|
||||
pub fn to_thick_boundary(
|
||||
&self,
|
||||
self_width: Distance,
|
||||
|
@ -360,6 +360,7 @@ fn deadend(
|
||||
let pt2 = pl_b.reversed().safe_dist_along(len).map(|(pt, _)| pt);
|
||||
if let (Some(pt1), Some(pt2)) = (pt1, pt2) {
|
||||
let r = roads.get_mut(&id).unwrap();
|
||||
if r.trimmed_center_pts.length() >= len + 3.0 * geom::EPSILON_DIST {
|
||||
if r.src_i == i {
|
||||
r.trimmed_center_pts = r
|
||||
.trimmed_center_pts
|
||||
@ -370,11 +371,13 @@ fn deadend(
|
||||
.exact_slice(Distance::ZERO, r.trimmed_center_pts.length() - len);
|
||||
}
|
||||
|
||||
(
|
||||
return (
|
||||
close_off_polygon(vec![pt1, pt2, pl_b.last_pt(), pl_a.last_pt()]),
|
||||
Vec::new(),
|
||||
)
|
||||
} else {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
timer.warn(format!(
|
||||
"{} is a dead-end for {}, which is too short to make degenerate intersection geometry",
|
||||
i, id
|
||||
@ -384,7 +387,6 @@ fn deadend(
|
||||
Vec::new(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn close_off_polygon(mut pts: Vec<Pt2D>) -> Vec<Pt2D> {
|
||||
if pts.last().unwrap().approx_eq(pts[0], Distance::meters(0.1)) {
|
||||
|
@ -450,7 +450,7 @@ fn make_crosswalks(i: IntersectionID, l1: &Lane, l2: &Lane) -> Vec<Turn> {
|
||||
// Jut out a bit into the intersection, cross over, then jut back in. Assumes sidewalks are the
|
||||
// same width.
|
||||
let line = Line::new(l1_pt, l2_pt).shift_either_direction(direction * l1.width / 2.0);
|
||||
let geom_fwds = PolyLine::new(vec![l1_pt, line.pt1(), line.pt2(), l2_pt]);
|
||||
let geom_fwds = PolyLine::deduping_new(vec![l1_pt, line.pt1(), line.pt2(), l2_pt]);
|
||||
|
||||
vec![
|
||||
Turn {
|
||||
@ -499,25 +499,25 @@ fn make_degenerate_crosswalks(
|
||||
id: turn_id(i, l1_in.id, l1_out.id),
|
||||
turn_type: TurnType::Crosswalk,
|
||||
other_crosswalk_ids: all_ids.clone(),
|
||||
geom: PolyLine::new(vec![l1_in.last_pt(), pt1, pt2, l1_out.first_pt()]),
|
||||
geom: PolyLine::deduping_new(vec![l1_in.last_pt(), pt1, pt2, l1_out.first_pt()]),
|
||||
},
|
||||
Turn {
|
||||
id: turn_id(i, l1_out.id, l1_in.id),
|
||||
turn_type: TurnType::Crosswalk,
|
||||
other_crosswalk_ids: all_ids.clone(),
|
||||
geom: PolyLine::new(vec![l1_out.first_pt(), pt2, pt1, l1_in.last_pt()]),
|
||||
geom: PolyLine::deduping_new(vec![l1_out.first_pt(), pt2, pt1, l1_in.last_pt()]),
|
||||
},
|
||||
Turn {
|
||||
id: turn_id(i, l2_in.id, l2_out.id),
|
||||
turn_type: TurnType::Crosswalk,
|
||||
other_crosswalk_ids: all_ids.clone(),
|
||||
geom: PolyLine::new(vec![l2_in.last_pt(), pt2, pt1, l2_out.first_pt()]),
|
||||
geom: PolyLine::deduping_new(vec![l2_in.last_pt(), pt2, pt1, l2_out.first_pt()]),
|
||||
},
|
||||
Turn {
|
||||
id: turn_id(i, l2_out.id, l2_in.id),
|
||||
turn_type: TurnType::Crosswalk,
|
||||
other_crosswalk_ids: all_ids.clone(),
|
||||
geom: PolyLine::new(vec![l2_out.first_pt(), pt1, pt2, l2_in.last_pt()]),
|
||||
geom: PolyLine::deduping_new(vec![l2_out.first_pt(), pt1, pt2, l2_in.last_pt()]),
|
||||
},
|
||||
]
|
||||
.into_iter()
|
||||
|
Loading…
Reference in New Issue
Block a user