minotor 7.0.0 → 7.0.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 +2 -7
- package/dist/cli.mjs +54 -46
- package/dist/cli.mjs.map +1 -1
- package/dist/parser.cjs.js +49 -42
- package/dist/parser.cjs.js.map +1 -1
- package/dist/parser.esm.js +49 -42
- 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 +1 -1
- package/package.json +1 -1
- package/src/routing/router.ts +8 -6
- package/src/timetable/route.ts +23 -22
- package/src/timetable/time.ts +23 -9
- package/src/timetable/timetable.ts +1 -3
package/dist/routing/router.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export type ReachingTime = {
|
|
|
14
14
|
origin: StopId;
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
|
-
* A public transportation network router
|
|
17
|
+
* A public transportation network router implementing the RAPTOR algorithm for
|
|
18
18
|
* efficient journey planning and routing. For more information on the RAPTOR
|
|
19
19
|
* algorithm, refer to its detailed explanation in the research paper:
|
|
20
20
|
* https://www.microsoft.com/en-us/research/wp-content/uploads/2012/01/raptor_alenex.pdf
|
package/package.json
CHANGED
package/src/routing/router.ts
CHANGED
|
@@ -28,7 +28,7 @@ type CurrentTrip = {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* A public transportation network router
|
|
31
|
+
* A public transportation network router implementing the RAPTOR algorithm for
|
|
32
32
|
* efficient journey planning and routing. For more information on the RAPTOR
|
|
33
33
|
* algorithm, refer to its detailed explanation in the research paper:
|
|
34
34
|
* https://www.microsoft.com/en-us/research/wp-content/uploads/2012/01/raptor_alenex.pdf
|
|
@@ -190,6 +190,10 @@ export class Router {
|
|
|
190
190
|
options.transportModes,
|
|
191
191
|
);
|
|
192
192
|
markedStops.clear();
|
|
193
|
+
const earliestArrivalAtAnyDestination = this.earliestArrivalAtAnyStop(
|
|
194
|
+
earliestArrivals,
|
|
195
|
+
destinations,
|
|
196
|
+
);
|
|
193
197
|
// for each route that can be reached with at least round - 1 trips
|
|
194
198
|
const reachableRoutesArray = Array.from(reachableRoutes.entries());
|
|
195
199
|
for (let i = 0; i < reachableRoutesArray.length; i++) {
|
|
@@ -214,9 +218,7 @@ export class Router {
|
|
|
214
218
|
if (
|
|
215
219
|
currentDropOffType !== 'NOT_AVAILABLE' &&
|
|
216
220
|
currentArrivalTime.isBefore(earliestArrivalAtCurrentStop) &&
|
|
217
|
-
currentArrivalTime.isBefore(
|
|
218
|
-
this.earliestArrivalAtAnyStop(earliestArrivals, destinations),
|
|
219
|
-
)
|
|
221
|
+
currentArrivalTime.isBefore(earliestArrivalAtAnyDestination)
|
|
220
222
|
) {
|
|
221
223
|
const bestHopOnDepartureTime = route.departureFrom(
|
|
222
224
|
currentTrip.bestHopOnStop,
|
|
@@ -252,10 +254,10 @@ export class Router {
|
|
|
252
254
|
earliestArrivalOnPreviousRound !== undefined &&
|
|
253
255
|
(currentTrip === undefined ||
|
|
254
256
|
earliestArrivalOnPreviousRound.isBefore(
|
|
255
|
-
route.
|
|
257
|
+
route.departureFrom(currentStop, currentTrip.tripIndex),
|
|
256
258
|
) ||
|
|
257
259
|
earliestArrivalOnPreviousRound.equals(
|
|
258
|
-
route.
|
|
260
|
+
route.departureFrom(currentStop, currentTrip.tripIndex),
|
|
259
261
|
))
|
|
260
262
|
) {
|
|
261
263
|
const earliestTrip = route.findEarliestTrip(
|
package/src/timetable/route.ts
CHANGED
|
@@ -286,32 +286,33 @@ export class Route {
|
|
|
286
286
|
after: Time = Time.origin(),
|
|
287
287
|
beforeTrip?: TripIndex,
|
|
288
288
|
): TripIndex | undefined {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
if (
|
|
294
|
-
return undefined;
|
|
295
|
-
}
|
|
296
|
-
let earliestTripIndex: TripIndex | undefined;
|
|
297
|
-
let lowTrip = 0;
|
|
298
|
-
let highTrip = maxTripIndex;
|
|
289
|
+
if (this.nbTrips <= 0) return undefined;
|
|
290
|
+
|
|
291
|
+
let hi = this.nbTrips - 1;
|
|
292
|
+
if (beforeTrip !== undefined) hi = Math.min(hi, beforeTrip - 1);
|
|
293
|
+
if (hi < 0) return undefined;
|
|
299
294
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
) {
|
|
308
|
-
earliestTripIndex = midTrip;
|
|
309
|
-
highTrip = midTrip - 1;
|
|
295
|
+
let lo = 0;
|
|
296
|
+
let lb = -1;
|
|
297
|
+
while (lo <= hi) {
|
|
298
|
+
const mid = (lo + hi) >>> 1;
|
|
299
|
+
const depMid = this.departureFrom(stopId, mid);
|
|
300
|
+
if (depMid.isBefore(after)) {
|
|
301
|
+
lo = mid + 1;
|
|
310
302
|
} else {
|
|
311
|
-
|
|
303
|
+
lb = mid;
|
|
304
|
+
hi = mid - 1;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
if (lb === -1) return undefined;
|
|
308
|
+
|
|
309
|
+
for (let t = lb; t < (beforeTrip ?? this.nbTrips); t++) {
|
|
310
|
+
const pickup = this.pickUpTypeFrom(stopId, t);
|
|
311
|
+
if (pickup !== 'NOT_AVAILABLE') {
|
|
312
|
+
return t;
|
|
312
313
|
}
|
|
313
314
|
}
|
|
314
|
-
return
|
|
315
|
+
return undefined;
|
|
315
316
|
}
|
|
316
317
|
|
|
317
318
|
/**
|
package/src/timetable/time.ts
CHANGED
|
@@ -193,9 +193,16 @@ export class Time {
|
|
|
193
193
|
if (times.length === 0) {
|
|
194
194
|
throw new Error('At least one Time instance is required.');
|
|
195
195
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
196
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
197
|
+
let maxTime = times[0]!;
|
|
198
|
+
for (let i = 1; i < times.length; i++) {
|
|
199
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
200
|
+
if (times[i]!.minutesSinceMidnight > maxTime.minutesSinceMidnight) {
|
|
201
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
202
|
+
maxTime = times[i]!;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return maxTime;
|
|
199
206
|
}
|
|
200
207
|
|
|
201
208
|
/**
|
|
@@ -208,9 +215,16 @@ export class Time {
|
|
|
208
215
|
if (times.length === 0) {
|
|
209
216
|
throw new Error('At least one Time instance is required.');
|
|
210
217
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
218
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
219
|
+
let minTime = times[0]!;
|
|
220
|
+
for (let i = 1; i < times.length; i++) {
|
|
221
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
222
|
+
if (times[i]!.minutesSinceMidnight < minTime.minutesSinceMidnight) {
|
|
223
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
224
|
+
minTime = times[i]!;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return minTime;
|
|
214
228
|
}
|
|
215
229
|
|
|
216
230
|
/**
|
|
@@ -220,7 +234,7 @@ export class Time {
|
|
|
220
234
|
* @returns True if the current Time instance is after the other Time instance, otherwise false.
|
|
221
235
|
*/
|
|
222
236
|
isAfter(otherTime: Time): boolean {
|
|
223
|
-
return this.minutesSinceMidnight > otherTime.
|
|
237
|
+
return this.minutesSinceMidnight > otherTime.minutesSinceMidnight;
|
|
224
238
|
}
|
|
225
239
|
|
|
226
240
|
/**
|
|
@@ -230,7 +244,7 @@ export class Time {
|
|
|
230
244
|
* @returns True if the current Time instance is before the other Time instance, otherwise false.
|
|
231
245
|
*/
|
|
232
246
|
isBefore(otherTime: Time): boolean {
|
|
233
|
-
return this.minutesSinceMidnight < otherTime.
|
|
247
|
+
return this.minutesSinceMidnight < otherTime.minutesSinceMidnight;
|
|
234
248
|
}
|
|
235
249
|
|
|
236
250
|
/**
|
|
@@ -240,6 +254,6 @@ export class Time {
|
|
|
240
254
|
* @returns True if the current Time instance is equal to the other Time instance, otherwise false.
|
|
241
255
|
*/
|
|
242
256
|
equals(otherTime: Time): boolean {
|
|
243
|
-
return this.minutesSinceMidnight === otherTime.
|
|
257
|
+
return this.minutesSinceMidnight === otherTime.minutesSinceMidnight;
|
|
244
258
|
}
|
|
245
259
|
}
|
|
@@ -184,9 +184,7 @@ export class Timetable {
|
|
|
184
184
|
`Service route not found for route ID: ${route.serviceRoute()}`,
|
|
185
185
|
);
|
|
186
186
|
}
|
|
187
|
-
|
|
188
|
-
const { routes, ...serviceRouteInfo } = serviceRoute;
|
|
189
|
-
return serviceRouteInfo;
|
|
187
|
+
return { type: serviceRoute.type, name: serviceRoute.name };
|
|
190
188
|
}
|
|
191
189
|
|
|
192
190
|
/**
|