gtfs 4.10.3 → 4.11.0
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 +22 -0
- package/README.md +57 -9
- package/bin/gtfs-export.js +4 -0
- package/bin/gtfs-import.js +4 -1
- package/bin/gtfsrealtime-update.js +4 -1
- package/lib/advancedQuery.js +1 -1
- package/lib/file-utils.js +23 -26
- 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 +15 -9
- package/lib/log-utils.js +1 -5
- 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 +7 -7
- 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
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import sqlString from 'sqlstring-sqlite';
|
|
2
|
+
|
|
3
|
+
import { openDb } from '../db.js';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
formatOrderByClause,
|
|
7
|
+
formatSelectClause,
|
|
8
|
+
formatWhereClauses,
|
|
9
|
+
} from '../utils.js';
|
|
10
|
+
import locationGroups from '../../models/gtfs/location-groups.js';
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* Returns an array of all location groups that match the query parameters.
|
|
14
|
+
*/
|
|
15
|
+
export function getLocationGroups(
|
|
16
|
+
query = {},
|
|
17
|
+
fields = [],
|
|
18
|
+
orderBy = [],
|
|
19
|
+
options = {},
|
|
20
|
+
) {
|
|
21
|
+
const db = options.db ?? openDb();
|
|
22
|
+
const tableName = sqlString.escapeId(locationGroups.filenameBase);
|
|
23
|
+
const selectClause = formatSelectClause(fields);
|
|
24
|
+
const whereClause = formatWhereClauses(query);
|
|
25
|
+
const orderByClause = formatOrderByClause(orderBy);
|
|
26
|
+
|
|
27
|
+
return db
|
|
28
|
+
.prepare(
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
30
|
+
)
|
|
31
|
+
.all();
|
|
32
|
+
}
|
package/lib/gtfs/pathways.js
CHANGED
|
@@ -16,7 +16,7 @@ export function getPathways(
|
|
|
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(pathways.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getPathways(
|
|
|
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/routes.js
CHANGED
|
@@ -18,7 +18,7 @@ function buildStoptimeSubquery(query) {
|
|
|
18
18
|
|
|
19
19
|
function buildTripSubquery(query) {
|
|
20
20
|
return `SELECT DISTINCT route_id FROM trips WHERE trip_id IN (${buildStoptimeSubquery(
|
|
21
|
-
query
|
|
21
|
+
query,
|
|
22
22
|
)})`;
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -37,7 +37,7 @@ export function getRoutes(query = {}, fields = [], orderBy = [], options = {}) {
|
|
|
37
37
|
const stoptimeQuery = pick(query, ['stop_id']);
|
|
38
38
|
|
|
39
39
|
const whereClauses = Object.entries(routeQuery).map(([key, value]) =>
|
|
40
|
-
formatWhereClause(key, value)
|
|
40
|
+
formatWhereClause(key, value),
|
|
41
41
|
);
|
|
42
42
|
|
|
43
43
|
if (Object.values(stoptimeQuery).length > 0) {
|
|
@@ -50,7 +50,7 @@ export function getRoutes(query = {}, fields = [], orderBy = [], options = {}) {
|
|
|
50
50
|
|
|
51
51
|
return db
|
|
52
52
|
.prepare(
|
|
53
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
53
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
54
54
|
)
|
|
55
55
|
.all();
|
|
56
56
|
}
|
package/lib/gtfs/shapes.js
CHANGED
|
@@ -48,7 +48,7 @@ export function getShapes(query = {}, fields = [], orderBy = [], options = {}) {
|
|
|
48
48
|
]);
|
|
49
49
|
|
|
50
50
|
const whereClauses = Object.entries(shapeQuery).map(([key, value]) =>
|
|
51
|
-
formatWhereClause(key, value)
|
|
51
|
+
formatWhereClause(key, value),
|
|
52
52
|
);
|
|
53
53
|
|
|
54
54
|
if (Object.values(tripQuery).length > 0) {
|
|
@@ -61,7 +61,7 @@ export function getShapes(query = {}, fields = [], orderBy = [], options = {}) {
|
|
|
61
61
|
|
|
62
62
|
return db
|
|
63
63
|
.prepare(
|
|
64
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause}
|
|
64
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
65
65
|
)
|
|
66
66
|
.all();
|
|
67
67
|
}
|
|
@@ -93,17 +93,17 @@ export function getShapesAsGeoJSON(query = {}, options = {}) {
|
|
|
93
93
|
shapeQuery,
|
|
94
94
|
['shape_id', 'shape_pt_sequence', 'shape_pt_lon', 'shape_pt_lat'],
|
|
95
95
|
[],
|
|
96
|
-
options
|
|
96
|
+
options,
|
|
97
97
|
);
|
|
98
98
|
const routeAttributes = getRouteAttributes(
|
|
99
99
|
{ route_id: route.route_id },
|
|
100
100
|
[],
|
|
101
101
|
[],
|
|
102
|
-
options
|
|
102
|
+
options,
|
|
103
103
|
);
|
|
104
104
|
|
|
105
105
|
const agency = agencies.find(
|
|
106
|
-
(agency) => agency.agency_id === route.agency_id
|
|
106
|
+
(agency) => agency.agency_id === route.agency_id,
|
|
107
107
|
);
|
|
108
108
|
|
|
109
109
|
const geojsonProperties = {
|
package/lib/gtfs/stop-areas.js
CHANGED
|
@@ -16,7 +16,7 @@ export function getStopAreas(
|
|
|
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(stopAreas.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getStopAreas(
|
|
|
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/stop-times.js
CHANGED
|
@@ -16,7 +16,7 @@ export function getStoptimes(
|
|
|
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(stopTimes.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getStoptimes(
|
|
|
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/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
|
@@ -348,7 +348,6 @@ const readFiles = async (task) => {
|
|
|
348
348
|
}
|
|
349
349
|
} catch (error) {
|
|
350
350
|
task.error(error);
|
|
351
|
-
console.error(error);
|
|
352
351
|
throw new Error(`Unable to unzip file ${task.path}`);
|
|
353
352
|
}
|
|
354
353
|
} else {
|
|
@@ -470,22 +469,29 @@ const formatLine = (line, model, totalLineCount) => {
|
|
|
470
469
|
}
|
|
471
470
|
}
|
|
472
471
|
|
|
473
|
-
// Convert to midnight timestamp
|
|
474
|
-
const
|
|
472
|
+
// Convert to midnight timestamp and add timestamp columns as integer seconds from midnight
|
|
473
|
+
const timeColumnNames = [
|
|
475
474
|
'start_time',
|
|
476
475
|
'end_time',
|
|
477
476
|
'arrival_time',
|
|
478
477
|
'departure_time',
|
|
478
|
+
'prior_notice_last_time',
|
|
479
|
+
'prior_notice_start_time',
|
|
480
|
+
'start_pickup_drop_off_window',
|
|
479
481
|
];
|
|
480
482
|
|
|
481
|
-
for (const
|
|
482
|
-
if (formattedLine[
|
|
483
|
-
|
|
484
|
-
|
|
483
|
+
for (const timeColumnName of timeColumnNames) {
|
|
484
|
+
if (formattedLine[timeColumnName]) {
|
|
485
|
+
const timestampColumnName = timeColumnName.endsWith('time')
|
|
486
|
+
? `${timeColumnName}stamp`
|
|
487
|
+
: `${timeColumnName}_timestamp`;
|
|
488
|
+
formattedLine[timestampColumnName] = calculateSecondsFromMidnight(
|
|
489
|
+
formattedLine[timeColumnName],
|
|
490
|
+
);
|
|
485
491
|
|
|
486
492
|
// Ensure leading zeros for time columns
|
|
487
|
-
formattedLine[
|
|
488
|
-
formattedLine[
|
|
493
|
+
formattedLine[timeColumnName] = padLeadingZeros(
|
|
494
|
+
formattedLine[timeColumnName],
|
|
489
495
|
);
|
|
490
496
|
}
|
|
491
497
|
}
|
package/lib/log-utils.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { clearLine, cursorTo } from 'node:readline';
|
|
2
|
-
import PrettyError from 'pretty-error';
|
|
3
2
|
import { noop } from 'lodash-es';
|
|
4
3
|
import * as colors from 'yoctocolors';
|
|
5
4
|
|
|
6
|
-
const pe = new PrettyError();
|
|
7
|
-
pe.start();
|
|
8
|
-
|
|
9
5
|
/*
|
|
10
6
|
* Returns a log function based on config settings
|
|
11
7
|
*/
|
|
@@ -71,7 +67,7 @@ export function formatError(error) {
|
|
|
71
67
|
const messageText = error instanceof Error ? error.message : error;
|
|
72
68
|
const errorMessage = `${colors.underline('Error')}: ${messageText.replace(
|
|
73
69
|
'Error: ',
|
|
74
|
-
''
|
|
70
|
+
'',
|
|
75
71
|
)}`;
|
|
76
72
|
return colors.red(errorMessage);
|
|
77
73
|
}
|
|
@@ -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
|
}
|