minotor 11.2.2 → 11.2.3
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 -0
- package/dist/cli.mjs +78 -29
- package/dist/cli.mjs.map +1 -1
- package/dist/parser.cjs.js.map +1 -1
- 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 -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/query.d.ts +20 -0
- package/dist/routing/rangeState.d.ts +1 -0
- package/dist/routing/raptor.d.ts +2 -0
- package/dist/routing/state.d.ts +11 -1
- package/dist/timetable/timetable.d.ts +2 -1
- package/package.json +1 -1
- package/src/cli/perf.ts +4 -2
- package/src/cli/repl.ts +49 -23
- package/src/router.ts +3 -0
- package/src/routing/__tests__/plainRouter.test.ts +22 -0
- package/src/routing/__tests__/rangeRouter.test.ts +22 -0
- package/src/routing/__tests__/raptor.test.ts +142 -0
- package/src/routing/plainRouter.ts +1 -0
- package/src/routing/query.ts +18 -0
- package/src/routing/rangeRouter.ts +2 -0
- package/src/routing/rangeState.ts +4 -0
- package/src/routing/raptor.ts +14 -4
- package/src/routing/state.ts +31 -1
- package/src/timetable/timetable.ts +2 -5
package/src/routing/state.ts
CHANGED
|
@@ -33,7 +33,7 @@ export type VehicleEdge = TripStop & {
|
|
|
33
33
|
export type TransferEdge = {
|
|
34
34
|
arrival: Time;
|
|
35
35
|
from: StopId;
|
|
36
|
-
to: StopId;
|
|
36
|
+
to: StopId; // TODO remove
|
|
37
37
|
type: TransferType;
|
|
38
38
|
minTransferTime?: Duration;
|
|
39
39
|
};
|
|
@@ -61,7 +61,16 @@ export class RoutingState implements IRaptorState {
|
|
|
61
61
|
* Indexed as graph[round][stopId]. Entries are undefined for stops not
|
|
62
62
|
* reached in that particular round.
|
|
63
63
|
*/
|
|
64
|
+
// TODO do not expose
|
|
64
65
|
readonly graph: (RoutingEdge | undefined)[][];
|
|
66
|
+
// TODO Can use typed arrays to represent the graph
|
|
67
|
+
// Uint32 [(alightStopId -> ? =index/to), boardingStopId (stopIndex,from),
|
|
68
|
+
// RouteId/TransferId, TripId (if not transfer), (previous_round, previous_stop
|
|
69
|
+
// -> allows to reconstruct transfers incl. continuous]
|
|
70
|
+
// TODO should try to reuse them in range raptor and use only one init
|
|
71
|
+
|
|
72
|
+
// TODO take out arrival times from Graph
|
|
73
|
+
// private arrivalTimes: Uint16Array[];
|
|
65
74
|
|
|
66
75
|
/**
|
|
67
76
|
* Earliest arrival time at each stop (minutes from midnight), indexed by stop ID.
|
|
@@ -89,6 +98,18 @@ export class RoutingState implements IRaptorState {
|
|
|
89
98
|
*/
|
|
90
99
|
private _destinationBest: Time = UNREACHED_TIME;
|
|
91
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Maximum arrival time allowed for this run. Defaults to UNREACHED_TIME when
|
|
103
|
+
* the query has no maxDuration limit.
|
|
104
|
+
*/
|
|
105
|
+
maxArrivalTime: Time = UNREACHED_TIME;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Query-level maximum duration, retained so resetFor() can recompute the
|
|
109
|
+
* absolute max arrival time for each departure-time iteration.
|
|
110
|
+
*/
|
|
111
|
+
private readonly maxDuration?: Duration;
|
|
112
|
+
|
|
92
113
|
/**
|
|
93
114
|
* Every stop that has received an arrival improvement during the current run,
|
|
94
115
|
* in the order the improvements occurred. Used by {@link resetFor} to clear
|
|
@@ -102,8 +123,12 @@ export class RoutingState implements IRaptorState {
|
|
|
102
123
|
accessPaths: AccessPoint[],
|
|
103
124
|
nbStops: number,
|
|
104
125
|
maxRounds: number = 0,
|
|
126
|
+
maxDuration?: Duration,
|
|
105
127
|
) {
|
|
106
128
|
this.destinations = destinations;
|
|
129
|
+
this.maxDuration = maxDuration;
|
|
130
|
+
this.maxArrivalTime =
|
|
131
|
+
maxDuration === undefined ? UNREACHED_TIME : departureTime + maxDuration;
|
|
107
132
|
this.destinationSet = new Set(destinations);
|
|
108
133
|
this.earliestArrivalTimes = new Uint16Array(nbStops).fill(UNREACHED_TIME);
|
|
109
134
|
this.earliestArrivalLegs = new Uint8Array(nbStops);
|
|
@@ -126,6 +151,7 @@ export class RoutingState implements IRaptorState {
|
|
|
126
151
|
const seededOrigins = new Set<StopId>();
|
|
127
152
|
for (const access of accessPaths) {
|
|
128
153
|
const arrival = depTime + access.duration;
|
|
154
|
+
if (arrival > this.maxArrivalTime) continue;
|
|
129
155
|
const edge: OriginNode | AccessEdge =
|
|
130
156
|
access.duration === 0
|
|
131
157
|
? { stopId: access.fromStopId, arrival: depTime }
|
|
@@ -224,6 +250,10 @@ export class RoutingState implements IRaptorState {
|
|
|
224
250
|
}
|
|
225
251
|
this.reachedStops.length = 0;
|
|
226
252
|
this._destinationBest = UNREACHED_TIME;
|
|
253
|
+
this.maxArrivalTime =
|
|
254
|
+
this.maxDuration === undefined
|
|
255
|
+
? UNREACHED_TIME
|
|
256
|
+
: depTime + this.maxDuration;
|
|
227
257
|
this.seedAccessPaths(depTime, accessPaths);
|
|
228
258
|
}
|
|
229
259
|
|
|
@@ -18,11 +18,8 @@ import { Route, RouteId, StopRouteIndex, TripRouteIndex } from './route.js';
|
|
|
18
18
|
import { Duration, DURATION_ZERO, Time, TIME_ORIGIN } from './time.js';
|
|
19
19
|
import { encode, TripStopId } from './tripStopId.js';
|
|
20
20
|
|
|
21
|
-
export type TransferType =
|
|
22
|
-
| '
|
|
23
|
-
| 'GUARANTEED'
|
|
24
|
-
| 'REQUIRES_MINIMAL_TIME'
|
|
25
|
-
| 'IN_SEAT';
|
|
21
|
+
export type TransferType = // TODO use number to represent that.
|
|
22
|
+
'RECOMMENDED' | 'GUARANTEED' | 'REQUIRES_MINIMAL_TIME' | 'IN_SEAT';
|
|
26
23
|
|
|
27
24
|
export type Transfer = {
|
|
28
25
|
destination: StopId;
|