minotor 9.0.0 → 9.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/.github/workflows/minotor.yml +1 -1
- package/CHANGELOG.md +2 -7
- package/dist/cli.mjs +601 -524
- package/dist/cli.mjs.map +1 -1
- package/dist/parser.cjs.js +494 -410
- package/dist/parser.cjs.js.map +1 -1
- package/dist/parser.esm.js +494 -410
- 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/package.json +1 -1
- package/src/routing/router.ts +1 -1
- package/src/timetable/tripBoardingId.ts +4 -4
- package/tsconfig.json +2 -2
package/dist/parser.esm.js
CHANGED
|
@@ -5,6 +5,58 @@ import require$$3 from 'events';
|
|
|
5
5
|
import require$$4 from 'zlib';
|
|
6
6
|
import require$$5, { Transform } from 'stream';
|
|
7
7
|
|
|
8
|
+
/******************************************************************************
|
|
9
|
+
Copyright (c) Microsoft Corporation.
|
|
10
|
+
|
|
11
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
12
|
+
purpose with or without fee is hereby granted.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
15
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
16
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
17
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
18
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
19
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
20
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
21
|
+
***************************************************************************** */
|
|
22
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function __values(o) {
|
|
36
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
37
|
+
if (m) return m.call(o);
|
|
38
|
+
if (o && typeof o.length === "number") return {
|
|
39
|
+
next: function () {
|
|
40
|
+
if (o && i >= o.length) o = void 0;
|
|
41
|
+
return { value: o && o[i++], done: !o };
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function __asyncValues(o) {
|
|
48
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
49
|
+
var m = o[Symbol.asyncIterator], i;
|
|
50
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
51
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
52
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
56
|
+
var e = new Error(message);
|
|
57
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
58
|
+
};
|
|
59
|
+
|
|
8
60
|
function getDefaultExportFromCjs (x) {
|
|
9
61
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
10
62
|
}
|
|
@@ -11500,13 +11552,14 @@ const Stop = {
|
|
|
11500
11552
|
sourceStopId: isSet$1(object.sourceStopId) ? globalThis.String(object.sourceStopId) : "",
|
|
11501
11553
|
lat: isSet$1(object.lat) ? globalThis.Number(object.lat) : undefined,
|
|
11502
11554
|
lon: isSet$1(object.lon) ? globalThis.Number(object.lon) : undefined,
|
|
11503
|
-
children: globalThis.Array.isArray(object
|
|
11555
|
+
children: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.children) ? object.children.map((e) => globalThis.Number(e)) : [],
|
|
11504
11556
|
parent: isSet$1(object.parent) ? globalThis.Number(object.parent) : undefined,
|
|
11505
11557
|
locationType: isSet$1(object.locationType) ? locationTypeFromJSON(object.locationType) : 0,
|
|
11506
11558
|
platform: isSet$1(object.platform) ? globalThis.String(object.platform) : undefined,
|
|
11507
11559
|
};
|
|
11508
11560
|
},
|
|
11509
11561
|
toJSON(message) {
|
|
11562
|
+
var _a;
|
|
11510
11563
|
const obj = {};
|
|
11511
11564
|
if (message.name !== "") {
|
|
11512
11565
|
obj.name = message.name;
|
|
@@ -11520,7 +11573,7 @@ const Stop = {
|
|
|
11520
11573
|
if (message.lon !== undefined) {
|
|
11521
11574
|
obj.lon = message.lon;
|
|
11522
11575
|
}
|
|
11523
|
-
if (message.children
|
|
11576
|
+
if ((_a = message.children) === null || _a === void 0 ? void 0 : _a.length) {
|
|
11524
11577
|
obj.children = message.children.map((e) => Math.round(e));
|
|
11525
11578
|
}
|
|
11526
11579
|
if (message.parent !== undefined) {
|
|
@@ -11535,18 +11588,19 @@ const Stop = {
|
|
|
11535
11588
|
return obj;
|
|
11536
11589
|
},
|
|
11537
11590
|
create(base) {
|
|
11538
|
-
return Stop.fromPartial(base
|
|
11591
|
+
return Stop.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
11539
11592
|
},
|
|
11540
11593
|
fromPartial(object) {
|
|
11594
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
11541
11595
|
const message = createBaseStop();
|
|
11542
|
-
message.name = object.name
|
|
11543
|
-
message.sourceStopId = object.sourceStopId
|
|
11544
|
-
message.lat = object.lat
|
|
11545
|
-
message.lon = object.lon
|
|
11546
|
-
message.children = object.children
|
|
11547
|
-
message.parent = object.parent
|
|
11548
|
-
message.locationType = object.locationType
|
|
11549
|
-
message.platform = object.platform
|
|
11596
|
+
message.name = (_a = object.name) !== null && _a !== void 0 ? _a : "";
|
|
11597
|
+
message.sourceStopId = (_b = object.sourceStopId) !== null && _b !== void 0 ? _b : "";
|
|
11598
|
+
message.lat = (_c = object.lat) !== null && _c !== void 0 ? _c : undefined;
|
|
11599
|
+
message.lon = (_d = object.lon) !== null && _d !== void 0 ? _d : undefined;
|
|
11600
|
+
message.children = ((_e = object.children) === null || _e === void 0 ? void 0 : _e.map((e) => e)) || [];
|
|
11601
|
+
message.parent = (_f = object.parent) !== null && _f !== void 0 ? _f : undefined;
|
|
11602
|
+
message.locationType = (_g = object.locationType) !== null && _g !== void 0 ? _g : 0;
|
|
11603
|
+
message.platform = (_h = object.platform) !== null && _h !== void 0 ? _h : undefined;
|
|
11550
11604
|
return message;
|
|
11551
11605
|
},
|
|
11552
11606
|
};
|
|
@@ -11595,26 +11649,28 @@ const StopsMap = {
|
|
|
11595
11649
|
fromJSON(object) {
|
|
11596
11650
|
return {
|
|
11597
11651
|
version: isSet$1(object.version) ? globalThis.String(object.version) : "",
|
|
11598
|
-
stops: globalThis.Array.isArray(object
|
|
11652
|
+
stops: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.stops) ? object.stops.map((e) => Stop.fromJSON(e)) : [],
|
|
11599
11653
|
};
|
|
11600
11654
|
},
|
|
11601
11655
|
toJSON(message) {
|
|
11656
|
+
var _a;
|
|
11602
11657
|
const obj = {};
|
|
11603
11658
|
if (message.version !== "") {
|
|
11604
11659
|
obj.version = message.version;
|
|
11605
11660
|
}
|
|
11606
|
-
if (message.stops
|
|
11661
|
+
if ((_a = message.stops) === null || _a === void 0 ? void 0 : _a.length) {
|
|
11607
11662
|
obj.stops = message.stops.map((e) => Stop.toJSON(e));
|
|
11608
11663
|
}
|
|
11609
11664
|
return obj;
|
|
11610
11665
|
},
|
|
11611
11666
|
create(base) {
|
|
11612
|
-
return StopsMap.fromPartial(base
|
|
11667
|
+
return StopsMap.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
11613
11668
|
},
|
|
11614
11669
|
fromPartial(object) {
|
|
11670
|
+
var _a, _b;
|
|
11615
11671
|
const message = createBaseStopsMap();
|
|
11616
|
-
message.version = object.version
|
|
11617
|
-
message.stops = object.stops
|
|
11672
|
+
message.version = (_a = object.version) !== null && _a !== void 0 ? _a : "";
|
|
11673
|
+
message.stops = ((_b = object.stops) === null || _b === void 0 ? void 0 : _b.map((e) => Stop.fromPartial(e))) || [];
|
|
11618
11674
|
return message;
|
|
11619
11675
|
},
|
|
11620
11676
|
};
|
|
@@ -11698,12 +11754,8 @@ const serializeLocationType = (locationType) => {
|
|
|
11698
11754
|
* to efficiently find stops based on user queries.
|
|
11699
11755
|
*/
|
|
11700
11756
|
class StopsIndex {
|
|
11701
|
-
stops;
|
|
11702
|
-
sourceStopsMap;
|
|
11703
|
-
textIndex;
|
|
11704
|
-
geoIndex;
|
|
11705
|
-
stopPoints;
|
|
11706
11757
|
constructor(stops) {
|
|
11758
|
+
var _a;
|
|
11707
11759
|
this.stops = stops;
|
|
11708
11760
|
this.sourceStopsMap = new Map();
|
|
11709
11761
|
const stopsSet = new Map();
|
|
@@ -11712,7 +11764,7 @@ class StopsIndex {
|
|
|
11712
11764
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
11713
11765
|
const stop = stops[id];
|
|
11714
11766
|
this.sourceStopsMap.set(stop.sourceStopId, id);
|
|
11715
|
-
const effectiveStopId = stop.parent
|
|
11767
|
+
const effectiveStopId = (_a = stop.parent) !== null && _a !== void 0 ? _a : id;
|
|
11716
11768
|
if (!stopsSet.has(effectiveStopId)) {
|
|
11717
11769
|
stopsSet.set(effectiveStopId, {
|
|
11718
11770
|
id: effectiveStopId,
|
|
@@ -11827,6 +11879,7 @@ class StopsIndex {
|
|
|
11827
11879
|
* Find ids of all sibling stops.
|
|
11828
11880
|
*/
|
|
11829
11881
|
equivalentStops(sourceId) {
|
|
11882
|
+
var _a, _b;
|
|
11830
11883
|
const id = this.sourceStopsMap.get(sourceId);
|
|
11831
11884
|
if (id === undefined) {
|
|
11832
11885
|
return [];
|
|
@@ -11836,14 +11889,13 @@ class StopsIndex {
|
|
|
11836
11889
|
return [];
|
|
11837
11890
|
}
|
|
11838
11891
|
const equivalentStops = stop.parent
|
|
11839
|
-
? (this.stops[stop.parent]
|
|
11892
|
+
? ((_b = (_a = this.stops[stop.parent]) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : [])
|
|
11840
11893
|
: stop.children;
|
|
11841
11894
|
return Array.from(new Set([id, ...equivalentStops])).map((stopId) => this.stops[stopId]);
|
|
11842
11895
|
}
|
|
11843
11896
|
}
|
|
11844
11897
|
|
|
11845
11898
|
class Duration {
|
|
11846
|
-
totalSeconds;
|
|
11847
11899
|
constructor(totalSeconds) {
|
|
11848
11900
|
this.totalSeconds = totalSeconds;
|
|
11849
11901
|
}
|
|
@@ -12146,14 +12198,15 @@ const Route$1 = {
|
|
|
12146
12198
|
return obj;
|
|
12147
12199
|
},
|
|
12148
12200
|
create(base) {
|
|
12149
|
-
return Route$1.fromPartial(base
|
|
12201
|
+
return Route$1.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
12150
12202
|
},
|
|
12151
12203
|
fromPartial(object) {
|
|
12204
|
+
var _a, _b, _c, _d;
|
|
12152
12205
|
const message = createBaseRoute();
|
|
12153
|
-
message.stopTimes = object.stopTimes
|
|
12154
|
-
message.pickUpDropOffTypes = object.pickUpDropOffTypes
|
|
12155
|
-
message.stops = object.stops
|
|
12156
|
-
message.serviceRouteId = object.serviceRouteId
|
|
12206
|
+
message.stopTimes = (_a = object.stopTimes) !== null && _a !== void 0 ? _a : new Uint8Array(0);
|
|
12207
|
+
message.pickUpDropOffTypes = (_b = object.pickUpDropOffTypes) !== null && _b !== void 0 ? _b : new Uint8Array(0);
|
|
12208
|
+
message.stops = (_c = object.stops) !== null && _c !== void 0 ? _c : new Uint8Array(0);
|
|
12209
|
+
message.serviceRouteId = (_d = object.serviceRouteId) !== null && _d !== void 0 ? _d : 0;
|
|
12157
12210
|
return message;
|
|
12158
12211
|
},
|
|
12159
12212
|
};
|
|
@@ -12230,13 +12283,14 @@ const Transfer = {
|
|
|
12230
12283
|
return obj;
|
|
12231
12284
|
},
|
|
12232
12285
|
create(base) {
|
|
12233
|
-
return Transfer.fromPartial(base
|
|
12286
|
+
return Transfer.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
12234
12287
|
},
|
|
12235
12288
|
fromPartial(object) {
|
|
12289
|
+
var _a, _b, _c;
|
|
12236
12290
|
const message = createBaseTransfer();
|
|
12237
|
-
message.destination = object.destination
|
|
12238
|
-
message.type = object.type
|
|
12239
|
-
message.minTransferTime = object.minTransferTime
|
|
12291
|
+
message.destination = (_a = object.destination) !== null && _a !== void 0 ? _a : 0;
|
|
12292
|
+
message.type = (_b = object.type) !== null && _b !== void 0 ? _b : 0;
|
|
12293
|
+
message.minTransferTime = (_c = object.minTransferTime) !== null && _c !== void 0 ? _c : undefined;
|
|
12240
12294
|
return message;
|
|
12241
12295
|
},
|
|
12242
12296
|
};
|
|
@@ -12313,13 +12367,14 @@ const TripBoarding = {
|
|
|
12313
12367
|
return obj;
|
|
12314
12368
|
},
|
|
12315
12369
|
create(base) {
|
|
12316
|
-
return TripBoarding.fromPartial(base
|
|
12370
|
+
return TripBoarding.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
12317
12371
|
},
|
|
12318
12372
|
fromPartial(object) {
|
|
12373
|
+
var _a, _b, _c;
|
|
12319
12374
|
const message = createBaseTripBoarding();
|
|
12320
|
-
message.hopOnStopIndex = object.hopOnStopIndex
|
|
12321
|
-
message.routeId = object.routeId
|
|
12322
|
-
message.tripIndex = object.tripIndex
|
|
12375
|
+
message.hopOnStopIndex = (_a = object.hopOnStopIndex) !== null && _a !== void 0 ? _a : 0;
|
|
12376
|
+
message.routeId = (_b = object.routeId) !== null && _b !== void 0 ? _b : 0;
|
|
12377
|
+
message.tripIndex = (_c = object.tripIndex) !== null && _c !== void 0 ? _c : 0;
|
|
12323
12378
|
return message;
|
|
12324
12379
|
},
|
|
12325
12380
|
};
|
|
@@ -12390,12 +12445,13 @@ const TripContinuationEntry = {
|
|
|
12390
12445
|
originStopIndex: isSet(object.originStopIndex) ? globalThis.Number(object.originStopIndex) : 0,
|
|
12391
12446
|
originRouteId: isSet(object.originRouteId) ? globalThis.Number(object.originRouteId) : 0,
|
|
12392
12447
|
originTripIndex: isSet(object.originTripIndex) ? globalThis.Number(object.originTripIndex) : 0,
|
|
12393
|
-
continuations: globalThis.Array.isArray(object
|
|
12448
|
+
continuations: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.continuations)
|
|
12394
12449
|
? object.continuations.map((e) => TripBoarding.fromJSON(e))
|
|
12395
12450
|
: [],
|
|
12396
12451
|
};
|
|
12397
12452
|
},
|
|
12398
12453
|
toJSON(message) {
|
|
12454
|
+
var _a;
|
|
12399
12455
|
const obj = {};
|
|
12400
12456
|
if (message.originStopIndex !== 0) {
|
|
12401
12457
|
obj.originStopIndex = Math.round(message.originStopIndex);
|
|
@@ -12406,20 +12462,21 @@ const TripContinuationEntry = {
|
|
|
12406
12462
|
if (message.originTripIndex !== 0) {
|
|
12407
12463
|
obj.originTripIndex = Math.round(message.originTripIndex);
|
|
12408
12464
|
}
|
|
12409
|
-
if (message.continuations
|
|
12465
|
+
if ((_a = message.continuations) === null || _a === void 0 ? void 0 : _a.length) {
|
|
12410
12466
|
obj.continuations = message.continuations.map((e) => TripBoarding.toJSON(e));
|
|
12411
12467
|
}
|
|
12412
12468
|
return obj;
|
|
12413
12469
|
},
|
|
12414
12470
|
create(base) {
|
|
12415
|
-
return TripContinuationEntry.fromPartial(base
|
|
12471
|
+
return TripContinuationEntry.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
12416
12472
|
},
|
|
12417
12473
|
fromPartial(object) {
|
|
12474
|
+
var _a, _b, _c, _d;
|
|
12418
12475
|
const message = createBaseTripContinuationEntry();
|
|
12419
|
-
message.originStopIndex = object.originStopIndex
|
|
12420
|
-
message.originRouteId = object.originRouteId
|
|
12421
|
-
message.originTripIndex = object.originTripIndex
|
|
12422
|
-
message.continuations = object.continuations
|
|
12476
|
+
message.originStopIndex = (_a = object.originStopIndex) !== null && _a !== void 0 ? _a : 0;
|
|
12477
|
+
message.originRouteId = (_b = object.originRouteId) !== null && _b !== void 0 ? _b : 0;
|
|
12478
|
+
message.originTripIndex = (_c = object.originTripIndex) !== null && _c !== void 0 ? _c : 0;
|
|
12479
|
+
message.continuations = ((_d = object.continuations) === null || _d === void 0 ? void 0 : _d.map((e) => TripBoarding.fromPartial(e))) || [];
|
|
12423
12480
|
return message;
|
|
12424
12481
|
},
|
|
12425
12482
|
};
|
|
@@ -12476,29 +12533,31 @@ const StopAdjacency = {
|
|
|
12476
12533
|
},
|
|
12477
12534
|
fromJSON(object) {
|
|
12478
12535
|
return {
|
|
12479
|
-
routes: globalThis.Array.isArray(object
|
|
12480
|
-
transfers: globalThis.Array.isArray(object
|
|
12536
|
+
routes: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.routes) ? object.routes.map((e) => globalThis.Number(e)) : [],
|
|
12537
|
+
transfers: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.transfers)
|
|
12481
12538
|
? object.transfers.map((e) => Transfer.fromJSON(e))
|
|
12482
12539
|
: [],
|
|
12483
12540
|
};
|
|
12484
12541
|
},
|
|
12485
12542
|
toJSON(message) {
|
|
12543
|
+
var _a, _b;
|
|
12486
12544
|
const obj = {};
|
|
12487
|
-
if (message.routes
|
|
12545
|
+
if ((_a = message.routes) === null || _a === void 0 ? void 0 : _a.length) {
|
|
12488
12546
|
obj.routes = message.routes.map((e) => Math.round(e));
|
|
12489
12547
|
}
|
|
12490
|
-
if (message.transfers
|
|
12548
|
+
if ((_b = message.transfers) === null || _b === void 0 ? void 0 : _b.length) {
|
|
12491
12549
|
obj.transfers = message.transfers.map((e) => Transfer.toJSON(e));
|
|
12492
12550
|
}
|
|
12493
12551
|
return obj;
|
|
12494
12552
|
},
|
|
12495
12553
|
create(base) {
|
|
12496
|
-
return StopAdjacency.fromPartial(base
|
|
12554
|
+
return StopAdjacency.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
12497
12555
|
},
|
|
12498
12556
|
fromPartial(object) {
|
|
12557
|
+
var _a, _b;
|
|
12499
12558
|
const message = createBaseStopAdjacency();
|
|
12500
|
-
message.routes = object.routes
|
|
12501
|
-
message.transfers = object.transfers
|
|
12559
|
+
message.routes = ((_a = object.routes) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
|
|
12560
|
+
message.transfers = ((_b = object.transfers) === null || _b === void 0 ? void 0 : _b.map((e) => Transfer.fromPartial(e))) || [];
|
|
12502
12561
|
return message;
|
|
12503
12562
|
},
|
|
12504
12563
|
};
|
|
@@ -12567,10 +12626,11 @@ const ServiceRoute = {
|
|
|
12567
12626
|
return {
|
|
12568
12627
|
type: isSet(object.type) ? routeTypeFromJSON(object.type) : 0,
|
|
12569
12628
|
name: isSet(object.name) ? globalThis.String(object.name) : "",
|
|
12570
|
-
routes: globalThis.Array.isArray(object
|
|
12629
|
+
routes: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.routes) ? object.routes.map((e) => globalThis.Number(e)) : [],
|
|
12571
12630
|
};
|
|
12572
12631
|
},
|
|
12573
12632
|
toJSON(message) {
|
|
12633
|
+
var _a;
|
|
12574
12634
|
const obj = {};
|
|
12575
12635
|
if (message.type !== 0) {
|
|
12576
12636
|
obj.type = routeTypeToJSON(message.type);
|
|
@@ -12578,19 +12638,20 @@ const ServiceRoute = {
|
|
|
12578
12638
|
if (message.name !== "") {
|
|
12579
12639
|
obj.name = message.name;
|
|
12580
12640
|
}
|
|
12581
|
-
if (message.routes
|
|
12641
|
+
if ((_a = message.routes) === null || _a === void 0 ? void 0 : _a.length) {
|
|
12582
12642
|
obj.routes = message.routes.map((e) => Math.round(e));
|
|
12583
12643
|
}
|
|
12584
12644
|
return obj;
|
|
12585
12645
|
},
|
|
12586
12646
|
create(base) {
|
|
12587
|
-
return ServiceRoute.fromPartial(base
|
|
12647
|
+
return ServiceRoute.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
12588
12648
|
},
|
|
12589
12649
|
fromPartial(object) {
|
|
12650
|
+
var _a, _b, _c;
|
|
12590
12651
|
const message = createBaseServiceRoute();
|
|
12591
|
-
message.type = object.type
|
|
12592
|
-
message.name = object.name
|
|
12593
|
-
message.routes = object.routes
|
|
12652
|
+
message.type = (_a = object.type) !== null && _a !== void 0 ? _a : 0;
|
|
12653
|
+
message.name = (_b = object.name) !== null && _b !== void 0 ? _b : "";
|
|
12654
|
+
message.routes = ((_c = object.routes) === null || _c === void 0 ? void 0 : _c.map((e) => e)) || [];
|
|
12594
12655
|
return message;
|
|
12595
12656
|
},
|
|
12596
12657
|
};
|
|
@@ -12669,49 +12730,51 @@ const Timetable$1 = {
|
|
|
12669
12730
|
fromJSON(object) {
|
|
12670
12731
|
return {
|
|
12671
12732
|
version: isSet(object.version) ? globalThis.String(object.version) : "",
|
|
12672
|
-
stopsAdjacency: globalThis.Array.isArray(object
|
|
12733
|
+
stopsAdjacency: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.stopsAdjacency)
|
|
12673
12734
|
? object.stopsAdjacency.map((e) => StopAdjacency.fromJSON(e))
|
|
12674
12735
|
: [],
|
|
12675
|
-
routesAdjacency: globalThis.Array.isArray(object
|
|
12736
|
+
routesAdjacency: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.routesAdjacency)
|
|
12676
12737
|
? object.routesAdjacency.map((e) => Route$1.fromJSON(e))
|
|
12677
12738
|
: [],
|
|
12678
|
-
serviceRoutes: globalThis.Array.isArray(object
|
|
12739
|
+
serviceRoutes: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.serviceRoutes)
|
|
12679
12740
|
? object.serviceRoutes.map((e) => ServiceRoute.fromJSON(e))
|
|
12680
12741
|
: [],
|
|
12681
|
-
tripContinuations: globalThis.Array.isArray(object
|
|
12742
|
+
tripContinuations: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.tripContinuations)
|
|
12682
12743
|
? object.tripContinuations.map((e) => TripContinuationEntry.fromJSON(e))
|
|
12683
12744
|
: [],
|
|
12684
12745
|
};
|
|
12685
12746
|
},
|
|
12686
12747
|
toJSON(message) {
|
|
12748
|
+
var _a, _b, _c, _d;
|
|
12687
12749
|
const obj = {};
|
|
12688
12750
|
if (message.version !== "") {
|
|
12689
12751
|
obj.version = message.version;
|
|
12690
12752
|
}
|
|
12691
|
-
if (message.stopsAdjacency
|
|
12753
|
+
if ((_a = message.stopsAdjacency) === null || _a === void 0 ? void 0 : _a.length) {
|
|
12692
12754
|
obj.stopsAdjacency = message.stopsAdjacency.map((e) => StopAdjacency.toJSON(e));
|
|
12693
12755
|
}
|
|
12694
|
-
if (message.routesAdjacency
|
|
12756
|
+
if ((_b = message.routesAdjacency) === null || _b === void 0 ? void 0 : _b.length) {
|
|
12695
12757
|
obj.routesAdjacency = message.routesAdjacency.map((e) => Route$1.toJSON(e));
|
|
12696
12758
|
}
|
|
12697
|
-
if (message.serviceRoutes
|
|
12759
|
+
if ((_c = message.serviceRoutes) === null || _c === void 0 ? void 0 : _c.length) {
|
|
12698
12760
|
obj.serviceRoutes = message.serviceRoutes.map((e) => ServiceRoute.toJSON(e));
|
|
12699
12761
|
}
|
|
12700
|
-
if (message.tripContinuations
|
|
12762
|
+
if ((_d = message.tripContinuations) === null || _d === void 0 ? void 0 : _d.length) {
|
|
12701
12763
|
obj.tripContinuations = message.tripContinuations.map((e) => TripContinuationEntry.toJSON(e));
|
|
12702
12764
|
}
|
|
12703
12765
|
return obj;
|
|
12704
12766
|
},
|
|
12705
12767
|
create(base) {
|
|
12706
|
-
return Timetable$1.fromPartial(base
|
|
12768
|
+
return Timetable$1.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
12707
12769
|
},
|
|
12708
12770
|
fromPartial(object) {
|
|
12771
|
+
var _a, _b, _c, _d, _e;
|
|
12709
12772
|
const message = createBaseTimetable();
|
|
12710
|
-
message.version = object.version
|
|
12711
|
-
message.stopsAdjacency = object.stopsAdjacency
|
|
12712
|
-
message.routesAdjacency = object.routesAdjacency
|
|
12713
|
-
message.serviceRoutes = object.serviceRoutes
|
|
12714
|
-
message.tripContinuations = object.tripContinuations
|
|
12773
|
+
message.version = (_a = object.version) !== null && _a !== void 0 ? _a : "";
|
|
12774
|
+
message.stopsAdjacency = ((_b = object.stopsAdjacency) === null || _b === void 0 ? void 0 : _b.map((e) => StopAdjacency.fromPartial(e))) || [];
|
|
12775
|
+
message.routesAdjacency = ((_c = object.routesAdjacency) === null || _c === void 0 ? void 0 : _c.map((e) => Route$1.fromPartial(e))) || [];
|
|
12776
|
+
message.serviceRoutes = ((_d = object.serviceRoutes) === null || _d === void 0 ? void 0 : _d.map((e) => ServiceRoute.fromPartial(e))) || [];
|
|
12777
|
+
message.tripContinuations = ((_e = object.tripContinuations) === null || _e === void 0 ? void 0 : _e.map((e) => TripContinuationEntry.fromPartial(e))) || [];
|
|
12715
12778
|
return message;
|
|
12716
12779
|
},
|
|
12717
12780
|
};
|
|
@@ -12748,11 +12811,6 @@ function isSet(value) {
|
|
|
12748
12811
|
* A class representing a time as minutes since midnight.
|
|
12749
12812
|
*/
|
|
12750
12813
|
class Time {
|
|
12751
|
-
/*
|
|
12752
|
-
* Number of minutes since midnight.
|
|
12753
|
-
Note that this value can go beyond 3600 to model services overlapping with the next day.
|
|
12754
|
-
*/
|
|
12755
|
-
minutesSinceMidnight;
|
|
12756
12814
|
/**
|
|
12757
12815
|
* Gets the infinity time as a Time instance.
|
|
12758
12816
|
* This represents a time that is conceptually beyond any real possible time.
|
|
@@ -13005,51 +13063,6 @@ const toPickupDropOffType = (numericalType) => {
|
|
|
13005
13063
|
* A route identifies all trips of a given service route sharing the same list of stops.
|
|
13006
13064
|
*/
|
|
13007
13065
|
class Route {
|
|
13008
|
-
id;
|
|
13009
|
-
/**
|
|
13010
|
-
* Arrivals and departures encoded as minutes from midnight.
|
|
13011
|
-
* Format: [arrival1, departure1, arrival2, departure2, etc.]
|
|
13012
|
-
*/
|
|
13013
|
-
stopTimes;
|
|
13014
|
-
/**
|
|
13015
|
-
* PickUp and DropOff types represented as a 2-bit encoded Uint8Array.
|
|
13016
|
-
* Values (2 bits each):
|
|
13017
|
-
* 0: REGULAR
|
|
13018
|
-
* 1: NOT_AVAILABLE
|
|
13019
|
-
* 2: MUST_PHONE_AGENCY
|
|
13020
|
-
* 3: MUST_COORDINATE_WITH_DRIVER
|
|
13021
|
-
*
|
|
13022
|
-
* Encoding format: Each byte contains 2 pickup/drop-off pairs (4 bits each)
|
|
13023
|
-
* Bit layout per byte: [pickup_1 (2 bits)][drop_off_1 (2 bits)][pickup_0 (2 bits)][drop_off_0 (2 bits)]
|
|
13024
|
-
* Example: For stops 0 and 1 in a trip, one byte encodes all 4 values
|
|
13025
|
-
*/
|
|
13026
|
-
pickUpDropOffTypes;
|
|
13027
|
-
/**
|
|
13028
|
-
* A binary array of stopIds in the route.
|
|
13029
|
-
* [stop1, stop2, stop3,...]
|
|
13030
|
-
*/
|
|
13031
|
-
stops;
|
|
13032
|
-
/**
|
|
13033
|
-
* A reverse mapping of each stop with their index in the route:
|
|
13034
|
-
* {
|
|
13035
|
-
* 4: 0,
|
|
13036
|
-
* 5: 1,
|
|
13037
|
-
* ...
|
|
13038
|
-
* }
|
|
13039
|
-
*/
|
|
13040
|
-
stopIndices;
|
|
13041
|
-
/**
|
|
13042
|
-
* The identifier of the route as a service shown to users.
|
|
13043
|
-
*/
|
|
13044
|
-
serviceRouteId;
|
|
13045
|
-
/**
|
|
13046
|
-
* The total number of stops in the route.
|
|
13047
|
-
*/
|
|
13048
|
-
nbStops;
|
|
13049
|
-
/**
|
|
13050
|
-
* The total number of trips in the route.
|
|
13051
|
-
*/
|
|
13052
|
-
nbTrips;
|
|
13053
13066
|
constructor(id, stopTimes, pickUpDropOffTypes, stops, serviceRouteId) {
|
|
13054
13067
|
this.id = id;
|
|
13055
13068
|
this.stopTimes = stopTimes;
|
|
@@ -13078,6 +13091,7 @@ class Route {
|
|
|
13078
13091
|
* @returns The new route.
|
|
13079
13092
|
*/
|
|
13080
13093
|
static of(params) {
|
|
13094
|
+
var _a, _b;
|
|
13081
13095
|
const { id, serviceRouteId, trips } = params;
|
|
13082
13096
|
if (trips.length === 0) {
|
|
13083
13097
|
throw new Error('At least one trip must be provided');
|
|
@@ -13124,8 +13138,8 @@ class Route {
|
|
|
13124
13138
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
13125
13139
|
const stop = trip.stops[stopIndex];
|
|
13126
13140
|
const globalIndex = tripIndex * numStops + stopIndex;
|
|
13127
|
-
const pickUp = stop.pickUpType
|
|
13128
|
-
const dropOff = stop.dropOffType
|
|
13141
|
+
const pickUp = (_a = stop.pickUpType) !== null && _a !== void 0 ? _a : REGULAR;
|
|
13142
|
+
const dropOff = (_b = stop.dropOffType) !== null && _b !== void 0 ? _b : REGULAR;
|
|
13129
13143
|
const byteIndex = Math.floor(globalIndex / 2);
|
|
13130
13144
|
const isSecondPair = globalIndex % 2 === 1;
|
|
13131
13145
|
if (isSecondPair) {
|
|
@@ -13285,7 +13299,7 @@ class Route {
|
|
|
13285
13299
|
}
|
|
13286
13300
|
if (lb === -1)
|
|
13287
13301
|
return undefined;
|
|
13288
|
-
for (let t = lb; t < (beforeTrip
|
|
13302
|
+
for (let t = lb; t < (beforeTrip !== null && beforeTrip !== void 0 ? beforeTrip : this.nbTrips); t++) {
|
|
13289
13303
|
const pickup = this.pickUpTypeFrom(stopIndex, t);
|
|
13290
13304
|
if (pickup !== 'NOT_AVAILABLE') {
|
|
13291
13305
|
return t;
|
|
@@ -13320,12 +13334,12 @@ class Route {
|
|
|
13320
13334
|
}
|
|
13321
13335
|
|
|
13322
13336
|
// Each value uses 20 bits, allowing values from 0 to 1,048,575 (2^20 - 1)
|
|
13323
|
-
const VALUE_MASK = (
|
|
13324
|
-
const MAX_VALUE =
|
|
13337
|
+
const VALUE_MASK = (BigInt(1) << BigInt(20)) - BigInt(1); // 0xFFFFF
|
|
13338
|
+
const MAX_VALUE = 1048575; // 2^20 - 1
|
|
13325
13339
|
// Bit positions for each value in the 60-bit bigint
|
|
13326
|
-
const TRIP_INDEX_SHIFT =
|
|
13327
|
-
const ROUTE_ID_SHIFT =
|
|
13328
|
-
const STOP_INDEX_SHIFT =
|
|
13340
|
+
const TRIP_INDEX_SHIFT = BigInt(0);
|
|
13341
|
+
const ROUTE_ID_SHIFT = BigInt(20);
|
|
13342
|
+
const STOP_INDEX_SHIFT = BigInt(40);
|
|
13329
13343
|
/**
|
|
13330
13344
|
* Validates that a value fits within 20 bits (0 to 1,048,575)
|
|
13331
13345
|
* @param value - The value to validate
|
|
@@ -13433,13 +13447,9 @@ const serializeStopsAdjacency = (stopsAdjacency) => {
|
|
|
13433
13447
|
return stopsAdjacency.map((value) => {
|
|
13434
13448
|
return {
|
|
13435
13449
|
transfers: value.transfers
|
|
13436
|
-
? value.transfers.map((transfer) => ({
|
|
13437
|
-
|
|
13438
|
-
|
|
13439
|
-
...(transfer.minTransferTime !== undefined && {
|
|
13440
|
-
minTransferTime: transfer.minTransferTime.toSeconds(),
|
|
13441
|
-
}),
|
|
13442
|
-
}))
|
|
13450
|
+
? value.transfers.map((transfer) => (Object.assign({ destination: transfer.destination, type: serializeTransferType(transfer.type) }, (transfer.minTransferTime !== undefined && {
|
|
13451
|
+
minTransferTime: transfer.minTransferTime.toSeconds(),
|
|
13452
|
+
}))))
|
|
13443
13453
|
: [],
|
|
13444
13454
|
routes: value.routes,
|
|
13445
13455
|
};
|
|
@@ -13476,13 +13486,9 @@ const deserializeStopsAdjacency = (protoStopsAdjacency) => {
|
|
|
13476
13486
|
for (let j = 0; j < value.transfers.length; j++) {
|
|
13477
13487
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
13478
13488
|
const transfer = value.transfers[j];
|
|
13479
|
-
const newTransfer = {
|
|
13480
|
-
|
|
13481
|
-
|
|
13482
|
-
...(transfer.minTransferTime !== undefined && {
|
|
13483
|
-
minTransferTime: Duration.fromSeconds(transfer.minTransferTime),
|
|
13484
|
-
}),
|
|
13485
|
-
};
|
|
13489
|
+
const newTransfer = Object.assign({ destination: transfer.destination, type: parseTransferType(transfer.type) }, (transfer.minTransferTime !== undefined && {
|
|
13490
|
+
minTransferTime: Duration.fromSeconds(transfer.minTransferTime),
|
|
13491
|
+
}));
|
|
13486
13492
|
transfers.push(newTransfer);
|
|
13487
13493
|
}
|
|
13488
13494
|
const stopAdjacency = {
|
|
@@ -13647,11 +13653,6 @@ const CURRENT_VERSION = '0.0.9';
|
|
|
13647
13653
|
* The internal transit timetable format.
|
|
13648
13654
|
*/
|
|
13649
13655
|
class Timetable {
|
|
13650
|
-
stopsAdjacency;
|
|
13651
|
-
routesAdjacency;
|
|
13652
|
-
serviceRoutes;
|
|
13653
|
-
tripContinuations;
|
|
13654
|
-
activeStops;
|
|
13655
13656
|
constructor(stopsAdjacency, routesAdjacency, routes, tripContinuations) {
|
|
13656
13657
|
this.stopsAdjacency = stopsAdjacency;
|
|
13657
13658
|
this.routesAdjacency = routesAdjacency;
|
|
@@ -13740,7 +13741,8 @@ class Timetable {
|
|
|
13740
13741
|
* @returns An array of trip continuation options available at the stop for the specified trip.
|
|
13741
13742
|
*/
|
|
13742
13743
|
getContinuousTrips(stopIndex, routeId, tripIndex) {
|
|
13743
|
-
|
|
13744
|
+
var _a;
|
|
13745
|
+
const tripContinuations = (_a = this.tripContinuations) === null || _a === void 0 ? void 0 : _a.get(encode(stopIndex, routeId, tripIndex));
|
|
13744
13746
|
if (!tripContinuations) {
|
|
13745
13747
|
return EMPTY_TRIP_CONTINUATIONS;
|
|
13746
13748
|
}
|
|
@@ -15788,22 +15790,35 @@ const parseCsv = (stream, numericColumns = []) => {
|
|
|
15788
15790
|
* @param profile A configuration object defining the specificities of the GTFS feed.
|
|
15789
15791
|
* @returns A map of all the valid routes.
|
|
15790
15792
|
*/
|
|
15791
|
-
const parseRoutes =
|
|
15793
|
+
const parseRoutes = (routesStream_1, ...args_1) => __awaiter(void 0, [routesStream_1, ...args_1], void 0, function* (routesStream, profile = standardProfile) {
|
|
15794
|
+
var _a, e_1, _b, _c;
|
|
15792
15795
|
const routes = new Map();
|
|
15793
|
-
|
|
15794
|
-
|
|
15795
|
-
|
|
15796
|
-
|
|
15797
|
-
|
|
15798
|
-
|
|
15796
|
+
try {
|
|
15797
|
+
for (var _d = true, _e = __asyncValues(parseCsv(routesStream, ['route_type'])), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
|
|
15798
|
+
_c = _f.value;
|
|
15799
|
+
_d = false;
|
|
15800
|
+
const rawLine = _c;
|
|
15801
|
+
const line = rawLine;
|
|
15802
|
+
const routeType = profile.routeTypeParser(line.route_type);
|
|
15803
|
+
if (routeType === undefined) {
|
|
15804
|
+
log.info(`Unsupported route type ${line.route_type} for route ${line.route_id}.`);
|
|
15805
|
+
continue;
|
|
15806
|
+
}
|
|
15807
|
+
routes.set(line.route_id, {
|
|
15808
|
+
name: line.route_short_name,
|
|
15809
|
+
type: routeType,
|
|
15810
|
+
});
|
|
15799
15811
|
}
|
|
15800
|
-
|
|
15801
|
-
|
|
15802
|
-
|
|
15803
|
-
|
|
15812
|
+
}
|
|
15813
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
15814
|
+
finally {
|
|
15815
|
+
try {
|
|
15816
|
+
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
15817
|
+
}
|
|
15818
|
+
finally { if (e_1) throw e_1.error; }
|
|
15804
15819
|
}
|
|
15805
15820
|
return routes;
|
|
15806
|
-
};
|
|
15821
|
+
});
|
|
15807
15822
|
/**
|
|
15808
15823
|
* Creates an array of ServiceRoute objects by combining GTFS route data with service route mappings.
|
|
15809
15824
|
*
|
|
@@ -15866,33 +15881,46 @@ const weekdays = {
|
|
|
15866
15881
|
* @param date The active date.
|
|
15867
15882
|
* @param calendarStream A readable stream for the GTFS calendar.txt file.
|
|
15868
15883
|
*/
|
|
15869
|
-
const parseCalendar =
|
|
15884
|
+
const parseCalendar = (calendarStream, serviceIds, date) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15885
|
+
var _a, e_1, _b, _c;
|
|
15870
15886
|
const activeDate = toGtfsDate(date);
|
|
15871
15887
|
const weekday = date.weekday;
|
|
15872
15888
|
const weekdayIndex = weekdays[weekday];
|
|
15873
|
-
|
|
15874
|
-
|
|
15875
|
-
|
|
15876
|
-
|
|
15877
|
-
|
|
15878
|
-
|
|
15879
|
-
|
|
15880
|
-
|
|
15881
|
-
|
|
15882
|
-
|
|
15883
|
-
|
|
15884
|
-
|
|
15885
|
-
|
|
15886
|
-
|
|
15887
|
-
|
|
15889
|
+
try {
|
|
15890
|
+
for (var _d = true, _e = __asyncValues(parseCsv(calendarStream, [
|
|
15891
|
+
'monday',
|
|
15892
|
+
'tuesday',
|
|
15893
|
+
'wednesday',
|
|
15894
|
+
'thursday',
|
|
15895
|
+
'friday',
|
|
15896
|
+
'saturday',
|
|
15897
|
+
'sunday',
|
|
15898
|
+
'start_date',
|
|
15899
|
+
'end_date',
|
|
15900
|
+
])), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
|
|
15901
|
+
_c = _f.value;
|
|
15902
|
+
_d = false;
|
|
15903
|
+
const rawLine = _c;
|
|
15904
|
+
const line = rawLine;
|
|
15905
|
+
if (activeDate < line.start_date || activeDate > line.end_date) {
|
|
15906
|
+
// If the service is not valid on this date
|
|
15907
|
+
continue;
|
|
15908
|
+
}
|
|
15909
|
+
if (line[weekdayIndex] !== 1) {
|
|
15910
|
+
// If the service is not valid on this week day
|
|
15911
|
+
continue;
|
|
15912
|
+
}
|
|
15913
|
+
serviceIds.add(line['service_id']);
|
|
15888
15914
|
}
|
|
15889
|
-
|
|
15890
|
-
|
|
15891
|
-
|
|
15915
|
+
}
|
|
15916
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
15917
|
+
finally {
|
|
15918
|
+
try {
|
|
15919
|
+
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
15892
15920
|
}
|
|
15893
|
-
|
|
15921
|
+
finally { if (e_1) throw e_1.error; }
|
|
15894
15922
|
}
|
|
15895
|
-
};
|
|
15923
|
+
});
|
|
15896
15924
|
/**
|
|
15897
15925
|
* Parses a gtfs calendar_dates.txt file and finds the service ids valid at a given date.
|
|
15898
15926
|
*
|
|
@@ -15900,24 +15928,39 @@ const parseCalendar = async (calendarStream, serviceIds, date) => {
|
|
|
15900
15928
|
* @param date The active date, in the format "YYYYMMDD".
|
|
15901
15929
|
* @param calendarDatesStream A readable stream for the GTFS calendar_dates.txt file.
|
|
15902
15930
|
*/
|
|
15903
|
-
const parseCalendarDates =
|
|
15931
|
+
const parseCalendarDates = (calendarDatesStream, serviceIds, date) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15932
|
+
var _a, e_2, _b, _c;
|
|
15904
15933
|
const activeDate = toGtfsDate(date);
|
|
15905
|
-
|
|
15906
|
-
|
|
15907
|
-
|
|
15908
|
-
|
|
15909
|
-
|
|
15910
|
-
|
|
15911
|
-
|
|
15912
|
-
|
|
15913
|
-
|
|
15934
|
+
try {
|
|
15935
|
+
for (var _d = true, _e = __asyncValues(parseCsv(calendarDatesStream, [
|
|
15936
|
+
'date',
|
|
15937
|
+
'exception_type',
|
|
15938
|
+
])), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
|
|
15939
|
+
_c = _f.value;
|
|
15940
|
+
_d = false;
|
|
15941
|
+
const rawLine = _c;
|
|
15942
|
+
const line = rawLine;
|
|
15943
|
+
if (line.date !== activeDate) {
|
|
15944
|
+
// No rule on the active date
|
|
15945
|
+
}
|
|
15946
|
+
else if (line.exception_type === 2 && serviceIds.has(line.service_id)) {
|
|
15947
|
+
// Service has been removed for the specified date.
|
|
15948
|
+
serviceIds.delete(line.service_id);
|
|
15949
|
+
}
|
|
15950
|
+
else if (line.exception_type === 1) {
|
|
15951
|
+
// Service is present on the active date
|
|
15952
|
+
serviceIds.add(line.service_id);
|
|
15953
|
+
}
|
|
15914
15954
|
}
|
|
15915
|
-
|
|
15916
|
-
|
|
15917
|
-
|
|
15955
|
+
}
|
|
15956
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
15957
|
+
finally {
|
|
15958
|
+
try {
|
|
15959
|
+
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
15918
15960
|
}
|
|
15961
|
+
finally { if (e_2) throw e_2.error; }
|
|
15919
15962
|
}
|
|
15920
|
-
};
|
|
15963
|
+
});
|
|
15921
15964
|
|
|
15922
15965
|
/**
|
|
15923
15966
|
* Parses the stops.txt file from a GTFS feed.
|
|
@@ -15925,30 +15968,33 @@ const parseCalendarDates = async (calendarDatesStream, serviceIds, date) => {
|
|
|
15925
15968
|
* @param stopsStream The readable stream containing the stops data.
|
|
15926
15969
|
* @return A mapping of stop IDs to corresponding stop details.
|
|
15927
15970
|
*/
|
|
15928
|
-
const parseStops =
|
|
15971
|
+
const parseStops = (stopsStream) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15972
|
+
var _a, e_1, _b, _c;
|
|
15929
15973
|
const parsedStops = new Map();
|
|
15930
15974
|
let i = 0;
|
|
15931
|
-
|
|
15932
|
-
|
|
15933
|
-
|
|
15934
|
-
|
|
15935
|
-
|
|
15936
|
-
|
|
15937
|
-
|
|
15938
|
-
|
|
15939
|
-
|
|
15940
|
-
|
|
15941
|
-
lat: line.stop_lat,
|
|
15942
|
-
|
|
15943
|
-
|
|
15944
|
-
|
|
15945
|
-
|
|
15946
|
-
|
|
15947
|
-
|
|
15948
|
-
|
|
15949
|
-
|
|
15950
|
-
|
|
15951
|
-
|
|
15975
|
+
try {
|
|
15976
|
+
for (var _d = true, _e = __asyncValues(parseCsv(stopsStream, [
|
|
15977
|
+
'stop_lat',
|
|
15978
|
+
'stop_lon',
|
|
15979
|
+
'location_type',
|
|
15980
|
+
])), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
|
|
15981
|
+
_c = _f.value;
|
|
15982
|
+
_d = false;
|
|
15983
|
+
const rawLine = _c;
|
|
15984
|
+
const line = rawLine;
|
|
15985
|
+
const stop = Object.assign(Object.assign(Object.assign({ id: i, sourceStopId: line.stop_id, name: line.stop_name, lat: line.stop_lat, lon: line.stop_lon, locationType: line.location_type
|
|
15986
|
+
? parseGtfsLocationType(line.location_type)
|
|
15987
|
+
: 'SIMPLE_STOP_OR_PLATFORM' }, (line.platform_code && { platform: line.platform_code })), { children: [] }), (line.parent_station && { parentSourceId: line.parent_station }));
|
|
15988
|
+
parsedStops.set(line.stop_id, stop);
|
|
15989
|
+
i = i + 1;
|
|
15990
|
+
}
|
|
15991
|
+
}
|
|
15992
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
15993
|
+
finally {
|
|
15994
|
+
try {
|
|
15995
|
+
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
15996
|
+
}
|
|
15997
|
+
finally { if (e_1) throw e_1.error; }
|
|
15952
15998
|
}
|
|
15953
15999
|
for (const [sourceStopId, stop] of parsedStops) {
|
|
15954
16000
|
if (stop.parentSourceId) {
|
|
@@ -15962,7 +16008,7 @@ const parseStops = async (stopsStream) => {
|
|
|
15962
16008
|
}
|
|
15963
16009
|
}
|
|
15964
16010
|
return parsedStops;
|
|
15965
|
-
};
|
|
16011
|
+
});
|
|
15966
16012
|
const parseGtfsLocationType = (gtfsLocationType) => {
|
|
15967
16013
|
switch (gtfsLocationType) {
|
|
15968
16014
|
case 0:
|
|
@@ -15985,73 +16031,82 @@ const parseGtfsLocationType = (gtfsLocationType) => {
|
|
|
15985
16031
|
* @param stopsStream The readable stream containing the stops data.
|
|
15986
16032
|
* @return A mapping of stop IDs to corresponding stop details.
|
|
15987
16033
|
*/
|
|
15988
|
-
const parseTransfers =
|
|
16034
|
+
const parseTransfers = (transfersStream, stopsMap) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16035
|
+
var _a, e_1, _b, _c;
|
|
15989
16036
|
const transfers = new Map();
|
|
15990
16037
|
const tripContinuations = [];
|
|
15991
|
-
|
|
15992
|
-
|
|
15993
|
-
|
|
15994
|
-
|
|
15995
|
-
|
|
15996
|
-
|
|
15997
|
-
|
|
15998
|
-
|
|
15999
|
-
|
|
16000
|
-
|
|
16001
|
-
|
|
16002
|
-
continue;
|
|
16003
|
-
}
|
|
16004
|
-
const fromStop = stopsMap.get(transferEntry.from_stop_id);
|
|
16005
|
-
const toStop = stopsMap.get(transferEntry.to_stop_id);
|
|
16006
|
-
if (!fromStop || !toStop) {
|
|
16007
|
-
console.warn(`Transfer references non-existent stop(s): from_stop_id=${transferEntry.from_stop_id}, to_stop_id=${transferEntry.to_stop_id}`);
|
|
16008
|
-
continue;
|
|
16009
|
-
}
|
|
16010
|
-
if (transferEntry.transfer_type === 4) {
|
|
16011
|
-
if (transferEntry.from_trip_id === undefined ||
|
|
16012
|
-
transferEntry.from_trip_id === '' ||
|
|
16013
|
-
transferEntry.to_trip_id === undefined ||
|
|
16014
|
-
transferEntry.to_trip_id === '') {
|
|
16015
|
-
console.warn(`Unsupported in-seat transfer, missing from_trip_id and/or to_trip_id.`);
|
|
16038
|
+
try {
|
|
16039
|
+
for (var _d = true, _e = __asyncValues(parseCsv(transfersStream, [
|
|
16040
|
+
'transfer_type',
|
|
16041
|
+
'min_transfer_time',
|
|
16042
|
+
])), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
|
|
16043
|
+
_c = _f.value;
|
|
16044
|
+
_d = false;
|
|
16045
|
+
const rawLine = _c;
|
|
16046
|
+
const transferEntry = rawLine;
|
|
16047
|
+
if (transferEntry.transfer_type === 3 ||
|
|
16048
|
+
transferEntry.transfer_type === 5) {
|
|
16016
16049
|
continue;
|
|
16017
16050
|
}
|
|
16018
|
-
|
|
16019
|
-
|
|
16020
|
-
|
|
16021
|
-
|
|
16022
|
-
|
|
16023
|
-
|
|
16024
|
-
|
|
16025
|
-
|
|
16026
|
-
|
|
16027
|
-
|
|
16028
|
-
|
|
16029
|
-
|
|
16030
|
-
|
|
16031
|
-
|
|
16032
|
-
|
|
16033
|
-
|
|
16051
|
+
if (!transferEntry.from_stop_id || !transferEntry.to_stop_id) {
|
|
16052
|
+
console.warn(`Missing transfer origin or destination stop.`);
|
|
16053
|
+
continue;
|
|
16054
|
+
}
|
|
16055
|
+
const fromStop = stopsMap.get(transferEntry.from_stop_id);
|
|
16056
|
+
const toStop = stopsMap.get(transferEntry.to_stop_id);
|
|
16057
|
+
if (!fromStop || !toStop) {
|
|
16058
|
+
console.warn(`Transfer references non-existent stop(s): from_stop_id=${transferEntry.from_stop_id}, to_stop_id=${transferEntry.to_stop_id}`);
|
|
16059
|
+
continue;
|
|
16060
|
+
}
|
|
16061
|
+
if (transferEntry.transfer_type === 4) {
|
|
16062
|
+
if (transferEntry.from_trip_id === undefined ||
|
|
16063
|
+
transferEntry.from_trip_id === '' ||
|
|
16064
|
+
transferEntry.to_trip_id === undefined ||
|
|
16065
|
+
transferEntry.to_trip_id === '') {
|
|
16066
|
+
console.warn(`Unsupported in-seat transfer, missing from_trip_id and/or to_trip_id.`);
|
|
16067
|
+
continue;
|
|
16068
|
+
}
|
|
16069
|
+
const tripBoardingEntry = {
|
|
16070
|
+
fromStop: fromStop.id,
|
|
16071
|
+
fromTrip: transferEntry.from_trip_id,
|
|
16072
|
+
toStop: toStop.id,
|
|
16073
|
+
toTrip: transferEntry.to_trip_id,
|
|
16074
|
+
};
|
|
16075
|
+
tripContinuations.push(tripBoardingEntry);
|
|
16076
|
+
continue;
|
|
16077
|
+
}
|
|
16078
|
+
if (transferEntry.from_trip_id && transferEntry.to_trip_id) {
|
|
16079
|
+
console.warn(`Unsupported transfer of type ${transferEntry.transfer_type} between trips ${transferEntry.from_trip_id} and ${transferEntry.to_trip_id}.`);
|
|
16080
|
+
continue;
|
|
16081
|
+
}
|
|
16082
|
+
if (transferEntry.from_route_id && transferEntry.to_route_id) {
|
|
16083
|
+
console.warn(`Unsupported transfer of type ${transferEntry.transfer_type} between routes ${transferEntry.from_route_id} and ${transferEntry.to_route_id}.`);
|
|
16084
|
+
continue;
|
|
16085
|
+
}
|
|
16086
|
+
if (transferEntry.transfer_type === 2 &&
|
|
16087
|
+
transferEntry.min_transfer_time === undefined) {
|
|
16088
|
+
console.info(`Missing minimum transfer time between ${transferEntry.from_stop_id} and ${transferEntry.to_stop_id}.`);
|
|
16089
|
+
}
|
|
16090
|
+
const transfer = Object.assign({ destination: toStop.id, type: parseGtfsTransferType(transferEntry.transfer_type) }, (transferEntry.min_transfer_time !== undefined && {
|
|
16091
|
+
minTransferTime: Duration.fromSeconds(transferEntry.min_transfer_time),
|
|
16092
|
+
}));
|
|
16093
|
+
const fromStopTransfers = transfers.get(fromStop.id) || [];
|
|
16094
|
+
fromStopTransfers.push(transfer);
|
|
16095
|
+
transfers.set(fromStop.id, fromStopTransfers);
|
|
16034
16096
|
}
|
|
16035
|
-
|
|
16036
|
-
|
|
16037
|
-
|
|
16097
|
+
}
|
|
16098
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
16099
|
+
finally {
|
|
16100
|
+
try {
|
|
16101
|
+
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
16038
16102
|
}
|
|
16039
|
-
|
|
16040
|
-
destination: toStop.id,
|
|
16041
|
-
type: parseGtfsTransferType(transferEntry.transfer_type),
|
|
16042
|
-
...(transferEntry.min_transfer_time !== undefined && {
|
|
16043
|
-
minTransferTime: Duration.fromSeconds(transferEntry.min_transfer_time),
|
|
16044
|
-
}),
|
|
16045
|
-
};
|
|
16046
|
-
const fromStopTransfers = transfers.get(fromStop.id) || [];
|
|
16047
|
-
fromStopTransfers.push(transfer);
|
|
16048
|
-
transfers.set(fromStop.id, fromStopTransfers);
|
|
16103
|
+
finally { if (e_1) throw e_1.error; }
|
|
16049
16104
|
}
|
|
16050
16105
|
return {
|
|
16051
16106
|
transfers,
|
|
16052
16107
|
tripContinuations,
|
|
16053
16108
|
};
|
|
16054
|
-
};
|
|
16109
|
+
});
|
|
16055
16110
|
/**
|
|
16056
16111
|
* Disambiguates stops involved in a transfer.
|
|
16057
16112
|
*
|
|
@@ -16244,22 +16299,35 @@ const finalizeRouteFromBuilder = (builder) => {
|
|
|
16244
16299
|
* @param serviceRoutes A mapping of route IDs to route details.
|
|
16245
16300
|
* @returns A mapping of trip IDs to corresponding route IDs.
|
|
16246
16301
|
*/
|
|
16247
|
-
const parseTrips =
|
|
16302
|
+
const parseTrips = (tripsStream, serviceIds, validGtfsRoutes) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16303
|
+
var _a, e_1, _b, _c;
|
|
16248
16304
|
const trips = new Map();
|
|
16249
|
-
|
|
16250
|
-
|
|
16251
|
-
|
|
16252
|
-
|
|
16253
|
-
|
|
16305
|
+
try {
|
|
16306
|
+
for (var _d = true, _e = __asyncValues(parseCsv(tripsStream, ['stop_sequence'])), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
|
|
16307
|
+
_c = _f.value;
|
|
16308
|
+
_d = false;
|
|
16309
|
+
const rawLine = _c;
|
|
16310
|
+
const line = rawLine;
|
|
16311
|
+
if (!serviceIds.has(line.service_id)) {
|
|
16312
|
+
// The trip doesn't correspond to an active service
|
|
16313
|
+
continue;
|
|
16314
|
+
}
|
|
16315
|
+
if (!validGtfsRoutes.has(line.route_id)) {
|
|
16316
|
+
// The trip doesn't correspond to a supported route
|
|
16317
|
+
continue;
|
|
16318
|
+
}
|
|
16319
|
+
trips.set(line.trip_id, line.route_id);
|
|
16254
16320
|
}
|
|
16255
|
-
|
|
16256
|
-
|
|
16257
|
-
|
|
16321
|
+
}
|
|
16322
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
16323
|
+
finally {
|
|
16324
|
+
try {
|
|
16325
|
+
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
16258
16326
|
}
|
|
16259
|
-
|
|
16327
|
+
finally { if (e_1) throw e_1.error; }
|
|
16260
16328
|
}
|
|
16261
16329
|
return trips;
|
|
16262
|
-
};
|
|
16330
|
+
});
|
|
16263
16331
|
const buildStopsAdjacencyStructure = (serviceRoutes, routes, transfersMap, nbStops, activeStops) => {
|
|
16264
16332
|
const stopsAdjacency = new Array(nbStops);
|
|
16265
16333
|
for (let i = 0; i < nbStops; i++) {
|
|
@@ -16311,7 +16379,9 @@ const buildStopsAdjacencyStructure = (serviceRoutes, routes, transfersMap, nbSto
|
|
|
16311
16379
|
* @param activeStopIds A set of valid stop IDs.
|
|
16312
16380
|
* @returns A mapping of route IDs to route details. The routes returned correspond to the set of trips from GTFS that share the same stop list.
|
|
16313
16381
|
*/
|
|
16314
|
-
const parseStopTimes =
|
|
16382
|
+
const parseStopTimes = (stopTimesStream, stopsMap, activeTripIds, activeStopIds) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16383
|
+
var _a, e_2, _b, _c;
|
|
16384
|
+
var _d, _e;
|
|
16315
16385
|
/**
|
|
16316
16386
|
* Adds a trip to the appropriate route builder
|
|
16317
16387
|
*/
|
|
@@ -16379,43 +16449,55 @@ const parseStopTimes = async (stopTimesStream, stopsMap, activeTripIds, activeSt
|
|
|
16379
16449
|
let pickUpTypes = [];
|
|
16380
16450
|
let dropOffTypes = [];
|
|
16381
16451
|
let currentTripId = undefined;
|
|
16382
|
-
|
|
16383
|
-
|
|
16384
|
-
|
|
16385
|
-
|
|
16386
|
-
|
|
16387
|
-
|
|
16388
|
-
|
|
16389
|
-
|
|
16390
|
-
|
|
16391
|
-
|
|
16392
|
-
|
|
16393
|
-
|
|
16394
|
-
|
|
16395
|
-
|
|
16396
|
-
|
|
16397
|
-
|
|
16398
|
-
|
|
16399
|
-
|
|
16400
|
-
|
|
16401
|
-
|
|
16402
|
-
|
|
16403
|
-
|
|
16404
|
-
|
|
16405
|
-
|
|
16452
|
+
try {
|
|
16453
|
+
for (var _f = true, _g = __asyncValues(parseCsv(stopTimesStream, ['stop_sequence'])), _h; _h = yield _g.next(), _a = _h.done, !_a; _f = true) {
|
|
16454
|
+
_c = _h.value;
|
|
16455
|
+
_f = false;
|
|
16456
|
+
const rawLine = _c;
|
|
16457
|
+
const line = rawLine;
|
|
16458
|
+
if (line.trip_id === currentTripId && line.stop_sequence <= previousSeq) {
|
|
16459
|
+
console.warn(`Stop sequences not increasing for trip ${line.trip_id}: ${line.stop_sequence} > ${previousSeq}.`);
|
|
16460
|
+
continue;
|
|
16461
|
+
}
|
|
16462
|
+
if (!line.arrival_time && !line.departure_time) {
|
|
16463
|
+
console.warn(`Missing arrival or departure time for ${line.trip_id} at stop ${line.stop_id}.`);
|
|
16464
|
+
continue;
|
|
16465
|
+
}
|
|
16466
|
+
if (line.pickup_type === '1' && line.drop_off_type === '1') {
|
|
16467
|
+
// Warning: could potentially lead to issues if there is an in-seat transfer
|
|
16468
|
+
// at this stop - it can be not boardable nor alightable but still useful for an in-seat transfer.
|
|
16469
|
+
// This doesn't seem to happen in practice for now so keeping this condition to save memory.
|
|
16470
|
+
continue;
|
|
16471
|
+
}
|
|
16472
|
+
if (currentTripId && line.trip_id !== currentTripId && stops.length > 0) {
|
|
16473
|
+
addTrip(currentTripId);
|
|
16474
|
+
}
|
|
16475
|
+
currentTripId = line.trip_id;
|
|
16476
|
+
const stopData = stopsMap.get(line.stop_id);
|
|
16477
|
+
if (!stopData) {
|
|
16478
|
+
console.warn(`Unknown stop ID: ${line.stop_id}`);
|
|
16479
|
+
continue;
|
|
16480
|
+
}
|
|
16481
|
+
stops.push(stopData.id);
|
|
16482
|
+
const departure = (_d = line.departure_time) !== null && _d !== void 0 ? _d : line.arrival_time;
|
|
16483
|
+
const arrival = (_e = line.arrival_time) !== null && _e !== void 0 ? _e : line.departure_time;
|
|
16484
|
+
if (!arrival || !departure) {
|
|
16485
|
+
console.warn(`Missing time data for ${line.trip_id} at stop ${line.stop_id}`);
|
|
16486
|
+
continue;
|
|
16487
|
+
}
|
|
16488
|
+
arrivalTimes.push(toTime(arrival).toMinutes());
|
|
16489
|
+
departureTimes.push(toTime(departure).toMinutes());
|
|
16490
|
+
pickUpTypes.push(parsePickupDropOffType(line.pickup_type));
|
|
16491
|
+
dropOffTypes.push(parsePickupDropOffType(line.drop_off_type));
|
|
16492
|
+
previousSeq = line.stop_sequence;
|
|
16406
16493
|
}
|
|
16407
|
-
|
|
16408
|
-
|
|
16409
|
-
|
|
16410
|
-
|
|
16411
|
-
|
|
16412
|
-
continue;
|
|
16494
|
+
}
|
|
16495
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
16496
|
+
finally {
|
|
16497
|
+
try {
|
|
16498
|
+
if (!_f && !_a && (_b = _g.return)) yield _b.call(_g);
|
|
16413
16499
|
}
|
|
16414
|
-
|
|
16415
|
-
departureTimes.push(toTime(departure).toMinutes());
|
|
16416
|
-
pickUpTypes.push(parsePickupDropOffType(line.pickup_type));
|
|
16417
|
-
dropOffTypes.push(parsePickupDropOffType(line.drop_off_type));
|
|
16418
|
-
previousSeq = line.stop_sequence;
|
|
16500
|
+
finally { if (e_2) throw e_2.error; }
|
|
16419
16501
|
}
|
|
16420
16502
|
if (currentTripId) {
|
|
16421
16503
|
addTrip(currentTripId);
|
|
@@ -16434,7 +16516,7 @@ const parseStopTimes = async (stopTimesStream, stopsMap, activeTripIds, activeSt
|
|
|
16434
16516
|
});
|
|
16435
16517
|
}
|
|
16436
16518
|
return { routes: routesAdjacency, serviceRoutesMap, tripsMapping };
|
|
16437
|
-
};
|
|
16519
|
+
});
|
|
16438
16520
|
const parsePickupDropOffType = (gtfsType) => {
|
|
16439
16521
|
switch (gtfsType) {
|
|
16440
16522
|
default:
|
|
@@ -16458,8 +16540,6 @@ const STOP_TIMES_FILE = 'stop_times.txt';
|
|
|
16458
16540
|
const STOPS_FILE = 'stops.txt';
|
|
16459
16541
|
const TRANSFERS_FILE = 'transfers.txt';
|
|
16460
16542
|
class GtfsParser {
|
|
16461
|
-
path;
|
|
16462
|
-
profile;
|
|
16463
16543
|
constructor(path, profile = standardProfile) {
|
|
16464
16544
|
// TODO: support input from multiple sources
|
|
16465
16545
|
this.path = path;
|
|
@@ -16471,81 +16551,83 @@ class GtfsParser {
|
|
|
16471
16551
|
* @param date The active date.
|
|
16472
16552
|
* @returns The parsed timetable.
|
|
16473
16553
|
*/
|
|
16474
|
-
|
|
16475
|
-
|
|
16476
|
-
|
|
16477
|
-
|
|
16478
|
-
|
|
16479
|
-
|
|
16480
|
-
|
|
16481
|
-
|
|
16482
|
-
|
|
16483
|
-
|
|
16484
|
-
|
|
16485
|
-
|
|
16486
|
-
|
|
16487
|
-
|
|
16488
|
-
|
|
16489
|
-
|
|
16490
|
-
|
|
16491
|
-
|
|
16492
|
-
|
|
16493
|
-
|
|
16494
|
-
|
|
16495
|
-
|
|
16496
|
-
|
|
16497
|
-
|
|
16498
|
-
|
|
16499
|
-
|
|
16500
|
-
|
|
16501
|
-
|
|
16502
|
-
|
|
16503
|
-
|
|
16504
|
-
|
|
16505
|
-
|
|
16506
|
-
|
|
16507
|
-
|
|
16508
|
-
|
|
16509
|
-
|
|
16510
|
-
|
|
16511
|
-
|
|
16512
|
-
|
|
16513
|
-
|
|
16514
|
-
|
|
16515
|
-
|
|
16516
|
-
|
|
16517
|
-
|
|
16518
|
-
|
|
16519
|
-
|
|
16520
|
-
|
|
16521
|
-
|
|
16522
|
-
|
|
16523
|
-
|
|
16524
|
-
|
|
16525
|
-
|
|
16526
|
-
|
|
16527
|
-
|
|
16528
|
-
|
|
16529
|
-
|
|
16530
|
-
|
|
16531
|
-
|
|
16532
|
-
|
|
16533
|
-
|
|
16534
|
-
|
|
16535
|
-
|
|
16536
|
-
|
|
16537
|
-
|
|
16538
|
-
|
|
16539
|
-
|
|
16540
|
-
|
|
16541
|
-
|
|
16542
|
-
|
|
16543
|
-
|
|
16544
|
-
|
|
16545
|
-
|
|
16546
|
-
|
|
16547
|
-
|
|
16548
|
-
|
|
16554
|
+
parseTimetable(date) {
|
|
16555
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16556
|
+
log.setLevel('INFO');
|
|
16557
|
+
const zip = new StreamZip.async({ file: this.path });
|
|
16558
|
+
const entries = yield zip.entries();
|
|
16559
|
+
const datetime = DateTime.fromJSDate(date);
|
|
16560
|
+
const activeServiceIds = new Set();
|
|
16561
|
+
const activeStopIds = new Set();
|
|
16562
|
+
log.info(`Parsing ${STOPS_FILE}`);
|
|
16563
|
+
const stopsStart = performance.now();
|
|
16564
|
+
const stopsStream = yield zip.stream(STOPS_FILE);
|
|
16565
|
+
const parsedStops = yield parseStops(stopsStream);
|
|
16566
|
+
const stopsEnd = performance.now();
|
|
16567
|
+
log.info(`${parsedStops.size} parsed stops. (${(stopsEnd - stopsStart).toFixed(2)}ms)`);
|
|
16568
|
+
if (entries[CALENDAR_FILE]) {
|
|
16569
|
+
log.info(`Parsing ${CALENDAR_FILE}`);
|
|
16570
|
+
const calendarStart = performance.now();
|
|
16571
|
+
const calendarStream = yield zip.stream(CALENDAR_FILE);
|
|
16572
|
+
yield parseCalendar(calendarStream, activeServiceIds, datetime);
|
|
16573
|
+
const calendarEnd = performance.now();
|
|
16574
|
+
log.info(`${activeServiceIds.size} valid services. (${(calendarEnd - calendarStart).toFixed(2)}ms)`);
|
|
16575
|
+
}
|
|
16576
|
+
if (entries[CALENDAR_DATES_FILE]) {
|
|
16577
|
+
log.info(`Parsing ${CALENDAR_DATES_FILE}`);
|
|
16578
|
+
const calendarDatesStart = performance.now();
|
|
16579
|
+
const calendarDatesStream = yield zip.stream(CALENDAR_DATES_FILE);
|
|
16580
|
+
yield parseCalendarDates(calendarDatesStream, activeServiceIds, datetime);
|
|
16581
|
+
const calendarDatesEnd = performance.now();
|
|
16582
|
+
log.info(`${activeServiceIds.size} valid services. (${(calendarDatesEnd - calendarDatesStart).toFixed(2)}ms)`);
|
|
16583
|
+
}
|
|
16584
|
+
log.info(`Parsing ${ROUTES_FILE}`);
|
|
16585
|
+
const routesStart = performance.now();
|
|
16586
|
+
const routesStream = yield zip.stream(ROUTES_FILE);
|
|
16587
|
+
const validGtfsRoutes = yield parseRoutes(routesStream, this.profile);
|
|
16588
|
+
const routesEnd = performance.now();
|
|
16589
|
+
log.info(`${validGtfsRoutes.size} valid GTFS routes. (${(routesEnd - routesStart).toFixed(2)}ms)`);
|
|
16590
|
+
log.info(`Parsing ${TRIPS_FILE}`);
|
|
16591
|
+
const tripsStart = performance.now();
|
|
16592
|
+
const tripsStream = yield zip.stream(TRIPS_FILE);
|
|
16593
|
+
const trips = yield parseTrips(tripsStream, activeServiceIds, validGtfsRoutes);
|
|
16594
|
+
const tripsEnd = performance.now();
|
|
16595
|
+
log.info(`${trips.size} valid trips. (${(tripsEnd - tripsStart).toFixed(2)}ms)`);
|
|
16596
|
+
let transfers = new Map();
|
|
16597
|
+
let tripContinuationsMap = [];
|
|
16598
|
+
if (entries[TRANSFERS_FILE]) {
|
|
16599
|
+
log.info(`Parsing ${TRANSFERS_FILE}`);
|
|
16600
|
+
const transfersStart = performance.now();
|
|
16601
|
+
const transfersStream = yield zip.stream(TRANSFERS_FILE);
|
|
16602
|
+
const { transfers: parsedTransfers, tripContinuations: parsedTripContinuations, } = yield parseTransfers(transfersStream, parsedStops);
|
|
16603
|
+
transfers = parsedTransfers;
|
|
16604
|
+
tripContinuationsMap = parsedTripContinuations;
|
|
16605
|
+
const transfersEnd = performance.now();
|
|
16606
|
+
log.info(`${transfers.size} valid transfers and ${tripContinuationsMap.length} trip continuations. (${(transfersEnd - transfersStart).toFixed(2)}ms)`);
|
|
16607
|
+
}
|
|
16608
|
+
log.info(`Parsing ${STOP_TIMES_FILE}`);
|
|
16609
|
+
const stopTimesStart = performance.now();
|
|
16610
|
+
const stopTimesStream = yield zip.stream(STOP_TIMES_FILE);
|
|
16611
|
+
const { routes, serviceRoutesMap, tripsMapping } = yield parseStopTimes(stopTimesStream, parsedStops, trips, activeStopIds);
|
|
16612
|
+
const serviceRoutes = indexRoutes(validGtfsRoutes, serviceRoutesMap);
|
|
16613
|
+
const stopTimesEnd = performance.now();
|
|
16614
|
+
log.info(`${routes.length} valid unique routes. (${(stopTimesEnd - stopTimesStart).toFixed(2)}ms)`);
|
|
16615
|
+
log.info('Building stops adjacency structure');
|
|
16616
|
+
const stopsAdjacencyStart = performance.now();
|
|
16617
|
+
const stopsAdjacency = buildStopsAdjacencyStructure(serviceRoutes, routes, transfers, parsedStops.size, activeStopIds);
|
|
16618
|
+
const stopsAdjacencyEnd = performance.now();
|
|
16619
|
+
log.info(`${stopsAdjacency.length} valid stops in the structure. (${(stopsAdjacencyEnd - stopsAdjacencyStart).toFixed(2)}ms)`);
|
|
16620
|
+
yield zip.close();
|
|
16621
|
+
// temporary timetable for building continuations
|
|
16622
|
+
const timetable = new Timetable(stopsAdjacency, routes, serviceRoutes);
|
|
16623
|
+
log.info('Building in-seat trip continuations');
|
|
16624
|
+
const tripContinuationsStart = performance.now();
|
|
16625
|
+
const tripContinuations = buildTripContinuations(tripsMapping, tripContinuationsMap, timetable, activeStopIds);
|
|
16626
|
+
const tripContinuationsEnd = performance.now();
|
|
16627
|
+
log.info(`${tripContinuations.size} in-seat trip continuations origins created. (${(tripContinuationsEnd - tripContinuationsStart).toFixed(2)}ms)`);
|
|
16628
|
+
log.info('Parsing complete.');
|
|
16629
|
+
return new Timetable(stopsAdjacency, routes, serviceRoutes, tripContinuations);
|
|
16630
|
+
});
|
|
16549
16631
|
}
|
|
16550
16632
|
/**
|
|
16551
16633
|
* Parses a GTFS feed to extract all stops.
|
|
@@ -16553,16 +16635,18 @@ class GtfsParser {
|
|
|
16553
16635
|
* @param activeStops The set of active stop IDs to include in the index.
|
|
16554
16636
|
* @returns An index of stops.
|
|
16555
16637
|
*/
|
|
16556
|
-
|
|
16557
|
-
|
|
16558
|
-
|
|
16559
|
-
|
|
16560
|
-
|
|
16561
|
-
|
|
16562
|
-
|
|
16563
|
-
|
|
16564
|
-
|
|
16565
|
-
|
|
16638
|
+
parseStops() {
|
|
16639
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16640
|
+
const zip = new StreamZip.async({ file: this.path });
|
|
16641
|
+
log.info(`Parsing ${STOPS_FILE}`);
|
|
16642
|
+
const stopsStart = performance.now();
|
|
16643
|
+
const stopsStream = yield zip.stream(STOPS_FILE);
|
|
16644
|
+
const stops = yield parseStops(stopsStream);
|
|
16645
|
+
const stopsEnd = performance.now();
|
|
16646
|
+
log.info(`${stops.size} parsed stops. (${(stopsEnd - stopsStart).toFixed(2)}ms)`);
|
|
16647
|
+
yield zip.close();
|
|
16648
|
+
return new StopsIndex(Array.from(stops.values()));
|
|
16649
|
+
});
|
|
16566
16650
|
}
|
|
16567
16651
|
}
|
|
16568
16652
|
|