UNPKG

minotor

Version:

A lightweight client-side transit routing library.

51 lines (50 loc) 2.86 kB
import { StopId } from '../stops/stops.js'; import type { RouteId, TripRouteIndex } from '../timetable/route.js'; import { Route } from '../timetable/route.js'; import { ServiceRoute, ServiceRouteId, StopAdjacency } from '../timetable/timetable.js'; import { FrequenciesMap } from './frequencies.js'; import { GtfsRouteId, GtfsRoutesMap } from './routes.js'; import { ServiceIds } from './services.js'; import { GtfsStopsMap } from './stops.js'; import { TransfersMap } from './transfers.js'; export type GtfsTripId = string; export type GtfsTripIdsMap = Map<GtfsTripId, GtfsRouteId>; export type TripsMapping = Map<GtfsTripId, { routeId: RouteId; tripRouteIndex: TripRouteIndex; }>; export type GtfsPickupDropOffType = '' | '0' | '1' | '2' | '3'; export type SerializedPickUpDropOffType = 0 | 1 | 2 | 3; /** * Encodes pickup/drop-off types into a Uint8Array using 2 bits per value. * Layout per byte: [drop_off_1][pickup_1][drop_off_0][pickup_0] for stops 0 and 1 */ export declare const encodePickUpDropOffTypes: (pickUpTypes: SerializedPickUpDropOffType[], dropOffTypes: SerializedPickUpDropOffType[]) => Uint8Array; /** * Parses the trips.txt file from a GTFS feed * * @param tripsStream The readable stream containing the trips data. * @param serviceIds A mapping of service IDs to corresponding route IDs. * @param serviceRoutes A mapping of route IDs to route details. * @returns A mapping of trip IDs to corresponding route IDs. */ export declare const parseTrips: (tripsStream: NodeJS.ReadableStream, serviceIds: ServiceIds, validGtfsRoutes: GtfsRoutesMap) => Promise<GtfsTripIdsMap>; export declare const buildStopsAdjacencyStructure: (serviceRoutes: ServiceRoute[], routes: Route[], transfersMap: TransfersMap, nbStops: number, activeStops: Set<StopId>) => StopAdjacency[]; /** * Parses the stop_times.txt data from a GTFS feed. * * @param stopTimesStream The readable stream containing the stop times data. * @param stopsMap A map of parsed stops from the GTFS feed. * @param activeTripIds A map of valid trip IDs to corresponding route IDs. * @param activeStopIds A set of valid stop IDs. * @param frequenciesMap An optional map of frequency windows per trip. * When provided, trips listed in this map are expanded into one concrete * trip per departure that fits within each frequency window, instead of * being kept as a single template trip. * @returns A mapping of route IDs to route details. The routes returned correspond to the set of trips from GTFS that share the same stop list. */ export declare const parseStopTimes: (stopTimesStream: NodeJS.ReadableStream, stopsMap: GtfsStopsMap, activeTripIds: GtfsTripIdsMap, activeStopIds: Set<StopId>, frequenciesMap?: FrequenciesMap) => Promise<{ routes: Route[]; serviceRoutesMap: Map<GtfsRouteId, ServiceRouteId>; tripsMapping: TripsMapping; }>;