geokit/bbox

Bounding box computation for a Geometry.

A bounding box is the smallest axis-aligned rectangle that contains every point of the geometry. The box is reported as the south-west and north-east corners. Empty inputs produce EmptyGeometry.

The implementation does not account for the antimeridian: a geometry that straddles 180° longitude is treated as if the world were a flat rectangle and produces a box that spans almost the entire globe in the longitude axis. Antimeridian-aware bounding boxes (the “narrow” variant chosen by Turfjs, terraformer, etc.) are an explicit design choice and are out of scope for this module.

Types

Errors returned by compute.

pub type BBoxError {
  EmptyGeometry
}

Constructors

  • EmptyGeometry

    The geometry contained no points (an empty LineString, Polygon, or MultiPolygon).

Values

pub fn compute(
  geometry geometry: geometry.Geometry,
) -> Result(#(latlng.LatLng, latlng.LatLng), BBoxError)

Compute the bounding box of geometry as #(sw, ne).

Search Document