Trait geo::algorithm::bool_ops::BooleanOps
source · 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 portion of ls
that lies within self
(known as the set-theoeretic
intersection) if invert
is false, and the difference (ls - self
) otherwise.