UNPKG

minotor

Version:

A lightweight client-side transit routing library.

35 lines (34 loc) 1.57 kB
import { RouteId, StopRouteIndex, TripRouteIndex } from './route.js'; export type TripStopId = bigint; /** * Encodes a stop index, route ID, and trip index into a single trip boarding ID. * @param stopIndex - The index of the stop within the route (0 to 1,048,575) * @param routeId - The route identifier (0 to 1,048,575) * @param tripIndex - The index of the trip within the route (0 to 1,048,575) * @returns The encoded trip ID as a bigint */ export declare const encode: (stopIndex: StopRouteIndex, routeId: RouteId, tripIndex: TripRouteIndex) => TripStopId; /** * Decodes a trip boarding ID back into its constituent stop index, route ID, and trip index. * @param tripStopId - The encoded trip ID * @returns A tuple containing [stopIndex, routeId, tripIndex] */ export declare const decode: (tripStopId: TripStopId) => [StopRouteIndex, RouteId, TripRouteIndex]; /** * Extracts just the stop index from a trip ID without full decoding. * @param tripStopId - The encoded trip boarding ID * @returns The stop index */ export declare const getStopIndex: (tripStopId: TripStopId) => StopRouteIndex; /** * Extracts just the route ID from a trip ID without full decoding. * @param tripStopId - The encoded trip boarding ID * @returns The route ID */ export declare const getRouteId: (tripStopId: TripStopId) => RouteId; /** * Extracts just the trip index from a trip ID without full decoding. * @param tripStopId - The encoded trip boarding ID * @returns The trip index */ export declare const getTripIndex: (tripStopId: TripStopId) => TripRouteIndex;