minotor 7.0.2 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cspell.json +11 -1
- package/CHANGELOG.md +8 -3
- package/README.md +26 -24
- package/dist/cli.mjs +1243 -267
- package/dist/cli.mjs.map +1 -1
- package/dist/gtfs/transfers.d.ts +13 -4
- package/dist/gtfs/trips.d.ts +12 -7
- package/dist/parser.cjs.js +494 -71
- package/dist/parser.cjs.js.map +1 -1
- package/dist/parser.esm.js +494 -71
- package/dist/parser.esm.js.map +1 -1
- package/dist/router.cjs.js +1 -1
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +2 -2
- package/dist/router.esm.js +1 -1
- package/dist/router.esm.js.map +1 -1
- package/dist/router.umd.js +1 -1
- package/dist/router.umd.js.map +1 -1
- package/dist/routing/__tests__/plotter.test.d.ts +1 -0
- package/dist/routing/plotter.d.ts +42 -3
- package/dist/routing/result.d.ts +23 -7
- package/dist/routing/route.d.ts +2 -0
- package/dist/routing/router.d.ts +78 -19
- package/dist/timetable/__tests__/tripId.test.d.ts +1 -0
- package/dist/timetable/io.d.ts +4 -2
- package/dist/timetable/proto/timetable.d.ts +13 -1
- package/dist/timetable/route.d.ts +41 -8
- package/dist/timetable/timetable.d.ts +18 -3
- package/dist/timetable/tripId.d.ts +15 -0
- package/package.json +1 -1
- package/src/__e2e__/router.test.ts +114 -105
- package/src/__e2e__/timetable/stops.bin +2 -2
- package/src/__e2e__/timetable/timetable.bin +2 -2
- package/src/cli/repl.ts +259 -1
- package/src/gtfs/__tests__/transfers.test.ts +468 -12
- package/src/gtfs/__tests__/trips.test.ts +350 -28
- package/src/gtfs/parser.ts +16 -4
- package/src/gtfs/transfers.ts +61 -18
- package/src/gtfs/trips.ts +97 -22
- package/src/router.ts +2 -2
- package/src/routing/__tests__/plotter.test.ts +230 -0
- package/src/routing/__tests__/result.test.ts +486 -125
- package/src/routing/__tests__/route.test.ts +7 -3
- package/src/routing/__tests__/router.test.ts +378 -172
- package/src/routing/plotter.ts +279 -48
- package/src/routing/result.ts +114 -34
- package/src/routing/route.ts +0 -3
- package/src/routing/router.ts +332 -211
- package/src/timetable/__tests__/io.test.ts +33 -1
- package/src/timetable/__tests__/route.test.ts +10 -3
- package/src/timetable/__tests__/timetable.test.ts +225 -57
- package/src/timetable/__tests__/tripId.test.ts +27 -0
- package/src/timetable/io.ts +71 -10
- package/src/timetable/proto/timetable.proto +14 -2
- package/src/timetable/proto/timetable.ts +218 -20
- package/src/timetable/route.ts +152 -19
- package/src/timetable/timetable.ts +45 -6
- package/src/timetable/tripId.ts +29 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,11 +1,50 @@
|
|
|
1
1
|
import { Result } from './result.js';
|
|
2
2
|
export declare class Plotter {
|
|
3
3
|
private result;
|
|
4
|
+
private readonly ROUND_COLORS;
|
|
4
5
|
constructor(result: Result);
|
|
5
6
|
/**
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
* Gets the color for a round based on the specified palette.
|
|
8
|
+
*/
|
|
9
|
+
private getRoundColor;
|
|
10
|
+
/**
|
|
11
|
+
* Escapes special characters in DOT strings to prevent syntax errors.
|
|
12
|
+
*/
|
|
13
|
+
private escapeDotString;
|
|
14
|
+
/**
|
|
15
|
+
* Determines station type (origin/destination) information.
|
|
16
|
+
*/
|
|
17
|
+
private getStationInfo;
|
|
18
|
+
/**
|
|
19
|
+
* Formats a stop name for display, including platform information.
|
|
20
|
+
*/
|
|
21
|
+
private formatStopName;
|
|
22
|
+
/**
|
|
23
|
+
* Gets the appropriate fill color for a station based on its type.
|
|
24
|
+
*/
|
|
25
|
+
private getStationFillColor;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a DOT node for a station.
|
|
28
|
+
*/
|
|
29
|
+
private createStationNode;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a vehicle edge with route information oval in the middle.
|
|
32
|
+
*/
|
|
33
|
+
private createVehicleEdge;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a transfer edge with transfer information oval in the middle.
|
|
36
|
+
*/
|
|
37
|
+
private createTransferEdge;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a continuation edge to visually link trip continuations.
|
|
40
|
+
*/
|
|
41
|
+
private createContinuationEdge;
|
|
42
|
+
/**
|
|
43
|
+
* Collects all stations and edges for the graph.
|
|
44
|
+
*/
|
|
45
|
+
private collectGraphData;
|
|
46
|
+
/**
|
|
47
|
+
* Plots the routing graph as a DOT graph for visualization.
|
|
9
48
|
*/
|
|
10
49
|
plotDotGraph(): string;
|
|
11
50
|
}
|
package/dist/routing/result.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Timetable } from '../router.js';
|
|
2
|
+
import { SourceStopId } from '../stops/stops.js';
|
|
2
3
|
import { StopsIndex } from '../stops/stopsIndex.js';
|
|
3
4
|
import { Query } from './query.js';
|
|
4
5
|
import { Route } from './route.js';
|
|
5
|
-
import {
|
|
6
|
+
import { Arrival, RoutingState } from './router.js';
|
|
6
7
|
export declare class Result {
|
|
7
8
|
private readonly query;
|
|
8
|
-
readonly
|
|
9
|
-
readonly
|
|
10
|
-
|
|
11
|
-
constructor(query: Query,
|
|
9
|
+
readonly routingState: RoutingState;
|
|
10
|
+
readonly stopsIndex: StopsIndex;
|
|
11
|
+
readonly timetable: Timetable;
|
|
12
|
+
constructor(query: Query, routingState: RoutingState, stopsIndex: StopsIndex, timetable: Timetable);
|
|
12
13
|
/**
|
|
13
14
|
* Reconstructs the best route to a stop.
|
|
14
15
|
* (to any stop reachable in less time / transfers than the destination(s) of the query)
|
|
@@ -17,6 +18,21 @@ export declare class Result {
|
|
|
17
18
|
* @returns a route to the destination stop if it exists.
|
|
18
19
|
*/
|
|
19
20
|
bestRoute(to?: SourceStopId | Set<SourceStopId>): Route | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Builds a vehicle leg from a chain of vehicle edges.
|
|
23
|
+
*
|
|
24
|
+
* @param edges Array of vehicle edges representing continuous trips on transit vehicles
|
|
25
|
+
* @returns A vehicle leg with departure/arrival information and route details
|
|
26
|
+
* @throws Error if the edges array is empty
|
|
27
|
+
*/
|
|
28
|
+
private buildVehicleLeg;
|
|
29
|
+
/**
|
|
30
|
+
* Builds a transfer leg from a transfer edge.
|
|
31
|
+
*
|
|
32
|
+
* @param edge Transfer edge representing a walking connection between stops
|
|
33
|
+
* @returns A transfer leg with from/to stops and transfer details
|
|
34
|
+
*/
|
|
35
|
+
private buildTransferLeg;
|
|
20
36
|
/**
|
|
21
37
|
* Returns the arrival time at any stop reachable in less time / transfers than the destination(s) of the query)
|
|
22
38
|
*
|
|
@@ -24,5 +40,5 @@ export declare class Result {
|
|
|
24
40
|
* @param maxTransfers The optional maximum number of transfers allowed.
|
|
25
41
|
* @returns The arrival time if the target stop is reachable, otherwise undefined.
|
|
26
42
|
*/
|
|
27
|
-
arrivalAt(stop: SourceStopId, maxTransfers?: number):
|
|
43
|
+
arrivalAt(stop: SourceStopId, maxTransfers?: number): Arrival | undefined;
|
|
28
44
|
}
|
package/dist/routing/route.d.ts
CHANGED
package/dist/routing/router.d.ts
CHANGED
|
@@ -1,22 +1,43 @@
|
|
|
1
1
|
import { StopId } from '../stops/stops.js';
|
|
2
2
|
import { StopsIndex } from '../stops/stopsIndex.js';
|
|
3
|
+
import { Duration } from '../timetable/duration.js';
|
|
4
|
+
import { RouteId, TripRouteIndex } from '../timetable/route.js';
|
|
3
5
|
import { Time } from '../timetable/time.js';
|
|
4
|
-
import { Timetable } from '../timetable/timetable.js';
|
|
6
|
+
import { Timetable, TransferType } from '../timetable/timetable.js';
|
|
5
7
|
import { Query } from './query.js';
|
|
6
8
|
import { Result } from './result.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
export type OriginNode = {
|
|
10
|
+
arrival: Time;
|
|
11
|
+
};
|
|
12
|
+
export type VehicleEdge = {
|
|
13
|
+
arrival: Time;
|
|
14
|
+
from: StopId;
|
|
15
|
+
to: StopId;
|
|
16
|
+
routeId: RouteId;
|
|
17
|
+
tripIndex: TripRouteIndex;
|
|
18
|
+
continuationOf?: VehicleEdge;
|
|
19
|
+
};
|
|
20
|
+
export type TransferEdge = {
|
|
21
|
+
arrival: Time;
|
|
22
|
+
from: StopId;
|
|
23
|
+
to: StopId;
|
|
24
|
+
type: TransferType;
|
|
25
|
+
minTransferTime?: Duration;
|
|
10
26
|
};
|
|
11
|
-
export type
|
|
27
|
+
export type RoutingEdge = OriginNode | VehicleEdge | TransferEdge;
|
|
28
|
+
export type Arrival = {
|
|
12
29
|
arrival: Time;
|
|
13
30
|
legNumber: number;
|
|
14
|
-
|
|
31
|
+
};
|
|
32
|
+
export type RoutingState = {
|
|
33
|
+
earliestArrivals: Map<StopId, Arrival>;
|
|
34
|
+
graph: Map<StopId, RoutingEdge>[];
|
|
35
|
+
destinations: StopId[];
|
|
15
36
|
};
|
|
16
37
|
/**
|
|
17
|
-
* A public transportation
|
|
18
|
-
*
|
|
19
|
-
*
|
|
38
|
+
* A public transportation router implementing the RAPTOR algorithm.
|
|
39
|
+
* For more information on the RAPTOR algorithm,
|
|
40
|
+
* refer to its detailed explanation in the research paper:
|
|
20
41
|
* https://www.microsoft.com/en-us/research/wp-content/uploads/2012/01/raptor_alenex.pdf
|
|
21
42
|
*/
|
|
22
43
|
export declare class Router {
|
|
@@ -24,9 +45,54 @@ export declare class Router {
|
|
|
24
45
|
private readonly stopsIndex;
|
|
25
46
|
constructor(timetable: Timetable, stopsIndex: StopsIndex);
|
|
26
47
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
48
|
+
* The main Raptor algorithm implementation.
|
|
49
|
+
*
|
|
50
|
+
* @param query The query containing the main parameters for the routing.
|
|
51
|
+
* @returns A result object containing data structures allowing to reconstruct routes and .
|
|
52
|
+
*/
|
|
53
|
+
route(query: Query): Result;
|
|
54
|
+
/**
|
|
55
|
+
* Finds trip continuations for the given marked stops and edges at the current round.
|
|
56
|
+
* @param markedStops The set of marked stops.
|
|
57
|
+
* @param edgesAtCurrentRound The map of edges at the current round.
|
|
58
|
+
* @returns An array of trip continuations.
|
|
59
|
+
*/
|
|
60
|
+
private findTripContinuations;
|
|
61
|
+
/**
|
|
62
|
+
* Initializes the routing state for the RAPTOR algorithm.
|
|
63
|
+
*
|
|
64
|
+
* This method sets up the initial data structures needed for route planning,
|
|
65
|
+
* including origin and destination stops (considering equivalent stops),
|
|
66
|
+
* earliest arrival times, and marked stops for processing.
|
|
67
|
+
*
|
|
68
|
+
* @param query The routing query containing origin, destination, and departure time
|
|
69
|
+
* @returns The initialized routing state with all necessary data structures
|
|
70
|
+
*/
|
|
71
|
+
private initRoutingState;
|
|
72
|
+
/**
|
|
73
|
+
* Scans a route to find the earliest possible trips (if not provided) and updates arrival times.
|
|
74
|
+
*
|
|
75
|
+
* This method implements the core route scanning logic of the RAPTOR algorithm.
|
|
76
|
+
* It iterates through all stops on a given route starting from the hop-on stop,
|
|
77
|
+
* maintaining the current best trip and updating arrival times when improvements
|
|
78
|
+
* are found. The method also handles boarding new trips when earlier departures
|
|
79
|
+
* are available if no given trip is provided as a parameter.
|
|
80
|
+
*
|
|
81
|
+
* @param route The route to scan for possible trips
|
|
82
|
+
* @param hopOnStop The stop ID where passengers can board the route
|
|
83
|
+
* @param round The current round number in the RAPTOR algorithm
|
|
84
|
+
* @param routingState The current routing state containing arrival times and marked stops
|
|
85
|
+
*/
|
|
86
|
+
private scanRoute;
|
|
87
|
+
/**
|
|
88
|
+
* Processes all currently marked stops to find available transfers
|
|
89
|
+
* and determines if using these transfers would result in earlier arrival times
|
|
90
|
+
* at destination stops. It handles different transfer types including in-seat
|
|
91
|
+
* transfers and walking transfers with appropriate minimum transfer times.
|
|
92
|
+
*
|
|
93
|
+
* @param query The routing query containing transfer options and constraints
|
|
94
|
+
* @param round The current round number in the RAPTOR algorithm
|
|
95
|
+
* @param routingState The current routing state containing arrival times and marked stops
|
|
30
96
|
*/
|
|
31
97
|
private considerTransfers;
|
|
32
98
|
/**
|
|
@@ -37,11 +103,4 @@ export declare class Router {
|
|
|
37
103
|
* @returns The earliest arrival time among the provided destinations.
|
|
38
104
|
*/
|
|
39
105
|
private earliestArrivalAtAnyStop;
|
|
40
|
-
/**
|
|
41
|
-
* The main Raptor algorithm implementation.
|
|
42
|
-
*
|
|
43
|
-
* @param query The query containing the main parameters for the routing.
|
|
44
|
-
* @returns A result object containing data structures allowing to reconstruct routes and .
|
|
45
|
-
*/
|
|
46
|
-
route(query: Query): Result;
|
|
47
106
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/timetable/io.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Route as ProtoRoute, ServiceRoute as ProtoServiceRoute, StopAdjacency as ProtoStopAdjacency } from './proto/timetable.js';
|
|
1
|
+
import { Route as ProtoRoute, ServiceRoute as ProtoServiceRoute, StopAdjacency as ProtoStopAdjacency, TripContinuationEntry as ProtoTripContinuationEntry } from './proto/timetable.js';
|
|
2
2
|
import { Route } from './route.js';
|
|
3
|
-
import { ServiceRoute, ServiceRouteId, StopAdjacency } from './timetable.js';
|
|
3
|
+
import { ServiceRoute, ServiceRouteId, StopAdjacency, TripBoarding } from './timetable.js';
|
|
4
4
|
export type SerializedRoute = {
|
|
5
5
|
stopTimes: Uint16Array;
|
|
6
6
|
pickUpDropOffTypes: Uint8Array;
|
|
@@ -13,3 +13,5 @@ export declare const serializeServiceRoutesMap: (serviceRoutes: ServiceRoute[])
|
|
|
13
13
|
export declare const deserializeStopsAdjacency: (protoStopsAdjacency: ProtoStopAdjacency[]) => StopAdjacency[];
|
|
14
14
|
export declare const deserializeRoutesAdjacency: (protoRoutesAdjacency: ProtoRoute[]) => Route[];
|
|
15
15
|
export declare const deserializeServiceRoutesMap: (protoServiceRoutes: ProtoServiceRoute[]) => ServiceRoute[];
|
|
16
|
+
export declare const serializeTripContinuations: (tripContinuations: Map<number, TripBoarding[]>) => ProtoTripContinuationEntry[];
|
|
17
|
+
export declare const deserializeTripContinuations: (protoTripContinuations: ProtoTripContinuationEntry[]) => Map<number, TripBoarding[]>;
|
|
@@ -53,9 +53,19 @@ export interface Transfer {
|
|
|
53
53
|
type: TransferType;
|
|
54
54
|
minTransferTime?: number | undefined;
|
|
55
55
|
}
|
|
56
|
+
export interface TripBoarding {
|
|
57
|
+
hopOnStop: number;
|
|
58
|
+
routeId: number;
|
|
59
|
+
tripIndex: number;
|
|
60
|
+
}
|
|
61
|
+
export interface TripContinuationEntry {
|
|
62
|
+
key: number;
|
|
63
|
+
value: TripBoarding[];
|
|
64
|
+
}
|
|
56
65
|
export interface StopAdjacency {
|
|
57
|
-
transfers: Transfer[];
|
|
58
66
|
routes: number[];
|
|
67
|
+
transfers: Transfer[];
|
|
68
|
+
tripContinuations: TripContinuationEntry[];
|
|
59
69
|
}
|
|
60
70
|
export interface ServiceRoute {
|
|
61
71
|
type: RouteType;
|
|
@@ -70,6 +80,8 @@ export interface Timetable {
|
|
|
70
80
|
}
|
|
71
81
|
export declare const Route: MessageFns<Route>;
|
|
72
82
|
export declare const Transfer: MessageFns<Transfer>;
|
|
83
|
+
export declare const TripBoarding: MessageFns<TripBoarding>;
|
|
84
|
+
export declare const TripContinuationEntry: MessageFns<TripContinuationEntry>;
|
|
73
85
|
export declare const StopAdjacency: MessageFns<StopAdjacency>;
|
|
74
86
|
export declare const ServiceRoute: MessageFns<ServiceRoute>;
|
|
75
87
|
export declare const Timetable: MessageFns<Timetable>;
|
|
@@ -17,11 +17,13 @@ export declare const REGULAR = 0;
|
|
|
17
17
|
export declare const NOT_AVAILABLE = 1;
|
|
18
18
|
export declare const MUST_PHONE_AGENCY = 2;
|
|
19
19
|
export declare const MUST_COORDINATE_WITH_DRIVER = 3;
|
|
20
|
-
export type
|
|
20
|
+
export type TripRouteIndex = number;
|
|
21
|
+
export type StopRouteIndex = number;
|
|
21
22
|
/**
|
|
22
23
|
* A route identifies all trips of a given service route sharing the same list of stops.
|
|
23
24
|
*/
|
|
24
25
|
export declare class Route {
|
|
26
|
+
readonly id: RouteId;
|
|
25
27
|
/**
|
|
26
28
|
* Arrivals and departures encoded as minutes from midnight.
|
|
27
29
|
* Format: [arrival1, departure1, arrival2, departure2, etc.]
|
|
@@ -66,7 +68,26 @@ export declare class Route {
|
|
|
66
68
|
* The total number of trips in the route.
|
|
67
69
|
*/
|
|
68
70
|
private readonly nbTrips;
|
|
69
|
-
constructor(stopTimes: Uint16Array, pickUpDropOffTypes: Uint8Array, stops: Uint32Array, serviceRouteId: ServiceRouteId);
|
|
71
|
+
constructor(id: RouteId, stopTimes: Uint16Array, pickUpDropOffTypes: Uint8Array, stops: Uint32Array, serviceRouteId: ServiceRouteId);
|
|
72
|
+
/**
|
|
73
|
+
* Creates a new route from multiple trips with their stops.
|
|
74
|
+
*
|
|
75
|
+
* @param params The route parameters including ID, service route ID, and trips.
|
|
76
|
+
* @returns The new route.
|
|
77
|
+
*/
|
|
78
|
+
static of(params: {
|
|
79
|
+
id: RouteId;
|
|
80
|
+
serviceRouteId: ServiceRouteId;
|
|
81
|
+
trips: Array<{
|
|
82
|
+
stops: Array<{
|
|
83
|
+
id: StopId;
|
|
84
|
+
arrivalTime: Time;
|
|
85
|
+
departureTime: Time;
|
|
86
|
+
dropOffType?: number;
|
|
87
|
+
pickUpType?: number;
|
|
88
|
+
}>;
|
|
89
|
+
}>;
|
|
90
|
+
}): Route;
|
|
70
91
|
/**
|
|
71
92
|
* Serializes the Route into binary arrays.
|
|
72
93
|
*
|
|
@@ -87,6 +108,12 @@ export declare class Route {
|
|
|
87
108
|
* @returns The total number of stops in the route.
|
|
88
109
|
*/
|
|
89
110
|
getNbStops(): number;
|
|
111
|
+
/**
|
|
112
|
+
* Retrieves the number of trips in the route.
|
|
113
|
+
*
|
|
114
|
+
* @returns The total number of trips in the route.
|
|
115
|
+
*/
|
|
116
|
+
getNbTrips(): number;
|
|
90
117
|
/**
|
|
91
118
|
* Finds the ServiceRouteId of the route. It corresponds the identifier
|
|
92
119
|
* of the service shown to the end user as a route.
|
|
@@ -101,7 +128,7 @@ export declare class Route {
|
|
|
101
128
|
* @param tripIndex - The index of the trip.
|
|
102
129
|
* @returns The arrival time at the specified stop and trip as a Time object.
|
|
103
130
|
*/
|
|
104
|
-
arrivalAt(stopId: StopId, tripIndex:
|
|
131
|
+
arrivalAt(stopId: StopId, tripIndex: TripRouteIndex): Time;
|
|
105
132
|
/**
|
|
106
133
|
* Retrieves the departure time at a specific stop for a given trip.
|
|
107
134
|
*
|
|
@@ -109,7 +136,7 @@ export declare class Route {
|
|
|
109
136
|
* @param tripIndex - The index of the trip.
|
|
110
137
|
* @returns The departure time at the specified stop and trip as a Time object.
|
|
111
138
|
*/
|
|
112
|
-
departureFrom(stopId: StopId, tripIndex:
|
|
139
|
+
departureFrom(stopId: StopId, tripIndex: TripRouteIndex): Time;
|
|
113
140
|
/**
|
|
114
141
|
* Retrieves the pick-up type for a specific stop and trip.
|
|
115
142
|
*
|
|
@@ -117,7 +144,7 @@ export declare class Route {
|
|
|
117
144
|
* @param tripIndex - The index of the trip.
|
|
118
145
|
* @returns The pick-up type at the specified stop and trip.
|
|
119
146
|
*/
|
|
120
|
-
pickUpTypeFrom(stopId: StopId, tripIndex:
|
|
147
|
+
pickUpTypeFrom(stopId: StopId, tripIndex: TripRouteIndex): PickUpDropOffType;
|
|
121
148
|
/**
|
|
122
149
|
* Retrieves the drop-off type for a specific stop and trip.
|
|
123
150
|
*
|
|
@@ -125,7 +152,7 @@ export declare class Route {
|
|
|
125
152
|
* @param tripIndex - The index of the trip.
|
|
126
153
|
* @returns The drop-off type at the specified stop and trip.
|
|
127
154
|
*/
|
|
128
|
-
dropOffTypeAt(stopId: StopId, tripIndex:
|
|
155
|
+
dropOffTypeAt(stopId: StopId, tripIndex: TripRouteIndex): PickUpDropOffType;
|
|
129
156
|
/**
|
|
130
157
|
* Finds the earliest trip that can be taken from a specific stop on a given route,
|
|
131
158
|
* optionally constrained by a latest trip index and a time before which the trip
|
|
@@ -138,11 +165,17 @@ export declare class Route {
|
|
|
138
165
|
* If not provided, searches all available trips.
|
|
139
166
|
* @returns The index of the earliest trip meeting the criteria, or undefined if no such trip is found.
|
|
140
167
|
*/
|
|
141
|
-
findEarliestTrip(stopId: StopId, after?: Time, beforeTrip?:
|
|
168
|
+
findEarliestTrip(stopId: StopId, after?: Time, beforeTrip?: TripRouteIndex): TripRouteIndex | undefined;
|
|
142
169
|
/**
|
|
143
170
|
* Retrieves the index of a stop within the route.
|
|
144
171
|
* @param stopId The StopId of the stop to locate in the route.
|
|
145
172
|
* @returns The index of the stop in the route.
|
|
146
173
|
*/
|
|
147
|
-
|
|
174
|
+
stopRouteIndex(stopId: StopId): StopRouteIndex;
|
|
175
|
+
/**
|
|
176
|
+
* Retrieves the id of a stop at a given index in a route.
|
|
177
|
+
* @param stopRouteIndex The route index of the stop.
|
|
178
|
+
* @returns The id of the stop at the given index in the route.
|
|
179
|
+
*/
|
|
180
|
+
stopId(stopRouteIndex: StopRouteIndex): StopId;
|
|
148
181
|
}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import { StopId } from '../stops/stops.js';
|
|
2
2
|
import { Duration } from './duration.js';
|
|
3
|
-
import { Route, RouteId } from './route.js';
|
|
3
|
+
import { Route, RouteId, TripRouteIndex } from './route.js';
|
|
4
|
+
import { TripId } from './tripId.js';
|
|
4
5
|
export type TransferType = 'RECOMMENDED' | 'GUARANTEED' | 'REQUIRES_MINIMAL_TIME' | 'IN_SEAT';
|
|
5
6
|
export type Transfer = {
|
|
6
7
|
destination: StopId;
|
|
7
8
|
type: TransferType;
|
|
8
9
|
minTransferTime?: Duration;
|
|
9
10
|
};
|
|
11
|
+
export type TripBoarding = {
|
|
12
|
+
hopOnStop: StopId;
|
|
13
|
+
routeId: RouteId;
|
|
14
|
+
tripIndex: TripRouteIndex;
|
|
15
|
+
};
|
|
10
16
|
export type StopAdjacency = {
|
|
11
|
-
transfers
|
|
17
|
+
transfers?: Transfer[];
|
|
18
|
+
tripContinuations?: Map<TripId, TripBoarding[]>;
|
|
12
19
|
routes: RouteId[];
|
|
13
20
|
};
|
|
14
21
|
export type ServiceRouteId = number;
|
|
@@ -20,7 +27,7 @@ export type ServiceRoute = {
|
|
|
20
27
|
};
|
|
21
28
|
export type ServiceRouteInfo = Omit<ServiceRoute, 'routes'>;
|
|
22
29
|
export declare const ALL_TRANSPORT_MODES: Set<RouteType>;
|
|
23
|
-
export declare const CURRENT_VERSION = "0.0.
|
|
30
|
+
export declare const CURRENT_VERSION = "0.0.8";
|
|
24
31
|
/**
|
|
25
32
|
* The internal transit timetable format.
|
|
26
33
|
*/
|
|
@@ -67,6 +74,14 @@ export declare class Timetable {
|
|
|
67
74
|
* @returns An array of transfer options available at the stop.
|
|
68
75
|
*/
|
|
69
76
|
getTransfers(stopId: StopId): Transfer[];
|
|
77
|
+
/**
|
|
78
|
+
* Retrieves all trip continuation options available at the specified stop for a given trip.
|
|
79
|
+
*
|
|
80
|
+
* @param stopId - The ID of the stop to get trip continuations for.
|
|
81
|
+
* @param tripIndex - The index of the trip to get continuations for.
|
|
82
|
+
* @returns An array of trip continuation options available at the stop for the specified trip.
|
|
83
|
+
*/
|
|
84
|
+
getContinuousTrips(stopId: StopId, routeId: RouteId, tripIndex: TripRouteIndex): TripBoarding[];
|
|
70
85
|
/**
|
|
71
86
|
* Retrieves the service route associated with the given route.
|
|
72
87
|
* A service route refers to a collection of trips that are displayed
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RouteId, TripRouteIndex } from './route.js';
|
|
2
|
+
export type TripId = number;
|
|
3
|
+
/**
|
|
4
|
+
* Encodes a route ID and trip index into a single trip ID.
|
|
5
|
+
* @param routeId - The route identifier, needs to fit on 17 bits
|
|
6
|
+
* @param tripIndex - The index of the trip within the route, needs to fit on 15 bits
|
|
7
|
+
* @returns The encoded trip ID
|
|
8
|
+
*/
|
|
9
|
+
export declare const encode: (routeId: RouteId, tripIndex: TripRouteIndex) => TripId;
|
|
10
|
+
/**
|
|
11
|
+
* Decodes a trip ID back into its constituent route ID and trip index.
|
|
12
|
+
* @param tripId - The encoded trip ID
|
|
13
|
+
* @returns A tuple containing the route ID and trip index
|
|
14
|
+
*/
|
|
15
|
+
export declare const decode: (tripId: TripId) => [RouteId, TripRouteIndex];
|