mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-09-11 10:55:27 +03:00
Catch panics in booleanops. There's a reproducible case in the LTN tool.
Remove when https://github.com/georust/geo/issues/913 fixed
This commit is contained in:
parent
c162cf438e
commit
717e97ccd1
@ -269,11 +269,27 @@ impl Polygon {
|
||||
}
|
||||
|
||||
pub fn intersection(&self, other: &Self) -> Result<Vec<Self>> {
|
||||
from_multi(self.to_geo().intersection(&other.to_geo()))
|
||||
match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
|
||||
from_multi(self.to_geo().intersection(&other.to_geo()))
|
||||
})) {
|
||||
Ok(result) => result,
|
||||
Err(err) => {
|
||||
println!("BooleanOps crashed: {err:?}");
|
||||
bail!("BooleanOps crashed: {err}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn difference(&self, other: &Self) -> Result<Vec<Self>> {
|
||||
from_multi(self.to_geo().difference(&other.to_geo()))
|
||||
match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
|
||||
from_multi(self.to_geo().difference(&other.to_geo()))
|
||||
})) {
|
||||
Ok(result) => result,
|
||||
Err(err) => {
|
||||
println!("BooleanOps crashed: {err:?}");
|
||||
bail!("BooleanOps crashed: {err}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn convex_hull(list: Vec<Self>) -> Result<Self> {
|
||||
|
@ -238,7 +238,16 @@ impl Tessellation {
|
||||
pub fn difference(&self, other: &Tessellation) -> Result<Vec<Polygon>> {
|
||||
use geo::BooleanOps;
|
||||
|
||||
crate::polygon::from_multi(self.to_geo().difference(&other.to_geo()))
|
||||
// TODO Remove after https://github.com/georust/geo/issues/913
|
||||
match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
|
||||
crate::polygon::from_multi(self.to_geo().difference(&other.to_geo()))
|
||||
})) {
|
||||
Ok(result) => result,
|
||||
Err(err) => {
|
||||
println!("BooleanOps crashed: {err:?}");
|
||||
bail!("BooleanOps crashed: {err}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user