pub trait BooleanOps: Sized {
type Scalar: GeoNum;
// Required methods
fn boolean_op(&self, other: &Self, op: OpType) -> MultiPolygon<Self::Scalar>;
fn clip(
&self,
ls: &MultiLineString<Self::Scalar>,
invert: bool,
) -> MultiLineString<Self::Scalar>;
// Provided methods
fn intersection(&self, other: &Self) -> MultiPolygon<Self::Scalar> { ... }
fn union(&self, other: &Self) -> MultiPolygon<Self::Scalar> { ... }
fn xor(&self, other: &Self) -> MultiPolygon<Self::Scalar> { ... }
fn difference(&self, other: &Self) -> MultiPolygon<Self::Scalar> { ... }
}
Expand description
Boolean Operations on geometry.
Boolean operations are set operations on geometries considered as a subset of the 2-D plane. The operations supported are: intersection, union, xor or symmetric difference, and set-difference on pairs of 2-D geometries and clipping a 1-D geometry with self.
These operations are implemented on Polygon
and the MultiPolygon
geometries.
§Validity
Note that the operations are strictly well-defined only on valid geometries. However, the implementation generally works well as long as the interiors of polygons are contained within their corresponding exteriors.
Degenerate 2-d geoms with 0 area are handled, and ignored by the algorithm.
In particular, taking union
with an empty geom should remove degeneracies
and fix invalid polygons as long the interior-exterior requirement above is
satisfied.
Required Associated Types§
Required Methods§
fn boolean_op(&self, other: &Self, op: OpType) -> MultiPolygon<Self::Scalar>
Sourcefn clip(
&self,
ls: &MultiLineString<Self::Scalar>,
invert: bool,
) -> MultiLineString<Self::Scalar>
fn clip( &self, ls: &MultiLineString<Self::Scalar>, invert: bool, ) -> MultiLineString<Self::Scalar>
Clip a 1-D geometry with self.
Returns the set-theoeretic intersection of self
and ls
if invert
is false, and the difference (ls - self
) otherwise.
Provided Methods§
fn intersection(&self, other: &Self) -> MultiPolygon<Self::Scalar>
fn union(&self, other: &Self) -> MultiPolygon<Self::Scalar>
fn xor(&self, other: &Self) -> MultiPolygon<Self::Scalar>
fn difference(&self, other: &Self) -> MultiPolygon<Self::Scalar>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.