Skip to main content

area

Function area 

Source
pub fn area<P>(p: &P) -> <DefaultAreaStrategy<P> as AreaStrategy<P>>::Out
Expand description

Signed area of a Polygon: exterior-ring area plus the sum of interior-ring areas (interior rings are conventionally wound opposite the exterior, so their signed area already cancels).

Mirrors boost::geometry::area(polygon) from boost/geometry/algorithms/area.hpp resolved through the dispatch::area<Polygon, polygon_tag> arm at algorithms/area.hpp:160-172.

The area is computed with the default strategy for the polygon’s coordinate-system family via geometry_strategy::DefaultAreaStrategy — Cartesian input resolves to the shoelace geometry_strategy::ShoelacePolygonArea (identical to the v1 behaviour), spherical to the spherical-excess geometry_strategy::SphericalPolygonArea, geographic to the authalic-sphere geometry_strategy::GeographicPolygonArea. For an explicit strategy use area_with.

§Behaviour on “wrong” kinds

This static entry point requires a Polygon; a Point or LineString argument is a compile error. Boost’s runtime “area of a non-areal kind is 0” contract is honoured on the dynamic path: crate::area_dyn returns 0 for Point, LineString, MultiPoint, … (the static/dynamic split is the same coherence workaround described on length).