workaround for awful intersection geometry causing get_outline's that

explode out to some corner and get constantly rendered
This commit is contained in:
Dustin Carlino 2019-05-16 18:04:14 -07:00
parent db04553626
commit ec015624c0
4 changed files with 69 additions and 74 deletions

View File

@ -1,42 +1,21 @@
75b7f158d24cb3d61e36dd0e25fb08c6 ../data/screenshots/pending_montlake/01x01_i85.png 30974091f1f479bde2ef38ca8c531191 ../data/screenshots/pending_montlake/01x01_i64.png
80e5ccac8b7a30e7c8e0251d117e98ae ../data/screenshots/pending_montlake/02x01_i64.png 768309d7f9d0fe147b398de3208ad1f4 ../data/screenshots/pending_montlake/02x01_i6.png
5a38a69e4d66ec283d414a4135ae10d1 ../data/screenshots/pending_montlake/03x01_i6.png f58cf3be474c543cf7945450a533d83d ../data/screenshots/pending_montlake/03x01_i4.png
5efa5b5e1b81d312ad2e75535bda4ecf ../data/screenshots/pending_montlake/04x01_i4.png 8bb7bd8d7ea828c505714b8f54215d86 ../data/screenshots/pending_montlake/01x02_i14.png
5c87d111e9afdec0d19ffd452b4fbd34 ../data/screenshots/pending_montlake/05x01_i208.png 579d9169e621b7ced54940b65e2ee965 ../data/screenshots/pending_montlake/02x02_i144.png
6575e92717461fa83a30d81e87914ae2 ../data/screenshots/pending_montlake/06x01_i193.png 7e485afed06f85c8502c867183a19128 ../data/screenshots/pending_montlake/03x02_i44.png
878ae97141bbb14bd347ce5a4982d97c ../data/screenshots/pending_montlake/01x02_i15.png 8c103049009019892e547fc2fec8c3c4 ../data/screenshots/pending_montlake/01x03_i111.png
87aef48c87031454c69cb3be930b3ebd ../data/screenshots/pending_montlake/02x02_i49.png dde24d03a4b3a0c051d0721d720eb8c8 ../data/screenshots/pending_montlake/02x03_i10.png
6c537f7c3e8677edc1c3fc5f2040926a ../data/screenshots/pending_montlake/03x02_i233.png e81077ba2615f9183b605662044f9ad6 ../data/screenshots/pending_montlake/03x03_i21.png
4ef4c6cd26790798de945d81028bfab5 ../data/screenshots/pending_montlake/04x02_i44.png 4120636dff151a87c11f2c13a8cc6a68 ../data/screenshots/pending_montlake/01x04_i8.png
1e19e6bd832184fbeb5f197f96593836 ../data/screenshots/pending_montlake/05x02_i13.png fb176e55ed4aff96cae3e6eacbe962b1 ../data/screenshots/pending_montlake/02x04_i0.png
d36de1650d145bf8e848df92ab3602b7 ../data/screenshots/pending_montlake/06x02_i48.png 47a908fb01793372e519aebf3ce1331c ../data/screenshots/pending_montlake/03x04_i20.png
d4acb3a16f7a2d173cbc733eab9eb0ca ../data/screenshots/pending_montlake/01x03_i111.png 56ab5c97e826fcda2d61f01ef9098316 ../data/screenshots/pending_montlake/01x05_i54.png
73521ae565b4437bd279b404fcbcce59 ../data/screenshots/pending_montlake/02x03_i80.png 353fa3e6a5147fc43fbd9df77341e48b ../data/screenshots/pending_montlake/02x05_i52.png
85f73456bb625660ae9be1280e991e6e ../data/screenshots/pending_montlake/03x03_i10.png 2b3d9b662d554264e26fb2a65b852cb6 ../data/screenshots/pending_montlake/03x05_i30.png
ac7baf5f8d8ba43beac331dabce43b05 ../data/screenshots/pending_montlake/04x03_i11.png 9806e3f0e42cd50f2499412ece773472 ../data/screenshots/pending_montlake/01x06_i18.png
4abc70f06782a0a4135436ec83932b40 ../data/screenshots/pending_montlake/05x03_i218.png 90266304da3f2926fa4a6965aeeffa4b ../data/screenshots/pending_montlake/02x06_i16.png
651708525fcb99e14cbd7722aff3df62 ../data/screenshots/pending_montlake/06x03_i21.png d6572135349481048d7455fe094b5e72 ../data/screenshots/pending_montlake/03x06_i1.png
d814831a4f725877f71869d9be0e3723 ../data/screenshots/pending_montlake/01x04_i22.png b89d68bc6b945609b7ea166e14f61670 ../data/screenshots/pending_montlake/01x07_i121.png
93e8d9cb1d10a223fe82036177e4d98a ../data/screenshots/pending_montlake/02x04_i8.png 74de0ca9fb695c6230e91c50795a8ed5 ../data/screenshots/pending_montlake/02x07_i28.png
42584d685bb8de3dc6eb88f0d3d04818 ../data/screenshots/pending_montlake/03x04_i0.png 5767e34c7299f799bf4da9cc6c1cb805 ../data/screenshots/pending_montlake/03x07_i25.png
92810426ed765ff73c3419631bf6812c ../data/screenshots/pending_montlake/04x04_i99.png
cc5aeeca165ebe2b5e235d55c8b220f1 ../data/screenshots/pending_montlake/05x04_i35.png
926f8d686c110aaec2798a3daf2045eb ../data/screenshots/pending_montlake/06x04_i20.png
853ac5ee9033fd5385a0fa6d41a4be3d ../data/screenshots/pending_montlake/01x05_i54.png
395e8b3860a545086a334c39b3e0fe4e ../data/screenshots/pending_montlake/02x05_i8.png
5026ceb7c440d698197da4c530651e4b ../data/screenshots/pending_montlake/03x05_i115.png
c35ce1868ac710113898f908096dc44c ../data/screenshots/pending_montlake/04x05_i56.png
2523529762f8e2ee403378d9c0873c1e ../data/screenshots/pending_montlake/05x05_i30.png
ccae56fb001cbb74a155f27c965f3fae ../data/screenshots/pending_montlake/06x05.png
81e66a7b84b3229fcf9b2d53f99313ee ../data/screenshots/pending_montlake/01x06_i18.png
f43b63d7a2c101e5fcc1192fdb61128a ../data/screenshots/pending_montlake/02x06_i82.png
d7d8de99b46b804855bcfca292411ed3 ../data/screenshots/pending_montlake/03x06_i16.png
6d662acde92ceb2ad731b464e999462a ../data/screenshots/pending_montlake/04x06_i33.png
486223fba22d766980b065eb19e90b06 ../data/screenshots/pending_montlake/05x06_i1.png
5773308a76bf8d165eec07ccbc30a41e ../data/screenshots/pending_montlake/06x06_i146.png
ab87926fd932469cefc3dc9e9b413c8d ../data/screenshots/pending_montlake/01x07_i121.png
2fa844b8cbbdf84b71fbfb28933aadd6 ../data/screenshots/pending_montlake/02x07_i288.png
f82cfa63ece790bf8d1f26bd5dd8caf0 ../data/screenshots/pending_montlake/03x07_i28.png
82e6af8c89fb95dd6a2db293fac2805e ../data/screenshots/pending_montlake/04x07_i24.png
ebe75953002a2370ff4a67c8161c28ea ../data/screenshots/pending_montlake/05x07_i25.png
bf5befd60f7509faabea570ac76a8d01 ../data/screenshots/pending_montlake/06x07_i109.png

View File

@ -1,7 +1,8 @@
#!/bin/bash #!/bin/bash
before=$1; name=$1;
after=$2; before=../data/screenshots/pending_$name;
after=../data/screenshots/$name;
rm -rf diff rm -rf diff
mkdir diff mkdir diff
@ -14,12 +15,10 @@ for file in `ls $before | grep -v full.png | grep -v combine.sh | grep -v MANIFE
diff $before/${prefix}* $after/${prefix}*; diff $before/${prefix}* $after/${prefix}*;
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
compare $before/${prefix}* $after/${prefix}* diff/${prefix}.png; compare $before/${prefix}* $after/${prefix}* diff/${prefix}.png;
if [ "$3" == "-i" ]; then feh diff/${prefix}.png $before/${prefix}* $after/${prefix}*;
feh diff/${prefix}.png $before/${prefix}* $after/${prefix}*; # Handle interrupts by killing the script entirely
# Handle interrupts by killing the script entirely if [ $? -ne 0 ]; then
if [ $? -ne 0 ]; then exit;
exit;
fi
fi fi
fi fi
done done

View File

@ -11,7 +11,6 @@ use ordered_float::NotNan;
pub struct DrawIntersection { pub struct DrawIntersection {
pub id: IntersectionID, pub id: IntersectionID,
pub polygon: Polygon,
pub crosswalks: Vec<DrawCrosswalk>, pub crosswalks: Vec<DrawCrosswalk>,
intersection_type: IntersectionType, intersection_type: IntersectionType,
zorder: isize, zorder: isize,
@ -67,7 +66,6 @@ impl DrawIntersection {
DrawIntersection { DrawIntersection {
id: i.id, id: i.id,
polygon: i.polygon.clone(),
crosswalks: calculate_crosswalks(i.id, map, prerender, cs), crosswalks: calculate_crosswalks(i.id, map, prerender, cs),
intersection_type: i.intersection_type, intersection_type: i.intersection_type,
zorder: i.get_zorder(map), zorder: i.get_zorder(map),
@ -92,7 +90,7 @@ impl Renderable for DrawIntersection {
fn draw(&self, g: &mut GfxCtx, opts: &DrawOptions, ctx: &DrawCtx) { fn draw(&self, g: &mut GfxCtx, opts: &DrawOptions, ctx: &DrawCtx) {
if let Some(color) = opts.color(self.get_id()) { if let Some(color) = opts.color(self.get_id()) {
// Don't draw the sidewalk corners // Don't draw the sidewalk corners
g.draw_polygon(color, &self.polygon); g.draw_polygon(color, &ctx.map.get_i(self.id).polygon);
} else { } else {
g.redraw(&self.draw_default); g.redraw(&self.draw_default);
@ -108,12 +106,15 @@ impl Renderable for DrawIntersection {
} }
} }
fn get_outline(&self, _: &Map) -> Polygon { fn get_outline(&self, map: &Map) -> Polygon {
PolyLine::make_polygons_for_boundary(self.polygon.points().clone(), OUTLINE_THICKNESS) PolyLine::make_polygons_for_boundary(
map.get_i(self.id).polygon.points().clone(),
OUTLINE_THICKNESS,
)
} }
fn contains_pt(&self, pt: Pt2D, _: &Map) -> bool { fn contains_pt(&self, pt: Pt2D, map: &Map) -> bool {
self.polygon.contains_pt(pt) map.get_i(self.id).polygon.contains_pt(pt)
} }
fn get_zorder(&self) -> isize { fn get_zorder(&self) -> isize {

View File

@ -61,22 +61,11 @@ pub fn intersection_polygon(
l.pt1().angle_to(intersection_center).normalized_degrees() as i64 l.pt1().angle_to(intersection_center).normalized_degrees() as i64
}); });
let mut endpoints = if lines.len() == 1 { if lines.len() == 1 {
deadend(roads, i.id, &lines).get(timer) deadend(roads, i.id, &lines).get(timer)
} else { } else {
generalized_trim_back(roads, i.id, &lines, timer) generalized_trim_back(roads, i.id, &lines, timer)
};
// Close off the polygon
if endpoints
.last()
.unwrap()
.approx_eq(endpoints[0], Distance::meters(0.1))
{
endpoints.pop();
} }
endpoints.push(endpoints[0]);
endpoints
} }
fn generalized_trim_back( fn generalized_trim_back(
@ -284,8 +273,27 @@ fn generalized_trim_back(
timer.warn(format!("Excluding collision between original polylines of {} and something, because stuff's too short", id)); timer.warn(format!("Excluding collision between original polylines of {} and something, because stuff's too short", id));
} }
} }
// TODO Caller will close off the polygon. Does that affect our dedupe? let main_result = close_off_polygon(Pt2D::approx_dedupe(endpoints, Distance::meters(0.1)));
Pt2D::approx_dedupe(endpoints, Distance::meters(0.1))
// There are bad polygons caused by weird short roads. As a temporary workaround, detect cases
// where polygons dramatically double back on themselves and force the polygon to proceed
// around its center.
let mut deduped = main_result.clone();
deduped.pop();
deduped.sort_by_key(|pt| HashablePt2D::from(*pt));
deduped = Pt2D::approx_dedupe(deduped, Distance::meters(0.1));
let center = Pt2D::center(&deduped);
deduped.sort_by_key(|pt| pt.angle_to(center).normalized_degrees() as i64);
deduped = close_off_polygon(deduped);
if main_result.len() == deduped.len() {
main_result
} else {
timer.warn(format!(
"{}'s polygon has weird repeats, forcibly removing points",
i
));
deduped
}
} }
fn deadend( fn deadend(
@ -316,15 +324,15 @@ fn deadend(
); );
} }
Warn::ok(vec![ Warn::ok(close_off_polygon(vec![
pt1.unwrap(), pt1.unwrap(),
pt2.unwrap(), pt2.unwrap(),
pl_b.last_pt(), pl_b.last_pt(),
pl_a.last_pt(), pl_a.last_pt(),
]) ]))
} else { } else {
Warn::warn( Warn::warn(
vec![pl_a.last_pt(), pl_b.last_pt()], vec![pl_a.last_pt(), pl_b.last_pt(), pl_a.last_pt()],
format!( format!(
"{} is a dead-end for {}, which is too short to make degenerate intersection geometry", "{} is a dead-end for {}, which is too short to make degenerate intersection geometry",
i, id i, id
@ -332,3 +340,11 @@ fn deadend(
) )
} }
} }
fn close_off_polygon(mut pts: Vec<Pt2D>) -> Vec<Pt2D> {
if pts.last().unwrap().approx_eq(pts[0], Distance::meters(0.1)) {
pts.pop();
}
pts.push(pts[0]);
pts
}