PostGIS
The platform is fundamentally route-based, so spatial data is not a set of latitude/longitude columns to be compared in application code. Every spatial column is GEOGRAPHY(..., 4326).
Why geography, not geometry
geometry stores coordinates in degrees and computes distance in degrees. geography stores them in degrees but computes distance, length and area in metres.
The matching engine expresses its rules in metres — "is the pickup within 800 m of the driver's route", "how many additional kilometres does this passenger add". Those thresholds are meaningless in degrees. Using geometry would make every distance threshold a per-latitude correction and every result wrong.
geography is slightly more expensive per operation. That is an acceptable trade for thresholds that can be read directly by RTA.
Spatial columns
| Table | Column | Type |
|---|---|---|
journeys | origin, destination | GEOGRAPHY(Point, 4326) |
journey_routes | route_geometry | GEOGRAPHY(LineString, 4326) |
journey_stops | location | GEOGRAPHY(Point, 4326) |
ride_requests | pickup, dropoff | GEOGRAPHY(Point, 4326) |
recurring_journeys | origin, destination | GEOGRAPHY(Point, 4326) |
Operations used
| Function | Question it answers |
|---|---|
ST_DWithin | Is this pickup point within 750 m of the driver's route? |
ST_Distance | What is the distance from the pickup point to the route? |
ST_LineLocatePoint | Which point on the route is closest to the pickup? |
ST_LineSubstring | What is the remaining route after that point? |
ST_Intersects | Does this zone or service area cover the point? |
ST_Contains | Is this point inside an approved service area? |
ST_Length | How long is the resulting route, in metres? |
Query order
Spatial work runs in two stages, and the order is a performance requirement, not a preference:
1. Coarse pre-filter ST_DWithin on journey origin/destination
cheap, index-backed, removes most candidates
↓
2. Precise evaluation join journey_routes, ST_Distance to the
LineString, compute detour
expensive, run only on survivorsNever recalculate routes before the pre-filter. A direct ST_Distance against every LineString in the table cannot use the GiST index on the point column and will scan the whole route table.
Indexes
CREATE INDEX idx_journeys_origin ON journeys USING GIST (origin);
CREATE INDEX idx_journeys_destination ON journeys USING GIST (destination);
CREATE INDEX idx_journey_routes_geometry ON journey_routes USING GIST (route_geometry);
CREATE INDEX idx_journey_stops_location ON journey_stops USING GIST (location);
CREATE INDEX idx_ride_requests_pickup ON ride_requests USING GIST (pickup);
CREATE INDEX idx_ride_requests_dropoff ON ride_requests USING GIST (dropoff);Plus the composite operational index used by the pre-filter:
CREATE INDEX idx_journeys_matching
ON journeys (status, departure_at, available_seats);Privacy
Exact home addresses are not stored for passengers.
Pickup and dropoff are stored as generalised commute hubs where practical — a named area rather than a building. journey_stops.name carries the human label so the journey still reads sensibly to the driver and passenger while the underlying geometry stays coarse.
See Privacy for the wider data-minimisation rules.
Frontier
The existing MapLibre and geospatial experience carries over directly: the same geometry that is stored in PostGIS is what the frontend renders, so client and server agree on distance without duplicating the routing logic.
