Working with Trips and Legs
Each TripPattern consists of one or more Leg messages. Legs describe individual travel segments — walking, waiting, or transit rides.
Leg Types
Section titled “Leg Types”- TransitLeg — a bus, train, metro, or ferry journey.
- NonTransitLeg — walking or biking segments.
- WaitingLeg — idle time between connections.
- FlexibleLeg — on‑demand transport (e.g., shared shuttle).
Example rendering logic
Section titled “Example rendering logic” function summarizeTrip(t) { const header = `🕒 ${hhmm(t.aimedStartTime)} → ${hhmm(t.aimedEndTime)} • ${t.duration}m • ${t.transfers} transfers`; const legs = t.legs.map(l => { if (l.transitLeg) return `🚆 ${l.transitLeg.line?.name}`; if (l.nonTransitLeg) return `🚶 ${(l.distance/1000).toFixed(1)} km`; if (l.waitingLeg) return `⏱️ wait ${hhmm(l.waitingLeg.startTime)} → ${hhmm(l.waitingLeg.endTime)}`; if (l.flexibleLeg) return `🚐 on-demand from ${l.flexibleLeg.fromPlace?.name}`; }); return [header, ...legs].join('\n');}This formatting helps visualize how trips progress from start to destination.