Skip to content

Spatial Service ​

Overview ​

The Spatial Service is OR geographic intelligence layer — responsible for all operations involving geographical data and mapping the geospatial relationships between entities in the OR stack. It functions as the unified interface to a suite of spatial tools and databases, enabling other services to geo-tag events, resolve locations, label road segments, and query spatial relationships without needing to manage low-level geospatial complexity directly.

From labelling an incident with the suburb it falls in, to determining which road segments are impacted by a traffic event, to encoding geographic regions into hexagonal tiles for efficient viewport queries — the Spatial Service is the single service through which all geospatial reasoning flows. It underpins OR ability to turn raw coordinates into meaningful location context that operators and AI agents can act on.

The service also integrates closely with the Location Reference Service (LRS), a API that ingests and transforms reference data into the location database. LRS enables point-and-click location referencing on the map — when a user clicks a point, LRS finds all intersecting geo-features (local government areas, postcodes, road names, and other spatial attributes), calculates the nearest intersection, and returns a rich location description including distance, direction, and locality.

Architecture ​

The Spatial Service operates as a dedicated geographic intelligence system that provides geospatial capabilities to the OR. It integrates multiple spatial capabilities including location databases, road network graphs, geocoding services, and hexagonal tiling.

Key Capabilities ​

  • Location Database Interface — Stores and queries real-time geospatial data, tracking positions, locations, and boundaries of objects. Supports spatial operations like point-in-polygon, proximity search, and geofencing.
  • Road Network Graph — Loads the relevant road network graph on startup (version retrieved from the central orchestration service) and exposes graph-level operations for mapping objects to and from the road network.
  • Geocoding Service — Converts latitude/longitude coordinates into street addresses for frontend display and human-readable location labelling.
  • Hexagonal Tiling API — Implements a hexagonal tiling system for spatial indexing and viewport-based data retrieval. Uses Resolution 6 for storing hex indices in the database.

Data Flow ​

The central orchestration service provides map version metadata to the Spatial Service. On startup, the Spatial Service loads the road network graph from cloud storage, initializes the location database, and exposes HTTP endpoints for spatial operations. Consumers including Data Loader, Data Ingestion, the Frontend, and the Location Reference Service utilise these spatial capabilities.

Real-Time Geospatial Store ​

The location database is the backbone of the Spatial Service's real-time geospatial capabilities. It provides an in-memory spatial database optimised for tracking the positions and boundaries of objects, with support for geofencing, proximity queries, and spatial searches.

The LRS module uses dedicated collections to store reference geospatial data — including local government areas, postcodes, declared roads, and other geo-features. These collections are loaded by the LRS Data Loader automated job, which runs on a schedule aligned with Map Manager updates.

Road Network Map Loading ​

On startup, the Spatial Service loads the current basemap as a road network graph object. The map version is determined by querying the central orchestration service's Map Data API, using the latest map based on the data loader timestamp.

This graph is held in memory and used for:

  • Mapping external coordinate data onto road segments
  • Geocoding operations (matching input coordinates to the nearest road network elements)
  • Providing the spatial backbone for other services that need to resolve coordinates to road IDs

The map can be reloaded at runtime without restarting the service.

Geocoding Interface ​

The geocoding interface maps coordinate-based route data onto road network segments. It accepts coordinate paths and configuration parametres, then returns matched road segment identifiers with directional information and match quality metrics. This capability enables external location data to be precisely aligned with OR road network representation, supporting accurate spatial analysis and visualisation.

Hexagonal Tiling ​

The hexagonal tiling system enables efficient spatial indexing for viewport-based data loading. The service provides capabilities for encoding geographic features (points, lines, polygons) into hexagonal tile indices and decoding viewport regions into tile coverage.

This hexagonal indexing supports zoom-level-aware data loading in the frontend, where different zoom levels load progressively more detailed road network data. Higher zoom levels show major highways and arterials, while lower zoom levels reveal the complete road network including local streets.

Location Reference Service (LRS) ​

The LRS is a API that provides rich location referencing for points and lines on the road network. It ingests reference data from Map Manager exports and map datasets into the location database, enabling queries that resolve coordinates to geographic features and road network elements.

Core LRS capabilities include finding the nearest road or intersection to a point, resolving road segment identifiers to their geographic attributes, and generating human-readable location descriptions that combine distance, direction, and locality information. The service supports snapping operations that align coordinates to network elements for precise location referencing.

LRS data is refreshed through Map Manager automated workflows, followed by the LRS Data Loader automated job which loads updated data into the location database.

  • Experiment Manager — Provides map version metadata and the central orchestration layer
  • Route Finder — Uses the same road network graph infrastructure for route calculation
  • Map Manager — Manages basemap versions, exports map data consumed by LRS
  • Schematics — Uses location database integration for spatial data in schematic views
  • Data Ingestion — Sends coordinate data to Spatial for geo-tagging
  • Data Loader — Loads reference data that Spatial Service consumes on startup

User documentation for Optimal Reality