Work around a crash on the intersection demand panel, reproducible by

watching https://www.openstreetmap.org/node/53214134 on the weekday
scenario. At some point, an arrow polygon with an inner ring is scaled
down, collapsing its points so much that the ring becomes invalid.
This commit is contained in:
Dustin Carlino 2020-08-14 12:09:06 -07:00
parent 25ee39af89
commit bc858fdbb3
2 changed files with 11 additions and 1 deletions

View File

@ -195,7 +195,9 @@ impl GeomBatch {
return self;
}
for (_, poly) in &mut self.list {
*poly = poly.scale(factor);
// strip_rings first -- sometimes when scaling down, the original rings collapse. Since
// this polygon is part of a GeomBatch anyway, not calling to_outline on it.
*poly = poly.strip_rings().scale(factor);
}
self
}

View File

@ -307,6 +307,14 @@ impl Polygon {
}
}
// Remove the internal rings used for to_outline. This is fine to do if the polygon is being
// added to some larger piece of geometry that won't need an outline.
pub fn strip_rings(&self) -> Polygon {
let mut p = self.clone();
p.rings = None;
p
}
// Usually m^2, unless the polygon is in screen-space
pub fn area(&self) -> f64 {
// Polygon orientation messes this up sometimes