Skip to main content

CentroidStrategy

Trait CentroidStrategy 

Source
pub trait CentroidStrategy<G: Geometry> {
    type Output: PointMut + Default;

    // Required method
    fn centroid(&self, g: &G) -> Self::Output;
}
Expand description

A strategy for computing the centroid of G.

Mirrors the per-CS centroid-strategy concept from boost/geometry/strategies/centroid/services.hpp. The Boost concept exposes a stateful apply(p1, p2, state) accumulator plus a result(state) reduction (see strategies/cartesian/centroid_bashein_detmer.hpp:173-231); the Rust analogue collapses the two phases into a single method CentroidStrategy::centroid keyed on the geometry type.

Required Associated Types§

Source

type Output: PointMut + Default

The output point type. Almost always G::Point — Boost picks the input point type by default (strategies/default_centroid_result.hpp).

Required Methods§

Source

fn centroid(&self, g: &G) -> Self::Output

Compute the centroid of g.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<G> CentroidStrategy<G> for CartesianBoxCentroid

Source§

impl<G> CentroidStrategy<G> for CartesianLinestringCentroid

Source§

impl<G> CentroidStrategy<G> for CartesianMultiPointCentroid

Source§

impl<G> CentroidStrategy<G> for CartesianPolygonCentroid

Source§

impl<G> CentroidStrategy<G> for CartesianRingCentroid

Source§

impl<G> CentroidStrategy<G> for CartesianSegmentCentroid