gtfs 4.10.4 → 4.11.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 +25 -0
- package/README.md +57 -9
- package/lib/advancedQuery.js +1 -1
- package/lib/geojson-utils.js +7 -7
- package/lib/gtfs/agencies.js +2 -2
- package/lib/gtfs/areas.js +1 -1
- package/lib/gtfs/attributions.js +2 -2
- package/lib/gtfs/booking-rules.js +32 -0
- package/lib/gtfs/calendar-dates.js +2 -2
- package/lib/gtfs/calendars.js +2 -2
- package/lib/gtfs/fare-attributes.js +2 -2
- package/lib/gtfs/fare-leg-rules.js +2 -2
- package/lib/gtfs/fare-products.js +2 -2
- package/lib/gtfs/fare-rules.js +2 -2
- package/lib/gtfs/fare-transfer-rules.js +2 -2
- package/lib/gtfs/feed-info.js +2 -2
- package/lib/gtfs/frequencies.js +2 -2
- package/lib/gtfs/levels.js +1 -1
- package/lib/gtfs/location-group-stops.js +32 -0
- package/lib/gtfs/location-groups.js +32 -0
- package/lib/gtfs/pathways.js +2 -2
- package/lib/gtfs/routes.js +3 -3
- package/lib/gtfs/shapes.js +5 -5
- package/lib/gtfs/stop-areas.js +2 -2
- package/lib/gtfs/stop-times.js +2 -2
- package/lib/gtfs/transfers.js +2 -2
- package/lib/gtfs/translations.js +2 -2
- package/lib/gtfs/trips.js +1 -1
- package/lib/gtfs-plus/calendar-attributes.js +2 -2
- package/lib/gtfs-plus/directions.js +2 -2
- package/lib/gtfs-plus/route-attributes.js +2 -2
- package/lib/gtfs-plus/stop-attributes.js +2 -2
- package/lib/gtfs-realtime/service-alerts.js +2 -2
- package/lib/gtfs-realtime/trip-updates.js +2 -2
- package/lib/gtfs-realtime/vehicle-positions.js +2 -2
- package/lib/gtfs-ride/board-alights.js +2 -2
- package/lib/gtfs-ride/ride-feed-infos.js +2 -2
- package/lib/gtfs-ride/rider-trips.js +2 -2
- package/lib/gtfs-ride/riderships.js +2 -2
- package/lib/gtfs-ride/trip-capacities.js +2 -2
- package/lib/gtfs.js +12 -0
- package/lib/import.js +30 -22
- package/lib/non-standard/timetable-notes-references.js +2 -2
- package/lib/non-standard/timetable-notes.js +2 -2
- package/lib/non-standard/timetable-pages.js +2 -2
- package/lib/non-standard/timetable-stop-order.js +2 -2
- package/lib/non-standard/timetables.js +2 -2
- package/lib/non-standard/trips-dated-vehicle-journey.js +2 -2
- package/lib/ods/deadhead-times.js +2 -2
- package/lib/ods/deadheads.js +2 -2
- package/lib/ods/ops-locations.js +2 -2
- package/lib/ods/run-events.js +2 -2
- package/lib/ods/runs-pieces.js +2 -2
- package/models/gtfs/attributions.js +2 -2
- package/models/gtfs/booking-rules.js +91 -0
- package/models/gtfs/fare-leg-rules.js +5 -0
- package/models/gtfs/location-group-stops.js +21 -0
- package/models/gtfs/location-groups.js +18 -0
- package/models/gtfs/stop-times.js +33 -0
- package/models/models.js +6 -0
- package/package.json +4 -5
- package/test/mocha/get-agencies.js +1 -1
- package/test/mocha/get-booking-rules.js +28 -0
- package/test/mocha/get-calendar-dates.js +1 -1
- package/test/mocha/get-fare-rules.js +1 -1
- package/test/mocha/get-location-group-stops.js +33 -0
- package/test/mocha/get-location-groups.js +28 -0
- package/test/mocha/get-routes.js +2 -2
- package/test/mocha/get-shapes.js +6 -6
- package/test/mocha/get-stoptimes.js +1 -1
package/lib/gtfs/transfers.js
CHANGED
|
@@ -16,7 +16,7 @@ export function getTransfers(
|
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
|
-
options = {}
|
|
19
|
+
options = {},
|
|
20
20
|
) {
|
|
21
21
|
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(transfers.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getTransfers(
|
|
|
26
26
|
|
|
27
27
|
return db
|
|
28
28
|
.prepare(
|
|
29
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
30
30
|
)
|
|
31
31
|
.all();
|
|
32
32
|
}
|
package/lib/gtfs/translations.js
CHANGED
|
@@ -16,7 +16,7 @@ export function getTranslations(
|
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
|
-
options = {}
|
|
19
|
+
options = {},
|
|
20
20
|
) {
|
|
21
21
|
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(translations.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getTranslations(
|
|
|
26
26
|
|
|
27
27
|
return db
|
|
28
28
|
.prepare(
|
|
29
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
30
30
|
)
|
|
31
31
|
.all();
|
|
32
32
|
}
|
package/lib/gtfs/trips.js
CHANGED
|
@@ -21,7 +21,7 @@ export function getTrips(query = {}, fields = [], orderBy = [], options = {}) {
|
|
|
21
21
|
|
|
22
22
|
return db
|
|
23
23
|
.prepare(
|
|
24
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
24
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
25
25
|
)
|
|
26
26
|
.all();
|
|
27
27
|
}
|
|
@@ -16,7 +16,7 @@ export function getCalendarAttributes(
|
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
|
-
options = {}
|
|
19
|
+
options = {},
|
|
20
20
|
) {
|
|
21
21
|
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(calendarAttributes.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getCalendarAttributes(
|
|
|
26
26
|
|
|
27
27
|
return db
|
|
28
28
|
.prepare(
|
|
29
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
30
30
|
)
|
|
31
31
|
.all();
|
|
32
32
|
}
|
|
@@ -16,7 +16,7 @@ export function getDirections(
|
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
|
-
options = {}
|
|
19
|
+
options = {},
|
|
20
20
|
) {
|
|
21
21
|
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(directions.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getDirections(
|
|
|
26
26
|
|
|
27
27
|
return db
|
|
28
28
|
.prepare(
|
|
29
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
30
30
|
)
|
|
31
31
|
.all();
|
|
32
32
|
}
|
|
@@ -16,7 +16,7 @@ export function getRouteAttributes(
|
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
|
-
options = {}
|
|
19
|
+
options = {},
|
|
20
20
|
) {
|
|
21
21
|
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(routeAttributes.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getRouteAttributes(
|
|
|
26
26
|
|
|
27
27
|
return db
|
|
28
28
|
.prepare(
|
|
29
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
30
30
|
)
|
|
31
31
|
.all();
|
|
32
32
|
}
|
|
@@ -16,7 +16,7 @@ export function getStopAttributes(
|
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
|
-
options = {}
|
|
19
|
+
options = {},
|
|
20
20
|
) {
|
|
21
21
|
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(stopAttributes.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getStopAttributes(
|
|
|
26
26
|
|
|
27
27
|
return db
|
|
28
28
|
.prepare(
|
|
29
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
30
30
|
)
|
|
31
31
|
.all();
|
|
32
32
|
}
|
|
@@ -17,7 +17,7 @@ export function getServiceAlerts(
|
|
|
17
17
|
query = {},
|
|
18
18
|
fields = [],
|
|
19
19
|
orderBy = [],
|
|
20
|
-
options = {}
|
|
20
|
+
options = {},
|
|
21
21
|
) {
|
|
22
22
|
const db = options.db ?? openDb();
|
|
23
23
|
const tableName = sqlString.escapeId(serviceAlerts.filenameBase);
|
|
@@ -28,7 +28,7 @@ export function getServiceAlerts(
|
|
|
28
28
|
|
|
29
29
|
return db
|
|
30
30
|
.prepare(
|
|
31
|
-
`${selectClause} FROM ${tableName} INNER JOIN ${joinTable} ON ${tableName}.id=${joinTable}.alert_id ${whereClause} ${orderByClause}
|
|
31
|
+
`${selectClause} FROM ${tableName} INNER JOIN ${joinTable} ON ${tableName}.id=${joinTable}.alert_id ${whereClause} ${orderByClause};`,
|
|
32
32
|
)
|
|
33
33
|
.all();
|
|
34
34
|
}
|
|
@@ -16,7 +16,7 @@ export function getTripUpdates(
|
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
|
-
options = {}
|
|
19
|
+
options = {},
|
|
20
20
|
) {
|
|
21
21
|
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(tripUpdates.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getTripUpdates(
|
|
|
26
26
|
|
|
27
27
|
return db
|
|
28
28
|
.prepare(
|
|
29
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
30
30
|
)
|
|
31
31
|
.all();
|
|
32
32
|
}
|
|
@@ -16,7 +16,7 @@ export function getVehiclePositions(
|
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
|
-
options = {}
|
|
19
|
+
options = {},
|
|
20
20
|
) {
|
|
21
21
|
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(vehiclePositions.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getVehiclePositions(
|
|
|
26
26
|
|
|
27
27
|
return db
|
|
28
28
|
.prepare(
|
|
29
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
30
30
|
)
|
|
31
31
|
.all();
|
|
32
32
|
}
|
|
@@ -16,7 +16,7 @@ export function getBoardAlights(
|
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
|
-
options = {}
|
|
19
|
+
options = {},
|
|
20
20
|
) {
|
|
21
21
|
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(boardAlights.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getBoardAlights(
|
|
|
26
26
|
|
|
27
27
|
return db
|
|
28
28
|
.prepare(
|
|
29
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
30
30
|
)
|
|
31
31
|
.all();
|
|
32
32
|
}
|
|
@@ -16,7 +16,7 @@ export function getRideFeedInfos(
|
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
|
-
options = {}
|
|
19
|
+
options = {},
|
|
20
20
|
) {
|
|
21
21
|
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(rideFeedInfo.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getRideFeedInfos(
|
|
|
26
26
|
|
|
27
27
|
return db
|
|
28
28
|
.prepare(
|
|
29
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
30
30
|
)
|
|
31
31
|
.all();
|
|
32
32
|
}
|
|
@@ -16,7 +16,7 @@ export function getRiderTrips(
|
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
|
-
options = {}
|
|
19
|
+
options = {},
|
|
20
20
|
) {
|
|
21
21
|
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(riderTrip.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getRiderTrips(
|
|
|
26
26
|
|
|
27
27
|
return db
|
|
28
28
|
.prepare(
|
|
29
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
30
30
|
)
|
|
31
31
|
.all();
|
|
32
32
|
}
|
|
@@ -16,7 +16,7 @@ export function getRiderships(
|
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
|
-
options = {}
|
|
19
|
+
options = {},
|
|
20
20
|
) {
|
|
21
21
|
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(riderships.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getRiderships(
|
|
|
26
26
|
|
|
27
27
|
return db
|
|
28
28
|
.prepare(
|
|
29
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
30
30
|
)
|
|
31
31
|
.all();
|
|
32
32
|
}
|
|
@@ -16,7 +16,7 @@ export function getTripCapacities(
|
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
|
-
options = {}
|
|
19
|
+
options = {},
|
|
20
20
|
) {
|
|
21
21
|
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(tripCapacity.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getTripCapacities(
|
|
|
26
26
|
|
|
27
27
|
return db
|
|
28
28
|
.prepare(
|
|
29
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
30
30
|
)
|
|
31
31
|
.all();
|
|
32
32
|
}
|
package/lib/gtfs.js
CHANGED
|
@@ -8,6 +8,7 @@ import exportGtfs from './export.js';
|
|
|
8
8
|
import { getAgencies } from './gtfs/agencies.js';
|
|
9
9
|
import { getAreas } from './gtfs/areas.js';
|
|
10
10
|
import { getAttributions } from './gtfs/attributions.js';
|
|
11
|
+
import { getBookingRules } from './gtfs/booking-rules.js';
|
|
11
12
|
import { getCalendarDates } from './gtfs/calendar-dates.js';
|
|
12
13
|
import { getCalendars } from './gtfs/calendars.js';
|
|
13
14
|
import { getFareAttributes } from './gtfs/fare-attributes.js';
|
|
@@ -19,6 +20,8 @@ import { getFareTransferRules } from './gtfs/fare-transfer-rules.js';
|
|
|
19
20
|
import { getFeedInfo } from './gtfs/feed-info.js';
|
|
20
21
|
import { getFrequencies } from './gtfs/frequencies.js';
|
|
21
22
|
import { getLevels } from './gtfs/levels.js';
|
|
23
|
+
import { getLocationGroups } from './gtfs/location-groups.js';
|
|
24
|
+
import { getLocationGroupStops } from './gtfs/location-group-stops.js';
|
|
22
25
|
import { getNetworks } from './gtfs/networks.js';
|
|
23
26
|
import { getPathways } from './gtfs/pathways.js';
|
|
24
27
|
import { getRouteNetworks } from './gtfs/route-networks.js';
|
|
@@ -86,6 +89,9 @@ export { _getAreas as getAreas };
|
|
|
86
89
|
const _getAttributions = getAttributions;
|
|
87
90
|
export { _getAttributions as getAttributions };
|
|
88
91
|
|
|
92
|
+
const _getBookingRules = getBookingRules;
|
|
93
|
+
export { _getBookingRules as getBookingRules };
|
|
94
|
+
|
|
89
95
|
const _getCalendarDates = getCalendarDates;
|
|
90
96
|
export { _getCalendarDates as getCalendarDates };
|
|
91
97
|
|
|
@@ -119,6 +125,12 @@ export { _getFrequencies as getFrequencies };
|
|
|
119
125
|
const _getLevels = getLevels;
|
|
120
126
|
export { _getLevels as getLevels };
|
|
121
127
|
|
|
128
|
+
const _getLocationGroups = getLocationGroups;
|
|
129
|
+
export { _getLocationGroups as getLocationGroups };
|
|
130
|
+
|
|
131
|
+
const _getLocationGroupStops = getLocationGroupStops;
|
|
132
|
+
export { _getLocationGroupStops as getLocationGroupStops };
|
|
133
|
+
|
|
122
134
|
const _getNetworks = getNetworks;
|
|
123
135
|
export { _getNetworks as getNetworks };
|
|
124
136
|
|
package/lib/import.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { createReadStream, existsSync, lstatSync } from 'node:fs';
|
|
3
|
-
import { readdir, rename, writeFile } from 'node:fs/promises';
|
|
4
|
-
import copy from 'recursive-copy';
|
|
3
|
+
import { cp, readdir, rename, writeFile } from 'node:fs/promises';
|
|
5
4
|
import fetch from 'node-fetch';
|
|
6
5
|
import { parse } from 'csv-parse';
|
|
7
6
|
import pluralize from 'pluralize';
|
|
@@ -42,7 +41,7 @@ const downloadFiles = async (task) => {
|
|
|
42
41
|
});
|
|
43
42
|
|
|
44
43
|
if (response.status !== 200) {
|
|
45
|
-
throw new Error(
|
|
44
|
+
throw new Error(`Unable to download GTFS from ${task.agency_url}`);
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
const buffer = await response.arrayBuffer();
|
|
@@ -51,14 +50,19 @@ const downloadFiles = async (task) => {
|
|
|
51
50
|
task.log('Download successful');
|
|
52
51
|
};
|
|
53
52
|
|
|
54
|
-
const downloadGtfsRealtimeData = async (url,
|
|
53
|
+
const downloadGtfsRealtimeData = async (url, task) => {
|
|
55
54
|
const response = await fetch(url, {
|
|
56
55
|
method: 'GET',
|
|
57
|
-
headers: {
|
|
56
|
+
headers: {
|
|
57
|
+
...{},
|
|
58
|
+
...task.realtime_headers,
|
|
59
|
+
...{ 'Accept-Encoding': 'gzip' },
|
|
60
|
+
},
|
|
58
61
|
});
|
|
59
62
|
|
|
60
63
|
if (response.status !== 200) {
|
|
61
|
-
|
|
64
|
+
task.warn(`Unable to download GTFS-Realtime from ${url}`);
|
|
65
|
+
return null;
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
const buffer = await response.arrayBuffer();
|
|
@@ -190,17 +194,14 @@ const updateRealtimeData = async (task) => {
|
|
|
190
194
|
for (const realtimeUrl of task.realtime_urls) {
|
|
191
195
|
task.log(`Downloading GTFS-Realtime from ${realtimeUrl}`);
|
|
192
196
|
// eslint-disable-next-line no-await-in-loop
|
|
193
|
-
const gtfsRealtimeData = await downloadGtfsRealtimeData(
|
|
194
|
-
realtimeUrl,
|
|
195
|
-
task.realtime_headers,
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
task.log(`Download successful`);
|
|
197
|
+
const gtfsRealtimeData = await downloadGtfsRealtimeData(realtimeUrl, task);
|
|
199
198
|
|
|
200
|
-
if (!gtfsRealtimeData
|
|
199
|
+
if (!gtfsRealtimeData?.entity) {
|
|
201
200
|
continue;
|
|
202
201
|
}
|
|
203
202
|
|
|
203
|
+
task.log(`Download successful`);
|
|
204
|
+
|
|
204
205
|
let totalLineCount = 0;
|
|
205
206
|
|
|
206
207
|
for (const entity of gtfsRealtimeData.entity) {
|
|
@@ -353,7 +354,7 @@ const readFiles = async (task) => {
|
|
|
353
354
|
} else {
|
|
354
355
|
// Local file is unzipped, just copy it from there.
|
|
355
356
|
try {
|
|
356
|
-
await
|
|
357
|
+
await cp(gtfsPath, task.downloadDir, { recursive: true });
|
|
357
358
|
} catch {
|
|
358
359
|
throw new Error(
|
|
359
360
|
`Unable to load files from path \`${gtfsPath}\` defined in configuration. Verify that path exists and contains GTFS files.`,
|
|
@@ -469,22 +470,29 @@ const formatLine = (line, model, totalLineCount) => {
|
|
|
469
470
|
}
|
|
470
471
|
}
|
|
471
472
|
|
|
472
|
-
// Convert to midnight timestamp
|
|
473
|
-
const
|
|
473
|
+
// Convert to midnight timestamp and add timestamp columns as integer seconds from midnight
|
|
474
|
+
const timeColumnNames = [
|
|
474
475
|
'start_time',
|
|
475
476
|
'end_time',
|
|
476
477
|
'arrival_time',
|
|
477
478
|
'departure_time',
|
|
479
|
+
'prior_notice_last_time',
|
|
480
|
+
'prior_notice_start_time',
|
|
481
|
+
'start_pickup_drop_off_window',
|
|
478
482
|
];
|
|
479
483
|
|
|
480
|
-
for (const
|
|
481
|
-
if (formattedLine[
|
|
482
|
-
|
|
483
|
-
|
|
484
|
+
for (const timeColumnName of timeColumnNames) {
|
|
485
|
+
if (formattedLine[timeColumnName]) {
|
|
486
|
+
const timestampColumnName = timeColumnName.endsWith('time')
|
|
487
|
+
? `${timeColumnName}stamp`
|
|
488
|
+
: `${timeColumnName}_timestamp`;
|
|
489
|
+
formattedLine[timestampColumnName] = calculateSecondsFromMidnight(
|
|
490
|
+
formattedLine[timeColumnName],
|
|
491
|
+
);
|
|
484
492
|
|
|
485
493
|
// Ensure leading zeros for time columns
|
|
486
|
-
formattedLine[
|
|
487
|
-
formattedLine[
|
|
494
|
+
formattedLine[timeColumnName] = padLeadingZeros(
|
|
495
|
+
formattedLine[timeColumnName],
|
|
488
496
|
);
|
|
489
497
|
}
|
|
490
498
|
}
|
|
@@ -16,7 +16,7 @@ export function getTimetableNotesReferences(
|
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
|
-
options = {}
|
|
19
|
+
options = {},
|
|
20
20
|
) {
|
|
21
21
|
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(timetableNotesReferences.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getTimetableNotesReferences(
|
|
|
26
26
|
|
|
27
27
|
return db
|
|
28
28
|
.prepare(
|
|
29
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
30
30
|
)
|
|
31
31
|
.all();
|
|
32
32
|
}
|
|
@@ -16,7 +16,7 @@ export function getTimetableNotes(
|
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
|
-
options = {}
|
|
19
|
+
options = {},
|
|
20
20
|
) {
|
|
21
21
|
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(timetableNotes.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getTimetableNotes(
|
|
|
26
26
|
|
|
27
27
|
return db
|
|
28
28
|
.prepare(
|
|
29
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
30
30
|
)
|
|
31
31
|
.all();
|
|
32
32
|
}
|
|
@@ -16,7 +16,7 @@ export function getTimetablePages(
|
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
|
-
options = {}
|
|
19
|
+
options = {},
|
|
20
20
|
) {
|
|
21
21
|
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(timetablePages.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getTimetablePages(
|
|
|
26
26
|
|
|
27
27
|
return db
|
|
28
28
|
.prepare(
|
|
29
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
30
30
|
)
|
|
31
31
|
.all();
|
|
32
32
|
}
|
|
@@ -16,7 +16,7 @@ export function getTimetableStopOrders(
|
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
|
-
options = {}
|
|
19
|
+
options = {},
|
|
20
20
|
) {
|
|
21
21
|
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(timetableStopOrder.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getTimetableStopOrders(
|
|
|
26
26
|
|
|
27
27
|
return db
|
|
28
28
|
.prepare(
|
|
29
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
30
30
|
)
|
|
31
31
|
.all();
|
|
32
32
|
}
|
|
@@ -16,7 +16,7 @@ export function getTimetables(
|
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
|
-
options = {}
|
|
19
|
+
options = {},
|
|
20
20
|
) {
|
|
21
21
|
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(timetables.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getTimetables(
|
|
|
26
26
|
|
|
27
27
|
return db
|
|
28
28
|
.prepare(
|
|
29
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
30
30
|
)
|
|
31
31
|
.all();
|
|
32
32
|
}
|
|
@@ -16,7 +16,7 @@ export function getTripsDatedVehicleJourneys(
|
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
|
-
options = {}
|
|
19
|
+
options = {},
|
|
20
20
|
) {
|
|
21
21
|
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(directions.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getTripsDatedVehicleJourneys(
|
|
|
26
26
|
|
|
27
27
|
return db
|
|
28
28
|
.prepare(
|
|
29
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
30
30
|
)
|
|
31
31
|
.all();
|
|
32
32
|
}
|
|
@@ -16,7 +16,7 @@ export function getDeadheadTimes(
|
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
|
-
options = {}
|
|
19
|
+
options = {},
|
|
20
20
|
) {
|
|
21
21
|
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(deadheadTimes.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getDeadheadTimes(
|
|
|
26
26
|
|
|
27
27
|
return db
|
|
28
28
|
.prepare(
|
|
29
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
30
30
|
)
|
|
31
31
|
.all();
|
|
32
32
|
}
|
package/lib/ods/deadheads.js
CHANGED
|
@@ -16,7 +16,7 @@ export function getDeadheads(
|
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
|
-
options = {}
|
|
19
|
+
options = {},
|
|
20
20
|
) {
|
|
21
21
|
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(deadheads.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getDeadheads(
|
|
|
26
26
|
|
|
27
27
|
return db
|
|
28
28
|
.prepare(
|
|
29
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
30
30
|
)
|
|
31
31
|
.all();
|
|
32
32
|
}
|
package/lib/ods/ops-locations.js
CHANGED
|
@@ -16,7 +16,7 @@ export function getOpsLocations(
|
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
|
-
options = {}
|
|
19
|
+
options = {},
|
|
20
20
|
) {
|
|
21
21
|
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(opsLocations.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getOpsLocations(
|
|
|
26
26
|
|
|
27
27
|
return db
|
|
28
28
|
.prepare(
|
|
29
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
30
30
|
)
|
|
31
31
|
.all();
|
|
32
32
|
}
|
package/lib/ods/run-events.js
CHANGED
|
@@ -16,7 +16,7 @@ export function getRunEvents(
|
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
|
-
options = {}
|
|
19
|
+
options = {},
|
|
20
20
|
) {
|
|
21
21
|
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(runEvents.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getRunEvents(
|
|
|
26
26
|
|
|
27
27
|
return db
|
|
28
28
|
.prepare(
|
|
29
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
30
30
|
)
|
|
31
31
|
.all();
|
|
32
32
|
}
|
package/lib/ods/runs-pieces.js
CHANGED
|
@@ -16,7 +16,7 @@ export function getRunsPieces(
|
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
|
-
options = {}
|
|
19
|
+
options = {},
|
|
20
20
|
) {
|
|
21
21
|
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(runsPieces.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getRunsPieces(
|
|
|
26
26
|
|
|
27
27
|
return db
|
|
28
28
|
.prepare(
|
|
29
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
30
30
|
)
|
|
31
31
|
.all();
|
|
32
32
|
}
|