minotor 11.1.2 → 11.2.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 +7 -1
- package/CHANGELOG.md +3 -3
- package/README.md +111 -86
- package/dist/cli/perf.d.ts +57 -18
- package/dist/cli.mjs +1371 -342
- package/dist/cli.mjs.map +1 -1
- package/dist/parser.cjs.js +57 -4
- package/dist/parser.cjs.js.map +1 -1
- package/dist/parser.esm.js +57 -4
- 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 +5 -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/__tests__/access.test.d.ts +1 -0
- package/dist/routing/__tests__/plainRouter.test.d.ts +1 -0
- package/dist/routing/__tests__/rangeResult.test.d.ts +1 -0
- package/dist/routing/__tests__/rangeRouter.test.d.ts +1 -0
- package/dist/routing/__tests__/rangeState.test.d.ts +1 -0
- package/dist/routing/__tests__/raptor.test.d.ts +1 -0
- package/dist/routing/__tests__/state.test.d.ts +1 -0
- package/dist/routing/access.d.ts +55 -0
- package/dist/routing/plainRouter.d.ts +21 -0
- package/dist/routing/plotter.d.ts +9 -0
- package/dist/routing/query.d.ts +132 -13
- package/dist/routing/rangeResult.d.ts +155 -0
- package/dist/routing/rangeRouter.d.ts +24 -0
- package/dist/routing/rangeState.d.ts +83 -0
- package/dist/routing/raptor.d.ts +96 -0
- package/dist/routing/result.d.ts +27 -7
- package/dist/routing/route.d.ts +5 -21
- package/dist/routing/router.d.ts +20 -91
- package/dist/routing/state.d.ts +92 -17
- package/dist/timetable/route.d.ts +8 -0
- package/dist/timetable/timetable.d.ts +17 -1
- package/package.json +1 -1
- package/src/__e2e__/benchmark.json +18 -0
- package/src/__e2e__/router.test.ts +461 -127
- package/src/cli/minotor.ts +39 -3
- package/src/cli/perf.ts +324 -60
- package/src/cli/repl.ts +96 -41
- package/src/router.ts +11 -3
- package/src/routing/__tests__/access.test.ts +294 -0
- package/src/routing/__tests__/plainRouter.test.ts +1633 -0
- package/src/routing/__tests__/plotter.test.ts +8 -8
- package/src/routing/__tests__/rangeResult.test.ts +273 -0
- package/src/routing/__tests__/rangeRouter.test.ts +472 -0
- package/src/routing/__tests__/rangeState.test.ts +246 -0
- package/src/routing/__tests__/raptor.test.ts +366 -0
- package/src/routing/__tests__/result.test.ts +27 -27
- package/src/routing/__tests__/route.test.ts +28 -0
- package/src/routing/__tests__/router.test.ts +75 -1587
- package/src/routing/__tests__/state.test.ts +78 -0
- package/src/routing/access.ts +144 -0
- package/src/routing/plainRouter.ts +60 -0
- package/src/routing/plotter.ts +53 -6
- package/src/routing/query.ts +116 -13
- package/src/routing/rangeResult.ts +292 -0
- package/src/routing/rangeRouter.ts +167 -0
- package/src/routing/rangeState.ts +150 -0
- package/src/routing/raptor.ts +416 -0
- package/src/routing/result.ts +68 -26
- package/src/routing/route.ts +15 -53
- package/src/routing/router.ts +40 -480
- package/src/routing/state.ts +191 -32
- package/src/timetable/__tests__/timetable.test.ts +373 -0
- package/src/timetable/route.ts +16 -4
- package/src/timetable/timetable.ts +54 -1
package/dist/parser.cjs.js
CHANGED
|
@@ -12715,6 +12715,7 @@ function isSet(value) {
|
|
|
12715
12715
|
}
|
|
12716
12716
|
|
|
12717
12717
|
const TIME_ORIGIN = 0;
|
|
12718
|
+
const DURATION_ZERO = 0;
|
|
12718
12719
|
/**
|
|
12719
12720
|
* Creates a Time from hours, minutes, and seconds.
|
|
12720
12721
|
* Rounds to the closest minute as times are represented in minutes from midnight.
|
|
@@ -12921,6 +12922,17 @@ class Route {
|
|
|
12921
12922
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
12922
12923
|
return this.stopTimes[(offset + stopIndex) * 2];
|
|
12923
12924
|
}
|
|
12925
|
+
/**
|
|
12926
|
+
* Hot-path variant of {@link departureFrom} that accepts a precomputed base offset.
|
|
12927
|
+
*
|
|
12928
|
+
* @param stopIndex - The index of the stop in the route.
|
|
12929
|
+
* @param offset - Precomputed value from {@link tripStopOffset}.
|
|
12930
|
+
* @returns The departure time at the specified stop.
|
|
12931
|
+
*/
|
|
12932
|
+
departureAtOffset(stopIndex, offset) {
|
|
12933
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
12934
|
+
return this.stopTimes[(offset + stopIndex) * 2 + 1];
|
|
12935
|
+
}
|
|
12924
12936
|
/**
|
|
12925
12937
|
* Hot-path variant of {@link dropOffTypeAt} that accepts a precomputed base offset.
|
|
12926
12938
|
*
|
|
@@ -12960,8 +12972,8 @@ class Route {
|
|
|
12960
12972
|
*/
|
|
12961
12973
|
pickUpTypeFrom(stopIndex, tripIndex) {
|
|
12962
12974
|
const globalIndex = tripIndex * this.stops.length + stopIndex;
|
|
12963
|
-
const byteIndex =
|
|
12964
|
-
const isSecondPair = globalIndex
|
|
12975
|
+
const byteIndex = globalIndex >> 1;
|
|
12976
|
+
const isSecondPair = (globalIndex & 1) === 1;
|
|
12965
12977
|
const byte = this.pickupDropOffTypes[byteIndex];
|
|
12966
12978
|
if (byte === undefined) {
|
|
12967
12979
|
throw new Error(`Pick up type not found for stop ${this.stopId(stopIndex)} (${stopIndex}) at trip index ${tripIndex} in route ${this.serviceRouteId}`);
|
|
@@ -12980,8 +12992,8 @@ class Route {
|
|
|
12980
12992
|
*/
|
|
12981
12993
|
dropOffTypeAt(stopIndex, tripIndex) {
|
|
12982
12994
|
const globalIndex = tripIndex * this.stops.length + stopIndex;
|
|
12983
|
-
const byteIndex =
|
|
12984
|
-
const isSecondPair = globalIndex
|
|
12995
|
+
const byteIndex = globalIndex >> 1;
|
|
12996
|
+
const isSecondPair = (globalIndex & 1) === 1;
|
|
12985
12997
|
const byte = this.pickupDropOffTypes[byteIndex];
|
|
12986
12998
|
if (byte === undefined) {
|
|
12987
12999
|
throw new Error(`Drop off type not found for stop ${this.stopId(stopIndex)} (${stopIndex}) at trip index ${tripIndex} in route ${this.serviceRouteId}`);
|
|
@@ -13581,6 +13593,47 @@ class Timetable {
|
|
|
13581
13593
|
}
|
|
13582
13594
|
return false;
|
|
13583
13595
|
}
|
|
13596
|
+
/**
|
|
13597
|
+
* Finds the first trip on `route` at `stopIndex` that can be boarded, starting
|
|
13598
|
+
* from `earliestTrip` and respecting pickup availability, transfer guarantees,
|
|
13599
|
+
* and minimum transfer times.
|
|
13600
|
+
*
|
|
13601
|
+
* @param stopIndex Stop at which boarding is attempted.
|
|
13602
|
+
* @param route The route to search.
|
|
13603
|
+
* @param earliestTrip First trip index to consider.
|
|
13604
|
+
* @param after Earliest time after which boarding is allowed.
|
|
13605
|
+
* @param beforeTrip Exclusive upper bound on the trip index (omit to search all).
|
|
13606
|
+
* @param fromTripStop The alighted trip stop when transferring from another trip;
|
|
13607
|
+
* `undefined` when boarding from a walk or origin.
|
|
13608
|
+
* @param transferTime Minimum transfer time required between trips.
|
|
13609
|
+
* @returns The index of the first boardable trip, or `undefined` if none found.
|
|
13610
|
+
*/
|
|
13611
|
+
findFirstBoardableTrip(stopIndex, route, earliestTrip, after = TIME_ORIGIN, beforeTrip, fromTripStop, transferTime = DURATION_ZERO) {
|
|
13612
|
+
const nbTrips = route.getNbTrips();
|
|
13613
|
+
for (let t = earliestTrip; t < (beforeTrip !== null && beforeTrip !== void 0 ? beforeTrip : nbTrips); t++) {
|
|
13614
|
+
const pickup = route.pickUpTypeFrom(stopIndex, t);
|
|
13615
|
+
if (pickup === NOT_AVAILABLE) {
|
|
13616
|
+
continue;
|
|
13617
|
+
}
|
|
13618
|
+
if (fromTripStop === undefined) {
|
|
13619
|
+
return t;
|
|
13620
|
+
}
|
|
13621
|
+
const isGuaranteed = this.isTripTransferGuaranteed(fromTripStop, {
|
|
13622
|
+
stopIndex,
|
|
13623
|
+
routeId: route.id,
|
|
13624
|
+
tripIndex: t,
|
|
13625
|
+
});
|
|
13626
|
+
if (isGuaranteed) {
|
|
13627
|
+
return t;
|
|
13628
|
+
}
|
|
13629
|
+
const departure = route.departureFrom(stopIndex, t);
|
|
13630
|
+
const requiredTime = after + transferTime;
|
|
13631
|
+
if (departure >= requiredTime) {
|
|
13632
|
+
return t;
|
|
13633
|
+
}
|
|
13634
|
+
}
|
|
13635
|
+
return undefined;
|
|
13636
|
+
}
|
|
13584
13637
|
/**
|
|
13585
13638
|
* Retrieves all guaranteed trip transfer options available at the specified stop for a given trip.
|
|
13586
13639
|
*
|