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