GIS and PostGIS#
Tina4 stores geographic points in PostGIS, queries distance in metres, and returns GeoJSON. Coordinates are always [longitude, latitude].
typescript
import { Point } from "tina4-nodejs/orm";āsite.location = new Point(18.4241, -33.9249);await site.save();āconst nearby = await ChargePoint.query() .withinDistance("location", [18.42, -33.92], 5_000) .selectDistance("location", [18.42, -33.92]) .orderByDistance("location", [18.42, -33.92]) .get();āconst feature = site.toFeature();Declare the model field as location: { type: "point", srid: 4326, spatialIndex: true }. Tina4 maps it to geography(Point,4326) and creates a GiST index. Unsupported database engines fail clearly. Point.parse() accepts coordinate pairs, WKT/EWKT, GeoJSON, or WKB/EWKB and never guesses coordinate order.