Route Schema

Routes are stored as a sub-collection on the ride document. They are not a top-level Firestore collection.

Firestore Document (rides/{rideId}/routes/{routeId})

routeId encodes direction and alternative index: to-0 is the first outgoing route (origin → destination), to-1 the second alternative, from-0 the first return route (destination → origin). Currently only to-0 is stored; return routes and multiple alternatives are planned.

Field Type Required Constraints Description
distanceMeters number yes ≥ 0 Total route distance in metres
staticDuration.seconds number \| string yes ≥ 0 Total travel time in seconds (may arrive as string from Google API)
staticDuration.nanos number yes ≥ 0 Sub-second nanosecond component
legs Leg[] yes Ordered list of route legs (one per segment between consecutive waypoints)
viewport.high.latitude number yes North-east corner latitude of the bounding box
viewport.high.longitude number yes North-east corner longitude of the bounding box
viewport.low.latitude number yes South-west corner latitude of the bounding box
viewport.low.longitude number yes South-west corner longitude of the bounding box
routeLabels string[] yes Labels from Google Routes API (e.g. "DEFAULT_ROUTE", "FUEL_EFFICIENT")
description string no non-empty Optional human-readable route description
polylineDetails PolylineDetails no Flyover and narrow-road metadata for the full route polyline
warnings string[] no Warning messages from Google Routes API

Leg object (each element of legs):

Field Type Required Description
distanceMeters number yes Leg distance in metres
staticDuration Duration yes Leg travel time
startLocation.latLng {latitude, longitude} yes Leg start coordinates
startLocation.heading number \| null yes Heading at start (degrees); null if unavailable
endLocation.latLng {latitude, longitude} yes Leg end coordinates
endLocation.heading number \| null yes Heading at end (degrees); null if unavailable
steps Step[] yes Turn-by-turn navigation steps for this leg

Step object (each element of leg.steps):

Field Type Required Description
distanceMeters number yes Step distance in metres
staticDuration Duration yes Step travel time
startLocation Location yes Step start
endLocation Location yes Step end
polyline.encodedPolyline string yes Encoded polyline for this step
navigationInstruction.instructions string yes Human-readable instruction text
navigationInstruction.maneuver string yes Maneuver type (e.g. "TURN_LEFT", "STRAIGHT")
travelMode string yes Travel mode (e.g. "DRIVE")
{
  "distanceMeters": 425000,
  "staticDuration": { "seconds": 18000, "nanos": 0 },
  "legs": [
    {
      "distanceMeters": 425000,
      "staticDuration": { "seconds": 18000, "nanos": 0 },
      "startLocation": {
        "latLng": { "latitude": 12.9716, "longitude": 77.5946 },
        "heading": null,
      },
      "endLocation": {
        "latLng": { "latitude": 15.3647, "longitude": 75.1240 },
        "heading": null,
      },
      "steps": [
        {
          "distanceMeters": 500,
          "staticDuration": { "seconds": 60, "nanos": 0 },
          "startLocation": {
            "latLng": { "latitude": 12.9716, "longitude": 77.5946 },
            "heading": null,
          },
          "endLocation": {
            "latLng": { "latitude": 12.9750, "longitude": 77.5980 },
            "heading": null,
          },
          "polyline": { "encodedPolyline": "abc123..." },
          "navigationInstruction": {
            "instructions": "Head north on MG Road",
            "maneuver": "STRAIGHT",
          },
          "travelMode": "DRIVE",
        },
      ],
    },
  ],
  "viewport": {
    "high": { "latitude": 15.3647, "longitude": 77.5946 },
    "low": { "latitude": 12.9716, "longitude": 75.1240 },
  },
  "routeLabels": ["DEFAULT_ROUTE"],
  "description": "Via NH 48",
  "warnings": [],
}

Indexes

No indexes required. Routes are always accessed by their full path (rides/{rideId}/routes/{routeId}).