gtfs-to-html 2.10.13 → 2.10.15
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/dist/app/index.js +35 -44
- package/dist/app/index.js.map +1 -1
- package/dist/bin/gtfs-to-html.js +37 -44
- package/dist/bin/gtfs-to-html.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +37 -44
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
- package/views/default/formatting_functions.pug +16 -1
- package/views/default/overview.pug +1 -1
package/dist/app/index.js
CHANGED
|
@@ -93,7 +93,6 @@ import {
|
|
|
93
93
|
flatMap as flatMap2,
|
|
94
94
|
flattenDeep,
|
|
95
95
|
flow,
|
|
96
|
-
isEqual,
|
|
97
96
|
groupBy,
|
|
98
97
|
head,
|
|
99
98
|
last,
|
|
@@ -121,7 +120,7 @@ import {
|
|
|
121
120
|
getFrequencies,
|
|
122
121
|
getTimetables,
|
|
123
122
|
getTimetablePages,
|
|
124
|
-
getAgencies,
|
|
123
|
+
getAgencies as getAgencies2,
|
|
125
124
|
openDb
|
|
126
125
|
} from "gtfs";
|
|
127
126
|
import { stringify } from "csv-stringify";
|
|
@@ -325,7 +324,7 @@ import { featureCollection, round } from "@turf/helpers";
|
|
|
325
324
|
import { clearLine, cursorTo } from "readline";
|
|
326
325
|
import { noop } from "lodash-es";
|
|
327
326
|
import * as colors from "yoctocolors";
|
|
328
|
-
import { getFeedInfo } from "gtfs";
|
|
327
|
+
import { getAgencies, getFeedInfo } from "gtfs";
|
|
329
328
|
import Table from "cli-table";
|
|
330
329
|
function logWarning(config2) {
|
|
331
330
|
if (config2.logFunction) {
|
|
@@ -420,7 +419,7 @@ function getAgencyGeoJSON(config2) {
|
|
|
420
419
|
// package.json
|
|
421
420
|
var package_default = {
|
|
422
421
|
name: "gtfs-to-html",
|
|
423
|
-
version: "2.10.
|
|
422
|
+
version: "2.10.15",
|
|
424
423
|
private: false,
|
|
425
424
|
description: "Build human readable transit timetables as HTML, PDF or CSV from GTFS",
|
|
426
425
|
keywords: [
|
|
@@ -471,18 +470,18 @@ var package_default = {
|
|
|
471
470
|
anchorme: "^3.0.8",
|
|
472
471
|
archiver: "^7.0.1",
|
|
473
472
|
"cli-table": "^0.3.11",
|
|
474
|
-
"csv-stringify": "^6.
|
|
473
|
+
"csv-stringify": "^6.6.0",
|
|
475
474
|
express: "^5.1.0",
|
|
476
|
-
gtfs: "^4.17.
|
|
475
|
+
gtfs: "^4.17.5",
|
|
477
476
|
"gtfs-realtime-pbf-js-module": "^1.0.0",
|
|
478
477
|
"js-beautify": "^1.15.4",
|
|
479
478
|
"lodash-es": "^4.17.21",
|
|
480
|
-
marked: "^
|
|
479
|
+
marked: "^16.1.1",
|
|
481
480
|
moment: "^2.30.1",
|
|
482
481
|
pbf: "^4.0.1",
|
|
483
482
|
"pretty-error": "^4.0.0",
|
|
484
483
|
pug: "^3.0.3",
|
|
485
|
-
puppeteer: "^24.
|
|
484
|
+
puppeteer: "^24.15.0",
|
|
486
485
|
"sanitize-filename": "^1.6.3",
|
|
487
486
|
"sanitize-html": "^2.17.0",
|
|
488
487
|
sqlstring: "^2.3.3",
|
|
@@ -494,19 +493,19 @@ var package_default = {
|
|
|
494
493
|
},
|
|
495
494
|
devDependencies: {
|
|
496
495
|
"@types/archiver": "^6.0.3",
|
|
497
|
-
"@types/express": "^5.0.
|
|
496
|
+
"@types/express": "^5.0.3",
|
|
498
497
|
"@types/insane": "^1.0.0",
|
|
499
498
|
"@types/js-beautify": "^1.14.3",
|
|
500
499
|
"@types/lodash-es": "^4.17.12",
|
|
501
|
-
"@types/morgan": "^1.9.
|
|
502
|
-
"@types/node": "^22
|
|
500
|
+
"@types/morgan": "^1.9.10",
|
|
501
|
+
"@types/node": "^22",
|
|
503
502
|
"@types/pug": "^2.0.10",
|
|
504
503
|
"@types/sanitize-html": "^2.16.0",
|
|
505
504
|
"@types/timer-machine": "^1.1.3",
|
|
506
505
|
"@types/yargs": "^17.0.33",
|
|
507
506
|
husky: "^9.1.7",
|
|
508
|
-
"lint-staged": "^16.1.
|
|
509
|
-
prettier: "^3.
|
|
507
|
+
"lint-staged": "^16.1.2",
|
|
508
|
+
prettier: "^3.6.2",
|
|
510
509
|
tsup: "^8.5.0",
|
|
511
510
|
typescript: "^5.8.3"
|
|
512
511
|
},
|
|
@@ -576,37 +575,20 @@ var findCommonStopId = (trips, config2) => {
|
|
|
576
575
|
});
|
|
577
576
|
return commonStoptime ? commonStoptime.stop_id : null;
|
|
578
577
|
};
|
|
579
|
-
var deduplicateTrips = (trips
|
|
580
|
-
|
|
578
|
+
var deduplicateTrips = (trips) => {
|
|
579
|
+
if (trips.length <= 1) {
|
|
580
|
+
return trips;
|
|
581
|
+
}
|
|
582
|
+
const uniqueTrips = /* @__PURE__ */ new Map();
|
|
581
583
|
for (const trip of trips) {
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
const selectedStoptime = commonStopId ? find(trip.stoptimes, {
|
|
588
|
-
stop_id: commonStopId
|
|
589
|
-
}) : trip.stoptimes[0];
|
|
590
|
-
const similarTrips = deduplicatedTrips.filter((trip2) => {
|
|
591
|
-
const stoptime = find(trip2.stoptimes, {
|
|
592
|
-
stop_id: selectedStoptime?.stop_id
|
|
593
|
-
});
|
|
594
|
-
if (!stoptime) {
|
|
595
|
-
return false;
|
|
596
|
-
}
|
|
597
|
-
return stoptime.departure_time === selectedStoptime?.departure_time;
|
|
598
|
-
});
|
|
599
|
-
const tripIsUnique = every2(similarTrips, (similarTrip) => {
|
|
600
|
-
const similarTripStoptimes = similarTrip.stoptimes.map(
|
|
601
|
-
(stoptime) => stoptime.departure_time
|
|
602
|
-
);
|
|
603
|
-
return !isEqual(stoptimes, similarTripStoptimes);
|
|
604
|
-
});
|
|
605
|
-
if (tripIsUnique) {
|
|
606
|
-
deduplicatedTrips.push(trip);
|
|
584
|
+
const tripSignature = trip.stoptimes.map(
|
|
585
|
+
(stoptime) => `${stoptime.stop_id}|${stoptime.departure_time}|${stoptime.arrival_time}`
|
|
586
|
+
).join("|");
|
|
587
|
+
if (!uniqueTrips.has(tripSignature)) {
|
|
588
|
+
uniqueTrips.set(tripSignature, trip);
|
|
607
589
|
}
|
|
608
590
|
}
|
|
609
|
-
return
|
|
591
|
+
return Array.from(uniqueTrips.values());
|
|
610
592
|
};
|
|
611
593
|
var sortTrips = (trips, config2) => {
|
|
612
594
|
let sortedTrips;
|
|
@@ -660,7 +642,10 @@ var sortTrips = (trips, config2) => {
|
|
|
660
642
|
const lastStopId = last(longestTripStoptimes).stop_id;
|
|
661
643
|
sortedTrips = sortTripsByStoptimeAtStop(trips, lastStopId);
|
|
662
644
|
}
|
|
663
|
-
|
|
645
|
+
if (config2.showDuplicateTrips === false) {
|
|
646
|
+
return deduplicateTrips(sortedTrips ?? []);
|
|
647
|
+
}
|
|
648
|
+
return sortedTrips ?? [];
|
|
664
649
|
};
|
|
665
650
|
var sortTripsByStoptimeAtStop = (trips, stopId) => sortBy(trips, (trip) => {
|
|
666
651
|
const stoptime = find(trip.stoptimes, { stop_id: stopId });
|
|
@@ -991,6 +976,11 @@ var getStopOrder = (timetable, config2) => {
|
|
|
991
976
|
stopGraph.push([stopId, sortedStopIds[index + 1]]);
|
|
992
977
|
}
|
|
993
978
|
}
|
|
979
|
+
if (stopGraph.length === 0 && config2.showOnlyTimepoint === true) {
|
|
980
|
+
timetable.warnings.push(
|
|
981
|
+
`Timetable ${timetable.timetable_id}'s trips have stoptimes with timepoints but \`showOnlyTimepoint\` is true. Try setting \`showOnlyTimepoint\` to false.`
|
|
982
|
+
);
|
|
983
|
+
}
|
|
994
984
|
const stopIds = toposort(stopGraph);
|
|
995
985
|
return duplicateStopsForDifferentArrivalDeparture(
|
|
996
986
|
stopIds,
|
|
@@ -1525,6 +1515,7 @@ function setDefaultConfig(initialConfig) {
|
|
|
1525
1515
|
serviceProvidedOnText: "Service provided on",
|
|
1526
1516
|
showArrivalOnDifference: 0.2,
|
|
1527
1517
|
showCalendarExceptions: true,
|
|
1518
|
+
showDuplicateTrips: false,
|
|
1528
1519
|
showMap: false,
|
|
1529
1520
|
showOnlyTimepoint: false,
|
|
1530
1521
|
showRouteTitle: true,
|
|
@@ -1598,7 +1589,7 @@ function getFormattedTimetablePage(timetablePageId, config2) {
|
|
|
1598
1589
|
return formattedTimetablePage;
|
|
1599
1590
|
}
|
|
1600
1591
|
function generateTimetableHTML(timetablePage, config2) {
|
|
1601
|
-
const agencies =
|
|
1592
|
+
const agencies = getAgencies2();
|
|
1602
1593
|
const templateVars = {
|
|
1603
1594
|
timetablePage,
|
|
1604
1595
|
config: config2,
|
|
@@ -1607,7 +1598,7 @@ function generateTimetableHTML(timetablePage, config2) {
|
|
|
1607
1598
|
return renderTemplate("timetablepage", templateVars, config2);
|
|
1608
1599
|
}
|
|
1609
1600
|
function generateOverviewHTML(timetablePages, config2) {
|
|
1610
|
-
const agencies =
|
|
1601
|
+
const agencies = getAgencies2();
|
|
1611
1602
|
if (agencies.length === 0) {
|
|
1612
1603
|
throw new Error("No agencies found");
|
|
1613
1604
|
}
|