PostGIS Spatial Adapter
API Contract
REST
/api/v1/spatial
7 endpoints
GET
/api/v1/spatial/api/v1/spatial/queries
List recent spatial query logs (admin/audit use)
Public
Response Example
{
"data": [
{
"query_id": "spq_001a2b",
"function_name": "get_mentors_in_bounds",
"params": {
"sw_lat": 59.89,
"sw_lng": 10.7,
"ne_lat": 59.95,
"ne_lng": 10.8
},
"row_count": 7,
"executed_at": "2026-03-26T08:00:00Z",
"duration_ms": 12
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 1
}
}
GET
/api/v1/spatial/api/v1/spatial/queries/:query_id
Get a specific spatial query log entry
Public
Response Example
{
"query_id": "spq_001a2b",
"function_name": "get_mentors_in_bounds",
"params": {
"sw_lat": 59.89,
"sw_lng": 10.7,
"ne_lat": 59.95,
"ne_lng": 10.8
},
"envelope_wkt": "POLYGON((10.70 59.89, 10.80 59.89, 10.80 59.95, 10.70 59.95, 10.70 59.89))",
"row_count": 7,
"executed_at": "2026-03-26T08:00:00Z",
"duration_ms": 12
}
POST
/api/v1/spatial/api/v1/spatial/convert/bounds-to-envelope
Convert a LatLngBounds object to PostGIS envelope parameters
Public
Request Example
{
"sw_lat": 59.89,
"sw_lng": 10.7,
"ne_lat": 59.95,
"ne_lng": 10.8
}
Response Example
{
"xmin": 10.7,
"ymin": 59.89,
"xmax": 10.8,
"ymax": 59.95,
"srid": 4326,
"envelope_wkt": "ST_MakeEnvelope(10.70, 59.89, 10.80, 59.95, 4326)"
}
POST
/api/v1/spatial/api/v1/spatial/convert/coord-to-point
Convert a lat/lng coordinate to a WKT GEOGRAPHY POINT string
Public
Request Example
{
"lat": 59.9139,
"lng": 10.7522
}
Response Example
{
"wkt": "POINT(10.7522 59.9139)",
"geography_expression": "ST_GeogFromText('POINT(10.7522 59.9139)')",
"srid": 4326
}
POST
/api/v1/spatial/api/v1/spatial/convert/point-to-coord
Parse a WKT GEOGRAPHY POINT string back to a lat/lng coordinate
Public
Request Example
{
"wkt": "POINT(10.7522 59.9139)"
}
Response Example
{
"lat": 59.9139,
"lng": 10.7522
}
PUT
/api/v1/spatial/api/v1/spatial/queries/:query_id
Annotate or tag a spatial query log entry (admin use)
Public
Request Example
{
"note": "Suspicious high-frequency query — investigate",
"flagged": true
}
Response Example
{
"query_id": "spq_001a2b",
"note": "Suspicious high-frequency query — investigate",
"flagged": true,
"updated_at": "2026-03-26T10:00:00Z"
}
DELETE
/api/v1/spatial/api/v1/spatial/queries/:query_id
Delete a spatial query log entry (GDPR/audit purge)
Public
Response Example
{
"query_id": "spq_001a2b",
"deleted": true,
"deleted_at": "2026-03-26T10:05:00Z"
}