UNPKG

minotor

Version:

A lightweight client-side transit routing library.

56 lines (54 loc) 2.43 kB
import { StopId } from '../stops/stops.js'; import { StopsIndex } from '../stops/stopsIndex.js'; import { Duration, Time } from '../timetable/time.js'; import { Timetable } from '../timetable/timetable.js'; /** * An access path from the query origin to an initial boarding stop. * * Equivalent origin stops (reached at zero cost) have no `duration`. * Stops reachable via a timed walking transfer carry a `duration` in minutes. */ export type AccessPoint = { fromStopId: StopId; toStopId: StopId; duration: Duration; }; /** * Collects access paths from a query origin and resolves the set of * distinct departure-time slots for Range RAPTOR. */ export declare class AccessFinder { private readonly timetable; private readonly stopsIndex; constructor(timetable: Timetable, stopsIndex: StopsIndex); /** * Returns every initial access path from the query origin: equivalent stops * (no duration) plus every stop reachable via a single timed walking transfer * (REQUIRES_MINIMAL_TIME), keeping the shortest walk when multiple origins * can reach the same stop. * * @param origin Origin stop ID. * @param fallbackMinTransferTime Transfer time used when a walking transfer * has no explicit `minTransferTime` in the timetable data. */ collectAccessPaths(queryOrigin: StopId, fallbackMinTransferTime: Duration): AccessPoint[]; /** * Collects all distinct origin departure times within `[from, to]` * (inclusive) and, for each slot, the specific access paths that directly * induce it — i.e. paths whose boarded stop has a boardable trip departing * at exactly `depTime + path.duration`. * * Returned array is sorted **latest-first**. The Range RAPTOR outer loop * seeds only the responsible paths for each slot, avoiding redundant * exploration of access stops whose boarding opportunities belong to a * later slot and whose journeys would therefore be dominated by it. * * @param accessPaths Access paths from the origin to initial boarding stops. * @param from Earliest origin departure time (inclusive). * @param to Latest origin departure time (inclusive). */ collectDepartureTimes(accessPaths: AccessPoint[], from: Time, to: Time): { depTime: Time; legs: AccessPoint[]; }[]; }