Metro first and last mile
Built: 2026-11-02. For the operator, and for whoever maintains the code.
Commuters take an auto or a cab to the metro and home from it. Namma Yatri and Uber India both sell this trip. Here it has three parts:
- Nearest stations, one tap. The rider's search screen lists the metro stations near the pickup, within 5 km and closest first. Each shows the line colour and distance, and is marked "Fixed fare" where the station has fixed fares. One tap goes to the confirm screen with the station as the drop.
- Fixed feeder fares. A trip with one end inside the station and the
other end within the feeder radius costs the station's fixed fare for that
ride type, whatever the meter says.
- The confirm screen says "Fixed metro fare · to {station}" (or "from").
- The fare is quote-locked. Only waiting time and a real detour past the reroute threshold can add to it, at the normal per-km rate.
- A trip with stops is priced as usual.
- The onward ticket. When a completed trip ends at a station that has a ticket link, the rider's receipt shows "Buy your metro ticket", with the station and line. It opens the metro's own QR ticketing.
Setting up a station (Admin → Zones → Draw new zone → Metro station)
| Field | What to put |
|---|---|
| Name | The station as riders know it, e.g. "Kurla" |
| Boundary | Drawn around the entrances. A trip that starts or ends inside counts as at the station. |
| Line | "Blue Line 1" (optional) |
| Line colour | #RRGGBB, shown as a dot on the chip |
| Feeder radius | 0.5 to 15 km from the station (default 3) |
| Metro ticket link | An https link to the metro's ticketing |
| Fixed feeder fares | Per ride type. Leave one blank to price it as usual. |
Ticketing links differ by city, for example Delhi Metro, Namma Metro, Mumbai One and Kochi Metro. The metro's own app or website is the safe choice. ONDC metro ticketing (TRV11) would need its own buyer-side integration, which is not built.
For developers
| Piece | Where |
|---|---|
| Rules | backend/src/geo/metro-rules.ts (parseMetroRules, metroRulesOf), on a metro_station zone (migration 121) |
| Queries | GeoService.metroStationsNear, metroStationAt, metroFeederAt. The other end's distance is measured from the station's centroid. |
| Pricing | PricingService.estimate returns the fixed fare with metroFeeder. RidesService.buildFareQuote freezes it as quote_locked with the real per-km rate, so a detour is still charged. |
| API | GET /geo/metro-stations?lat&lng; the rider receipt carries metro { station, line, color, ticketUrl } |
| Rider app | app/(app)/search.tsx (chips), confirm.tsx (label), trip/[id].tsx (ticket link) |
| Admin | zones/MetroFields.tsx |
| Tests | geo/metro-rules.spec.ts. It covers validation, and that a fixed fare holds through settlement with only a real detour added. |
Tested end to end on the Android emulator, with a station drawn in Kurla:
- the search chip appears with "Fixed fare";
- Auto shows ₹30.00 and Economy ₹60.00 while Bike, Sedan and SUV are priced as usual;
- the confirm label reads "Fixed metro fare · to …";
- the trip settles at ₹60.00 and the receipt shows the ticket link;
- in Chrome, the admin editor refuses an http link and stores the fares in minor units.
The iOS simulator was not run for this item. The screens are the same React Native screens that are tested on Android.
Importing a whole network, and sponsored feeder fares (added 2026-11-02)
Built for Saudi Arabia (Riyadh Metro's six lines and 85 stations, the Haramain railway), and useful anywhere a network is too big to draw by hand.
Importing stations
Admin → Zones → Import stations. Paste or choose:
- a CSV with a header row:
name, lat, lngand optionallyname_ar(or anyname_<language>),line,color,radius_m(default 150 m), or - a GeoJSON file of Point features with the same properties.
Below the file, settings for every station: feeder radius, a fixed feeder fare per ride type, the ticket link and a sponsor's share. Check shows what would be created, which stations already exist (same name within 150 m — left as they are) and which rows have problems, with their row numbers. Import then creates the stations.
Each station also has a name in the market's language (Admin → Zones → the station). Riders see station chips, the confirm note and the receipt link in their own language.
Sponsored feeder fares
A transport authority or the metro operator can pay part of each fixed feeder fare to get people to the station:
- on the station (or in the import settings): Sponsor, Share (%) and optionally Most per trip;
- the rider sees and pays the reduced fare. The confirm screen says "Riyadh Metro (RCRC) pays SAR 7.50 of it", and the receipt has a "Paid by Riyadh Metro (RCRC)" line;
- the driver earns on the whole fixed fare. The sponsor's share is drawn from the subsidy receivable account (ledger), as a promo is drawn from the promo budget;
- the tax invoice is for the whole fare;
- Admin → Reports → Sponsored feeder trips: per month and sponsor, the trips, what riders paid and what the sponsor owes, with a Statement CSV of every trip to send them.
Stored on each ride: subsidy_minor, subsidy_sponsor, subsidy_station_id.
The share is fixed into the trip's quote at booking, so a sponsor changing
its share later doesn't change trips already booked.