Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

46 Commits

Repository files navigation

MobilityAPI

License: PostgreSQLGo 1.25+OGC API – Moving Features

The reference implementation of the OGC API – Moving Features Standard over MobilityDB — a thin, compiled HTTP tier for clients that don't speak SQL or the PostgreSQL wire protocol.

What it is

MobilityAPI exposes MobilityDB collections of moving features over plain HTTP — for browser apps, mobile clients, microservices, and ETL / lakehouse pipelines. It is a thin tier: every temporal computation and (de)serialization runs inside MobilityDB itself (asMFJSON, atTime, tgeompointFromMFJSON, appendInstant). The server holds no MEOS — no cgo, no embedded library — so it stays small and stateless, and the database is the single source of truth.

  • Streaming responses — a FeatureCollection is written row by row from a server-side cursor, so memory is bounded regardless of result size.
  • Keyset paginationWHERE id > :after with OGC next links, no OFFSET, constant cost through large collections.
  • Index-using filtersbbox and datetime push to the MobilityDB GiST index; subtrajectory clips with atTime.
  • Lakehouse export — a streaming GET …/export feed (NDJSON, or ?format=parquet with the trajectory WKB plus a bbox/time sidecar) that DuckDB / MobilityDuck / Spark can ingest directly.

This Go server is the reference (production) implementation. A PyMEOS-based Python implementation is also available at MobilityAPI-Python.

Architecture

HTTP client ──▶ MobilityAPI (Go · net/http + pgxpool) ──▶ MobilityDB / PostgreSQL

The tier translates between OGC API – Moving Features requests/responses and MobilityDB SQL; all geometry and temporal logic lives in the database.

Endpoints

MethodPathDescription
GET/ · /api · /conformanceLanding page, OpenAPI document, conformance declaration
GET · POST · PUT · DELETE/collections · /collections/{cid}List, register, replace and delete collections (spatial + temporal extent)
GET/collections/{cid}/itemsMoving features, streamed and keyset-paged, with bbox / datetime / subtrajectory filters
GET · POST · PUT · DELETE/collections/{cid}/items/{fid}Read, replace and delete a moving feature; POST on the collection creates one from a MovingFeatureJSON body
GET · POST/collections/{cid}/items/{fid}/tgsequenceTemporal geometry sequence (TemporalGeometrySequence); members are the trajectory's gap-separated sequences, each with a 1-based id; POST appends a temporally-disjoint member
DELETE/collections/{cid}/items/{fid}/tgsequence/{tgid}Delete a temporal primitive geometry (member sequence) by id
GET/collections/{cid}/items/{fid}/tgsequence/{tgid}/{distance|velocity}Derived kinematics on member {tgid}; acceleration returns 501 for the piecewise-constant motion model
GET · POST · DELETE/collections/{cid}/items/{fid}/tproperties · /.../{pname}User-supplied, stored temporal properties (TReal · TInt · TText · TBool), held as native MobilityDB temporal values
GET/collections/{cid}/exportLakehouse feed: NDJSON, or ?format=parquet
POST/collections/{cid}/bulkBulk ingest of a fleet feed: GeoJSON / GeoParquet observations, each appended as one instant

GET /export, PUT, and POST /bulk are opt-in extensions beyond the OGC conformance classes declared at GET /conformance. The surface is mapped against the OGC standard and the aistairc/mf-api reference in docs/mf-api-comparison.md.

Prerequisites

  • Go 1.25 or later
  • PostgreSQL with the MobilityDB extension (and PostGIS)

Build and run

go build -o mfapi .
MFAPI_DSN="postgres:///mydb?host=/var/run/postgresql&port=5432&user=me" ./mfapi

The server listens on :8088 by default. Configuration is by environment variable:

VariableDefaultMeaning
MFAPI_DSNpostgres:///mfapi_demo?host=/tmp&port=5432&user=estebanMobilityDB connection string
MFAPI_PORT8088Listen port
MFAPI_MAXCONNS16Connection-pool size
MFAPI_DEFAULT_LIMIT / MFAPI_MAX_LIMIT100 / 10000Page size defaults and ceiling
MFAPI_EXPORT_LIMIT0 (unbounded)Rows per export stream
MFAPI_PARQUET_ROWGROUP1024Rows per Parquet row group (bounds export memory)

Test

go test ./...

Repository layout

  • main.go — the server: routing, OGC request/response shaping, streaming and export.
  • bulk.go — the bulk-ingest extension endpoint (GeoJSON / GeoParquet fleet feed).
  • bench/ — a comparison harness and results.
  • tutorial/ — a notebook walkthrough of the endpoints against the canonical AIS dataset.
  • docs/ — the OGC standard / aistairc/mf-api surface comparison.

Where MobilityAPI fits

MobilityAPI is the HTTP / OGC layer of the MEOS ecosystem:

  • MEOS (canonical C library) — the underlying type system and computations.
  • MobilityDB · MobilityDuck · MobilitySpark — peer SQL surfaces over MEOS.
  • Language bindingsPyMEOS, JMEOS, meos-rs, GoMEOS, MEOS.NET, MEOS.js.

A longer overview is at libmeos.org.

License

MobilityAPI is released under The PostgreSQL License.

About

A thin compiled (Go) OGC API – Moving Features tier over MobilityDB

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages