UNPKG

minotor

Version:

A lightweight client-side transit routing library.

70 lines (69 loc) 2.71 kB
import { SourceStopId, Stop, StopId, StopsMap } from './stops.js'; /** * The StopMap class provides functionality to search for public transport stops * by name or geographic location. It leverages text search and geospatial indexing * to efficiently find stops based on user queries. */ export declare class StopsIndex { private readonly stopsMap; private readonly sourceStopsMap; private readonly textIndex; private readonly geoIndex; private readonly stopPoints; constructor(stopsMap: StopsMap); /** * Deserializes a binary representation of the stops. * * @param {Uint8Array} data - The binary data to deserialize. * @returns {StopsMap} - The deserialized StopFinder. */ static fromData(data: Uint8Array): StopsIndex; /** * Serializes the stops into a binary protobuf. * * @returns {Uint8Array} - The serialized binary data. */ serialize(): Uint8Array; /** * Returns the number of stops in the index. * * @returns The total number of stops. */ size(): number; /** * Finds stops by their name using a text search. * * @param query - The name or partial name of the stop to search for. * @param maxResults - The maximum number of results to return (default is 5). * @returns An array of Stop objects that match the search query. */ findStopsByName(query: string, maxResults?: number): Stop[]; /** * Finds stops by their geographic location using latitude and longitude. * * @param lat - The latitude of the location to search near. * @param lon - The longitude of the location to search near. * @param maxResults - The maximum number of results to return (default is 10). * @param radius - The search radius in kilometers (default is 0.5). * @returns An array of Stop objects that are closest to the specified location. */ findStopsByLocation(lat: number, lon: number, maxResults?: number, radius?: number): Stop[]; /** * Finds a stop by its internal ID. * * @param id - The internal ID of the stop to search for. * @returns The Stop object that matches the specified ID, or undefined if not found. */ findStopById(id: StopId): Stop | undefined; /** * Finds a stop by its ID in the transit data source (e.g. GTFS). * * @param id - The source ID of the stop to search for. * @returns The Stop object that matches the specified ID, or undefined if not found. */ findStopBySourceStopId(sourceStopId: SourceStopId): Stop | undefined; /** * Find ids of all sibling stops. */ equivalentStops(sourceId: SourceStopId): Stop[]; }