Function GeodesicPolygonAccumulator.tryCompute
Measure the polygon's complete perimeter and signed area without throwing.
This includes the closing edge from the last corner to the first. A successful result gives the number of corners, perimeter in the ellipsoid's length unit and area in that unit squared. You can call this repeatedly or add more points afterward; it changes no state.
Example
Example computing a closed polygon without mutating the accumulator.
const solver =
Geodesic!double .fromEllipsoid(
Ellipsoid!double .sphere(
6_371_000.0));
auto accumulator =
GeodesicPolygonAccumulator!double .fromGeodesic(
solver);
accumulator .addPoint(
GeographicCoordinate!double .fromComponents(
Latitude!double .fromDegrees(0.0),
Longitude!double .fromDegrees(0.0)));
accumulator .addPoint(
GeographicCoordinate!double .fromComponents(
Latitude!double .fromDegrees(0.0),
Longitude!double .fromDegrees(1.0)));
accumulator .addPoint(
GeographicCoordinate!double .fromComponents(
Latitude!double .fromDegrees(1.0),
Longitude!double .fromDegrees(0.0)));
GeodesicPolygonResult!double result;
assert(accumulator .tryCompute(result));
assert(result .pointCount == 3);
assert(result .perimeter > 0.0);
assert(result .signedArea > 0.0);
assert(accumulator .pointCount == 3);