OpenTrip Docs
Backend

Geo

Geo

Internal geospatial capability used by the trip agent (and future HTTP consumers). Callers never talk to Nominatim, Overpass, OSRM, or Google Maps directly.

Entry points

ConsumerPathNotes
AgentplaceSearchFree-text place search; optional near bias
AgentplaceNearbyPOIs around a coordinate + radius
AgentplaceDetailEnrich a place id from search/nearby
AgentrouteComputeOrdered waypoints → distance/duration (+ optional geometry)
AgentrouteMatrixOrigins × destinations travel matrix
AgentreviewLookupPlace reviews when the provider supports them

All tools are read-only and skip toolApproval. Inserting a found place into a trip still goes through insertStop (trip ops registry) and member approval. See agent.md.

Layering

Agent read tools
        → GeoService (application) → stable DTOs
                → GeoProvider (domain port)
                        → OsmGeoProvider | GoogleGeoProvider
  • Domain (domain/geo) — vendor-neutral place/route/review types and the GeoProvider port (placeSearch, placeNearby, placeDetail, routeCompute, routeMatrix, reviewLookup). Coordinates stay lat/lng.
  • Application — validates limits, coordinates, and travel modes; maps port results to DTOs; raises DomainError for bad input and lets adapters raise GeoError for upstream/config failures.
  • Infrastructure — provider adapters + shared cache/rate-limit/HTTP helpers. GEO_PROVIDER=osm|google selects the implementation in createGeoProvider at composition time.

Providers

OSM (default)

CapabilityUpstream
placeSearch / placeDetailNominatim /search, /lookup
placeNearbyOverpass around: + out center
routeCompute / routeMatrixOSRM /route/v1, /table/v1
reviewLookupUnsupported (supported: false)

Base URLs and GEO_OSM_USER_AGENT are configurable so self-hosted Nominatim / Overpass / OSRM can replace the public endpoints without code changes.

Google

CapabilityUpstream
search / nearby / detail / reviewsPlaces API (New)
route / matrixRoutes API v2 (computeRoutes, computeRouteMatrix)

Requires GOOGLE_MAPS_API_KEY when GEO_PROVIDER=google.

Caching and pacing

  • On-demand only — agent tool calls may refresh upstream. No cron.
  • TTL — default 30 minutes per cache key (provider + operation + rounded inputs).
  • Single-flight + SWR — concurrent misses share one upstream call; expired entries return stale while refreshing.
  • OSM rate limits — Nominatim ~1 req/s and soft Overpass pacing via a token bucket, plus required User-Agent.

Configuration

See .env.example:

VariableDefaultNotes
GEO_PROVIDERosmosm or google
GEO_OSM_NOMINATIM_URLpublic Nominatim
GEO_OSM_OVERPASS_URLpublic Overpass interpreter
GEO_OSM_OSRM_URLpublic OSRM demo
GEO_OSM_USER_AGENTOpenTrip identifying UARequired for public OSM etiquette
GEO_TIMEOUT_MS12000Upstream abort timeout
GEO_CACHE_TTL_MS180000030 minutes
GOOGLE_MAPS_API_KEYunsetRequired when provider is google

GeoError codes: geo_not_configured503, geo_timeout504, other upstream failures → 502.

Provider notes

  • OSM coordinate order — tool/DTO inputs are lat/lng; OSRM paths use longitude,latitude.
  • Overpass centroids — nearby queries use out center so ways/relations return usable POI coordinates.
  • Nominatim — requests use format=jsonv2 with addressdetails, extratags, namedetails, and accept-language when available.
  • Google Places field masks — search/nearby masks are prefixed with places.; Place Details masks are unprefixed (displayName, reviews, …).
  • Google Routes field maskscomputeRoutes requires routes.distanceMeters,routes.duration,…; matrix elements use originIndex,destinationIndex,condition,distanceMeters,duration.
  • OSM reviews — always supported: false; use Google when reviews matter.
  • Transit on OSM — public OSRM demos have no transit profile; the adapter falls back to the driving profile for mode=transit.

On this page