minotor 11.5.2 → 12.0.1
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/CHANGELOG.md +3 -3
- package/README.md +1 -1
- package/dist/cli/perf.d.ts +15 -5
- package/dist/cli.mjs +139 -151
- package/dist/cli.mjs.map +1 -1
- package/dist/parser.cjs.js +37 -19
- package/dist/parser.cjs.js.map +1 -1
- package/dist/parser.esm.js +37 -19
- 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 +6 -5
- 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/route.d.ts +6 -9
- package/dist/routing/state.d.ts +2 -2
- package/dist/stops/stopsIndex.d.ts +1 -1
- package/dist/timetable/route.d.ts +7 -4
- package/package.json +2 -2
- package/src/__e2e__/router.test.ts +55 -56
- package/src/cli/minotor.ts +19 -2
- package/src/cli/perf.ts +94 -107
- package/src/cli/repl.ts +9 -5
- package/src/router.ts +21 -8
- package/src/routing/__tests__/plainRouter.test.ts +2 -2
- package/src/routing/__tests__/result.test.ts +1 -1
- package/src/routing/__tests__/route.test.ts +8 -7
- package/src/routing/__tests__/router.test.ts +21 -1
- package/src/routing/__tests__/state.test.ts +29 -0
- package/src/routing/result.ts +11 -45
- package/src/routing/route.ts +11 -13
- package/src/routing/state.ts +11 -3
- package/src/stops/__tests__/stopFinder.test.ts +13 -0
- package/src/stops/stopsIndex.ts +13 -19
- package/src/timetable/__tests__/io.test.ts +27 -0
- package/src/timetable/__tests__/route.test.ts +30 -0
- package/src/timetable/io.ts +15 -1
- package/src/timetable/route.ts +40 -12
- package/src/timetable/timetable.ts +1 -1
package/dist/routing/route.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { Stop } from '../stops/stops.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { PickUpDropOffType } from '../timetable/route.js';
|
|
3
3
|
import { Duration, Time } from '../timetable/time.js';
|
|
4
|
-
import type {
|
|
5
|
-
export type ServiceRouteInfo
|
|
6
|
-
type: RouteTypeString;
|
|
7
|
-
name: string;
|
|
8
|
-
};
|
|
4
|
+
import type { ServiceRouteInfo, TransferType } from '../timetable/timetable.js';
|
|
5
|
+
export type { ServiceRouteInfo } from '../timetable/timetable.js';
|
|
9
6
|
export type BaseLeg = {
|
|
10
7
|
from: Stop;
|
|
11
8
|
to: Stop;
|
|
@@ -15,14 +12,14 @@ export type Access = BaseLeg & {
|
|
|
15
12
|
};
|
|
16
13
|
export type Transfer = BaseLeg & {
|
|
17
14
|
minTransferTime?: Duration;
|
|
18
|
-
type:
|
|
15
|
+
type: TransferType;
|
|
19
16
|
};
|
|
20
17
|
export type VehicleLeg = BaseLeg & {
|
|
21
18
|
route: ServiceRouteInfo;
|
|
22
19
|
departureTime: Time;
|
|
23
20
|
arrivalTime: Time;
|
|
24
|
-
pickUpType:
|
|
25
|
-
dropOffType:
|
|
21
|
+
pickUpType: PickUpDropOffType;
|
|
22
|
+
dropOffType: PickUpDropOffType;
|
|
26
23
|
};
|
|
27
24
|
export type Leg = Transfer | Access | VehicleLeg;
|
|
28
25
|
/**
|
package/dist/routing/state.d.ts
CHANGED
|
@@ -87,8 +87,8 @@ export declare class RoutingState implements IRaptorState {
|
|
|
87
87
|
*/
|
|
88
88
|
private readonly maxDuration?;
|
|
89
89
|
/**
|
|
90
|
-
* Every stop
|
|
91
|
-
*
|
|
90
|
+
* Every stop reached during the current run, recorded once in first-reached
|
|
91
|
+
* order. Used by {@link resetFor} to clear
|
|
92
92
|
* only the touched entries instead of scanning the entire array.
|
|
93
93
|
*/
|
|
94
94
|
private readonly reachedStops;
|
|
@@ -9,7 +9,7 @@ export declare class StopsIndex {
|
|
|
9
9
|
private readonly sourceStopsMap;
|
|
10
10
|
private readonly textIndex;
|
|
11
11
|
private readonly geoIndex;
|
|
12
|
-
private readonly
|
|
12
|
+
private readonly geoStopIds;
|
|
13
13
|
constructor(stops: Stop[]);
|
|
14
14
|
/**
|
|
15
15
|
* Deserializes a binary representation of the stops.
|
|
@@ -17,7 +17,8 @@ export declare const PickUpDropOffTypes: {
|
|
|
17
17
|
};
|
|
18
18
|
export type PickUpDropOffType = (typeof PickUpDropOffTypes)[keyof typeof PickUpDropOffTypes];
|
|
19
19
|
export type PickUpDropOffTypeString = keyof typeof PickUpDropOffTypes;
|
|
20
|
-
|
|
20
|
+
/** Returns the identifier name for a pickup/drop-off type. */
|
|
21
|
+
export declare const pickUpDropOffTypeToString: (type: PickUpDropOffType) => PickUpDropOffTypeString;
|
|
21
22
|
export type TripRouteIndex = number;
|
|
22
23
|
export type StopRouteIndex = number;
|
|
23
24
|
/**
|
|
@@ -156,7 +157,7 @@ export declare class Route {
|
|
|
156
157
|
* @param offset - Precomputed value from {@link tripStopOffset}.
|
|
157
158
|
* @returns The drop-off type at the specified stop.
|
|
158
159
|
*/
|
|
159
|
-
dropOffTypeAtOffset(stopIndex: StopRouteIndex, offset: number):
|
|
160
|
+
dropOffTypeAtOffset(stopIndex: StopRouteIndex, offset: number): PickUpDropOffType;
|
|
160
161
|
/**
|
|
161
162
|
* Retrieves the departure time at a specific stop for a given trip.
|
|
162
163
|
*
|
|
@@ -172,7 +173,7 @@ export declare class Route {
|
|
|
172
173
|
* @param tripIndex - The index of the trip.
|
|
173
174
|
* @returns The pick-up type at the specified stop and trip.
|
|
174
175
|
*/
|
|
175
|
-
pickUpTypeFrom(stopIndex: StopRouteIndex, tripIndex: TripRouteIndex):
|
|
176
|
+
pickUpTypeFrom(stopIndex: StopRouteIndex, tripIndex: TripRouteIndex): PickUpDropOffType;
|
|
176
177
|
/**
|
|
177
178
|
* Retrieves the drop-off type for a specific stop and trip.
|
|
178
179
|
*
|
|
@@ -180,7 +181,7 @@ export declare class Route {
|
|
|
180
181
|
* @param tripIndex - The index of the trip.
|
|
181
182
|
* @returns The drop-off type at the specified stop and trip.
|
|
182
183
|
*/
|
|
183
|
-
dropOffTypeAt(stopIndex: StopRouteIndex, tripIndex: TripRouteIndex):
|
|
184
|
+
dropOffTypeAt(stopIndex: StopRouteIndex, tripIndex: TripRouteIndex): PickUpDropOffType;
|
|
184
185
|
/**
|
|
185
186
|
* Finds the earliest trip that can be taken from a specific stop on a given route,
|
|
186
187
|
* optionally constrained by a latest trip index and a time before which the trip
|
|
@@ -200,6 +201,8 @@ export declare class Route {
|
|
|
200
201
|
* @returns An array of indices where the stop appears in the route, or an empty array if the stop is not found.
|
|
201
202
|
*/
|
|
202
203
|
stopRouteIndices(stopId: StopId): StopRouteIndex[];
|
|
204
|
+
/** Returns the first occurrence without allocating an array. */
|
|
205
|
+
firstStopRouteIndex(stopId: StopId): StopRouteIndex | undefined;
|
|
203
206
|
/**
|
|
204
207
|
* Retrieves the id of a stop at a given index in a route.
|
|
205
208
|
* @param stopRouteIndex The route index of the stop.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "minotor",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.1",
|
|
4
4
|
"description": "A lightweight client-side transit routing library.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"minotor",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"format": "prettier --write .",
|
|
66
66
|
"test": "tsx --test src/**/__tests__/*.test.ts",
|
|
67
67
|
"e2e": "tsx --test src/__e2e__/*.test.ts",
|
|
68
|
-
"perf": "tsx src/cli/minotor perf -s src/__e2e__/timetable/stops.bin -t src/__e2e__/timetable/timetable.bin src/__e2e__/benchmark.json",
|
|
68
|
+
"perf": "node --expose-gc --import tsx src/cli/minotor perf -s src/__e2e__/timetable/stops.bin -t src/__e2e__/timetable/timetable.bin src/__e2e__/benchmark.json",
|
|
69
69
|
"repl": "tsx src/cli/minotor repl -s src/__e2e__/timetable/stops.bin -t src/__e2e__/timetable/timetable.bin",
|
|
70
70
|
"test:watch": "tsx --watch --test src/**/*.test.ts",
|
|
71
71
|
"test:coverage": "c8 -x 'src/**/proto/**/*.ts' -x 'src/**/__tests__/*.ts' --check-coverage --lines=85 tsx --test src/**/__tests__/*.test.ts",
|
|
@@ -3,18 +3,17 @@ import { describe, it } from 'node:test';
|
|
|
3
3
|
|
|
4
4
|
import fs from 'fs';
|
|
5
5
|
|
|
6
|
-
import type {
|
|
7
|
-
ServiceRouteInfo,
|
|
8
|
-
TransferType as TransferTypeString,
|
|
9
|
-
} from '../router.js';
|
|
6
|
+
import type { ServiceRouteInfo, TransferType } from '../router.js';
|
|
10
7
|
import {
|
|
11
8
|
Query,
|
|
12
9
|
RangeQuery,
|
|
13
10
|
Route,
|
|
14
11
|
Router,
|
|
12
|
+
RouteTypes,
|
|
15
13
|
Stop,
|
|
16
14
|
StopsIndex,
|
|
17
15
|
Timetable,
|
|
16
|
+
TransferTypes,
|
|
18
17
|
} from '../router.js';
|
|
19
18
|
import { timeFromString, timeToString } from '../timetable/time.js';
|
|
20
19
|
|
|
@@ -31,7 +30,7 @@ type ExpectedVehicleLeg = {
|
|
|
31
30
|
type ExpectedTransferLeg = {
|
|
32
31
|
from: StopRef;
|
|
33
32
|
to: StopRef;
|
|
34
|
-
type:
|
|
33
|
+
type: TransferType;
|
|
35
34
|
minTransferTime?: number;
|
|
36
35
|
};
|
|
37
36
|
|
|
@@ -121,12 +120,12 @@ const pointRoutes: {
|
|
|
121
120
|
to: { name: 'Bulle', platform: '2' },
|
|
122
121
|
departure: '08:34',
|
|
123
122
|
arrival: '09:10',
|
|
124
|
-
route: { type:
|
|
123
|
+
route: { type: RouteTypes.RAIL, name: 'RE2' },
|
|
125
124
|
},
|
|
126
125
|
{
|
|
127
126
|
from: { name: 'Bulle', platform: '2' },
|
|
128
127
|
to: { name: 'Bulle', platform: '4' },
|
|
129
|
-
type:
|
|
128
|
+
type: TransferTypes.REQUIRES_MINIMAL_TIME,
|
|
130
129
|
minTransferTime: 3,
|
|
131
130
|
},
|
|
132
131
|
{
|
|
@@ -134,12 +133,12 @@ const pointRoutes: {
|
|
|
134
133
|
to: { name: 'Gruyères', platform: '1' },
|
|
135
134
|
departure: '09:20',
|
|
136
135
|
arrival: '09:28',
|
|
137
|
-
route: { type:
|
|
136
|
+
route: { type: RouteTypes.RAIL, name: 'S51' },
|
|
138
137
|
},
|
|
139
138
|
{
|
|
140
139
|
from: { name: 'Gruyères', platform: '1' },
|
|
141
140
|
to: { name: 'Gruyères, gare', platform: 'B' },
|
|
142
|
-
type:
|
|
141
|
+
type: TransferTypes.REQUIRES_MINIMAL_TIME,
|
|
143
142
|
minTransferTime: 2,
|
|
144
143
|
},
|
|
145
144
|
{
|
|
@@ -147,7 +146,7 @@ const pointRoutes: {
|
|
|
147
146
|
to: { name: 'Moléson-sur-Gruyères' },
|
|
148
147
|
departure: '09:33',
|
|
149
148
|
arrival: '09:44',
|
|
150
|
-
route: { type:
|
|
149
|
+
route: { type: RouteTypes.BUS, name: '263' },
|
|
151
150
|
},
|
|
152
151
|
],
|
|
153
152
|
},
|
|
@@ -161,12 +160,12 @@ const pointRoutes: {
|
|
|
161
160
|
to: { name: 'Zürich HB', platform: '33' },
|
|
162
161
|
departure: '12:31',
|
|
163
162
|
arrival: '13:28',
|
|
164
|
-
route: { type:
|
|
163
|
+
route: { type: RouteTypes.RAIL, name: 'IC1' },
|
|
165
164
|
},
|
|
166
165
|
{
|
|
167
166
|
from: { name: 'Zürich HB', platform: '33' },
|
|
168
167
|
to: { name: 'Zürich HB', platform: '6' },
|
|
169
|
-
type:
|
|
168
|
+
type: TransferTypes.REQUIRES_MINIMAL_TIME,
|
|
170
169
|
minTransferTime: 7,
|
|
171
170
|
},
|
|
172
171
|
{
|
|
@@ -174,12 +173,12 @@ const pointRoutes: {
|
|
|
174
173
|
to: { name: 'Chur', platform: '9' },
|
|
175
174
|
departure: '13:38',
|
|
176
175
|
arrival: '14:52',
|
|
177
|
-
route: { type:
|
|
176
|
+
route: { type: RouteTypes.RAIL, name: 'IC3' },
|
|
178
177
|
},
|
|
179
178
|
{
|
|
180
179
|
from: { name: 'Chur', platform: '9' },
|
|
181
180
|
to: { name: 'Chur', platform: '10' },
|
|
182
|
-
type:
|
|
181
|
+
type: TransferTypes.REQUIRES_MINIMAL_TIME,
|
|
183
182
|
minTransferTime: 3,
|
|
184
183
|
},
|
|
185
184
|
{
|
|
@@ -187,7 +186,7 @@ const pointRoutes: {
|
|
|
187
186
|
to: { name: 'St. Moritz', platform: '1' },
|
|
188
187
|
departure: '14:58',
|
|
189
188
|
arrival: '16:55',
|
|
190
|
-
route: { type:
|
|
189
|
+
route: { type: RouteTypes.RAIL, name: 'IR38' },
|
|
191
190
|
},
|
|
192
191
|
],
|
|
193
192
|
},
|
|
@@ -201,14 +200,14 @@ const pointRoutes: {
|
|
|
201
200
|
to: { name: 'Saint-Louis (Haut-Rhin)' },
|
|
202
201
|
departure: '17:08',
|
|
203
202
|
arrival: '17:16',
|
|
204
|
-
route: { type:
|
|
203
|
+
route: { type: RouteTypes.RAIL, name: 'TER' },
|
|
205
204
|
},
|
|
206
205
|
{
|
|
207
206
|
from: { name: 'Saint-Louis (Haut-Rhin)' },
|
|
208
207
|
to: { name: 'Strasbourg' },
|
|
209
208
|
departure: '17:30',
|
|
210
209
|
arrival: '18:39',
|
|
211
|
-
route: { type:
|
|
210
|
+
route: { type: RouteTypes.RAIL, name: 'K200' },
|
|
212
211
|
},
|
|
213
212
|
],
|
|
214
213
|
},
|
|
@@ -222,12 +221,12 @@ const pointRoutes: {
|
|
|
222
221
|
to: { name: 'Bern', platform: '10' },
|
|
223
222
|
departure: '08:33',
|
|
224
223
|
arrival: '08:56',
|
|
225
|
-
route: { type:
|
|
224
|
+
route: { type: RouteTypes.RAIL, name: 'IR15' },
|
|
226
225
|
},
|
|
227
226
|
{
|
|
228
227
|
from: { name: 'Bern', platform: '10' },
|
|
229
228
|
to: { name: 'Bern', platform: '2' },
|
|
230
|
-
type:
|
|
229
|
+
type: TransferTypes.REQUIRES_MINIMAL_TIME,
|
|
231
230
|
minTransferTime: 6,
|
|
232
231
|
},
|
|
233
232
|
{
|
|
@@ -235,12 +234,12 @@ const pointRoutes: {
|
|
|
235
234
|
to: { name: 'Zürich HB', platform: '34' },
|
|
236
235
|
departure: '09:02',
|
|
237
236
|
arrival: '09:58',
|
|
238
|
-
route: { type:
|
|
237
|
+
route: { type: RouteTypes.RAIL, name: 'IC81' },
|
|
239
238
|
},
|
|
240
239
|
{
|
|
241
240
|
from: { name: 'Zürich HB', platform: '34' },
|
|
242
241
|
to: { name: 'Zürich HB', platform: '10' },
|
|
243
|
-
type:
|
|
242
|
+
type: TransferTypes.REQUIRES_MINIMAL_TIME,
|
|
244
243
|
minTransferTime: 7,
|
|
245
244
|
},
|
|
246
245
|
{
|
|
@@ -248,12 +247,12 @@ const pointRoutes: {
|
|
|
248
247
|
to: { name: 'Landquart', platform: '2' },
|
|
249
248
|
departure: '10:07',
|
|
250
249
|
arrival: '11:11',
|
|
251
|
-
route: { type:
|
|
250
|
+
route: { type: RouteTypes.RAIL, name: 'IC3' },
|
|
252
251
|
},
|
|
253
252
|
{
|
|
254
253
|
from: { name: 'Landquart', platform: '2' },
|
|
255
254
|
to: { name: 'Landquart', platform: '6' },
|
|
256
|
-
type:
|
|
255
|
+
type: TransferTypes.REQUIRES_MINIMAL_TIME,
|
|
257
256
|
minTransferTime: 4,
|
|
258
257
|
},
|
|
259
258
|
{
|
|
@@ -261,7 +260,7 @@ const pointRoutes: {
|
|
|
261
260
|
to: { name: 'Davos Platz', platform: '2' },
|
|
262
261
|
departure: '11:20',
|
|
263
262
|
arrival: '12:27',
|
|
264
|
-
route: { type:
|
|
263
|
+
route: { type: RouteTypes.RAIL, name: 'RE13' },
|
|
265
264
|
},
|
|
266
265
|
],
|
|
267
266
|
},
|
|
@@ -275,12 +274,12 @@ const pointRoutes: {
|
|
|
275
274
|
to: { name: 'Bulle', platform: '2' },
|
|
276
275
|
departure: '09:04',
|
|
277
276
|
arrival: '09:40',
|
|
278
|
-
route: { type:
|
|
277
|
+
route: { type: RouteTypes.RAIL, name: 'RE3' },
|
|
279
278
|
},
|
|
280
279
|
{
|
|
281
280
|
from: { name: 'Bulle', platform: '2' },
|
|
282
281
|
to: { name: 'Bulle', platform: '4' },
|
|
283
|
-
type:
|
|
282
|
+
type: TransferTypes.REQUIRES_MINIMAL_TIME,
|
|
284
283
|
minTransferTime: 3,
|
|
285
284
|
},
|
|
286
285
|
{
|
|
@@ -288,12 +287,12 @@ const pointRoutes: {
|
|
|
288
287
|
to: { name: 'Gruyères', platform: '2' },
|
|
289
288
|
departure: '09:50',
|
|
290
289
|
arrival: '09:57',
|
|
291
|
-
route: { type:
|
|
290
|
+
route: { type: RouteTypes.RAIL, name: 'S50' },
|
|
292
291
|
},
|
|
293
292
|
{
|
|
294
293
|
from: { name: 'Gruyères', platform: '2' },
|
|
295
294
|
to: { name: 'Gruyères, gare', platform: 'B' },
|
|
296
|
-
type:
|
|
295
|
+
type: TransferTypes.REQUIRES_MINIMAL_TIME,
|
|
297
296
|
minTransferTime: 2,
|
|
298
297
|
},
|
|
299
298
|
{
|
|
@@ -301,12 +300,12 @@ const pointRoutes: {
|
|
|
301
300
|
to: { name: 'Moléson-sur-Gruyères' },
|
|
302
301
|
departure: '10:33',
|
|
303
302
|
arrival: '10:44',
|
|
304
|
-
route: { type:
|
|
303
|
+
route: { type: RouteTypes.BUS, name: '263' },
|
|
305
304
|
},
|
|
306
305
|
{
|
|
307
306
|
from: { name: 'Moléson-sur-Gruyères' },
|
|
308
307
|
to: { name: 'Moléson-sur-Gruyères (funi)' },
|
|
309
|
-
type:
|
|
308
|
+
type: TransferTypes.REQUIRES_MINIMAL_TIME,
|
|
310
309
|
minTransferTime: 2,
|
|
311
310
|
},
|
|
312
311
|
{
|
|
@@ -314,7 +313,7 @@ const pointRoutes: {
|
|
|
314
313
|
to: { name: 'Plan-Francey' },
|
|
315
314
|
departure: '11:00',
|
|
316
315
|
arrival: '11:05',
|
|
317
|
-
route: { type:
|
|
316
|
+
route: { type: RouteTypes.FUNICULAR, name: 'FUN' },
|
|
318
317
|
},
|
|
319
318
|
],
|
|
320
319
|
},
|
|
@@ -342,12 +341,12 @@ const rangeRoutes: {
|
|
|
342
341
|
to: { name: 'Bulle', platform: '2' },
|
|
343
342
|
departure: '09:34',
|
|
344
343
|
arrival: '10:10',
|
|
345
|
-
route: { type:
|
|
344
|
+
route: { type: RouteTypes.RAIL, name: 'RE2' },
|
|
346
345
|
},
|
|
347
346
|
{
|
|
348
347
|
from: { name: 'Bulle', platform: '2' },
|
|
349
348
|
to: { name: 'Bulle', platform: '4' },
|
|
350
|
-
type:
|
|
349
|
+
type: TransferTypes.REQUIRES_MINIMAL_TIME,
|
|
351
350
|
minTransferTime: 3,
|
|
352
351
|
},
|
|
353
352
|
{
|
|
@@ -355,12 +354,12 @@ const rangeRoutes: {
|
|
|
355
354
|
to: { name: 'Gruyères', platform: '1' },
|
|
356
355
|
departure: '10:20',
|
|
357
356
|
arrival: '10:28',
|
|
358
|
-
route: { type:
|
|
357
|
+
route: { type: RouteTypes.RAIL, name: 'S51' },
|
|
359
358
|
},
|
|
360
359
|
{
|
|
361
360
|
from: { name: 'Gruyères', platform: '1' },
|
|
362
361
|
to: { name: 'Gruyères, gare', platform: 'B' },
|
|
363
|
-
type:
|
|
362
|
+
type: TransferTypes.REQUIRES_MINIMAL_TIME,
|
|
364
363
|
minTransferTime: 2,
|
|
365
364
|
},
|
|
366
365
|
{
|
|
@@ -368,7 +367,7 @@ const rangeRoutes: {
|
|
|
368
367
|
to: { name: 'Moléson-sur-Gruyères' },
|
|
369
368
|
departure: '10:33',
|
|
370
369
|
arrival: '10:44',
|
|
371
|
-
route: { type:
|
|
370
|
+
route: { type: RouteTypes.BUS, name: '263' },
|
|
372
371
|
},
|
|
373
372
|
],
|
|
374
373
|
},
|
|
@@ -380,12 +379,12 @@ const rangeRoutes: {
|
|
|
380
379
|
to: { name: 'Bulle', platform: '2' },
|
|
381
380
|
departure: '08:34',
|
|
382
381
|
arrival: '09:10',
|
|
383
|
-
route: { type:
|
|
382
|
+
route: { type: RouteTypes.RAIL, name: 'RE2' },
|
|
384
383
|
},
|
|
385
384
|
{
|
|
386
385
|
from: { name: 'Bulle', platform: '2' },
|
|
387
386
|
to: { name: 'Bulle', platform: '4' },
|
|
388
|
-
type:
|
|
387
|
+
type: TransferTypes.REQUIRES_MINIMAL_TIME,
|
|
389
388
|
minTransferTime: 3,
|
|
390
389
|
},
|
|
391
390
|
{
|
|
@@ -393,12 +392,12 @@ const rangeRoutes: {
|
|
|
393
392
|
to: { name: 'Gruyères', platform: '1' },
|
|
394
393
|
departure: '09:20',
|
|
395
394
|
arrival: '09:28',
|
|
396
|
-
route: { type:
|
|
395
|
+
route: { type: RouteTypes.RAIL, name: 'S51' },
|
|
397
396
|
},
|
|
398
397
|
{
|
|
399
398
|
from: { name: 'Gruyères', platform: '1' },
|
|
400
399
|
to: { name: 'Gruyères, gare', platform: 'B' },
|
|
401
|
-
type:
|
|
400
|
+
type: TransferTypes.REQUIRES_MINIMAL_TIME,
|
|
402
401
|
minTransferTime: 2,
|
|
403
402
|
},
|
|
404
403
|
{
|
|
@@ -406,7 +405,7 @@ const rangeRoutes: {
|
|
|
406
405
|
to: { name: 'Moléson-sur-Gruyères' },
|
|
407
406
|
departure: '09:33',
|
|
408
407
|
arrival: '09:44',
|
|
409
|
-
route: { type:
|
|
408
|
+
route: { type: RouteTypes.BUS, name: '263' },
|
|
410
409
|
},
|
|
411
410
|
],
|
|
412
411
|
},
|
|
@@ -426,7 +425,7 @@ const rangeRoutes: {
|
|
|
426
425
|
to: { name: 'Strasbourg' },
|
|
427
426
|
departure: '17:21',
|
|
428
427
|
arrival: '18:39',
|
|
429
|
-
route: { type:
|
|
428
|
+
route: { type: RouteTypes.RAIL, name: 'TER' },
|
|
430
429
|
},
|
|
431
430
|
],
|
|
432
431
|
},
|
|
@@ -438,14 +437,14 @@ const rangeRoutes: {
|
|
|
438
437
|
to: { name: 'Saint-Louis (Haut-Rhin)' },
|
|
439
438
|
departure: '16:38',
|
|
440
439
|
arrival: '16:46',
|
|
441
|
-
route: { type:
|
|
440
|
+
route: { type: RouteTypes.RAIL, name: 'TER' },
|
|
442
441
|
},
|
|
443
442
|
{
|
|
444
443
|
from: { name: 'Saint-Louis (Haut-Rhin)' },
|
|
445
444
|
to: { name: 'Strasbourg' },
|
|
446
445
|
departure: '16:54',
|
|
447
446
|
arrival: '18:09',
|
|
448
|
-
route: { type:
|
|
447
|
+
route: { type: RouteTypes.RAIL, name: 'K200' },
|
|
449
448
|
},
|
|
450
449
|
],
|
|
451
450
|
},
|
|
@@ -465,12 +464,12 @@ const rangeRoutes: {
|
|
|
465
464
|
to: { name: 'Bern', platform: '10' },
|
|
466
465
|
departure: '08:33',
|
|
467
466
|
arrival: '08:56',
|
|
468
|
-
route: { type:
|
|
467
|
+
route: { type: RouteTypes.RAIL, name: 'IR15' },
|
|
469
468
|
},
|
|
470
469
|
{
|
|
471
470
|
from: { name: 'Bern', platform: '10' },
|
|
472
471
|
to: { name: 'Bern', platform: '2' },
|
|
473
|
-
type:
|
|
472
|
+
type: TransferTypes.REQUIRES_MINIMAL_TIME,
|
|
474
473
|
minTransferTime: 6,
|
|
475
474
|
},
|
|
476
475
|
{
|
|
@@ -478,12 +477,12 @@ const rangeRoutes: {
|
|
|
478
477
|
to: { name: 'Zürich HB', platform: '34' },
|
|
479
478
|
departure: '09:02',
|
|
480
479
|
arrival: '09:58',
|
|
481
|
-
route: { type:
|
|
480
|
+
route: { type: RouteTypes.RAIL, name: 'IC81' },
|
|
482
481
|
},
|
|
483
482
|
{
|
|
484
483
|
from: { name: 'Zürich HB', platform: '34' },
|
|
485
484
|
to: { name: 'Zürich HB', platform: '10' },
|
|
486
|
-
type:
|
|
485
|
+
type: TransferTypes.REQUIRES_MINIMAL_TIME,
|
|
487
486
|
minTransferTime: 7,
|
|
488
487
|
},
|
|
489
488
|
{
|
|
@@ -491,12 +490,12 @@ const rangeRoutes: {
|
|
|
491
490
|
to: { name: 'Landquart', platform: '2' },
|
|
492
491
|
departure: '10:07',
|
|
493
492
|
arrival: '11:11',
|
|
494
|
-
route: { type:
|
|
493
|
+
route: { type: RouteTypes.RAIL, name: 'IC3' },
|
|
495
494
|
},
|
|
496
495
|
{
|
|
497
496
|
from: { name: 'Landquart', platform: '2' },
|
|
498
497
|
to: { name: 'Landquart', platform: '6' },
|
|
499
|
-
type:
|
|
498
|
+
type: TransferTypes.REQUIRES_MINIMAL_TIME,
|
|
500
499
|
minTransferTime: 4,
|
|
501
500
|
},
|
|
502
501
|
{
|
|
@@ -504,7 +503,7 @@ const rangeRoutes: {
|
|
|
504
503
|
to: { name: 'Davos Platz', platform: '2' },
|
|
505
504
|
departure: '11:20',
|
|
506
505
|
arrival: '12:27',
|
|
507
|
-
route: { type:
|
|
506
|
+
route: { type: RouteTypes.RAIL, name: 'RE13' },
|
|
508
507
|
},
|
|
509
508
|
],
|
|
510
509
|
},
|
|
@@ -516,12 +515,12 @@ const rangeRoutes: {
|
|
|
516
515
|
to: { name: 'Zürich HB', platform: '33' },
|
|
517
516
|
departure: '08:03',
|
|
518
517
|
arrival: '09:28',
|
|
519
|
-
route: { type:
|
|
518
|
+
route: { type: RouteTypes.RAIL, name: 'IC1' },
|
|
520
519
|
},
|
|
521
520
|
{
|
|
522
521
|
from: { name: 'Zürich HB', platform: '33' },
|
|
523
522
|
to: { name: 'Zürich HB', platform: '4' },
|
|
524
|
-
type:
|
|
523
|
+
type: TransferTypes.REQUIRES_MINIMAL_TIME,
|
|
525
524
|
minTransferTime: 7,
|
|
526
525
|
},
|
|
527
526
|
{
|
|
@@ -529,12 +528,12 @@ const rangeRoutes: {
|
|
|
529
528
|
to: { name: 'Landquart', platform: '2' },
|
|
530
529
|
departure: '09:38',
|
|
531
530
|
arrival: '10:41',
|
|
532
|
-
route: { type:
|
|
531
|
+
route: { type: RouteTypes.RAIL, name: 'IC3' },
|
|
533
532
|
},
|
|
534
533
|
{
|
|
535
534
|
from: { name: 'Landquart', platform: '2' },
|
|
536
535
|
to: { name: 'Landquart', platform: '6' },
|
|
537
|
-
type:
|
|
536
|
+
type: TransferTypes.REQUIRES_MINIMAL_TIME,
|
|
538
537
|
minTransferTime: 4,
|
|
539
538
|
},
|
|
540
539
|
{
|
|
@@ -542,7 +541,7 @@ const rangeRoutes: {
|
|
|
542
541
|
to: { name: 'Davos Platz', platform: '1' },
|
|
543
542
|
departure: '10:49',
|
|
544
543
|
arrival: '12:03',
|
|
545
|
-
route: { type:
|
|
544
|
+
route: { type: RouteTypes.RAIL, name: 'RE24' },
|
|
546
545
|
},
|
|
547
546
|
],
|
|
548
547
|
},
|
package/src/cli/minotor.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { Router, StopsIndex, Timetable } from '../router.js';
|
|
|
14
14
|
import {
|
|
15
15
|
loadQueriesFromJson,
|
|
16
16
|
loadRangeQueriesFromJson,
|
|
17
|
+
measureRetainedMemory,
|
|
17
18
|
prettyPrintPerformanceResults,
|
|
18
19
|
testBestRoutePerformance,
|
|
19
20
|
testRangeResultPerformance,
|
|
@@ -175,9 +176,25 @@ program
|
|
|
175
176
|
const stopsIndex = StopsIndex.fromData(
|
|
176
177
|
fs.readFileSync(options.stopsPath),
|
|
177
178
|
);
|
|
178
|
-
const
|
|
179
|
-
fs.readFileSync(options.timetablePath),
|
|
179
|
+
const loading = measureRetainedMemory(() =>
|
|
180
|
+
Timetable.fromData(fs.readFileSync(options.timetablePath)),
|
|
180
181
|
);
|
|
182
|
+
const timetable = loading.value;
|
|
183
|
+
console.log(
|
|
184
|
+
`Timetable load (read + decode): ${loading.loadTimeMs.toFixed(2)} ms`,
|
|
185
|
+
);
|
|
186
|
+
if (
|
|
187
|
+
loading.retainedHeapMiB !== undefined &&
|
|
188
|
+
loading.retainedArrayBuffersMiB !== undefined
|
|
189
|
+
) {
|
|
190
|
+
console.log(
|
|
191
|
+
`Timetable retained after GC: heap ${loading.retainedHeapMiB.toFixed(2)} MiB; ArrayBuffers ${loading.retainedArrayBuffersMiB.toFixed(2)} MiB`,
|
|
192
|
+
);
|
|
193
|
+
} else {
|
|
194
|
+
console.log(
|
|
195
|
+
'Retained memory skipped: explicit GC unavailable; use node --expose-gc.',
|
|
196
|
+
);
|
|
197
|
+
}
|
|
181
198
|
const router = new Router(timetable, stopsIndex);
|
|
182
199
|
|
|
183
200
|
const queries = loadQueriesFromJson(routesPath, stopsIndex);
|