gtfs-to-html 2.5.5 → 2.5.7
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 +18 -0
- package/lib/formatters.js +28 -15
- package/lib/utils.js +107 -89
- package/package.json +8 -8
- package/views/default/timetable_horizontal.pug +1 -1
- package/views/default/timetable_vertical.pug +1 -1
- package/www/blog/2021-11-06-CSV-Export.md +1 -1
- package/www/docs/configuration.md +136 -136
- package/www/docs/logging-sql-queries.md +2 -2
- package/www/docs/quick-start.md +41 -38
- package/www/docs/related-libraries.md +3 -3
- package/www/package.json +5 -14
- package/www/yarn.lock +3012 -2131
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [2.5.7] - 2023-11-07
|
|
9
|
+
|
|
10
|
+
### Updated
|
|
11
|
+
|
|
12
|
+
- Dependency updates
|
|
13
|
+
- Docusaurus 3.0 for documentation site
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- Add is_timepoint value to each stop
|
|
18
|
+
|
|
19
|
+
## [2.5.6] - 2023-08-23
|
|
20
|
+
|
|
21
|
+
### Updated
|
|
22
|
+
|
|
23
|
+
- Dependency updates
|
|
24
|
+
- Use most common headsign for timetable name
|
|
25
|
+
|
|
8
26
|
## [2.5.5] - 2023-07-18
|
|
9
27
|
|
|
10
28
|
### Updated
|
package/lib/formatters.js
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
toGTFSTime,
|
|
21
21
|
updateTimeByOffset,
|
|
22
22
|
} from './time-utils.js';
|
|
23
|
+
import { isTimepoint } from './utils.js';
|
|
23
24
|
|
|
24
25
|
/*
|
|
25
26
|
* Replace all instances in a string with items from an object.
|
|
@@ -141,13 +142,13 @@ function filterHourlyTimes(stops) {
|
|
|
141
142
|
time,
|
|
142
143
|
}));
|
|
143
144
|
const sortedFirstStopTimesAndIndex = sortBy(firstStopTimesAndIndex, (item) =>
|
|
144
|
-
Number.parseInt(item.time.format('m'), 10)
|
|
145
|
+
Number.parseInt(item.time.format('m'), 10),
|
|
145
146
|
);
|
|
146
147
|
|
|
147
148
|
// Filter and arrange stoptimes for all stops based on sort.
|
|
148
149
|
return stops.map((stop) => {
|
|
149
150
|
stop.hourlyTimes = sortedFirstStopTimesAndIndex.map((item) =>
|
|
150
|
-
fromGTFSTime(stop.trips[item.idx].arrival_time).format(':mm')
|
|
151
|
+
fromGTFSTime(stop.trips[item.idx].arrival_time).format(':mm'),
|
|
151
152
|
);
|
|
152
153
|
|
|
153
154
|
return stop;
|
|
@@ -234,7 +235,7 @@ export function formatTrip(trip, timetable, calendars, config) {
|
|
|
234
235
|
trip.route_short_name = timetable.routes[0].route_short_name;
|
|
235
236
|
} else {
|
|
236
237
|
const route = timetable.routes.find(
|
|
237
|
-
(route) => route.route_id === trip.route_id
|
|
238
|
+
(route) => route.route_id === trip.route_id,
|
|
238
239
|
);
|
|
239
240
|
trip.route_short_name = route.route_short_name;
|
|
240
241
|
}
|
|
@@ -274,7 +275,7 @@ export function formatFrequency(frequency, config) {
|
|
|
274
275
|
*/
|
|
275
276
|
export function formatTimetableId(timetable) {
|
|
276
277
|
let timetableId = `${timetable.route_ids.join('_')}|${calendarToCalendarCode(
|
|
277
|
-
timetable
|
|
278
|
+
timetable,
|
|
278
279
|
)}`;
|
|
279
280
|
if (!isNullOrEmpty(timetable.direction_id)) {
|
|
280
281
|
timetableId += `|${timetable.direction_id}`;
|
|
@@ -328,7 +329,7 @@ export function formatStops(timetable, config) {
|
|
|
328
329
|
const departureStoptime = clone(stoptime);
|
|
329
330
|
departureStoptime.type = 'departure';
|
|
330
331
|
timetable.stops[stopIndex + 1].trips.push(
|
|
331
|
-
formatStopTime(departureStoptime, timetable, config)
|
|
332
|
+
formatStopTime(departureStoptime, timetable, config),
|
|
332
333
|
);
|
|
333
334
|
}
|
|
334
335
|
|
|
@@ -343,8 +344,13 @@ export function formatStops(timetable, config) {
|
|
|
343
344
|
for (const stop of timetable.stops) {
|
|
344
345
|
const lastStopTime = last(stop.trips);
|
|
345
346
|
if (!lastStopTime || lastStopTime.trip_id !== trip.trip_id) {
|
|
346
|
-
|
|
347
|
-
|
|
347
|
+
stop.trips.push(
|
|
348
|
+
formatStopTime(
|
|
349
|
+
createEmptyStoptime(stop.stop_id, trip.trip_id),
|
|
350
|
+
timetable,
|
|
351
|
+
config,
|
|
352
|
+
),
|
|
353
|
+
);
|
|
348
354
|
}
|
|
349
355
|
}
|
|
350
356
|
}
|
|
@@ -353,6 +359,10 @@ export function formatStops(timetable, config) {
|
|
|
353
359
|
timetable.stops = filterHourlyTimes(timetable.stops);
|
|
354
360
|
}
|
|
355
361
|
|
|
362
|
+
for (const stop of timetable.stops) {
|
|
363
|
+
stop.is_timepoint = stop.trips.some((stoptime) => isTimepoint(stoptime));
|
|
364
|
+
}
|
|
365
|
+
|
|
356
366
|
return timetable.stops;
|
|
357
367
|
}
|
|
358
368
|
|
|
@@ -393,15 +403,18 @@ export function formatTripContinuesAs(trip) {
|
|
|
393
403
|
*/
|
|
394
404
|
export function resetStoptimesToMidnight(trip) {
|
|
395
405
|
const offsetSeconds = secondsAfterMidnight(
|
|
396
|
-
first(trip.stoptimes).departure_time
|
|
406
|
+
first(trip.stoptimes).departure_time,
|
|
397
407
|
);
|
|
398
408
|
if (offsetSeconds > 0) {
|
|
399
409
|
for (const stoptime of trip.stoptimes) {
|
|
400
410
|
stoptime.departure_time = toGTFSTime(
|
|
401
|
-
fromGTFSTime(stoptime.departure_time).subtract(
|
|
411
|
+
fromGTFSTime(stoptime.departure_time).subtract(
|
|
412
|
+
offsetSeconds,
|
|
413
|
+
'seconds',
|
|
414
|
+
),
|
|
402
415
|
);
|
|
403
416
|
stoptime.arrival_time = toGTFSTime(
|
|
404
|
-
fromGTFSTime(stoptime.arrival_time).subtract(offsetSeconds, 'seconds')
|
|
417
|
+
fromGTFSTime(stoptime.arrival_time).subtract(offsetSeconds, 'seconds'),
|
|
405
418
|
);
|
|
406
419
|
}
|
|
407
420
|
}
|
|
@@ -418,11 +431,11 @@ export function updateStoptimesByOffset(trip, offsetSeconds) {
|
|
|
418
431
|
delete stoptime._id;
|
|
419
432
|
stoptime.departure_time = updateTimeByOffset(
|
|
420
433
|
stoptime.departure_time,
|
|
421
|
-
offsetSeconds
|
|
434
|
+
offsetSeconds,
|
|
422
435
|
);
|
|
423
436
|
stoptime.arrival_time = updateTimeByOffset(
|
|
424
437
|
stoptime.arrival_time,
|
|
425
|
-
offsetSeconds
|
|
438
|
+
offsetSeconds,
|
|
426
439
|
);
|
|
427
440
|
stoptime.trip_id = trip.trip_id;
|
|
428
441
|
return stoptime;
|
|
@@ -483,9 +496,9 @@ export function formatTimetablePageLabel(timetablePage) {
|
|
|
483
496
|
const routes = uniqBy(
|
|
484
497
|
flatMap(
|
|
485
498
|
timetablePage.consolidatedTimetables,
|
|
486
|
-
(timetable) => timetable.routes
|
|
499
|
+
(timetable) => timetable.routes,
|
|
487
500
|
),
|
|
488
|
-
'route_id'
|
|
501
|
+
'route_id',
|
|
489
502
|
);
|
|
490
503
|
const timetablePageLabel = routes.map((route) => formatRouteName(route));
|
|
491
504
|
|
|
@@ -509,7 +522,7 @@ export function mergeTimetablesWithSameId(timetables) {
|
|
|
509
522
|
const mergedTimetable = omit(timetableGroup[0], 'route_id');
|
|
510
523
|
|
|
511
524
|
mergedTimetable.route_ids = timetableGroup.map(
|
|
512
|
-
(timetable) => timetable.route_id
|
|
525
|
+
(timetable) => timetable.route_id,
|
|
513
526
|
);
|
|
514
527
|
|
|
515
528
|
return mergedTimetable;
|