minotor
Version:
A lightweight client-side transit routing library.
59 lines (58 loc) • 2.54 kB
TypeScript
import { Stop } from '../stops/stops.js';
import { StopsIndex } from '../stops/stopsIndex.js';
import { GeneratedTransfers, TransferGenerator } from './generator.js';
export type StraightLineTransferGeneratorOptions = {
/**
* Maximum straight-line distance between two stops for a transfer to be generated, in meters.
*/
maxDistanceMeters?: number;
/**
* Assumed pedestrian walking speed, in kilometers per hour.
*/
walkingSpeedKmh?: number;
/**
* Multiplier applied to the straight-line distance to approximate the real
* walking path length. Use 1 to disable.
*/
detourFactor?: number;
/**
* Flat penalty, in minutes, added to every generated transfer to account for
* the general overhead of changing (orientation, walking through the
* station). Use 0 to disable.
*/
changePenaltyMinutes?: number;
};
/**
* A {@link TransferGenerator} that connects geographically close stops with
* virtual walking transfers.
*
* The transfer time is derived from the straight-line (great-circle / haversine)
* distance between two stops, scaled up by a detour factor to approximate the
* real walking path and divided by an assumed walking speed. This is a
* deliberately crude heuristic meant to fill in footpaths for feeds that
* under-specify `transfers.txt` (e.g. large interchanges where subway, tram and
* bus stops sit close together but are left unconnected).
*
* Generated transfers use {@link TransferTypes.REQUIRES_MINIMAL_TIME} so they
* are treated as walking connections by both the router's transfer step and
* its access/egress computation. Each origin is connected to its nearby stops
* with a single directed edge; the reverse edge is produced when the neighbor
* is itself visited as an origin.
*
* On top of the walking time, a flat `changePenaltyMinutes` is added for the
* general overhead of any change. It is symmetric, so the two directions of a
* transfer share the same minimum time.
*/
export declare class StraightLineTransferGenerator implements TransferGenerator {
private readonly maxDistanceMeters;
private readonly walkingSpeedKmh;
private readonly detourFactor;
private readonly changePenaltyMinutes;
constructor(options?: StraightLineTransferGeneratorOptions);
generate(originStops: Stop[], stops: StopsIndex): GeneratedTransfers;
private addTransfer;
/**
* Estimates the walking time between two coordinates, in whole minutes.
*/
private walkingDuration;
}