gtfs-to-html 2.10.0 → 2.10.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/dist/app/index.js +65 -26
- package/dist/app/index.js.map +1 -1
- package/dist/bin/gtfs-to-html.js +200 -178
- package/dist/bin/gtfs-to-html.js.map +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.js +200 -178
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/app/index.js
CHANGED
|
@@ -85,6 +85,7 @@ import {
|
|
|
85
85
|
cloneDeep,
|
|
86
86
|
compact,
|
|
87
87
|
countBy,
|
|
88
|
+
difference,
|
|
88
89
|
entries,
|
|
89
90
|
every as every2,
|
|
90
91
|
find,
|
|
@@ -310,6 +311,28 @@ import { getShapesAsGeoJSON, getStopsAsGeoJSON } from "gtfs";
|
|
|
310
311
|
import { flatMap } from "lodash-es";
|
|
311
312
|
import simplify from "@turf/simplify";
|
|
312
313
|
import { featureCollection, round } from "@turf/helpers";
|
|
314
|
+
|
|
315
|
+
// src/lib/log-utils.ts
|
|
316
|
+
import { noop } from "lodash-es";
|
|
317
|
+
import * as colors from "yoctocolors";
|
|
318
|
+
import { getFeedInfo } from "gtfs";
|
|
319
|
+
import Table from "cli-table";
|
|
320
|
+
function logWarning(config2) {
|
|
321
|
+
if (config2.logFunction) {
|
|
322
|
+
return config2.logFunction;
|
|
323
|
+
}
|
|
324
|
+
return (text) => {
|
|
325
|
+
process.stdout.write(`
|
|
326
|
+
${formatWarning(text)}
|
|
327
|
+
`);
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
function formatWarning(text) {
|
|
331
|
+
const warningMessage = `${colors.underline("Warning")}: ${text}`;
|
|
332
|
+
return colors.yellow(warningMessage);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// src/lib/geojson-utils.ts
|
|
313
336
|
var mergeGeojson = (...geojsons) => featureCollection(flatMap(geojsons, (geojson) => geojson.features));
|
|
314
337
|
var truncateGeoJSONDecimals = (geojson, config2) => {
|
|
315
338
|
for (const feature of geojson.features) {
|
|
@@ -337,18 +360,6 @@ var truncateGeoJSONDecimals = (geojson, config2) => {
|
|
|
337
360
|
}
|
|
338
361
|
return geojson;
|
|
339
362
|
};
|
|
340
|
-
var simplifyGeoJSON = (geojson, config2) => {
|
|
341
|
-
try {
|
|
342
|
-
const simplifiedGeojson = simplify(geojson, {
|
|
343
|
-
tolerance: 1 / 10 ** config2.coordinatePrecision,
|
|
344
|
-
highQuality: true
|
|
345
|
-
});
|
|
346
|
-
return truncateGeoJSONDecimals(simplifiedGeojson, config2);
|
|
347
|
-
} catch {
|
|
348
|
-
config2.logWarning("Unable to simplify geojson");
|
|
349
|
-
return truncateGeoJSONDecimals(geojson, config2);
|
|
350
|
-
}
|
|
351
|
-
};
|
|
352
363
|
function getTimetableGeoJSON(timetable, config2) {
|
|
353
364
|
const shapesGeojsons = timetable.route_ids.map(
|
|
354
365
|
(routeId) => getShapesAsGeoJSON({
|
|
@@ -365,17 +376,39 @@ function getTimetableGeoJSON(timetable, config2) {
|
|
|
365
376
|
})
|
|
366
377
|
);
|
|
367
378
|
const geojson = mergeGeojson(...shapesGeojsons, ...stopsGeojsons);
|
|
368
|
-
|
|
379
|
+
let simplifiedGeojson;
|
|
380
|
+
try {
|
|
381
|
+
simplifiedGeojson = simplify(geojson, {
|
|
382
|
+
tolerance: 1 / 10 ** config2.coordinatePrecision,
|
|
383
|
+
highQuality: true
|
|
384
|
+
});
|
|
385
|
+
} catch {
|
|
386
|
+
timetable.warnings.push(
|
|
387
|
+
`Timetable ${timetable.timetable_id} - Unable to simplify geojson`
|
|
388
|
+
);
|
|
389
|
+
simplifiedGeojson = geojson;
|
|
390
|
+
}
|
|
391
|
+
return truncateGeoJSONDecimals(simplifiedGeojson, config2);
|
|
369
392
|
}
|
|
370
393
|
function getAgencyGeoJSON(config2) {
|
|
371
394
|
const shapesGeojsons = getShapesAsGeoJSON();
|
|
372
395
|
const stopsGeojsons = getStopsAsGeoJSON();
|
|
373
396
|
const geojson = mergeGeojson(shapesGeojsons, stopsGeojsons);
|
|
374
|
-
|
|
397
|
+
let simplifiedGeojson;
|
|
398
|
+
try {
|
|
399
|
+
simplifiedGeojson = simplify(geojson, {
|
|
400
|
+
tolerance: 1 / 10 ** config2.coordinatePrecision,
|
|
401
|
+
highQuality: true
|
|
402
|
+
});
|
|
403
|
+
} catch {
|
|
404
|
+
logWarning(config2)("Unable to simplify geojson");
|
|
405
|
+
simplifiedGeojson = geojson;
|
|
406
|
+
}
|
|
407
|
+
return truncateGeoJSONDecimals(simplifiedGeojson, config2);
|
|
375
408
|
}
|
|
376
409
|
|
|
377
410
|
// package.json
|
|
378
|
-
var version = "2.10.
|
|
411
|
+
var version = "2.10.1";
|
|
379
412
|
|
|
380
413
|
// src/lib/utils.ts
|
|
381
414
|
var isTimepoint = (stoptime) => {
|
|
@@ -605,7 +638,7 @@ var getTimetableNotesForTimetable = (timetable, config2) => {
|
|
|
605
638
|
continue;
|
|
606
639
|
}
|
|
607
640
|
if (noteReference.stop_id === "" || noteReference.stop_id === null) {
|
|
608
|
-
|
|
641
|
+
timetable.warnings.push(
|
|
609
642
|
`Timetable Note Reference for note_id=${noteReference.note_id} has a \`stop_sequence\` but no \`stop_id\` - ignoring`
|
|
610
643
|
);
|
|
611
644
|
continue;
|
|
@@ -838,9 +871,19 @@ var getStopOrder = (timetable, config2) => {
|
|
|
838
871
|
config2
|
|
839
872
|
);
|
|
840
873
|
const stopIds = longestTripStoptimes.map((stoptime) => stoptime.stop_id);
|
|
841
|
-
|
|
842
|
-
|
|
874
|
+
const missingStopIds = difference(
|
|
875
|
+
uniq(
|
|
876
|
+
timetable.orderedTrips.flatMap(
|
|
877
|
+
(trip) => trip.stoptimes.map((stoptime) => stoptime.stop_id)
|
|
878
|
+
)
|
|
879
|
+
),
|
|
880
|
+
uniq(stopIds)
|
|
843
881
|
);
|
|
882
|
+
if (missingStopIds.length > 0) {
|
|
883
|
+
timetable.warnings.push(
|
|
884
|
+
`Timetable ${timetable.timetable_id} stops are unable to be topologically sorted and has no \`timetable_stop_order.txt\`. Falling back to using the using the stop order from trip with most stoptimes, but this does not include stop_ids ${new Intl.ListFormat("en", { style: "long", type: "conjunction" }).format(missingStopIds)}. Try manually specifying stops with \`timetable_stop_order.txt\`. Read more at https://gtfstohtml.com/docs/timetable-stop-order`
|
|
885
|
+
);
|
|
886
|
+
}
|
|
844
887
|
return duplicateStopsForDifferentArrivalDeparture(
|
|
845
888
|
stopIds,
|
|
846
889
|
timetable,
|
|
@@ -1831,17 +1874,13 @@ var selectedConfig = JSON.parse(readFileSync(configPath, "utf8"));
|
|
|
1831
1874
|
var config = setDefaultConfig(selectedConfig);
|
|
1832
1875
|
config.noHead = false;
|
|
1833
1876
|
config.assetPath = "/";
|
|
1834
|
-
config.
|
|
1835
|
-
config.logWarning = console.warn;
|
|
1836
|
-
config.logError = console.error;
|
|
1877
|
+
config.logFunction = console.log;
|
|
1837
1878
|
try {
|
|
1838
1879
|
openDb2(config);
|
|
1839
1880
|
} catch (error) {
|
|
1840
|
-
|
|
1841
|
-
config.
|
|
1842
|
-
|
|
1843
|
-
);
|
|
1844
|
-
}
|
|
1881
|
+
console.error(
|
|
1882
|
+
`Unable to open sqlite database "${config.sqlitePath}" defined as \`sqlitePath\` config.json. Ensure the parent directory exists and run gtfs-to-html to import GTFS before running this app.`
|
|
1883
|
+
);
|
|
1845
1884
|
throw error;
|
|
1846
1885
|
}
|
|
1847
1886
|
app.set("views", getPathToViewsFolder(config));
|