gtfs 4.10.4 → 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 +14 -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 +15 -8
- 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 -4
- 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/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,20 @@ 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
|
+
## [4.11.0] - 2024-06-01
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Support for [GTFS Flex](https://mobilitydata.org/🎉-gtfs-flex-is-officially-adopted-everything-you-need-to-know/)
|
|
13
|
+
- Support for [booking_rules.txt](https://gtfs.org/schedule/reference/#booking_rulestxt)
|
|
14
|
+
- Support for [location_groups.txt](https://gtfs.org/schedule/reference/#location_groupstxt)
|
|
15
|
+
- Support for [location_group_stops.txt](https://gtfs.org/schedule/reference/#location_group_stopstxt)
|
|
16
|
+
- Add `rule_priority` field to `fare_leg_rules.txt`
|
|
17
|
+
|
|
18
|
+
### Updated
|
|
19
|
+
|
|
20
|
+
- Dependency updates
|
|
21
|
+
|
|
8
22
|
## [4.10.4] - 2024-05-14
|
|
9
23
|
|
|
10
24
|
### Updated
|
package/README.md
CHANGED
|
@@ -166,7 +166,7 @@ Copy `config-sample.json` to `config.json` and then add your projects configurat
|
|
|
166
166
|
| --------------------------------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
167
167
|
| [`agencies`](#agencies) | array | An array of GTFS files to be imported, and which files to exclude. |
|
|
168
168
|
| [`csvOptions`](#csvOptions) | object | Options passed to `csv-parse` for parsing GTFS CSV files. Optional. |
|
|
169
|
-
| [`db`](#db) | database instance | An existing database instance to use instead of relying on node-gtfs to connect. Optional.
|
|
169
|
+
| [`db`](#db) | database instance | An existing database instance to use instead of relying on node-gtfs to connect. Optional. |
|
|
170
170
|
| [`downloadTimeout`](#downloadtimeout) | integer | The number of milliseconds to wait before throwing an error when downloading GTFS. Optional. |
|
|
171
171
|
| [`exportPath`](#exportPath) | string | A path to a directory to put exported GTFS files. Optional, defaults to `gtfs-export/<agency_name>`. |
|
|
172
172
|
| [`ignoreDuplicates`](#ignoreduplicates) | boolean | Whether or not to ignore unique constraints on ids when importing GTFS, such as `trip_id`, `calendar_id`. Optional, defaults to false. |
|
|
@@ -668,7 +668,7 @@ const routes = getRoutes(
|
|
|
668
668
|
{}, // No query filters
|
|
669
669
|
['route_id', 'route_short_name', 'route_color'], // Only return these fields
|
|
670
670
|
[['route_short_name', 'ASC']], // Sort by this field and direction
|
|
671
|
-
{ db: db } // Options for the query. Can specify which database to use if more than one are open
|
|
671
|
+
{ db: db }, // Options for the query. Can specify which database to use if more than one are open
|
|
672
672
|
);
|
|
673
673
|
|
|
674
674
|
closeDb(db);
|
|
@@ -690,7 +690,7 @@ const trips = getTrips(
|
|
|
690
690
|
{
|
|
691
691
|
route_id: '123',
|
|
692
692
|
},
|
|
693
|
-
['trip_id']
|
|
693
|
+
['trip_id'],
|
|
694
694
|
);
|
|
695
695
|
|
|
696
696
|
closeDb(db);
|
|
@@ -770,6 +770,22 @@ const attributions = getAttributions({
|
|
|
770
770
|
});
|
|
771
771
|
```
|
|
772
772
|
|
|
773
|
+
#### getBookingRules(query, fields, sortBy, options)
|
|
774
|
+
|
|
775
|
+
Returns an array of booking rules that match query parameters. [Details on booking_rules.txt](https://gtfs.org/schedule/reference/#booking_rulestxt)
|
|
776
|
+
|
|
777
|
+
```js
|
|
778
|
+
import { getBookingRules } from 'gtfs';
|
|
779
|
+
|
|
780
|
+
// Get all booking rules
|
|
781
|
+
const bookingRules = getBookingRules();
|
|
782
|
+
|
|
783
|
+
// Get a specific booking rule
|
|
784
|
+
const bookingRules = getBookingRules({
|
|
785
|
+
booking_rule_id: '1234',
|
|
786
|
+
});
|
|
787
|
+
```
|
|
788
|
+
|
|
773
789
|
#### getRoutes(query, fields, sortBy, options)
|
|
774
790
|
|
|
775
791
|
Returns an array of routes that match query parameters. [Details on routes.txt](https://gtfs.org/schedule/reference/#routestxt)
|
|
@@ -794,7 +810,7 @@ const routes = getRoutes(
|
|
|
794
810
|
stop_id: '70011',
|
|
795
811
|
},
|
|
796
812
|
[],
|
|
797
|
-
[['stop_name', 'ASC']]
|
|
813
|
+
[['stop_name', 'ASC']],
|
|
798
814
|
);
|
|
799
815
|
```
|
|
800
816
|
|
|
@@ -846,7 +862,7 @@ const stops = getStops({
|
|
|
846
862
|
const stops = getStops(
|
|
847
863
|
{
|
|
848
864
|
stop_lat: 37.58764,
|
|
849
|
-
stop_lon: -122.36265
|
|
865
|
+
stop_lon: -122.36265,
|
|
850
866
|
},
|
|
851
867
|
[],
|
|
852
868
|
[],
|
|
@@ -875,11 +891,11 @@ const stopsGeojson = getStopsAsGeoJSON({
|
|
|
875
891
|
const stopsGeojson = getStopsAsGeoJSON(
|
|
876
892
|
{
|
|
877
893
|
stop_lat: 37.58764,
|
|
878
|
-
stop_lon: -122.36265
|
|
894
|
+
stop_lon: -122.36265,
|
|
879
895
|
},
|
|
880
896
|
{
|
|
881
|
-
bounding_box_side_m: 1000
|
|
882
|
-
}
|
|
897
|
+
bounding_box_side_m: 1000,
|
|
898
|
+
},
|
|
883
899
|
);
|
|
884
900
|
```
|
|
885
901
|
|
|
@@ -904,7 +920,7 @@ const stoptimes = getStoptimes(
|
|
|
904
920
|
trip_id: '37a',
|
|
905
921
|
},
|
|
906
922
|
[],
|
|
907
|
-
[['stop_sequence', 'ASC']]
|
|
923
|
+
[['stop_sequence', 'ASC']],
|
|
908
924
|
);
|
|
909
925
|
|
|
910
926
|
// Get all stoptimes for a specific stop and service_id
|
|
@@ -1176,6 +1192,38 @@ import { getLevels } from 'gtfs';
|
|
|
1176
1192
|
const levels = getLevels();
|
|
1177
1193
|
```
|
|
1178
1194
|
|
|
1195
|
+
#### getLocationGroups(query, fields, sortBy, options)
|
|
1196
|
+
|
|
1197
|
+
Returns an array of location groups that match query parameters. [Details on location_groups.txt](https://gtfs.org/schedule/reference/#location_groupstxt)
|
|
1198
|
+
|
|
1199
|
+
```js
|
|
1200
|
+
import { getLocationGroups } from 'gtfs';
|
|
1201
|
+
|
|
1202
|
+
// Get all location groups
|
|
1203
|
+
const locationGroups = getLocationGroups();
|
|
1204
|
+
|
|
1205
|
+
// Get a specific location group
|
|
1206
|
+
const locationGroups = getLocationGroups({
|
|
1207
|
+
location_group_id: '1234',
|
|
1208
|
+
});
|
|
1209
|
+
```
|
|
1210
|
+
|
|
1211
|
+
#### getLocationGroupStops(query, fields, sortBy, options)
|
|
1212
|
+
|
|
1213
|
+
Returns an array of location group stops that match query parameters. [Details on location_group_stops.txt](https://gtfs.org/schedule/reference/#location_group_stopstxt)
|
|
1214
|
+
|
|
1215
|
+
```js
|
|
1216
|
+
import { getLocationGroupStops } from 'gtfs';
|
|
1217
|
+
|
|
1218
|
+
// Get all location group stops
|
|
1219
|
+
const locationGroupStops = getLocationGroupStops();
|
|
1220
|
+
|
|
1221
|
+
// Get location group stops for a specific stop_id
|
|
1222
|
+
const locationGroups = getLocationGroupStops({
|
|
1223
|
+
stop_id: '1234',
|
|
1224
|
+
});
|
|
1225
|
+
```
|
|
1226
|
+
|
|
1179
1227
|
#### getPathways(query, fields, sortBy, options)
|
|
1180
1228
|
|
|
1181
1229
|
Returns an array of pathways that match query parameters. [Details on pathways.txt](https://gtfs.org/schedule/reference/#pathwaystxt)
|
package/lib/advancedQuery.js
CHANGED
|
@@ -30,7 +30,7 @@ export function advancedQuery(table, advancedQueryOptions) {
|
|
|
30
30
|
const orderByClause = formatOrderByClause(queryOptions.orderBy);
|
|
31
31
|
return db
|
|
32
32
|
.prepare(
|
|
33
|
-
`${selectClause} FROM ${tableName} ${joinClause} ${whereClause} ${orderByClause}
|
|
33
|
+
`${selectClause} FROM ${tableName} ${joinClause} ${whereClause} ${orderByClause};`,
|
|
34
34
|
)
|
|
35
35
|
.all();
|
|
36
36
|
}
|
package/lib/geojson-utils.js
CHANGED
|
@@ -42,7 +42,7 @@ function consolidateShapes(shapes) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
return memo;
|
|
45
|
-
}, [])
|
|
45
|
+
}, []),
|
|
46
46
|
);
|
|
47
47
|
|
|
48
48
|
const consolidatedLineStrings = [];
|
|
@@ -90,7 +90,7 @@ function formatProperties(properties) {
|
|
|
90
90
|
|
|
91
91
|
if (properties.routes) {
|
|
92
92
|
formattedProperties.routes = properties.routes.map((route) =>
|
|
93
|
-
formatProperties(route)
|
|
93
|
+
formatProperties(route),
|
|
94
94
|
);
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -99,7 +99,7 @@ function formatProperties(properties) {
|
|
|
99
99
|
|
|
100
100
|
export function shapesToGeoJSONFeatures(shapes, properties = {}) {
|
|
101
101
|
const shapeGroups = Object.values(groupBy(shapes, 'shape_id')).map(
|
|
102
|
-
(shapeGroup) => sortBy(shapeGroup, 'shape_pt_sequence')
|
|
102
|
+
(shapeGroup) => sortBy(shapeGroup, 'shape_pt_sequence'),
|
|
103
103
|
);
|
|
104
104
|
const lineStrings = consolidateShapes(shapeGroups);
|
|
105
105
|
|
|
@@ -109,8 +109,8 @@ export function shapesToGeoJSONFeatures(shapes, properties = {}) {
|
|
|
109
109
|
type: 'LineString',
|
|
110
110
|
coordinates: lineString,
|
|
111
111
|
},
|
|
112
|
-
formatProperties(properties)
|
|
113
|
-
)
|
|
112
|
+
formatProperties(properties),
|
|
113
|
+
),
|
|
114
114
|
);
|
|
115
115
|
}
|
|
116
116
|
|
|
@@ -121,8 +121,8 @@ export function stopsToGeoJSON(stops) {
|
|
|
121
121
|
type: 'Point',
|
|
122
122
|
coordinates: [stop.stop_lon, stop.stop_lat],
|
|
123
123
|
},
|
|
124
|
-
formatProperties(omit(stop, ['stop_lat', 'stop_lon']))
|
|
125
|
-
)
|
|
124
|
+
formatProperties(omit(stop, ['stop_lat', 'stop_lon'])),
|
|
125
|
+
),
|
|
126
126
|
);
|
|
127
127
|
|
|
128
128
|
return featureCollection(features);
|
package/lib/gtfs/agencies.js
CHANGED
|
@@ -16,7 +16,7 @@ export function getAgencies(
|
|
|
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(agency.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getAgencies(
|
|
|
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/areas.js
CHANGED
|
@@ -21,7 +21,7 @@ export function getAreas(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
|
}
|
package/lib/gtfs/attributions.js
CHANGED
|
@@ -16,7 +16,7 @@ export function getAttributions(
|
|
|
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(attributions.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getAttributions(
|
|
|
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
|
}
|
|
@@ -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 bookingRules from '../../models/gtfs/booking-rules.js';
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* Returns an array of all booking rules that match the query parameters.
|
|
14
|
+
*/
|
|
15
|
+
export function getBookingRules(
|
|
16
|
+
query = {},
|
|
17
|
+
fields = [],
|
|
18
|
+
orderBy = [],
|
|
19
|
+
options = {},
|
|
20
|
+
) {
|
|
21
|
+
const db = options.db ?? openDb();
|
|
22
|
+
const tableName = sqlString.escapeId(bookingRules.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
|
+
}
|
|
@@ -16,7 +16,7 @@ export function getCalendarDates(
|
|
|
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(calendarDates.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getCalendarDates(
|
|
|
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/calendars.js
CHANGED
|
@@ -16,7 +16,7 @@ export function getCalendars(
|
|
|
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(calendars.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getCalendars(
|
|
|
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 getFareAttributes(
|
|
|
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(fareAttributes.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getFareAttributes(
|
|
|
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 getFareLegRules(
|
|
|
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(fareLegRules.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getFareLegRules(
|
|
|
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 getFareProducts(
|
|
|
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(fareProducts.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getFareProducts(
|
|
|
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/fare-rules.js
CHANGED
|
@@ -16,7 +16,7 @@ export function getFareRules(
|
|
|
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(fareRules.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getFareRules(
|
|
|
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 getFareTransferRules(
|
|
|
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(fareTransferRules.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getFareTransferRules(
|
|
|
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/feed-info.js
CHANGED
|
@@ -16,7 +16,7 @@ export function getFeedInfo(
|
|
|
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(feedInfo.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getFeedInfo(
|
|
|
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/frequencies.js
CHANGED
|
@@ -16,7 +16,7 @@ export function getFrequencies(
|
|
|
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(frequencies.filenameBase);
|
|
@@ -26,7 +26,7 @@ export function getFrequencies(
|
|
|
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/levels.js
CHANGED
|
@@ -21,7 +21,7 @@ export function getLevels(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
|
}
|
|
@@ -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 locationGroupStops from '../../models/gtfs/location-group-stops.js';
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* Returns an array of all location group stops that match the query parameters.
|
|
14
|
+
*/
|
|
15
|
+
export function getLocationGroupStops(
|
|
16
|
+
query = {},
|
|
17
|
+
fields = [],
|
|
18
|
+
orderBy = [],
|
|
19
|
+
options = {},
|
|
20
|
+
) {
|
|
21
|
+
const db = options.db ?? openDb();
|
|
22
|
+
const tableName = sqlString.escapeId(locationGroupStops.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
|
+
}
|
|
@@ -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
|
}
|