diff --git a/geo/CHANGES.md b/geo/CHANGES.md index 4b7c7895d..2b958d6ad 100644 --- a/geo/CHANGES.md +++ b/geo/CHANGES.md @@ -121,6 +121,8 @@ * * Point in `Triangle` and `Rect` performance improvemnets * +* Fix crashes in `BooleanOps` + * ## 0.27.0 diff --git a/geo/src/algorithm/bool_ops/i_overlay_integration.rs b/geo/src/algorithm/bool_ops/i_overlay_integration.rs index fcf3a0a1b..632a3472f 100644 --- a/geo/src/algorithm/bool_ops/i_overlay_integration.rs +++ b/geo/src/algorithm/bool_ops/i_overlay_integration.rs @@ -11,6 +11,7 @@ pub trait BoolOpsCoord: Copy { fn y(&self) -> T; } +/// A geometry coordinate number suitable for performing geometric boolean operations. pub trait BoolOpsNum: GeoNum { type CoordType: BoolOpsCoord; type OverlayType: BoolOpsOverlay; diff --git a/geo/src/algorithm/bool_ops/mod.rs b/geo/src/algorithm/bool_ops/mod.rs index f0391a1ad..16287b049 100644 --- a/geo/src/algorithm/bool_ops/mod.rs +++ b/geo/src/algorithm/bool_ops/mod.rs @@ -29,6 +29,13 @@ use crate::geometry::{LineString, MultiLineString, MultiPolygon, Polygon}; pub trait BooleanOps { type Scalar: BoolOpsNum; + /// The exterior and interior rings of the geometry. + /// + /// It doesn't particularly matter which order they are in, as the topology algorithm counts crossings + /// to determine the interior and exterior of the polygon. + /// + /// It is required that the rings are from valid geometries, that the rings not overlap. + /// In the case of a MultiPolygon, this requires that none of its polygon's interiors may overlap. fn rings(&self) -> impl Iterator>; fn boolean_op(