Expand description
CentroidStrategy<G> — geometric centre of a geometry.
Mirrors the per-CS centroid-strategy concept from
boost/geometry/strategies/centroid/services.hpp plus the Cartesian
implementations in boost/geometry/strategies/cartesian/centroid_*.hpp
and the per-kind dispatch in
boost/geometry/algorithms/centroid.hpp. Per-kind Cartesian formulas:
Segment,Box→ midpoint of endpoints / cornersLinestring→ length-weighted midpoint of segmentsRing(closed) /Polygon→ area-weighted Bashein–Detmer formulaMultiPoint→ arithmetic mean of points
Each per-kind impl lives behind a different strategy unit-struct so
coherence stays disjoint — the same distinct-struct-per-kind trick as
area (see strategies/cartesian/area.hpp and the module docs of
crate::area). Rust cannot prove a single type is not both a
Ring and a Polygon, so a single strategy carrying overlapping
impl CentroidStrategy<G> blocks keyed off the open traits would be
rejected (E0119); the sibling unit-structs below each carry a single
concept-bounded impl (impl<G: Ring> … for CartesianRingCentroid, …)
— distinct Self, so no overlap. The
[CentroidStrategyForKind] picker then routes G::Kind (the tag
Geometry::Kind already carries) to the right struct, disjoint on
the tag. This opens every kind to any concept-adapted foreign type,
not just the geometry-model structs.
Structs§
- Cartesian
BoxCentroid - Cartesian centroid for a
geometry_trait::Box— corner midpoint per dimension. - Cartesian
Linestring Centroid - Cartesian centroid for a
geometry_trait::Linestring— length-weighted midpoint of each segment, summed and divided by total length. - Cartesian
Multi Point Centroid - Cartesian centroid for a
geometry_trait::MultiPoint— arithmetic mean of the member points. - Cartesian
Polygon Centroid - Cartesian centroid for a
geometry_trait::Polygon— theCartesianRingCentroidformula applied to every ring (exterior plus interiors), combined by signed area. - Cartesian
Ring Centroid - Cartesian centroid for a
geometry_trait::Ring— the Bashein–Detmer formula (signed-area-weighted vertex pairs). - Cartesian
Segment Centroid - Cartesian centroid for a
geometry_trait::Segment—(start + end) / 2.
Traits§
- Centroid
Strategy - A strategy for computing the centroid of
G.