minotor 2.0.0 → 3.0.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/CHANGELOG.md +4 -4
- package/dist/cli.mjs +89 -47
- package/dist/cli.mjs.map +1 -1
- package/dist/parser.cjs.js +82 -40
- package/dist/parser.cjs.js.map +1 -1
- package/dist/parser.esm.js +82 -40
- 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 -2
- 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/timetable/time.d.ts +18 -9
- package/dist/timetable/timetable.d.ts +3 -3
- package/package.json +1 -1
- package/src/gtfs/__tests__/parser.test.ts +4 -4
- package/src/gtfs/__tests__/time.test.ts +2 -2
- package/src/gtfs/__tests__/trips.test.ts +36 -36
- package/src/gtfs/trips.ts +4 -4
- package/src/router.ts +3 -2
- package/src/routing/__tests__/route.test.ts +4 -4
- package/src/routing/__tests__/router.test.ts +60 -60
- package/src/routing/result.ts +2 -2
- package/src/routing/router.ts +5 -5
- package/src/timetable/__tests__/io.test.ts +12 -12
- package/src/timetable/__tests__/timetable.test.ts +16 -16
- package/src/timetable/io.ts +46 -2
- package/src/timetable/time.ts +51 -30
- package/src/timetable/timetable.ts +7 -7
package/dist/timetable/time.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Duration } from './duration.js';
|
|
2
2
|
/**
|
|
3
|
-
* A class representing a time
|
|
3
|
+
* A class representing a time as minutes since midnight.
|
|
4
4
|
*/
|
|
5
5
|
export declare class Time {
|
|
6
|
-
private
|
|
6
|
+
private minutesSinceMidnight;
|
|
7
7
|
/**
|
|
8
8
|
* Gets the infinity time as a Time instance.
|
|
9
9
|
* This represents a time that is conceptually beyond any real possible time.
|
|
@@ -14,19 +14,20 @@ export declare class Time {
|
|
|
14
14
|
/**
|
|
15
15
|
* Gets the midnight time as a Time instance.
|
|
16
16
|
*
|
|
17
|
-
* @returns A Time instance representing midnight
|
|
17
|
+
* @returns A Time instance representing midnight.
|
|
18
18
|
*/
|
|
19
19
|
static origin(): Time;
|
|
20
20
|
private constructor();
|
|
21
21
|
/**
|
|
22
|
-
* Creates a Time instance from the number of
|
|
22
|
+
* Creates a Time instance from the number of minutes since midnight.
|
|
23
23
|
*
|
|
24
|
-
* @param
|
|
24
|
+
* @param minutes - The number of minutes since midnight.
|
|
25
25
|
* @returns A Time instance representing the specified time.
|
|
26
26
|
*/
|
|
27
|
-
static
|
|
27
|
+
static fromMinutes(minutes: number): Time;
|
|
28
28
|
/**
|
|
29
29
|
* Creates a Time instance from hours, minutes, and seconds.
|
|
30
|
+
* Rounds to the closest minute as times are represented in minutes from midnight.
|
|
30
31
|
*
|
|
31
32
|
* @param hours - The hours component of the time.
|
|
32
33
|
* @param minutes - The minutes component of the time.
|
|
@@ -34,6 +35,14 @@ export declare class Time {
|
|
|
34
35
|
* @returns A Time instance representing the specified time.
|
|
35
36
|
*/
|
|
36
37
|
static fromHMS(hours: number, minutes: number, seconds: number): Time;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a Time instance from hours, minutes.
|
|
40
|
+
*
|
|
41
|
+
* @param hours - The hours component of the time.
|
|
42
|
+
* @param minutes - The minutes component of the time.
|
|
43
|
+
* @returns A Time instance representing the specified time.
|
|
44
|
+
*/
|
|
45
|
+
static fromHM(hours: number, minutes: number): Time;
|
|
37
46
|
/**
|
|
38
47
|
* Parses a JavaScript Date object and creates a Time instance.
|
|
39
48
|
*
|
|
@@ -55,11 +64,11 @@ export declare class Time {
|
|
|
55
64
|
*/
|
|
56
65
|
toString(): string;
|
|
57
66
|
/**
|
|
58
|
-
*
|
|
67
|
+
* Converts the Time instance to the total number of minutes since midnight, rounded to the closest minute.
|
|
59
68
|
*
|
|
60
|
-
* @returns The time in
|
|
69
|
+
* @returns The time in minutes since midnight.
|
|
61
70
|
*/
|
|
62
|
-
|
|
71
|
+
toMinutes(): number;
|
|
63
72
|
/**
|
|
64
73
|
* Adds a Duration to the current Time instance and returns a new Time instance.
|
|
65
74
|
*
|
|
@@ -9,10 +9,10 @@ export declare const MUST_COORDINATE_WITH_DRIVER = 3;
|
|
|
9
9
|
export type PickUpDropOffType = 0 | 1 | 2 | 3;
|
|
10
10
|
export type Route = {
|
|
11
11
|
/**
|
|
12
|
-
* Arrivals and departures encoded as
|
|
12
|
+
* Arrivals and departures encoded as minutes from midnight.
|
|
13
13
|
* Format: [arrival1, departure1, arrival2, departure2, etc.]
|
|
14
14
|
*/
|
|
15
|
-
stopTimes:
|
|
15
|
+
stopTimes: Uint16Array;
|
|
16
16
|
/**
|
|
17
17
|
* PickUp and DropOff types represented as a binary Uint8Array.
|
|
18
18
|
* Values:
|
|
@@ -62,7 +62,7 @@ export type ServiceRoute = {
|
|
|
62
62
|
export type ServiceRoutesMap = Map<ServiceRouteId, ServiceRoute>;
|
|
63
63
|
type TripIndex = number;
|
|
64
64
|
export declare const ALL_TRANSPORT_MODES: RouteType[];
|
|
65
|
-
export declare const CURRENT_VERSION = "0.0.
|
|
65
|
+
export declare const CURRENT_VERSION = "0.0.3";
|
|
66
66
|
/**
|
|
67
67
|
* The internal transit timetable format
|
|
68
68
|
* reuses some GTFS concepts for the sake of simplicity for now.
|
package/package.json
CHANGED
|
@@ -44,10 +44,10 @@ describe('GTFS parser', () => {
|
|
|
44
44
|
]);
|
|
45
45
|
assert.strictEqual(route.stopTimes.length, 4);
|
|
46
46
|
assert.strictEqual(route.pickUpDropOffTypes.length, 4);
|
|
47
|
-
assert.strictEqual(route.stopTimes[0], Time.fromHMS(8, 0, 0).
|
|
48
|
-
assert.strictEqual(route.stopTimes[1], Time.fromHMS(8, 0, 0).
|
|
49
|
-
assert.strictEqual(route.stopTimes[2], Time.fromHMS(8, 10, 0).
|
|
50
|
-
assert.strictEqual(route.stopTimes[3], Time.fromHMS(8, 15, 0).
|
|
47
|
+
assert.strictEqual(route.stopTimes[0], Time.fromHMS(8, 0, 0).toMinutes());
|
|
48
|
+
assert.strictEqual(route.stopTimes[1], Time.fromHMS(8, 0, 0).toMinutes());
|
|
49
|
+
assert.strictEqual(route.stopTimes[2], Time.fromHMS(8, 10, 0).toMinutes());
|
|
50
|
+
assert.strictEqual(route.stopTimes[3], Time.fromHMS(8, 15, 0).toMinutes());
|
|
51
51
|
|
|
52
52
|
const routes = timetable.getRoutesThroughStop(furCreekResId);
|
|
53
53
|
assert.strictEqual(routes.length, 2);
|
|
@@ -16,10 +16,10 @@ describe('Date converter', () => {
|
|
|
16
16
|
|
|
17
17
|
describe('Time converter', () => {
|
|
18
18
|
it('should convert a valid service time to numerical format', () => {
|
|
19
|
-
assert.equal(toTime('10:23:
|
|
19
|
+
assert.equal(toTime('10:23:00').toMinutes(), 623);
|
|
20
20
|
});
|
|
21
21
|
it('should convert a valid service time after midnight to numerical format', () => {
|
|
22
|
-
assert.equal(toTime('25:13:
|
|
22
|
+
assert.equal(toTime('25:13:00').toMinutes(), 1513);
|
|
23
23
|
});
|
|
24
24
|
it('should throw when trying to convert an invalid time', () => {
|
|
25
25
|
assert.throws(() => toTime('2513:31'));
|
|
@@ -31,7 +31,7 @@ describe('buildStopsAdjacencyStructure', () => {
|
|
|
31
31
|
[0, 0],
|
|
32
32
|
[1, 1],
|
|
33
33
|
]),
|
|
34
|
-
stopTimes: new
|
|
34
|
+
stopTimes: new Uint16Array(),
|
|
35
35
|
pickUpDropOffTypes: new Uint8Array(),
|
|
36
36
|
},
|
|
37
37
|
],
|
|
@@ -69,7 +69,7 @@ describe('buildStopsAdjacencyStructure', () => {
|
|
|
69
69
|
[0, 0],
|
|
70
70
|
[1, 1],
|
|
71
71
|
]),
|
|
72
|
-
stopTimes: new
|
|
72
|
+
stopTimes: new Uint16Array(),
|
|
73
73
|
pickUpDropOffTypes: new Uint8Array(),
|
|
74
74
|
},
|
|
75
75
|
],
|
|
@@ -229,11 +229,11 @@ describe('GTFS stop times parser', () => {
|
|
|
229
229
|
[0, 0],
|
|
230
230
|
[1, 1],
|
|
231
231
|
]),
|
|
232
|
-
stopTimes: new
|
|
233
|
-
Time.fromHMS(8, 0, 0).
|
|
234
|
-
Time.fromHMS(8, 5, 0).
|
|
235
|
-
Time.fromHMS(8, 10, 0).
|
|
236
|
-
Time.fromHMS(8, 15, 0).
|
|
232
|
+
stopTimes: new Uint16Array([
|
|
233
|
+
Time.fromHMS(8, 0, 0).toMinutes(),
|
|
234
|
+
Time.fromHMS(8, 5, 0).toMinutes(),
|
|
235
|
+
Time.fromHMS(8, 10, 0).toMinutes(),
|
|
236
|
+
Time.fromHMS(8, 15, 0).toMinutes(),
|
|
237
237
|
]),
|
|
238
238
|
pickUpDropOffTypes: new Uint8Array([0, 0, 0, 0]),
|
|
239
239
|
},
|
|
@@ -299,15 +299,15 @@ describe('GTFS stop times parser', () => {
|
|
|
299
299
|
[0, 0],
|
|
300
300
|
[1, 1],
|
|
301
301
|
]),
|
|
302
|
-
stopTimes: new
|
|
303
|
-
Time.fromHMS(8, 0, 0).
|
|
304
|
-
Time.fromHMS(8, 5, 0).
|
|
305
|
-
Time.fromHMS(8, 10, 0).
|
|
306
|
-
Time.fromHMS(8, 15, 0).
|
|
307
|
-
Time.fromHMS(9, 0, 0).
|
|
308
|
-
Time.fromHMS(9, 5, 0).
|
|
309
|
-
Time.fromHMS(9, 10, 0).
|
|
310
|
-
Time.fromHMS(9, 15, 0).
|
|
302
|
+
stopTimes: new Uint16Array([
|
|
303
|
+
Time.fromHMS(8, 0, 0).toMinutes(),
|
|
304
|
+
Time.fromHMS(8, 5, 0).toMinutes(),
|
|
305
|
+
Time.fromHMS(8, 10, 0).toMinutes(),
|
|
306
|
+
Time.fromHMS(8, 15, 0).toMinutes(),
|
|
307
|
+
Time.fromHMS(9, 0, 0).toMinutes(),
|
|
308
|
+
Time.fromHMS(9, 5, 0).toMinutes(),
|
|
309
|
+
Time.fromHMS(9, 10, 0).toMinutes(),
|
|
310
|
+
Time.fromHMS(9, 15, 0).toMinutes(),
|
|
311
311
|
]),
|
|
312
312
|
pickUpDropOffTypes: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0]),
|
|
313
313
|
},
|
|
@@ -373,15 +373,15 @@ describe('GTFS stop times parser', () => {
|
|
|
373
373
|
[0, 0],
|
|
374
374
|
[1, 1],
|
|
375
375
|
]),
|
|
376
|
-
stopTimes: new
|
|
377
|
-
Time.fromHMS(8, 0, 0).
|
|
378
|
-
Time.fromHMS(8, 5, 0).
|
|
379
|
-
Time.fromHMS(8, 10, 0).
|
|
380
|
-
Time.fromHMS(8, 15, 0).
|
|
381
|
-
Time.fromHMS(9, 0, 0).
|
|
382
|
-
Time.fromHMS(9, 5, 0).
|
|
383
|
-
Time.fromHMS(9, 10, 0).
|
|
384
|
-
Time.fromHMS(9, 15, 0).
|
|
376
|
+
stopTimes: new Uint16Array([
|
|
377
|
+
Time.fromHMS(8, 0, 0).toMinutes(),
|
|
378
|
+
Time.fromHMS(8, 5, 0).toMinutes(),
|
|
379
|
+
Time.fromHMS(8, 10, 0).toMinutes(),
|
|
380
|
+
Time.fromHMS(8, 15, 0).toMinutes(),
|
|
381
|
+
Time.fromHMS(9, 0, 0).toMinutes(),
|
|
382
|
+
Time.fromHMS(9, 5, 0).toMinutes(),
|
|
383
|
+
Time.fromHMS(9, 10, 0).toMinutes(),
|
|
384
|
+
Time.fromHMS(9, 15, 0).toMinutes(),
|
|
385
385
|
]),
|
|
386
386
|
pickUpDropOffTypes: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0]),
|
|
387
387
|
},
|
|
@@ -446,11 +446,11 @@ describe('GTFS stop times parser', () => {
|
|
|
446
446
|
[0, 0],
|
|
447
447
|
[1, 1],
|
|
448
448
|
]),
|
|
449
|
-
stopTimes: new
|
|
450
|
-
Time.fromHMS(8, 0, 0).
|
|
451
|
-
Time.fromHMS(8, 5, 0).
|
|
452
|
-
Time.fromHMS(8, 10, 0).
|
|
453
|
-
Time.fromHMS(8, 15, 0).
|
|
449
|
+
stopTimes: new Uint16Array([
|
|
450
|
+
Time.fromHMS(8, 0, 0).toMinutes(),
|
|
451
|
+
Time.fromHMS(8, 5, 0).toMinutes(),
|
|
452
|
+
Time.fromHMS(8, 10, 0).toMinutes(),
|
|
453
|
+
Time.fromHMS(8, 15, 0).toMinutes(),
|
|
454
454
|
]),
|
|
455
455
|
pickUpDropOffTypes: new Uint8Array([0, 0, 0, 0]),
|
|
456
456
|
},
|
|
@@ -461,9 +461,9 @@ describe('GTFS stop times parser', () => {
|
|
|
461
461
|
serviceRouteId: 'routeA',
|
|
462
462
|
stops: new Uint32Array([0]),
|
|
463
463
|
stopIndices: new Map([[0, 0]]),
|
|
464
|
-
stopTimes: new
|
|
465
|
-
Time.fromHMS(9, 0, 0).
|
|
466
|
-
Time.fromHMS(9, 15, 0).
|
|
464
|
+
stopTimes: new Uint16Array([
|
|
465
|
+
Time.fromHMS(9, 0, 0).toMinutes(),
|
|
466
|
+
Time.fromHMS(9, 15, 0).toMinutes(),
|
|
467
467
|
]),
|
|
468
468
|
pickUpDropOffTypes: new Uint8Array([0, 0]),
|
|
469
469
|
},
|
|
@@ -521,9 +521,9 @@ describe('GTFS stop times parser', () => {
|
|
|
521
521
|
serviceRouteId: 'routeA',
|
|
522
522
|
stops: new Uint32Array([0]),
|
|
523
523
|
stopIndices: new Map([[0, 0]]),
|
|
524
|
-
stopTimes: new
|
|
525
|
-
Time.fromHMS(8, 0, 0).
|
|
526
|
-
Time.fromHMS(8, 5, 0).
|
|
524
|
+
stopTimes: new Uint16Array([
|
|
525
|
+
Time.fromHMS(8, 0, 0).toMinutes(),
|
|
526
|
+
Time.fromHMS(8, 5, 0).toMinutes(),
|
|
527
527
|
]),
|
|
528
528
|
pickUpDropOffTypes: new Uint8Array([0, 0]),
|
|
529
529
|
},
|
package/src/gtfs/trips.ts
CHANGED
|
@@ -137,7 +137,7 @@ export const parseStopTimes = async (
|
|
|
137
137
|
if (!route) {
|
|
138
138
|
const stopsCount = stops.length;
|
|
139
139
|
const stopsArray = new Uint32Array(stops);
|
|
140
|
-
const stopTimesArray = new
|
|
140
|
+
const stopTimesArray = new Uint16Array(stopsCount * 2);
|
|
141
141
|
for (let i = 0; i < stopsCount; i++) {
|
|
142
142
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
143
143
|
stopTimesArray[i * 2] = arrivalTimes[i]!;
|
|
@@ -185,7 +185,7 @@ export const parseStopTimes = async (
|
|
|
185
185
|
|
|
186
186
|
// insert data for the new trip at the right place
|
|
187
187
|
const newStopTimesLength = route.stopTimes.length + stopsCount * 2;
|
|
188
|
-
const newStopTimes = new
|
|
188
|
+
const newStopTimes = new Uint16Array(newStopTimesLength);
|
|
189
189
|
const newPickUpDropOffTypes = new Uint8Array(newStopTimesLength);
|
|
190
190
|
|
|
191
191
|
newStopTimes.set(route.stopTimes.slice(0, insertPosition * 2), 0);
|
|
@@ -257,9 +257,9 @@ export const parseStopTimes = async (
|
|
|
257
257
|
const departure = line.departure_time ?? line.arrival_time;
|
|
258
258
|
const arrival = line.arrival_time ?? line.departure_time;
|
|
259
259
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
260
|
-
arrivalTimes.push(toTime(arrival!).
|
|
260
|
+
arrivalTimes.push(toTime(arrival!).toMinutes());
|
|
261
261
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
262
|
-
departureTimes.push(toTime(departure!).
|
|
262
|
+
departureTimes.push(toTime(departure!).toMinutes());
|
|
263
263
|
pickUpTypes.push(parsePickupDropOffType(line.pickup_type));
|
|
264
264
|
dropOffTypes.push(parsePickupDropOffType(line.drop_off_type));
|
|
265
265
|
|
package/src/router.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Query } from './routing/query.js';
|
|
|
3
3
|
import { Result } from './routing/result.js';
|
|
4
4
|
import { Leg, Route, Transfer, VehicleLeg } from './routing/route.js';
|
|
5
5
|
import { ReachingTime, Router } from './routing/router.js';
|
|
6
|
-
import { LocationType, SourceStopId, Stop } from './stops/stops.js';
|
|
6
|
+
import { LocationType, SourceStopId, Stop, StopId } from './stops/stops.js';
|
|
7
7
|
import { StopsIndex } from './stops/stopsIndex.js';
|
|
8
8
|
import { Duration } from './timetable/duration.js';
|
|
9
9
|
import { Time } from './timetable/time.js';
|
|
@@ -26,8 +26,9 @@ export {
|
|
|
26
26
|
Router,
|
|
27
27
|
RouteType,
|
|
28
28
|
ServiceRoute,
|
|
29
|
+
SourceStopId,
|
|
29
30
|
Stop,
|
|
30
|
-
|
|
31
|
+
StopId,
|
|
31
32
|
StopsIndex,
|
|
32
33
|
Time,
|
|
33
34
|
Timetable,
|
|
@@ -77,8 +77,8 @@ describe('Route', () => {
|
|
|
77
77
|
const route = new Route([vehicleLeg, transferLeg, secondVehicleLeg]);
|
|
78
78
|
const departureTime = route.departureTime();
|
|
79
79
|
assert.strictEqual(
|
|
80
|
-
departureTime.
|
|
81
|
-
Time.fromHMS(8, 0, 0).
|
|
80
|
+
departureTime.toMinutes(),
|
|
81
|
+
Time.fromHMS(8, 0, 0).toMinutes(),
|
|
82
82
|
);
|
|
83
83
|
});
|
|
84
84
|
|
|
@@ -86,8 +86,8 @@ describe('Route', () => {
|
|
|
86
86
|
const route = new Route([vehicleLeg, transferLeg, secondVehicleLeg]);
|
|
87
87
|
const arrivalTime = route.arrivalTime();
|
|
88
88
|
assert.strictEqual(
|
|
89
|
-
arrivalTime.
|
|
90
|
-
Time.fromHMS(9, 0, 0).
|
|
89
|
+
arrivalTime.toMinutes(),
|
|
90
|
+
Time.fromHMS(9, 0, 0).toMinutes(),
|
|
91
91
|
);
|
|
92
92
|
});
|
|
93
93
|
|
|
@@ -31,13 +31,13 @@ describe('Router', () => {
|
|
|
31
31
|
[
|
|
32
32
|
'route1',
|
|
33
33
|
{
|
|
34
|
-
stopTimes: new
|
|
35
|
-
Time.fromString('08:00:00').
|
|
36
|
-
Time.fromString('08:10:00').
|
|
37
|
-
Time.fromString('08:15:00').
|
|
38
|
-
Time.fromString('08:25:00').
|
|
39
|
-
Time.fromString('08:35:00').
|
|
40
|
-
Time.fromString('08:45:00').
|
|
34
|
+
stopTimes: new Uint16Array([
|
|
35
|
+
Time.fromString('08:00:00').toMinutes(),
|
|
36
|
+
Time.fromString('08:10:00').toMinutes(),
|
|
37
|
+
Time.fromString('08:15:00').toMinutes(),
|
|
38
|
+
Time.fromString('08:25:00').toMinutes(),
|
|
39
|
+
Time.fromString('08:35:00').toMinutes(),
|
|
40
|
+
Time.fromString('08:45:00').toMinutes(),
|
|
41
41
|
]),
|
|
42
42
|
pickUpDropOffTypes: new Uint8Array([
|
|
43
43
|
0,
|
|
@@ -147,8 +147,8 @@ describe('Router', () => {
|
|
|
147
147
|
|
|
148
148
|
const timeToStop3 = result.arrivalAt('stop3');
|
|
149
149
|
assert.strictEqual(
|
|
150
|
-
timeToStop3?.time.
|
|
151
|
-
Time.fromString('08:35:00').
|
|
150
|
+
timeToStop3?.time.toMinutes(),
|
|
151
|
+
Time.fromString('08:35:00').toMinutes(),
|
|
152
152
|
);
|
|
153
153
|
});
|
|
154
154
|
});
|
|
@@ -168,13 +168,13 @@ describe('Router', () => {
|
|
|
168
168
|
[
|
|
169
169
|
'route1',
|
|
170
170
|
{
|
|
171
|
-
stopTimes: new
|
|
172
|
-
Time.fromString('08:00:00').
|
|
173
|
-
Time.fromString('08:15:00').
|
|
174
|
-
Time.fromString('08:30:00').
|
|
175
|
-
Time.fromString('08:45:00').
|
|
176
|
-
Time.fromString('09:00:00').
|
|
177
|
-
Time.fromString('09:10:00').
|
|
171
|
+
stopTimes: new Uint16Array([
|
|
172
|
+
Time.fromString('08:00:00').toMinutes(),
|
|
173
|
+
Time.fromString('08:15:00').toMinutes(),
|
|
174
|
+
Time.fromString('08:30:00').toMinutes(),
|
|
175
|
+
Time.fromString('08:45:00').toMinutes(),
|
|
176
|
+
Time.fromString('09:00:00').toMinutes(),
|
|
177
|
+
Time.fromString('09:10:00').toMinutes(),
|
|
178
178
|
]),
|
|
179
179
|
pickUpDropOffTypes: new Uint8Array([
|
|
180
180
|
0, // REGULAR
|
|
@@ -196,13 +196,13 @@ describe('Router', () => {
|
|
|
196
196
|
[
|
|
197
197
|
'route2',
|
|
198
198
|
{
|
|
199
|
-
stopTimes: new
|
|
200
|
-
Time.fromString('08:05:00').
|
|
201
|
-
Time.fromString('08:20:00').
|
|
202
|
-
Time.fromString('09:00:00').
|
|
203
|
-
Time.fromString('09:15:00').
|
|
204
|
-
Time.fromString('09:20:00').
|
|
205
|
-
Time.fromString('09:35:00').
|
|
199
|
+
stopTimes: new Uint16Array([
|
|
200
|
+
Time.fromString('08:05:00').toMinutes(),
|
|
201
|
+
Time.fromString('08:20:00').toMinutes(),
|
|
202
|
+
Time.fromString('09:00:00').toMinutes(),
|
|
203
|
+
Time.fromString('09:15:00').toMinutes(),
|
|
204
|
+
Time.fromString('09:20:00').toMinutes(),
|
|
205
|
+
Time.fromString('09:35:00').toMinutes(),
|
|
206
206
|
]),
|
|
207
207
|
pickUpDropOffTypes: new Uint8Array([
|
|
208
208
|
0, // REGULAR
|
|
@@ -333,8 +333,8 @@ describe('Router', () => {
|
|
|
333
333
|
|
|
334
334
|
const timeToStop5 = result.arrivalAt('stop5');
|
|
335
335
|
assert.strictEqual(
|
|
336
|
-
timeToStop5?.time.
|
|
337
|
-
Time.fromString('09:20:00').
|
|
336
|
+
timeToStop5?.time.toMinutes(),
|
|
337
|
+
Time.fromString('09:20:00').toMinutes(),
|
|
338
338
|
);
|
|
339
339
|
});
|
|
340
340
|
});
|
|
@@ -368,13 +368,13 @@ describe('Router', () => {
|
|
|
368
368
|
[
|
|
369
369
|
'route1',
|
|
370
370
|
{
|
|
371
|
-
stopTimes: new
|
|
372
|
-
Time.fromString('08:00:00').
|
|
373
|
-
Time.fromString('08:15:00').
|
|
374
|
-
Time.fromString('08:25:00').
|
|
375
|
-
Time.fromString('08:35:00').
|
|
376
|
-
Time.fromString('08:45:00').
|
|
377
|
-
Time.fromString('08:55:00').
|
|
371
|
+
stopTimes: new Uint16Array([
|
|
372
|
+
Time.fromString('08:00:00').toMinutes(),
|
|
373
|
+
Time.fromString('08:15:00').toMinutes(),
|
|
374
|
+
Time.fromString('08:25:00').toMinutes(),
|
|
375
|
+
Time.fromString('08:35:00').toMinutes(),
|
|
376
|
+
Time.fromString('08:45:00').toMinutes(),
|
|
377
|
+
Time.fromString('08:55:00').toMinutes(),
|
|
378
378
|
]),
|
|
379
379
|
pickUpDropOffTypes: new Uint8Array([
|
|
380
380
|
0, // REGULAR
|
|
@@ -396,13 +396,13 @@ describe('Router', () => {
|
|
|
396
396
|
[
|
|
397
397
|
'route2',
|
|
398
398
|
{
|
|
399
|
-
stopTimes: new
|
|
400
|
-
Time.fromString('08:10:00').
|
|
401
|
-
Time.fromString('08:20:00').
|
|
402
|
-
Time.fromString('08:40:00').
|
|
403
|
-
Time.fromString('08:50:00').
|
|
404
|
-
Time.fromString('09:00:00').
|
|
405
|
-
Time.fromString('09:10:00').
|
|
399
|
+
stopTimes: new Uint16Array([
|
|
400
|
+
Time.fromString('08:10:00').toMinutes(),
|
|
401
|
+
Time.fromString('08:20:00').toMinutes(),
|
|
402
|
+
Time.fromString('08:40:00').toMinutes(),
|
|
403
|
+
Time.fromString('08:50:00').toMinutes(),
|
|
404
|
+
Time.fromString('09:00:00').toMinutes(),
|
|
405
|
+
Time.fromString('09:10:00').toMinutes(),
|
|
406
406
|
]),
|
|
407
407
|
pickUpDropOffTypes: new Uint8Array([
|
|
408
408
|
0, // REGULAR
|
|
@@ -543,8 +543,8 @@ describe('Router', () => {
|
|
|
543
543
|
|
|
544
544
|
const timeToStop5 = result.arrivalAt('stop5');
|
|
545
545
|
assert.strictEqual(
|
|
546
|
-
timeToStop5?.time.
|
|
547
|
-
Time.fromString('08:30:00').
|
|
546
|
+
timeToStop5?.time.toMinutes(),
|
|
547
|
+
Time.fromString('08:30:00').toMinutes(),
|
|
548
548
|
);
|
|
549
549
|
});
|
|
550
550
|
});
|
|
@@ -565,13 +565,13 @@ describe('Router', () => {
|
|
|
565
565
|
[
|
|
566
566
|
'route1',
|
|
567
567
|
{
|
|
568
|
-
stopTimes: new
|
|
569
|
-
Time.fromString('08:00:00').
|
|
570
|
-
Time.fromString('08:15:00').
|
|
571
|
-
Time.fromString('08:30:00').
|
|
572
|
-
Time.fromString('08:45:00').
|
|
573
|
-
Time.fromString('09:00:00').
|
|
574
|
-
Time.fromString('09:15:00').
|
|
568
|
+
stopTimes: new Uint16Array([
|
|
569
|
+
Time.fromString('08:00:00').toMinutes(),
|
|
570
|
+
Time.fromString('08:15:00').toMinutes(),
|
|
571
|
+
Time.fromString('08:30:00').toMinutes(),
|
|
572
|
+
Time.fromString('08:45:00').toMinutes(),
|
|
573
|
+
Time.fromString('09:00:00').toMinutes(),
|
|
574
|
+
Time.fromString('09:15:00').toMinutes(),
|
|
575
575
|
]),
|
|
576
576
|
pickUpDropOffTypes: new Uint8Array([
|
|
577
577
|
0, // REGULAR
|
|
@@ -593,13 +593,13 @@ describe('Router', () => {
|
|
|
593
593
|
[
|
|
594
594
|
'route2',
|
|
595
595
|
{
|
|
596
|
-
stopTimes: new
|
|
597
|
-
Time.fromString('08:10:00').
|
|
598
|
-
Time.fromString('08:25:00').
|
|
599
|
-
Time.fromString('08:50:00').
|
|
600
|
-
Time.fromString('09:05:00').
|
|
601
|
-
Time.fromString('09:10:00').
|
|
602
|
-
Time.fromString('09:25:00').
|
|
596
|
+
stopTimes: new Uint16Array([
|
|
597
|
+
Time.fromString('08:10:00').toMinutes(),
|
|
598
|
+
Time.fromString('08:25:00').toMinutes(),
|
|
599
|
+
Time.fromString('08:50:00').toMinutes(),
|
|
600
|
+
Time.fromString('09:05:00').toMinutes(),
|
|
601
|
+
Time.fromString('09:10:00').toMinutes(),
|
|
602
|
+
Time.fromString('09:25:00').toMinutes(),
|
|
603
603
|
]),
|
|
604
604
|
pickUpDropOffTypes: new Uint8Array([
|
|
605
605
|
0, // REGULAR
|
|
@@ -621,11 +621,11 @@ describe('Router', () => {
|
|
|
621
621
|
[
|
|
622
622
|
'route3',
|
|
623
623
|
{
|
|
624
|
-
stopTimes: new
|
|
625
|
-
Time.fromString('08:00:00').
|
|
626
|
-
Time.fromString('08:15:00').
|
|
627
|
-
Time.fromString('09:45:00').
|
|
628
|
-
Time.fromString('10:00:00').
|
|
624
|
+
stopTimes: new Uint16Array([
|
|
625
|
+
Time.fromString('08:00:00').toMinutes(),
|
|
626
|
+
Time.fromString('08:15:00').toMinutes(),
|
|
627
|
+
Time.fromString('09:45:00').toMinutes(),
|
|
628
|
+
Time.fromString('10:00:00').toMinutes(),
|
|
629
629
|
]),
|
|
630
630
|
pickUpDropOffTypes: new Uint8Array([
|
|
631
631
|
0, // REGULAR
|
package/src/routing/result.ts
CHANGED
|
@@ -42,7 +42,7 @@ export class Result {
|
|
|
42
42
|
if (arrivalTime !== undefined) {
|
|
43
43
|
if (
|
|
44
44
|
fastestTime === undefined ||
|
|
45
|
-
arrivalTime.time.
|
|
45
|
+
arrivalTime.time.toMinutes() < fastestTime.time.toMinutes()
|
|
46
46
|
) {
|
|
47
47
|
fastestDestination = destination.id;
|
|
48
48
|
fastestTime = arrivalTime;
|
|
@@ -99,7 +99,7 @@ export class Result {
|
|
|
99
99
|
if (arrivalTime !== undefined) {
|
|
100
100
|
if (
|
|
101
101
|
earliestArrival === undefined ||
|
|
102
|
-
arrivalTime.time.
|
|
102
|
+
arrivalTime.time.toMinutes() < earliestArrival.time.toMinutes()
|
|
103
103
|
) {
|
|
104
104
|
earliestArrival = arrivalTime;
|
|
105
105
|
}
|
package/src/routing/router.ts
CHANGED
|
@@ -64,7 +64,7 @@ export class Router {
|
|
|
64
64
|
.time.plus(transferTime);
|
|
65
65
|
const originalArrival =
|
|
66
66
|
arrivalsAtCurrentRound.get(transfer.destination)?.time ?? UNREACHED;
|
|
67
|
-
if (arrivalAfterTransfer.
|
|
67
|
+
if (arrivalAfterTransfer.toMinutes() < originalArrival.toMinutes()) {
|
|
68
68
|
const origin = arrivalsAtCurrentRound.get(stop)?.origin ?? stop;
|
|
69
69
|
arrivalsAtCurrentRound.set(transfer.destination, {
|
|
70
70
|
time: arrivalAfterTransfer,
|
|
@@ -157,7 +157,7 @@ export class Router {
|
|
|
157
157
|
if (currentTrip !== undefined) {
|
|
158
158
|
const currentArrivalIndex =
|
|
159
159
|
(currentTrip.trip * stopNumbers + i) * 2;
|
|
160
|
-
const currentArrivalTime = Time.
|
|
160
|
+
const currentArrivalTime = Time.fromMinutes(
|
|
161
161
|
route.stopTimes[currentArrivalIndex]!,
|
|
162
162
|
);
|
|
163
163
|
const currentDropOffType = route.pickUpDropOffTypes[i * 2 + 1];
|
|
@@ -185,14 +185,14 @@ export class Router {
|
|
|
185
185
|
}
|
|
186
186
|
if (
|
|
187
187
|
currentDropOffType !== NOT_AVAILABLE &&
|
|
188
|
-
currentArrivalTime.
|
|
188
|
+
currentArrivalTime.toMinutes() < arrivalToImprove.toMinutes()
|
|
189
189
|
) {
|
|
190
190
|
const bestHopOnStopIndex = route.stopIndices.get(
|
|
191
191
|
currentTrip.bestHopOnStop,
|
|
192
192
|
)!;
|
|
193
193
|
const bestHopOnStopDepartureIndex =
|
|
194
194
|
currentTrip.trip * stopNumbers * 2 + bestHopOnStopIndex * 2 + 1;
|
|
195
|
-
const bestHopOnDepartureTime = Time.
|
|
195
|
+
const bestHopOnDepartureTime = Time.fromMinutes(
|
|
196
196
|
route.stopTimes[bestHopOnStopDepartureIndex]!,
|
|
197
197
|
);
|
|
198
198
|
arrivalsAtCurrentRound.set(currentStop, {
|
|
@@ -224,7 +224,7 @@ export class Router {
|
|
|
224
224
|
if (
|
|
225
225
|
earliestArrivalOnPreviousRound !== undefined &&
|
|
226
226
|
(currentTrip === undefined ||
|
|
227
|
-
earliestArrivalOnPreviousRound.
|
|
227
|
+
earliestArrivalOnPreviousRound.toMinutes() <=
|
|
228
228
|
route.stopTimes[(currentTrip.trip * stopNumbers + i) * 2]!)
|
|
229
229
|
) {
|
|
230
230
|
const earliestTrip = this.timetable.findEarliestTrip(
|
|
@@ -44,9 +44,9 @@ describe('timetable io', () => {
|
|
|
44
44
|
[
|
|
45
45
|
'route1',
|
|
46
46
|
{
|
|
47
|
-
stopTimes: new
|
|
48
|
-
Time.fromHMS(
|
|
49
|
-
Time.fromHMS(
|
|
47
|
+
stopTimes: new Uint16Array([
|
|
48
|
+
Time.fromHMS(16, 40, 0).toMinutes(),
|
|
49
|
+
Time.fromHMS(16, 50, 0).toMinutes(),
|
|
50
50
|
]),
|
|
51
51
|
pickUpDropOffTypes: new Uint8Array([0, 0]), // REGULAR
|
|
52
52
|
stops: new Uint32Array([1, 2]),
|
|
@@ -60,9 +60,9 @@ describe('timetable io', () => {
|
|
|
60
60
|
[
|
|
61
61
|
'route2',
|
|
62
62
|
{
|
|
63
|
-
stopTimes: new
|
|
64
|
-
Time.fromHMS(
|
|
65
|
-
Time.fromHMS(
|
|
63
|
+
stopTimes: new Uint16Array([
|
|
64
|
+
Time.fromHMS(15, 20, 0).toMinutes(),
|
|
65
|
+
Time.fromHMS(15, 30, 0).toMinutes(),
|
|
66
66
|
]),
|
|
67
67
|
pickUpDropOffTypes: new Uint8Array([0, 0]), // REGULAR
|
|
68
68
|
stops: new Uint32Array([2, 1]),
|
|
@@ -101,9 +101,9 @@ describe('timetable io', () => {
|
|
|
101
101
|
routes: {
|
|
102
102
|
route1: {
|
|
103
103
|
stopTimes: new Uint8Array(
|
|
104
|
-
new
|
|
105
|
-
Time.fromHMS(
|
|
106
|
-
Time.fromHMS(
|
|
104
|
+
new Uint16Array([
|
|
105
|
+
Time.fromHMS(16, 40, 0).toMinutes(),
|
|
106
|
+
Time.fromHMS(16, 50, 0).toMinutes(),
|
|
107
107
|
]).buffer,
|
|
108
108
|
),
|
|
109
109
|
pickUpDropOffTypes: new Uint8Array([0, 0]), // REGULAR
|
|
@@ -112,9 +112,9 @@ describe('timetable io', () => {
|
|
|
112
112
|
},
|
|
113
113
|
route2: {
|
|
114
114
|
stopTimes: new Uint8Array(
|
|
115
|
-
new
|
|
116
|
-
Time.fromHMS(
|
|
117
|
-
Time.fromHMS(
|
|
115
|
+
new Uint16Array([
|
|
116
|
+
Time.fromHMS(15, 20, 0).toMinutes(),
|
|
117
|
+
Time.fromHMS(15, 30, 0).toMinutes(),
|
|
118
118
|
]).buffer,
|
|
119
119
|
),
|
|
120
120
|
pickUpDropOffTypes: new Uint8Array([0, 0]), // REGULAR
|