geokit/geometry

Geometry types shared by geokit/bbox, geokit/centroid, and geokit/simplify.

The ADT mirrors RFC 7946 GeoJSON (Point, LineString, Polygon, MultiPolygon) but only carries geometric data — no properties, no IDs, no coordinate-reference-system metadata — because every consumer in this package operates on coordinates alone.

LineString and Polygon rings are simple lists of points; no invariant is enforced at the type level. Operations that require a particular shape (a polygon with a closed exterior ring, for example) document and check their preconditions explicitly.

Types

A geometry value. Pattern-match to dispatch on the kind of shape; the points are accessible via the latlng module.

pub type Geometry {
  Point(point: latlng.LatLng)
  LineString(points: List(latlng.LatLng))
  Polygon(rings: List(List(latlng.LatLng)))
  MultiPolygon(polygons: List(List(List(latlng.LatLng))))
}

Constructors

  • Point(point: latlng.LatLng)

    A single point.

  • LineString(points: List(latlng.LatLng))

    A connected sequence of segments. The list should have at least two points for the geometry to be meaningful, but the type does not enforce this.

  • Polygon(rings: List(List(latlng.LatLng)))

    A polygon defined by one or more rings. The first ring is the exterior; subsequent rings are interior holes. Each ring should be closed (first point equal to last); operations that need a closed ring will close it themselves if necessary.

  • MultiPolygon(polygons: List(List(List(latlng.LatLng))))

    A collection of polygons sharing one geometric meaning (an archipelago, a country with several territories, …).

Search Document