UNPKG

minotor

Version:

A lightweight client-side transit routing library.

84 lines (83 loc) 3.49 kB
import { Timetable } from '../router.js'; import { SourceStopId, StopId } from '../stops/stops.js'; import { StopsIndex } from '../stops/stopsIndex.js'; import { Route } from './route.js'; import { Arrival, RoutingState } from './router.js'; export declare class Result { private readonly destinations; readonly routingState: RoutingState; readonly stopsIndex: StopsIndex; readonly timetable: Timetable; constructor(destinations: ReadonlySet<StopId>, routingState: RoutingState, stopsIndex: StopsIndex, timetable: Timetable); /** * Expands a target stop or stop set to all equivalent concrete stop IDs. * * When `to` is omitted, defaults to the resolved destinations stored on this * result. * * Equivalent stops are expanded here so destination handling has a single * source of truth shared by route reconstruction and arrival lookups. */ private expandDestinations; /** * Reconstructs the best route to a stop by SourceStopId. * (to any stop reachable in less time / transfers than this result's * destination set) * * @param to The destination stop by SourceStopId. * @returns a route to the destination stop if it exists. */ bestRouteToSourceStopId(to: SourceStopId | Set<SourceStopId>): Route | undefined; /** * Reconstructs the best route to a stop. * (to any stop reachable in less time / transfers than this result's * destination set) * * @param to The destination stop. Defaults to this result's resolved * destinations. * @returns a route to the destination stop if it exists. */ bestRoute(to?: StopId | Set<StopId>): Route | undefined; private buildServiceRouteInfo; /** * Builds a vehicle leg from a chain of vehicle edges. * * @param edges Array of vehicle edges representing continuous trips on transit vehicles. * edges[0] is the alighting edge (last in the journey); edges[length-1] is the * boarding edge (first in the journey). * @returns A vehicle leg with departure/arrival information and route details * @throws Error if the edges array is empty */ private buildVehicleLeg; /** * Builds a transfer leg from a transfer edge. * * @param edge Transfer edge representing a walking connection between stops * @returns A transfer leg with from/to stops and transfer details */ private buildTransferLeg; /** * Builds a transfer leg from a transfer edge. * * @param edge Transfer edge representing a walking connection between stops * @returns A transfer leg with from/to stops and transfer details */ private buildAccessLeg; /** * Builds a guaranteed transfer leg between two consecutive vehicle legs. * * @param fromEdge The vehicle edge we're alighting from * @param toEdge The vehicle edge we're boarding * @returns A transfer leg with type 'GUARANTEED' */ private buildGuaranteedTransferLeg; /** * Returns the arrival time at any stop reachable in less time / transfers * than this result's destination set. * * @param stop The target stop for which to return the arrival time. * @param maxTransfers The optional maximum number of transfers allowed. * @returns The arrival time if the target stop is reachable, otherwise undefined. */ arrivalAt(stop: StopId, maxTransfers?: number): Arrival | undefined; }