sphericalRingArea function

num sphericalRingArea(
  1. List<List<Object?>> ring,
  2. bool interior
)

Returns the spherical area of the specified ring, which is an array of points [[x₀, y₀], [x₁, y₁], …] where x and y represent longitude and latitude in degrees, respectively.

The first point must be equal to the last point. This implementation uses d4_geo’s winding order convention to determine which side of the polygon is the inside: polygons smaller than a hemisphere must be clockwise, while polygons larger than a hemisphere must be anticlockwise. If interior is true, the opposite winding order is used. This winding order convention is also used by ESRI shapefiles; however, it is the opposite convention of GeoJSON’s RFC 7946.

Implementation

num sphericalRingArea(List<List<Object?>> ring, bool interior) {
  var sum = _halfArea(ring, true);
  if (interior) sum *= -1;
  return (sum < 0 ? _tau + sum : sum) * 2;
}