UNPKG

minotor

Version:

A lightweight client-side transit routing library.

76 lines (75 loc) 2.82 kB
import { SourceStopId, Stop, StopId } from './stops.js'; /** * The StopsIndex 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 stops; private readonly sourceStopsMap; private readonly textIndex; private readonly geoIndex; private readonly stopPoints; constructor(stops: Stop[]); /** * Deserializes a binary representation of the stops. * * @param data - The binary data to deserialize. * @returns The deserialized StopFinder. */ static fromData(data: Uint8Array): StopsIndex; /** * Serializes the stops into a binary protobuf. * * @returns 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(id: StopId): Stop[]; /** * Makes the StopsIndex iterable, allowing iteration over all stops. * * @returns An iterator for the stops. */ [Symbol.iterator](): Iterator<Stop>; }