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.esm.js
CHANGED
|
@@ -12713,6 +12713,7 @@ function isSet(value) {
|
|
|
12713
12713
|
}
|
|
12714
12714
|
|
|
12715
12715
|
const TIME_ORIGIN = 0;
|
|
12716
|
+
const DURATION_ZERO = 0;
|
|
12716
12717
|
/**
|
|
12717
12718
|
* Creates a Time from hours, minutes, and seconds.
|
|
12718
12719
|
* Rounds to the closest minute as times are represented in minutes from midnight.
|
|
@@ -12919,6 +12920,17 @@ class Route {
|
|
|
12919
12920
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
12920
12921
|
return this.stopTimes[(offset + stopIndex) * 2];
|
|
12921
12922
|
}
|
|
12923
|
+
/**
|
|
12924
|
+
* Hot-path variant of {@link departureFrom} that accepts a precomputed base offset.
|
|
12925
|
+
*
|
|
12926
|
+
* @param stopIndex - The index of the stop in the route.
|
|
12927
|
+
* @param offset - Precomputed value from {@link tripStopOffset}.
|
|
12928
|
+
* @returns The departure time at the specified stop.
|
|
12929
|
+
*/
|
|
12930
|
+
departureAtOffset(stopIndex, offset) {
|
|
12931
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
12932
|
+
return this.stopTimes[(offset + stopIndex) * 2 + 1];
|
|
12933
|
+
}
|
|
12922
12934
|
/**
|
|
12923
12935
|
* Hot-path variant of {@link dropOffTypeAt} that accepts a precomputed base offset.
|
|
12924
12936
|
*
|
|
@@ -12958,8 +12970,8 @@ class Route {
|
|
|
12958
12970
|
*/
|
|
12959
12971
|
pickUpTypeFrom(stopIndex, tripIndex) {
|
|
12960
12972
|
const globalIndex = tripIndex * this.stops.length + stopIndex;
|
|
12961
|
-
const byteIndex =
|
|
12962
|
-
const isSecondPair = globalIndex
|
|
12973
|
+
const byteIndex = globalIndex >> 1;
|
|
12974
|
+
const isSecondPair = (globalIndex & 1) === 1;
|
|
12963
12975
|
const byte = this.pickupDropOffTypes[byteIndex];
|
|
12964
12976
|
if (byte === undefined) {
|
|
12965
12977
|
throw new Error(`Pick up type not found for stop ${this.stopId(stopIndex)} (${stopIndex}) at trip index ${tripIndex} in route ${this.serviceRouteId}`);
|
|
@@ -12978,8 +12990,8 @@ class Route {
|
|
|
12978
12990
|
*/
|
|
12979
12991
|
dropOffTypeAt(stopIndex, tripIndex) {
|
|
12980
12992
|
const globalIndex = tripIndex * this.stops.length + stopIndex;
|
|
12981
|
-
const byteIndex =
|
|
12982
|
-
const isSecondPair = globalIndex
|
|
12993
|
+
const byteIndex = globalIndex >> 1;
|
|
12994
|
+
const isSecondPair = (globalIndex & 1) === 1;
|
|
12983
12995
|
const byte = this.pickupDropOffTypes[byteIndex];
|
|
12984
12996
|
if (byte === undefined) {
|
|
12985
12997
|
throw new Error(`Drop off type not found for stop ${this.stopId(stopIndex)} (${stopIndex}) at trip index ${tripIndex} in route ${this.serviceRouteId}`);
|
|
@@ -13579,6 +13591,47 @@ class Timetable {
|
|
|
13579
13591
|
}
|
|
13580
13592
|
return false;
|
|
13581
13593
|
}
|
|
13594
|
+
/**
|
|
13595
|
+
* Finds the first trip on `route` at `stopIndex` that can be boarded, starting
|
|
13596
|
+
* from `earliestTrip` and respecting pickup availability, transfer guarantees,
|
|
13597
|
+
* and minimum transfer times.
|
|
13598
|
+
*
|
|
13599
|
+
* @param stopIndex Stop at which boarding is attempted.
|
|
13600
|
+
* @param route The route to search.
|
|
13601
|
+
* @param earliestTrip First trip index to consider.
|
|
13602
|
+
* @param after Earliest time after which boarding is allowed.
|
|
13603
|
+
* @param beforeTrip Exclusive upper bound on the trip index (omit to search all).
|
|
13604
|
+
* @param fromTripStop The alighted trip stop when transferring from another trip;
|
|
13605
|
+
* `undefined` when boarding from a walk or origin.
|
|
13606
|
+
* @param transferTime Minimum transfer time required between trips.
|
|
13607
|
+
* @returns The index of the first boardable trip, or `undefined` if none found.
|
|
13608
|
+
*/
|
|
13609
|
+
findFirstBoardableTrip(stopIndex, route, earliestTrip, after = TIME_ORIGIN, beforeTrip, fromTripStop, transferTime = DURATION_ZERO) {
|
|
13610
|
+
const nbTrips = route.getNbTrips();
|
|
13611
|
+
for (let t = earliestTrip; t < (beforeTrip !== null && beforeTrip !== void 0 ? beforeTrip : nbTrips); t++) {
|
|
13612
|
+
const pickup = route.pickUpTypeFrom(stopIndex, t);
|
|
13613
|
+
if (pickup === NOT_AVAILABLE) {
|
|
13614
|
+
continue;
|
|
13615
|
+
}
|
|
13616
|
+
if (fromTripStop === undefined) {
|
|
13617
|
+
return t;
|
|
13618
|
+
}
|
|
13619
|
+
const isGuaranteed = this.isTripTransferGuaranteed(fromTripStop, {
|
|
13620
|
+
stopIndex,
|
|
13621
|
+
routeId: route.id,
|
|
13622
|
+
tripIndex: t,
|
|
13623
|
+
});
|
|
13624
|
+
if (isGuaranteed) {
|
|
13625
|
+
return t;
|
|
13626
|
+
}
|
|
13627
|
+
const departure = route.departureFrom(stopIndex, t);
|
|
13628
|
+
const requiredTime = after + transferTime;
|
|
13629
|
+
if (departure >= requiredTime) {
|
|
13630
|
+
return t;
|
|
13631
|
+
}
|
|
13632
|
+
}
|
|
13633
|
+
return undefined;
|
|
13634
|
+
}
|
|
13582
13635
|
/**
|
|
13583
13636
|
* Retrieves all guaranteed trip transfer options available at the specified stop for a given trip.
|
|
13584
13637
|
*
|