geo::algorithm::bool_ops

Trait BooleanOps

Source
pub trait BooleanOps {
    type Scalar: BoolOpsNum;

    // Required method
    fn rings(&self) -> impl Iterator<Item = &LineString<Self::Scalar>>;

    // Provided methods
    fn boolean_op(
        &self,
        other: &impl BooleanOps<Scalar = Self::Scalar>,
        op: OpType,
    ) -> MultiPolygon<Self::Scalar> { ... }
    fn intersection(
        &self,
        other: &impl BooleanOps<Scalar = Self::Scalar>,
    ) -> MultiPolygon<Self::Scalar> { ... }
    fn union(
        &self,
        other: &impl BooleanOps<Scalar = Self::Scalar>,
    ) -> MultiPolygon<Self::Scalar> { ... }
    fn xor(
        &self,
        other: &impl BooleanOps<Scalar = Self::Scalar>,
    ) -> MultiPolygon<Self::Scalar> { ... }
    fn difference(
        &self,
        other: &impl BooleanOps<Scalar = Self::Scalar>,
    ) -> MultiPolygon<Self::Scalar> { ... }
    fn clip(
        &self,
        multi_line_string: &MultiLineString<Self::Scalar>,
        invert: bool,
    ) -> MultiLineString<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§

Source

fn rings(&self) -> impl Iterator<Item = &LineString<Self::Scalar>>

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.

Provided Methods§

Source

fn boolean_op( &self, other: &impl BooleanOps<Scalar = Self::Scalar>, op: OpType, ) -> MultiPolygon<Self::Scalar>

Source

fn intersection( &self, other: &impl BooleanOps<Scalar = Self::Scalar>, ) -> MultiPolygon<Self::Scalar>

Source

fn union( &self, other: &impl BooleanOps<Scalar = Self::Scalar>, ) -> MultiPolygon<Self::Scalar>

Source

fn xor( &self, other: &impl BooleanOps<Scalar = Self::Scalar>, ) -> MultiPolygon<Self::Scalar>

Source

fn difference( &self, other: &impl BooleanOps<Scalar = Self::Scalar>, ) -> MultiPolygon<Self::Scalar>

Source

fn clip( &self, multi_line_string: &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.

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.

Implementors§