minotor 11.1.0 → 11.1.2
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/dist/cli.mjs +316 -139
- package/dist/cli.mjs.map +1 -1
- package/dist/parser.cjs.js +71 -15
- package/dist/parser.cjs.js.map +1 -1
- package/dist/parser.esm.js +71 -15
- 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.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/router.d.ts +28 -42
- package/dist/routing/state.d.ts +119 -0
- package/dist/timetable/route.d.ts +27 -0
- package/dist/timetable/timetable.d.ts +4 -0
- package/package.json +1 -1
- package/src/routing/__tests__/plotter.test.ts +47 -59
- package/src/routing/__tests__/result.test.ts +203 -267
- package/src/routing/plotter.ts +10 -7
- package/src/routing/result.ts +22 -20
- package/src/routing/router.ts +158 -143
- package/src/routing/state.ts +199 -0
- package/src/timetable/route.ts +47 -0
- package/src/timetable/timetable.ts +33 -18
package/dist/parser.esm.js
CHANGED
|
@@ -12895,6 +12895,45 @@ class Route {
|
|
|
12895
12895
|
}
|
|
12896
12896
|
return arrival;
|
|
12897
12897
|
}
|
|
12898
|
+
/**
|
|
12899
|
+
* Computes the per-trip base offset used by the hot-path scanning methods.
|
|
12900
|
+
*
|
|
12901
|
+
* Cache the result once when boarding a new trip and pass it to
|
|
12902
|
+
* {@link arrivalAtOffset} and {@link dropOffTypeAtOffset} throughout the
|
|
12903
|
+
* scanning loop to avoid recomputing `tripIndex × nbStops` on every stop.
|
|
12904
|
+
*
|
|
12905
|
+
* @param tripIndex - The index of the trip.
|
|
12906
|
+
* @returns `tripIndex × nbStops`.
|
|
12907
|
+
*/
|
|
12908
|
+
tripStopOffset(tripIndex) {
|
|
12909
|
+
return tripIndex * this.nbStops;
|
|
12910
|
+
}
|
|
12911
|
+
/**
|
|
12912
|
+
* Hot-path variant of {@link arrivalAt} that accepts a precomputed base offset.
|
|
12913
|
+
*
|
|
12914
|
+
* @param stopIndex - The index of the stop in the route.
|
|
12915
|
+
* @param offset - Precomputed value from {@link tripStopOffset}.
|
|
12916
|
+
* @returns The arrival time at the specified stop.
|
|
12917
|
+
*/
|
|
12918
|
+
arrivalAtOffset(stopIndex, offset) {
|
|
12919
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
12920
|
+
return this.stopTimes[(offset + stopIndex) * 2];
|
|
12921
|
+
}
|
|
12922
|
+
/**
|
|
12923
|
+
* Hot-path variant of {@link dropOffTypeAt} that accepts a precomputed base offset.
|
|
12924
|
+
*
|
|
12925
|
+
* @param stopIndex - The index of the stop in the route.
|
|
12926
|
+
* @param offset - Precomputed value from {@link tripStopOffset}.
|
|
12927
|
+
* @returns The drop-off type at the specified stop.
|
|
12928
|
+
*/
|
|
12929
|
+
dropOffTypeAtOffset(stopIndex, offset) {
|
|
12930
|
+
const globalIndex = offset + stopIndex;
|
|
12931
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
12932
|
+
const byte = this.pickupDropOffTypes[globalIndex >> 1];
|
|
12933
|
+
// Bit layout per byte (two pairs): [pickup_1(2)][dropOff_1(2)][pickup_0(2)][dropOff_0(2)]
|
|
12934
|
+
// First pair → drop-off in lower 2 bits; second pair → drop-off in bits 4-5.
|
|
12935
|
+
return (globalIndex & 1 ? (byte >> 4) & 0x03 : byte & 0x03);
|
|
12936
|
+
}
|
|
12898
12937
|
/**
|
|
12899
12938
|
* Retrieves the departure time at a specific stop for a given trip.
|
|
12900
12939
|
*
|
|
@@ -13394,6 +13433,12 @@ class Timetable {
|
|
|
13394
13433
|
isActive(stopId) {
|
|
13395
13434
|
return this.activeStops.has(stopId);
|
|
13396
13435
|
}
|
|
13436
|
+
/**
|
|
13437
|
+
* Returns the total number of stops in the timetable.
|
|
13438
|
+
*/
|
|
13439
|
+
nbStops() {
|
|
13440
|
+
return this.stopsAdjacency.length;
|
|
13441
|
+
}
|
|
13397
13442
|
/**
|
|
13398
13443
|
* Retrieves the route associated with the given route ID.
|
|
13399
13444
|
*
|
|
@@ -13480,21 +13525,26 @@ class Timetable {
|
|
|
13480
13525
|
*/
|
|
13481
13526
|
findReachableRoutes(fromStops, transportModes = ALL_TRANSPORT_MODES) {
|
|
13482
13527
|
const reachableRoutes = new Map();
|
|
13483
|
-
|
|
13484
|
-
|
|
13485
|
-
|
|
13486
|
-
|
|
13487
|
-
|
|
13488
|
-
|
|
13489
|
-
|
|
13490
|
-
for (let
|
|
13491
|
-
const route =
|
|
13492
|
-
|
|
13493
|
-
|
|
13528
|
+
// Skip the per-route mode check entirely when all modes are allowed,
|
|
13529
|
+
// which is the common case.
|
|
13530
|
+
const filterByMode = transportModes !== ALL_TRANSPORT_MODES;
|
|
13531
|
+
for (const originStop of fromStops) {
|
|
13532
|
+
const stopData = this.stopsAdjacency[originStop];
|
|
13533
|
+
if (!stopData)
|
|
13534
|
+
continue;
|
|
13535
|
+
for (let i = 0; i < stopData.routes.length; i++) {
|
|
13536
|
+
const route = this.routesAdjacency[stopData.routes[i]];
|
|
13537
|
+
if (!route)
|
|
13538
|
+
continue;
|
|
13539
|
+
if (filterByMode) {
|
|
13540
|
+
const serviceRoute = this.serviceRoutes[route.serviceRoute()];
|
|
13541
|
+
if (!serviceRoute || !transportModes.has(serviceRoute.type))
|
|
13542
|
+
continue;
|
|
13543
|
+
}
|
|
13544
|
+
const originStopIndex = route.stopRouteIndices(originStop)[0];
|
|
13494
13545
|
const existingHopOnStopIndex = reachableRoutes.get(route);
|
|
13495
13546
|
if (existingHopOnStopIndex !== undefined) {
|
|
13496
13547
|
if (originStopIndex < existingHopOnStopIndex) {
|
|
13497
|
-
// if the current stop is before the existing hop on stop, replace it
|
|
13498
13548
|
reachableRoutes.set(route, originStopIndex);
|
|
13499
13549
|
}
|
|
13500
13550
|
}
|
|
@@ -13519,9 +13569,15 @@ class Timetable {
|
|
|
13519
13569
|
if (!guaranteedTransfers) {
|
|
13520
13570
|
return false;
|
|
13521
13571
|
}
|
|
13522
|
-
|
|
13523
|
-
transfer
|
|
13524
|
-
transfer.
|
|
13572
|
+
for (let i = 0; i < guaranteedTransfers.length; i++) {
|
|
13573
|
+
const transfer = guaranteedTransfers[i];
|
|
13574
|
+
if (transfer.stopIndex === toTripStop.stopIndex &&
|
|
13575
|
+
transfer.routeId === toTripStop.routeId &&
|
|
13576
|
+
transfer.tripIndex === toTripStop.tripIndex) {
|
|
13577
|
+
return true;
|
|
13578
|
+
}
|
|
13579
|
+
}
|
|
13580
|
+
return false;
|
|
13525
13581
|
}
|
|
13526
13582
|
/**
|
|
13527
13583
|
* Retrieves all guaranteed trip transfer options available at the specified stop for a given trip.
|