minotor 13.0.0 → 13.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -9
- package/dist/cli.mjs +1419 -1420
- package/dist/cli.mjs.map +1 -1
- package/dist/gtfs/__tests__/logging.test.d.ts +1 -0
- package/dist/gtfs/logging.d.ts +8 -0
- package/dist/parser.cjs.js +108 -98
- package/dist/parser.cjs.js.map +1 -1
- package/dist/parser.d.ts +4 -2
- package/dist/parser.esm.js +108 -99
- package/dist/parser.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/minotor.ts +3 -11
- package/src/gtfs/__tests__/logging.test.ts +100 -0
- package/src/gtfs/frequencies.ts +1 -2
- package/src/gtfs/logging.ts +15 -0
- package/src/gtfs/parser.ts +1 -2
- package/src/gtfs/routes.ts +1 -2
- package/src/gtfs/stops.ts +1 -2
- package/src/gtfs/transfers.ts +1 -2
- package/src/gtfs/trips.ts +1 -2
- package/src/parser.ts +4 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import log from 'loglevel';
|
|
2
|
+
export type ParserLogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent';
|
|
3
|
+
export declare const parserLog: log.Logger;
|
|
4
|
+
/**
|
|
5
|
+
* Set logging for all GTFS parser instances in this module.
|
|
6
|
+
* Defaults to warn.
|
|
7
|
+
*/
|
|
8
|
+
export declare function setParserLogLevel(level: ParserLogLevel): void;
|
package/dist/parser.cjs.js
CHANGED
|
@@ -7,58 +7,6 @@ var require$$3 = require('events');
|
|
|
7
7
|
var require$$4 = require('zlib');
|
|
8
8
|
var require$$5 = require('stream');
|
|
9
9
|
|
|
10
|
-
/******************************************************************************
|
|
11
|
-
Copyright (c) Microsoft Corporation.
|
|
12
|
-
|
|
13
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
14
|
-
purpose with or without fee is hereby granted.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
17
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
18
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
19
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
20
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
21
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
22
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
23
|
-
***************************************************************************** */
|
|
24
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
28
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
29
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
30
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
31
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
32
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
33
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function __values(o) {
|
|
38
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
39
|
-
if (m) return m.call(o);
|
|
40
|
-
if (o && typeof o.length === "number") return {
|
|
41
|
-
next: function () {
|
|
42
|
-
if (o && i >= o.length) o = void 0;
|
|
43
|
-
return { value: o && o[i++], done: !o };
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function __asyncValues(o) {
|
|
50
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
51
|
-
var m = o[Symbol.asyncIterator], i;
|
|
52
|
-
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);
|
|
53
|
-
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); }); }; }
|
|
54
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
58
|
-
var e = new Error(message);
|
|
59
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
10
|
function getDefaultExportFromCjs (x) {
|
|
63
11
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
64
12
|
}
|
|
@@ -433,6 +381,68 @@ function requireLoglevel () {
|
|
|
433
381
|
var loglevelExports = requireLoglevel();
|
|
434
382
|
var log = /*@__PURE__*/getDefaultExportFromCjs(loglevelExports);
|
|
435
383
|
|
|
384
|
+
const parserLog = log.getLogger('minotor:gtfs');
|
|
385
|
+
parserLog.setLevel('warn', false);
|
|
386
|
+
/**
|
|
387
|
+
* Set logging for all GTFS parser instances in this module.
|
|
388
|
+
* Defaults to warn.
|
|
389
|
+
*/
|
|
390
|
+
function setParserLogLevel(level) {
|
|
391
|
+
parserLog.setLevel(level, false);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/******************************************************************************
|
|
395
|
+
Copyright (c) Microsoft Corporation.
|
|
396
|
+
|
|
397
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
398
|
+
purpose with or without fee is hereby granted.
|
|
399
|
+
|
|
400
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
401
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
402
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
403
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
404
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
405
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
406
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
407
|
+
***************************************************************************** */
|
|
408
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
412
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
413
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
414
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
415
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
416
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
417
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
function __values(o) {
|
|
422
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
423
|
+
if (m) return m.call(o);
|
|
424
|
+
if (o && typeof o.length === "number") return {
|
|
425
|
+
next: function () {
|
|
426
|
+
if (o && i >= o.length) o = void 0;
|
|
427
|
+
return { value: o && o[i++], done: !o };
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function __asyncValues(o) {
|
|
434
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
435
|
+
var m = o[Symbol.asyncIterator], i;
|
|
436
|
+
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);
|
|
437
|
+
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); }); }; }
|
|
438
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
442
|
+
var e = new Error(message);
|
|
443
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
444
|
+
};
|
|
445
|
+
|
|
436
446
|
// these aren't really private, but nor are they really useful to document
|
|
437
447
|
|
|
438
448
|
/**
|
|
@@ -16374,7 +16384,7 @@ const parseFrequencies = (stream, activeTripIds) => __awaiter(void 0, void 0, vo
|
|
|
16374
16384
|
continue;
|
|
16375
16385
|
}
|
|
16376
16386
|
if (line.exact_times !== '1') {
|
|
16377
|
-
|
|
16387
|
+
parserLog.warn(`${line.trip_id} will be treated as a scheduled-based trip.`);
|
|
16378
16388
|
}
|
|
16379
16389
|
const window = {
|
|
16380
16390
|
startTime: toTime(line.start_time),
|
|
@@ -16448,7 +16458,7 @@ const parseRoutes = (routesStream_1, ...args_1) => __awaiter(void 0, [routesStre
|
|
|
16448
16458
|
const line = rawLine;
|
|
16449
16459
|
const routeType = profile.routeTypeParser(line.route_type);
|
|
16450
16460
|
if (routeType === undefined) {
|
|
16451
|
-
|
|
16461
|
+
parserLog.info(`Unsupported route type ${line.route_type} for route ${line.route_id}.`);
|
|
16452
16462
|
continue;
|
|
16453
16463
|
}
|
|
16454
16464
|
routes.set(line.route_id, {
|
|
@@ -16478,7 +16488,7 @@ const indexRoutes = (gtfsRoutesMap, serviceRoutesMap) => {
|
|
|
16478
16488
|
for (const [gtfsRouteId, serviceRouteId] of serviceRoutesMap) {
|
|
16479
16489
|
const route = gtfsRoutesMap.get(gtfsRouteId);
|
|
16480
16490
|
if (route === undefined) {
|
|
16481
|
-
|
|
16491
|
+
parserLog.warn(`Route ${gtfsRouteId} not found.`);
|
|
16482
16492
|
continue;
|
|
16483
16493
|
}
|
|
16484
16494
|
serviceRoutes[serviceRouteId] = {
|
|
@@ -16625,7 +16635,7 @@ const parseStops = (stopsStream) => __awaiter(void 0, void 0, void 0, function*
|
|
|
16625
16635
|
if (stop.parentSourceId) {
|
|
16626
16636
|
const parentStop = parsedStops.get(stop.parentSourceId);
|
|
16627
16637
|
if (!parentStop) {
|
|
16628
|
-
|
|
16638
|
+
parserLog.warn(`Cannot find parent stop ${stop.parentSourceId} of ${sourceStopId}`);
|
|
16629
16639
|
continue;
|
|
16630
16640
|
}
|
|
16631
16641
|
stop.parent = parentStop.id;
|
|
@@ -16658,7 +16668,7 @@ const processInSeatTransfer = (transferEntry, fromStop, toStop, tripContinuation
|
|
|
16658
16668
|
transferEntry.from_trip_id === '' ||
|
|
16659
16669
|
transferEntry.to_trip_id === undefined ||
|
|
16660
16670
|
transferEntry.to_trip_id === '') {
|
|
16661
|
-
|
|
16671
|
+
parserLog.warn(`Unsupported in-seat transfer, missing from_trip_id and/or to_trip_id.`);
|
|
16662
16672
|
return;
|
|
16663
16673
|
}
|
|
16664
16674
|
const tripContinuationEntry = {
|
|
@@ -16694,7 +16704,7 @@ const processGuaranteedTripTransfer = (transferEntry, fromStop, toStop, guarante
|
|
|
16694
16704
|
const processGuaranteedStopTransfer = (transferEntry, fromStop, toStop, transfers) => {
|
|
16695
16705
|
// Reject transfers that specify route IDs - these are not supported for stop-to-stop transfers
|
|
16696
16706
|
if (transferEntry.from_route_id || transferEntry.to_route_id) {
|
|
16697
|
-
|
|
16707
|
+
parserLog.warn(`Unsupported transfer of type ${transferEntry.transfer_type} between routes ${transferEntry.from_route_id} and ${transferEntry.to_route_id}.`);
|
|
16698
16708
|
return;
|
|
16699
16709
|
}
|
|
16700
16710
|
const transfer = Object.assign({ destination: toStop, type: TransferTypes.GUARANTEED }, (transferEntry.min_transfer_time !== undefined && {
|
|
@@ -16709,11 +16719,11 @@ const processGuaranteedStopTransfer = (transferEntry, fromStop, toStop, transfer
|
|
|
16709
16719
|
*/
|
|
16710
16720
|
const processStopToStopTransfer = (transferEntry, fromStop, toStop, transfers) => {
|
|
16711
16721
|
if (transferEntry.from_trip_id || transferEntry.to_trip_id) {
|
|
16712
|
-
|
|
16722
|
+
parserLog.warn(`Unsupported transfer of type ${transferEntry.transfer_type} between trips ${transferEntry.from_trip_id} and ${transferEntry.to_trip_id}.`);
|
|
16713
16723
|
return;
|
|
16714
16724
|
}
|
|
16715
16725
|
if (transferEntry.from_route_id || transferEntry.to_route_id) {
|
|
16716
|
-
|
|
16726
|
+
parserLog.warn(`Unsupported transfer of type ${transferEntry.transfer_type} between routes ${transferEntry.from_route_id} and ${transferEntry.to_route_id}.`);
|
|
16717
16727
|
return;
|
|
16718
16728
|
}
|
|
16719
16729
|
if (transferEntry.transfer_type === 2 &&
|
|
@@ -16761,13 +16771,13 @@ const parseTransfers = (transfersStream, stopsMap, activeServiceIds) => __awaite
|
|
|
16761
16771
|
continue;
|
|
16762
16772
|
}
|
|
16763
16773
|
if (!transferEntry.from_stop_id || !transferEntry.to_stop_id) {
|
|
16764
|
-
|
|
16774
|
+
parserLog.warn(`Missing transfer origin or destination stop.`);
|
|
16765
16775
|
continue;
|
|
16766
16776
|
}
|
|
16767
16777
|
const fromStop = stopsMap.get(transferEntry.from_stop_id);
|
|
16768
16778
|
const toStop = stopsMap.get(transferEntry.to_stop_id);
|
|
16769
16779
|
if (!fromStop || !toStop) {
|
|
16770
|
-
|
|
16780
|
+
parserLog.warn(`Transfer references non-existent stop(s): from_stop_id=${transferEntry.from_stop_id}, to_stop_id=${transferEntry.to_stop_id}`);
|
|
16771
16781
|
continue;
|
|
16772
16782
|
}
|
|
16773
16783
|
switch (transferEntry.transfer_type) {
|
|
@@ -16792,7 +16802,7 @@ const parseTransfers = (transfersStream, stopsMap, activeServiceIds) => __awaite
|
|
|
16792
16802
|
transferEntry.to_trip_id ||
|
|
16793
16803
|
transferEntry.from_route_id ||
|
|
16794
16804
|
transferEntry.to_route_id) {
|
|
16795
|
-
|
|
16805
|
+
parserLog.warn(`Unsupported transfer of type 3 with trip or route constraints: from_trip_id=${transferEntry.from_trip_id}, to_trip_id=${transferEntry.to_trip_id}, from_route_id=${transferEntry.from_route_id}, to_route_id=${transferEntry.to_route_id}.`);
|
|
16796
16806
|
break;
|
|
16797
16807
|
}
|
|
16798
16808
|
const forbiddenDestinations = (_d = forbiddenTransfers.get(fromStop.id)) !== null && _d !== void 0 ? _d : new Set();
|
|
@@ -17193,7 +17203,7 @@ const parseStopTimes = (stopTimesStream, stopsMap, activeTripIds, activeStopIds,
|
|
|
17193
17203
|
}
|
|
17194
17204
|
const firstDeparture = departureTimes[0];
|
|
17195
17205
|
if (firstDeparture === undefined) {
|
|
17196
|
-
|
|
17206
|
+
parserLog.warn(`Empty trip ${currentTripId}`);
|
|
17197
17207
|
stops = [];
|
|
17198
17208
|
arrivalTimes = [];
|
|
17199
17209
|
departureTimes = [];
|
|
@@ -17276,11 +17286,11 @@ const parseStopTimes = (stopTimesStream, stopsMap, activeTripIds, activeStopIds,
|
|
|
17276
17286
|
const rawLine = _c;
|
|
17277
17287
|
const line = rawLine;
|
|
17278
17288
|
if (line.trip_id === currentTripId && line.stop_sequence <= previousSeq) {
|
|
17279
|
-
|
|
17289
|
+
parserLog.warn(`Stop sequences not increasing for trip ${line.trip_id}: ${line.stop_sequence} > ${previousSeq}.`);
|
|
17280
17290
|
continue;
|
|
17281
17291
|
}
|
|
17282
17292
|
if (!line.arrival_time && !line.departure_time) {
|
|
17283
|
-
|
|
17293
|
+
parserLog.warn(`Missing arrival or departure time for ${line.trip_id} at stop ${line.stop_id}.`);
|
|
17284
17294
|
continue;
|
|
17285
17295
|
}
|
|
17286
17296
|
if (line.pickup_type === '1' && line.drop_off_type === '1') {
|
|
@@ -17295,14 +17305,14 @@ const parseStopTimes = (stopTimesStream, stopsMap, activeTripIds, activeStopIds,
|
|
|
17295
17305
|
currentTripId = line.trip_id;
|
|
17296
17306
|
const stopData = stopsMap.get(line.stop_id);
|
|
17297
17307
|
if (!stopData) {
|
|
17298
|
-
|
|
17308
|
+
parserLog.warn(`Unknown stop ID: ${line.stop_id}`);
|
|
17299
17309
|
continue;
|
|
17300
17310
|
}
|
|
17301
17311
|
stops.push(stopData.id);
|
|
17302
17312
|
const departure = (_d = line.departure_time) !== null && _d !== void 0 ? _d : line.arrival_time;
|
|
17303
17313
|
const arrival = (_e = line.arrival_time) !== null && _e !== void 0 ? _e : line.departure_time;
|
|
17304
17314
|
if (!arrival || !departure) {
|
|
17305
|
-
|
|
17315
|
+
parserLog.warn(`Missing time data for ${line.trip_id} at stop ${line.stop_id}`);
|
|
17306
17316
|
continue;
|
|
17307
17317
|
}
|
|
17308
17318
|
arrivalTimes.push(toTime(arrival));
|
|
@@ -17375,52 +17385,51 @@ class GtfsParser {
|
|
|
17375
17385
|
*/
|
|
17376
17386
|
parseTimetable(date) {
|
|
17377
17387
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17378
|
-
log.setLevel('INFO');
|
|
17379
17388
|
const zip = new StreamZip.async({ file: this.path });
|
|
17380
17389
|
const entries = yield zip.entries();
|
|
17381
17390
|
const datetime = DateTime.fromJSDate(date);
|
|
17382
17391
|
const activeServiceIds = new Set();
|
|
17383
17392
|
const activeStopIds = new Set();
|
|
17384
|
-
|
|
17393
|
+
parserLog.info(`Parsing ${STOPS_FILE}`);
|
|
17385
17394
|
const stopsStart = performance.now();
|
|
17386
17395
|
const stopsStream = yield zip.stream(STOPS_FILE);
|
|
17387
17396
|
const parsedStops = yield parseStops(stopsStream);
|
|
17388
17397
|
const stopsEnd = performance.now();
|
|
17389
|
-
|
|
17398
|
+
parserLog.info(`${parsedStops.size} parsed stops. (${(stopsEnd - stopsStart).toFixed(2)}ms)`);
|
|
17390
17399
|
if (entries[CALENDAR_FILE]) {
|
|
17391
|
-
|
|
17400
|
+
parserLog.info(`Parsing ${CALENDAR_FILE}`);
|
|
17392
17401
|
const calendarStart = performance.now();
|
|
17393
17402
|
const calendarStream = yield zip.stream(CALENDAR_FILE);
|
|
17394
17403
|
yield parseCalendar(calendarStream, activeServiceIds, datetime);
|
|
17395
17404
|
const calendarEnd = performance.now();
|
|
17396
|
-
|
|
17405
|
+
parserLog.info(`${activeServiceIds.size} valid services. (${(calendarEnd - calendarStart).toFixed(2)}ms)`);
|
|
17397
17406
|
}
|
|
17398
17407
|
if (entries[CALENDAR_DATES_FILE]) {
|
|
17399
|
-
|
|
17408
|
+
parserLog.info(`Parsing ${CALENDAR_DATES_FILE}`);
|
|
17400
17409
|
const calendarDatesStart = performance.now();
|
|
17401
17410
|
const calendarDatesStream = yield zip.stream(CALENDAR_DATES_FILE);
|
|
17402
17411
|
yield parseCalendarDates(calendarDatesStream, activeServiceIds, datetime);
|
|
17403
17412
|
const calendarDatesEnd = performance.now();
|
|
17404
|
-
|
|
17413
|
+
parserLog.info(`${activeServiceIds.size} valid services. (${(calendarDatesEnd - calendarDatesStart).toFixed(2)}ms)`);
|
|
17405
17414
|
}
|
|
17406
|
-
|
|
17415
|
+
parserLog.info(`Parsing ${ROUTES_FILE}`);
|
|
17407
17416
|
const routesStart = performance.now();
|
|
17408
17417
|
const routesStream = yield zip.stream(ROUTES_FILE);
|
|
17409
17418
|
const validGtfsRoutes = yield parseRoutes(routesStream, this.profile);
|
|
17410
17419
|
const routesEnd = performance.now();
|
|
17411
|
-
|
|
17412
|
-
|
|
17420
|
+
parserLog.info(`${validGtfsRoutes.size} valid GTFS routes. (${(routesEnd - routesStart).toFixed(2)}ms)`);
|
|
17421
|
+
parserLog.info(`Parsing ${TRIPS_FILE}`);
|
|
17413
17422
|
const tripsStart = performance.now();
|
|
17414
17423
|
const tripsStream = yield zip.stream(TRIPS_FILE);
|
|
17415
17424
|
const trips = yield parseTrips(tripsStream, activeServiceIds, validGtfsRoutes);
|
|
17416
17425
|
const tripsEnd = performance.now();
|
|
17417
|
-
|
|
17426
|
+
parserLog.info(`${trips.size} valid trips. (${(tripsEnd - tripsStart).toFixed(2)}ms)`);
|
|
17418
17427
|
let transfers = new Map();
|
|
17419
17428
|
let forbiddenTransfers = new Map();
|
|
17420
17429
|
let tripContinuationsList = [];
|
|
17421
17430
|
let guaranteedTripTransfersList = [];
|
|
17422
17431
|
if (entries[TRANSFERS_FILE]) {
|
|
17423
|
-
|
|
17432
|
+
parserLog.info(`Parsing ${TRANSFERS_FILE}`);
|
|
17424
17433
|
const transfersStart = performance.now();
|
|
17425
17434
|
const transfersStream = yield zip.stream(TRANSFERS_FILE);
|
|
17426
17435
|
const { transfers: parsedTransfers, forbiddenTransfers: parsedForbiddenTransfers, tripContinuations: parsedTripContinuations, guaranteedTripTransfers: parsedGuaranteedTripTransfers, } = yield parseTransfers(transfersStream, parsedStops, activeServiceIds);
|
|
@@ -17429,32 +17438,32 @@ class GtfsParser {
|
|
|
17429
17438
|
tripContinuationsList = parsedTripContinuations;
|
|
17430
17439
|
guaranteedTripTransfersList = parsedGuaranteedTripTransfers;
|
|
17431
17440
|
const transfersEnd = performance.now();
|
|
17432
|
-
|
|
17441
|
+
parserLog.info(`${transfers.size} valid transfers and ${tripContinuationsList.length} trip continuations and ${guaranteedTripTransfersList.length} guaranteed trip transfers. (${(transfersEnd - transfersStart).toFixed(2)}ms)`);
|
|
17433
17442
|
}
|
|
17434
17443
|
let frequenciesMap;
|
|
17435
17444
|
if (entries[FREQUENCIES_FILE]) {
|
|
17436
|
-
|
|
17445
|
+
parserLog.info(`Parsing ${FREQUENCIES_FILE}`);
|
|
17437
17446
|
const frequenciesStart = performance.now();
|
|
17438
17447
|
const frequenciesStream = yield zip.stream(FREQUENCIES_FILE);
|
|
17439
17448
|
frequenciesMap = yield parseFrequencies(frequenciesStream, new Set(trips.keys()));
|
|
17440
17449
|
const frequenciesEnd = performance.now();
|
|
17441
|
-
|
|
17450
|
+
parserLog.info(`${frequenciesMap.size} trips with frequency data. (${(frequenciesEnd - frequenciesStart).toFixed(2)}ms)`);
|
|
17442
17451
|
}
|
|
17443
|
-
|
|
17452
|
+
parserLog.info(`Parsing ${STOP_TIMES_FILE}`);
|
|
17444
17453
|
const stopTimesStart = performance.now();
|
|
17445
17454
|
const stopTimesStream = yield zip.stream(STOP_TIMES_FILE);
|
|
17446
17455
|
const { routes, serviceRoutesMap, tripsMapping } = yield parseStopTimes(stopTimesStream, parsedStops, trips, activeStopIds, frequenciesMap);
|
|
17447
17456
|
const serviceRoutes = indexRoutes(validGtfsRoutes, serviceRoutesMap);
|
|
17448
17457
|
const stopTimesEnd = performance.now();
|
|
17449
|
-
|
|
17458
|
+
parserLog.info(`${routes.length} valid unique routes. (${(stopTimesEnd - stopTimesStart).toFixed(2)}ms)`);
|
|
17450
17459
|
if (this.profile.deriveSiblingTransfers !== false) {
|
|
17451
17460
|
const siblingTransfersStart = performance.now();
|
|
17452
17461
|
const siblingTransfersAdded = addMissingSiblingTransfers(parsedStops, activeStopIds, transfers, forbiddenTransfers);
|
|
17453
17462
|
const siblingTransfersEnd = performance.now();
|
|
17454
|
-
|
|
17463
|
+
parserLog.info(`${siblingTransfersAdded} sibling transfers added. (${(siblingTransfersEnd - siblingTransfersStart).toFixed(2)}ms)`);
|
|
17455
17464
|
}
|
|
17456
17465
|
if (this.transferGenerator) {
|
|
17457
|
-
|
|
17466
|
+
parserLog.info('Generating virtual transfers');
|
|
17458
17467
|
const virtualTransfersStart = performance.now();
|
|
17459
17468
|
// Only route-served stops with coordinates are worth connecting: a
|
|
17460
17469
|
// transfer to a stop no route calls at is a dead end for the router.
|
|
@@ -17465,28 +17474,28 @@ class GtfsParser {
|
|
|
17465
17474
|
const generatedTransfers = yield this.transferGenerator.generate(originStops, stopsIndex);
|
|
17466
17475
|
const addedTransfers = addGeneratedTransfers(generatedTransfers, activeStopIds, transfers, forbiddenTransfers);
|
|
17467
17476
|
const virtualTransfersEnd = performance.now();
|
|
17468
|
-
|
|
17477
|
+
parserLog.info(`${addedTransfers} virtual transfers added. (${(virtualTransfersEnd - virtualTransfersStart).toFixed(2)}ms)`);
|
|
17469
17478
|
}
|
|
17470
|
-
|
|
17479
|
+
parserLog.info('Building stops adjacency structure');
|
|
17471
17480
|
const stopsAdjacencyStart = performance.now();
|
|
17472
17481
|
const stopsAdjacency = buildStopsAdjacencyStructure(serviceRoutes, routes, transfers, parsedStops.size, activeStopIds);
|
|
17473
17482
|
const stopsAdjacencyEnd = performance.now();
|
|
17474
|
-
|
|
17483
|
+
parserLog.info(`${stopsAdjacency.length} valid stops in the structure. (${(stopsAdjacencyEnd - stopsAdjacencyStart).toFixed(2)}ms)`);
|
|
17475
17484
|
yield zip.close();
|
|
17476
17485
|
// temporary timetable for building continuations
|
|
17477
17486
|
const timetable = new Timetable(stopsAdjacency, routes, serviceRoutes);
|
|
17478
|
-
|
|
17487
|
+
parserLog.info('Building in-seat trip continuations');
|
|
17479
17488
|
const tripContinuationsStart = performance.now();
|
|
17480
17489
|
const tripContinuations = buildTripTransfers(tripsMapping, tripContinuationsList, timetable, activeStopIds);
|
|
17481
17490
|
const tripContinuationsEnd = performance.now();
|
|
17482
|
-
|
|
17483
|
-
|
|
17484
|
-
|
|
17491
|
+
parserLog.info(`${tripContinuations.size} in-seat trip continuations origins created. (${(tripContinuationsEnd - tripContinuationsStart).toFixed(2)}ms)`);
|
|
17492
|
+
parserLog.info('Parsing complete.');
|
|
17493
|
+
parserLog.info('Building guaranteed trip transfers');
|
|
17485
17494
|
const guaranteedTripTransfersStart = performance.now();
|
|
17486
17495
|
const guaranteedTripTransfers = buildTripTransfers(tripsMapping, guaranteedTripTransfersList, timetable, activeStopIds);
|
|
17487
17496
|
const guaranteedTripTransfersEnd = performance.now();
|
|
17488
|
-
|
|
17489
|
-
|
|
17497
|
+
parserLog.info(`${guaranteedTripTransfers.size} guaranteed trip transfers origins created. (${(guaranteedTripTransfersEnd - guaranteedTripTransfersStart).toFixed(2)}ms)`);
|
|
17498
|
+
parserLog.info('Parsing complete.');
|
|
17490
17499
|
return new Timetable(stopsAdjacency, routes, serviceRoutes, tripContinuations, guaranteedTripTransfers);
|
|
17491
17500
|
});
|
|
17492
17501
|
}
|
|
@@ -17499,12 +17508,12 @@ class GtfsParser {
|
|
|
17499
17508
|
parseStops() {
|
|
17500
17509
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17501
17510
|
const zip = new StreamZip.async({ file: this.path });
|
|
17502
|
-
|
|
17511
|
+
parserLog.info(`Parsing ${STOPS_FILE}`);
|
|
17503
17512
|
const stopsStart = performance.now();
|
|
17504
17513
|
const stopsStream = yield zip.stream(STOPS_FILE);
|
|
17505
17514
|
const stops = yield parseStops(stopsStream);
|
|
17506
17515
|
const stopsEnd = performance.now();
|
|
17507
|
-
|
|
17516
|
+
parserLog.info(`${stops.size} parsed stops. (${(stopsEnd - stopsStart).toFixed(2)}ms)`);
|
|
17508
17517
|
yield zip.close();
|
|
17509
17518
|
return new StopsIndex(Array.from(stops.values()));
|
|
17510
17519
|
});
|
|
@@ -17740,5 +17749,6 @@ exports.GtfsParser = GtfsParser;
|
|
|
17740
17749
|
exports.StraightLineTransferGenerator = StraightLineTransferGenerator;
|
|
17741
17750
|
exports.TransferTypes = TransferTypes;
|
|
17742
17751
|
exports.extendedGtfsProfile = extendedGtfsProfile;
|
|
17752
|
+
exports.setParserLogLevel = setParserLogLevel;
|
|
17743
17753
|
exports.standardGtfsProfile = standardGtfsProfile;
|
|
17744
17754
|
//# sourceMappingURL=parser.cjs.js.map
|