Skip to content

geo://

Pure-Go geospatial processor (backed by pkg/geo, no cgo). The producer treats the exchange body as a geometry and runs one operation against it: parse, centroid, bounding box, area, length, geohash, distance, point-in-polygon, and radius containment. It is the route-level counterpart of the sl::gis Starlang module and the geo.* agent tools — all three share pkg/geo.

URI shape

geo://<operation>?precision=7&to=lon,lat&point=lon,lat&meters=5000

Producer-only — CreateConsumer returns an error.

Token Description
<operation> Required — one of parse, centroid, bbox, area, length, geohash, distance, contains, dwithin.

Coordinates are always (longitude, latitude) in WGS84 (EPSG:4326), matching GeoJSON axis order.

Parameters

Param Type Default Producer/Consumer/Both Description
precision integer 7 Producer geohash — number of characters (1–12).
to string — Producer distance — the reference point as "lon,lat".
point string — Producer contains / dwithin — the test point as "lon,lat".
meters number — Producer dwithin — the radius in meters.

Body contracts

The body is interpreted as a geometry in any of these forms:

Body type Interpreted as
GeoJSON object (map[string]any) a geometry via GeoJSON
string / []byte starting { or [ GeoJSON
string / []byte otherwise WKT (e.g. POINT(30 10), POLYGON((...)))
[]float64 / []any of length ≥ 2 a [lon, lat] Point

Operations

Operation Body Output Content-Type
parse any geometry normalized GeoJSON object application/geo+json
centroid any geometry centroid Point (GeoJSON object) application/geo+json
bbox any geometry []float64 = [minLon, minLat, maxLon, maxLat] —
area any geometry float64 — area in m² (geodesic) —
length any geometry float64 — length/perimeter in meters (geodesic) —
geohash a Point string — geohash at precision —
distance a Point + to=lon,lat float64 — geodesic meters between the two points —
contains a geometry + point=lon,lat bool — is the point inside the geometry —
dwithin a Point + point=lon,lat + meters bool — is the body point within meters of point —

Distances/areas are geodesic (Haversine / spherical), consistent with pkg/geo and sl::gis.

Headers

Written by the producer

Header Description
geo.operation The operation executed.
Content-Type Set to application/geo+json only for GeoJSON geometry output (parse, centroid).

Examples

Geohash a coordinate (body is a [lon, lat] pair):

- target: geo://geohash?precision=5
# body [-5.6, 42.6] -> "ezs42"

Centroid of a WKT polygon, emitted as GeoJSON:

- set-body:
    constant: "POLYGON((-1 -1, 1 -1, 1 1, -1 1, -1 -1))"
- target: geo://centroid
# body -> {"type":"Point","coordinates":[0,0]}, Content-Type application/geo+json

Point-in-polygon test used to branch a route:

- set-body:
    constant: "POLYGON((-74.02 40.70, -73.95 40.70, -73.95 40.75, -74.02 40.75, -74.02 40.70))"
- target: geo://contains?point=-73.98,40.72
# body -> true

Distance between two points (meters):

- target: geo://distance?to=-73.9857,40.7484
# body [-74.006, 40.7128] -> ~5000 (meters to the reference point)

Behavior notes

  • Pure Go — no GEOS/GDAL/PROJ; the operations above are the pure-Go tier. Heavy topology (buffer/union/arbitrary intersection) and binary formats (shapefile/GeoTIFF) are out of scope.
  • Axis order — (lon, lat). A common mistake is passing lat,lon; results will be far from expected.
  • Producer-only — use it as a target: step; the transformed body flows to the next step.

Source

pkg/component/geo/geo.go

See also

  • geocoder — turn addresses into the coordinates these operations consume.
  • sl::gis — the same operations inside a Starlang transform.
  • geo agent tools — the same operations as agent-callable tools.
  • RAG store: postgis — geospatial RAG (vector + PostGIS geometry).