Skip to content

0.12.0

Latest

Choose a tag to compare

@wingkwong wingkwong released this 19 Oct 03:10
4fd8921

This release corrects distance, polygon-area, and geodesic-line calculations. It includes breaking changes where previous results used incorrect units or geometry.

Breaking Changes

Distance units

equirectangularDistance and sphericalLawOfCosinesDistance now return meters.

  • Spherical-law results were previously returned in kilometers.
  • Divide the new result by 1,000 when kilometers are required.
  • Equirectangular results also change because calculations now convert degrees to radians correctly.

Polygon areas

Polygon APIs now return square meters using spherical geometry.

  • Edges follow shorter great-circle arcs.
  • Results represent the smaller enclosed region.
  • Ring direction no longer changes area.
  • Previous results used planar degree-squared calculations despite documenting square meters.

Invalid geodesics

Undefined geodesics now throw ArgumentError.

This includes:

  • Identical endpoints
  • Antipodal endpoints
  • Invalid coordinates
  • Projections without a unique nearest point

Fixes

Vincenty distance

  • Return zero for identical coordinates.
  • Handle equatorial routes correctly.
  • Handle equivalent dateline and pole coordinates.
  • Reject non-finite and out-of-range coordinates.
  • Stop after 200 unsuccessful iterations.
  • Throw StateError for non-convergent antipodal or nearly antipodal pairs.

Distance calculations

  • Convert equirectangular inputs to radians.
  • Use the short longitude difference across the antimeridian.
  • Return meters consistently.
  • Clamp spherical-law cosine values against floating-point overflow.
  • Return exact zero for identical points.

Polygon areas and holes

  • Calculate spherical areas using a 6,371,000-meter Earth radius.
  • Support antimeridian and polar polygons.
  • Preserve small-polygon precision.
  • Support open and explicitly closed rings.
  • Return zero for degenerate rings.
  • Support empty hole lists.
  • Subtract holes independently of ring direction.
  • Reject total hole area exceeding the outer area.
  • Leave hole containment and overlap validation to callers.

Geodesic intersections

  • Intersect finite shorter great-circle segments.
  • Include segment endpoints.
  • Handle antimeridian crossings.
  • Return null for disjoint segments.
  • Return null for coincident or overlapping segments without a unique intersection.
  • Produce the same result regardless of segment direction or argument order.

Geodesic projections

  • Project onto the infinite great circle through both endpoints.
  • Preserve points already on the great circle.
  • Produce the same result when endpoints are reversed.
  • Normalize antimeridian results.
  • Do not clamp projections to the finite segment.

Full Changelog: 0.11.0...0.12.0