Expand description
Strategy for computing the area of a Cartesian geometry.
Mirrors three pieces of Boost.Geometry that collaborate to make
boost::geometry::area(g) work for any ring / polygon / box /
multi-polygon in any coordinate system:
boost/geometry/strategies/area/services.hpp— theservices::default_strategy<G>metafunction that picks the per-CS area strategy.boost/geometry/strategies/area/cartesian.hpp—strategies::area::cartesian<>plus itsservices::default_strategy<Geometry, cartesian_tag>specialisation; the umbrella strategy hands outstrategy::area::cartesian<>for ring / polygon geometries andstrategy::area::cartesian_box<>for boxes.boost/geometry/strategy/cartesian/area.hpp:91-120— the trapezoidal-rule accumulation(x1 + x2) * (y1 - y2)summed over consecutive segments and halved at the end. The Boost code wraps the ring inclosed_clockwise_viewfirst so a counter-clockwise declared ring traversed in its declared order still produces a positive area; the Rust port mirrors that by flipping the sign whenPointOrder::CounterClockwiseis declared.
T34 lands the Cartesian implementation only — Boost’s Spherical / Geographic area strategies arrive alongside the Haversine / geographic distance work in later tasks (T40+).
§Coherence note
Rust’s coherence rules cannot prove that no single type is both a
Ring and a Polygon (or a Box / MultiPolygon) at the
same time, so a single ShoelaceArea carrying four
impl AreaStrategy<G> blocks keyed off G: Ring, G: Polygon,
G: Box, G: MultiPolygon is rejected as overlapping. Boost
sidesteps this with tag dispatch (strategy::area::cartesian vs.
strategy::area::cartesian_box, plus the per-tag dispatch::area
arms in algorithms/area.hpp:131-187); we mirror that split with
four sibling unit-structs below, each implementing
AreaStrategy for exactly one geometry kind.
Structs§
- Shoelace
Area - Cartesian shoelace area for a
Ring. - Shoelace
BoxArea - Cartesian area for a
Box:(xmax - xmin) * (ymax - ymin). - Shoelace
Multi Polygon Area - Cartesian shoelace area for a
MultiPolygon— sum of the areas of its member polygons. - Shoelace
Polygon Area - Cartesian shoelace area for a
Polygon— outer ring area minus the sum of interior-ring areas.
Traits§
- Area
Strategy - A strategy for computing the area of a geometry.
- Default
Area - “Which (polygon) area strategy do we pick by default for this CS family?”
Type Aliases§
- Default
Area Strategy - Type alias resolving the default area strategy for geometry
Gby walkingG -> G::Point -> Cs -> Family -> DefaultArea::Strategy.