Skip to main content

Module measure

Module measure 

Source
Expand description

Linear and areal measurements on the geonative-core IR.

§What this module is

Pure-math primitives: Euclidean distance between two coords, length of a polyline, signed/unsigned area of a polygon ring. They operate in the same units as their input (degrees for lng/lat data, meters for projected data) — there is no geodetic correction here. If you need great-circle distances, project to a metric CRS first or wait for a future geonative-proj-aware measure module.

§Clever bits

  • signed_area uses the shoelace formula directly. Positive result means CCW ring (OGC exterior); negative means CW (OGC interior). Callers that just want magnitude take .abs().
  • area of a Polygon subtracts hole areas from the exterior. Standard “shell minus holes” formula. Works for any polygon as long as holes are inside the exterior (the IR’s invariant).
  • length ignores empty/single-point inputs (returns 0.0).
  • No allocation. All four entry points are non-allocating.

Functions§

area
Area of a polygon = exterior area minus the sum of hole areas. Returns the absolute value (sign of the exterior winding doesn’t matter for the final magnitude).
distance
Euclidean distance between two coords in the input units (degrees / meters / whatever).
length
Total length of a polyline (sum of segment lengths). Empty or single-point inputs return 0.
ring_area
Unsigned area of a single ring.
signed_area
Signed area of a ring using the shoelace formula. Positive = CCW (OGC exterior convention); negative = CW (interior / hole convention). Rings with < 3 coords return 0.