gtfs 3.1.0 → 3.1.4
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/.eslintrc.json +14 -19
- package/.husky/pre-commit +4 -0
- package/.prettierrc.js +4 -0
- package/CHANGELOG.md +173 -0
- package/README.md +115 -126
- package/bin/gtfs-export.js +4 -5
- package/bin/gtfs-import.js +6 -7
- package/config-sample-full.json +2 -7
- package/lib/db.js +4 -2
- package/lib/export.js +26 -9
- package/lib/file-utils.js +26 -9
- package/lib/geojson-utils.js +51 -38
- package/lib/gtfs/agencies.js +8 -2
- package/lib/gtfs/attributions.js +8 -2
- package/lib/gtfs/calendar-dates.js +8 -2
- package/lib/gtfs/calendars.js +8 -2
- package/lib/gtfs/fare-attributes.js +8 -2
- package/lib/gtfs/fare-rules.js +8 -2
- package/lib/gtfs/feed-info.js +8 -2
- package/lib/gtfs/frequencies.js +8 -2
- package/lib/gtfs/levels.js +8 -2
- package/lib/gtfs/pathways.js +8 -2
- package/lib/gtfs/routes.js +15 -4
- package/lib/gtfs/shapes.js +49 -18
- package/lib/gtfs/stop-times.js +8 -2
- package/lib/gtfs/stops.js +45 -16
- package/lib/gtfs/transfers.js +8 -2
- package/lib/gtfs/translations.js +8 -2
- package/lib/gtfs/trips.js +8 -2
- package/lib/gtfs-ride/board-alights.js +8 -2
- package/lib/gtfs-ride/ride-feed-infos.js +8 -2
- package/lib/gtfs-ride/rider-trips.js +8 -2
- package/lib/gtfs-ride/riderships.js +8 -2
- package/lib/gtfs-ride/trip-capacities.js +8 -2
- package/lib/import.js +200 -125
- package/lib/log-utils.js +8 -4
- package/lib/non-standard/directions.js +8 -2
- package/lib/non-standard/stop-attributes.js +8 -2
- package/lib/non-standard/timetable-notes-references.js +13 -3
- package/lib/non-standard/timetable-notes.js +8 -2
- package/lib/non-standard/timetable-pages.js +8 -2
- package/lib/non-standard/timetable-stop-order.js +13 -3
- package/lib/non-standard/timetables.js +8 -2
- package/lib/utils.js +22 -11
- package/models/gtfs/agency.js +11 -11
- package/models/gtfs/attributions.js +14 -14
- package/models/gtfs/calendar-dates.js +7 -7
- package/models/gtfs/calendar.js +12 -12
- package/models/gtfs/fare-attributes.js +9 -9
- package/models/gtfs/fare-rules.js +8 -8
- package/models/gtfs/feed-info.js +12 -12
- package/models/gtfs/frequencies.js +10 -10
- package/models/gtfs/levels.js +5 -5
- package/models/gtfs/pathways.js +14 -14
- package/models/gtfs/routes.js +14 -14
- package/models/gtfs/shapes.js +8 -8
- package/models/gtfs/stop-times.js +17 -17
- package/models/gtfs/stops.js +17 -17
- package/models/gtfs/transfers.js +7 -7
- package/models/gtfs/translations.js +10 -10
- package/models/gtfs/trips.js +12 -12
- package/models/gtfs-ride/board-alight.js +24 -24
- package/models/gtfs-ride/ride-feed-info.js +8 -8
- package/models/gtfs-ride/rider-trip.js +21 -21
- package/models/gtfs-ride/ridership.js +23 -23
- package/models/gtfs-ride/trip-capacity.js +10 -10
- package/models/models.js +1 -1
- package/models/non-standard/directions.js +6 -6
- package/models/non-standard/stop-attributes.js +5 -5
- package/models/non-standard/timetable-notes-references.js +9 -9
- package/models/non-standard/timetable-notes.js +5 -5
- package/models/non-standard/timetable-pages.js +5 -5
- package/models/non-standard/timetable-stop-order.js +6 -6
- package/models/non-standard/timetables.js +27 -27
- package/package.json +29 -11
- package/test/mocha/export-gtfs.js +63 -40
- package/test/mocha/get-agencies.js +11 -11
- package/test/mocha/get-attributions.js +1 -1
- package/test/mocha/get-board-alights.js +1 -1
- package/test/mocha/get-calendar-dates.js +22 -21
- package/test/mocha/get-calendars.js +8 -8
- package/test/mocha/get-db.js +9 -2
- package/test/mocha/get-directions.js +1 -1
- package/test/mocha/get-fare-attributes.js +3 -3
- package/test/mocha/get-fare-rules.js +8 -10
- package/test/mocha/get-feed-info.js +1 -1
- package/test/mocha/get-frequencies.js +1 -1
- package/test/mocha/get-levels.js +1 -1
- package/test/mocha/get-pathways.js +1 -1
- package/test/mocha/get-rider-trips.js +1 -1
- package/test/mocha/get-riderships.js +1 -1
- package/test/mocha/get-routes.js +9 -13
- package/test/mocha/get-shapes-as-geojson.js +3 -3
- package/test/mocha/get-shapes.js +28 -36
- package/test/mocha/get-stop-attributes.js +1 -1
- package/test/mocha/get-stops-as-geojson.js +2 -2
- package/test/mocha/get-stops.js +59 -48
- package/test/mocha/get-stoptimes.js +9 -7
- package/test/mocha/get-timetable-pages.js +1 -1
- package/test/mocha/get-timetable-stop-orders.js +1 -1
- package/test/mocha/get-timetables.js +1 -1
- package/test/mocha/get-transfers.js +1 -1
- package/test/mocha/get-translations.js +1 -1
- package/test/mocha/get-trip-capacities.js +1 -1
- package/test/mocha/get-trips.js +3 -3
- package/test/mocha/import-gtfs.js +59 -42
- package/test/test-config.js +9 -4
package/README.md
CHANGED
|
@@ -22,6 +22,8 @@ The [GTFS-to-geojson](https://github.com/blinktaginc/gtfs-to-geojson) app create
|
|
|
22
22
|
|
|
23
23
|
The [GTFS-to-chart](https://github.com/blinktaginc/gtfs-to-chart) app generates a stringline chart in D3 for all trips for a specific route using data from an agency's GTFS. It uses `node-gtfs` for downloading, importing and querying GTFS data.
|
|
24
24
|
|
|
25
|
+
The [GTFS-Text-to-Speech](https://github.com/blinktaginc/node-gtfs-tts) app tests GTFS stop name pronunciation for text-to-speech. It uses `node-gtfs` for loading stop names from GTFS data.
|
|
26
|
+
|
|
25
27
|
## Installation
|
|
26
28
|
|
|
27
29
|
If you would like to use this library as a command-line utility, you can install it globally directly from [npm](https://npmjs.org):
|
|
@@ -34,12 +36,12 @@ If you are using this as a node module as part of an application, you can includ
|
|
|
34
36
|
|
|
35
37
|
gtfs-import --gtfsUrl http://www.bart.gov/dev/schedules/google_transit.zip
|
|
36
38
|
|
|
37
|
-
or
|
|
38
|
-
|
|
39
|
+
or
|
|
40
|
+
|
|
39
41
|
gtfs-import --gtfsPath /path/to/your/gtfs.zip
|
|
40
42
|
|
|
41
|
-
or
|
|
42
|
-
|
|
43
|
+
or
|
|
44
|
+
|
|
43
45
|
gtfs-import --gtfsPath /path/to/your/unzipped/gtfs
|
|
44
46
|
|
|
45
47
|
or
|
|
@@ -53,15 +55,17 @@ or
|
|
|
53
55
|
```js
|
|
54
56
|
import { importGtfs } from 'gtfs';
|
|
55
57
|
import { readFile } from 'fs/promises';
|
|
56
|
-
const config = JSON.parse(
|
|
58
|
+
const config = JSON.parse(
|
|
59
|
+
await readFile(new URL('./config.json', import.meta.url))
|
|
60
|
+
);
|
|
57
61
|
|
|
58
62
|
importGtfs(config)
|
|
59
|
-
.then(() => {
|
|
60
|
-
|
|
61
|
-
})
|
|
62
|
-
.catch(err => {
|
|
63
|
-
|
|
64
|
-
});
|
|
63
|
+
.then(() => {
|
|
64
|
+
console.log('Import Successful');
|
|
65
|
+
})
|
|
66
|
+
.catch((err) => {
|
|
67
|
+
console.error(err);
|
|
68
|
+
});
|
|
65
69
|
```
|
|
66
70
|
|
|
67
71
|
## Command Line Usage
|
|
@@ -84,14 +88,14 @@ Specify a local path to GTFS, either zipped or unzipped.
|
|
|
84
88
|
|
|
85
89
|
gtfs-import --gtfsPath /path/to/your/gtfs.zip
|
|
86
90
|
|
|
87
|
-
or
|
|
88
|
-
|
|
91
|
+
or
|
|
92
|
+
|
|
89
93
|
gtfs-import --gtfsPath /path/to/your/unzipped/gtfs
|
|
90
94
|
|
|
91
95
|
`gtfsUrl`
|
|
92
96
|
|
|
93
97
|
Specify a URL to a zipped GTFS file.
|
|
94
|
-
|
|
98
|
+
|
|
95
99
|
gtfs-import --gtfsUrl http://www.bart.gov/dev/schedules/google_transit.zip
|
|
96
100
|
|
|
97
101
|
## Configuration Files
|
|
@@ -100,13 +104,13 @@ Copy `config-sample.json` to `config.json` and then add your projects configurat
|
|
|
100
104
|
|
|
101
105
|
cp config-sample.json config.json
|
|
102
106
|
|
|
103
|
-
| option
|
|
104
|
-
|
|
|
105
|
-
| [`agencies`](#agencies)
|
|
106
|
-
| [`csvOptions`](#csvOptions) | object
|
|
107
|
-
| [`exportPath`](#exportPath) | string
|
|
108
|
-
| [`sqlitePath`](#sqlitePath) | string
|
|
109
|
-
| [`verbose`](#verbose)
|
|
107
|
+
| option | type | description |
|
|
108
|
+
| --------------------------- | ------- | ---------------------------------------------------------------------------------------------------- |
|
|
109
|
+
| [`agencies`](#agencies) | array | An array of GTFS files to be imported. |
|
|
110
|
+
| [`csvOptions`](#csvOptions) | object | Options passed to `csv-parse` for parsing GTFS CSV files. Optional. |
|
|
111
|
+
| [`exportPath`](#exportPath) | string | A path to a directory to put exported GTFS files. Optional, defaults to `gtfs-export/<agency_name>`. |
|
|
112
|
+
| [`sqlitePath`](#sqlitePath) | string | A path to an SQLite database. Optional, defaults to using an in-memory database. |
|
|
113
|
+
| [`verbose`](#verbose) | boolean | Whether or not to print output to the console. Optional, defaults to true. |
|
|
110
114
|
|
|
111
115
|
### agencies
|
|
112
116
|
|
|
@@ -118,7 +122,8 @@ To find an agency's GTFS file, visit [transitfeeds.com](http://transitfeeds.com)
|
|
|
118
122
|
URL from the agency's website or you can use a URL generated from the transitfeeds.com
|
|
119
123
|
API along with your API token.
|
|
120
124
|
|
|
121
|
-
|
|
125
|
+
- Specify a download URL:
|
|
126
|
+
|
|
122
127
|
```json
|
|
123
128
|
{
|
|
124
129
|
"agencies": [
|
|
@@ -129,7 +134,8 @@ API along with your API token.
|
|
|
129
134
|
}
|
|
130
135
|
```
|
|
131
136
|
|
|
132
|
-
|
|
137
|
+
- Specify a download URL with custom headers:
|
|
138
|
+
|
|
133
139
|
```json
|
|
134
140
|
{
|
|
135
141
|
"agencies": [
|
|
@@ -138,13 +144,14 @@ API along with your API token.
|
|
|
138
144
|
"headers": {
|
|
139
145
|
"Content-Type": "application/json",
|
|
140
146
|
"Authorization": "bearer 1234567890"
|
|
141
|
-
}
|
|
147
|
+
}
|
|
142
148
|
}
|
|
143
149
|
]
|
|
144
150
|
}
|
|
145
151
|
```
|
|
146
152
|
|
|
147
|
-
|
|
153
|
+
- Specify a path to a zipped GTFS file:
|
|
154
|
+
|
|
148
155
|
```json
|
|
149
156
|
{
|
|
150
157
|
"agencies": [
|
|
@@ -154,7 +161,9 @@ API along with your API token.
|
|
|
154
161
|
]
|
|
155
162
|
}
|
|
156
163
|
```
|
|
157
|
-
|
|
164
|
+
|
|
165
|
+
- Specify a path to an unzipped GTFS file:
|
|
166
|
+
|
|
158
167
|
```json
|
|
159
168
|
{
|
|
160
169
|
"agencies": [
|
|
@@ -165,23 +174,20 @@ API along with your API token.
|
|
|
165
174
|
}
|
|
166
175
|
```
|
|
167
176
|
|
|
168
|
-
|
|
177
|
+
- Exclude files - if you don't want all GTFS files to be imported, you can specify an array of files to exclude.
|
|
169
178
|
|
|
170
179
|
```json
|
|
171
180
|
{
|
|
172
181
|
"agencies": [
|
|
173
182
|
{
|
|
174
183
|
"path": "/path/to/the/unzipped/gtfs/",
|
|
175
|
-
"exclude": [
|
|
176
|
-
"shapes",
|
|
177
|
-
"stops"
|
|
178
|
-
]
|
|
184
|
+
"exclude": ["shapes", "stops"]
|
|
179
185
|
}
|
|
180
186
|
]
|
|
181
187
|
}
|
|
182
188
|
```
|
|
183
189
|
|
|
184
|
-
|
|
190
|
+
- Specify multiple agencies to be imported into the same database
|
|
185
191
|
|
|
186
192
|
```json
|
|
187
193
|
{
|
|
@@ -237,7 +243,7 @@ See [full list of options](https://csv.js.org/parse/options/).
|
|
|
237
243
|
}
|
|
238
244
|
```
|
|
239
245
|
|
|
240
|
-
If you want to route logs to a custom function, you can pass a function that takes a single `text` argument as `logFunction`. This can't be defined in `config.json` but instead passed in a config object to `importGtfs()`.
|
|
246
|
+
If you want to route logs to a custom function, you can pass a function that takes a single `text` argument as `logFunction`. This can't be defined in `config.json` but instead passed in a config object to `importGtfs()`. For example:
|
|
241
247
|
|
|
242
248
|
```js
|
|
243
249
|
import { importGtfs } from 'gtfs';
|
|
@@ -246,15 +252,13 @@ const config = {
|
|
|
246
252
|
agencies: [
|
|
247
253
|
{
|
|
248
254
|
url: 'http://countyconnection.com/GTFS/google_transit.zip',
|
|
249
|
-
exclude: [
|
|
250
|
-
|
|
251
|
-
]
|
|
252
|
-
}
|
|
255
|
+
exclude: ['shapes'],
|
|
256
|
+
},
|
|
253
257
|
],
|
|
254
|
-
logFunction: function(text) {
|
|
258
|
+
logFunction: function (text) {
|
|
255
259
|
// Do something with the logs here, like save it or send it somewhere
|
|
256
260
|
console.log(text);
|
|
257
|
-
}
|
|
261
|
+
},
|
|
258
262
|
};
|
|
259
263
|
|
|
260
264
|
importGtfs(config);
|
|
@@ -280,15 +284,17 @@ Use `importGtfs()` in your code to run an import of a GTFS file specified in a c
|
|
|
280
284
|
import { importGtfs } from 'gtfs';
|
|
281
285
|
import { readFile } from 'fs/promises';
|
|
282
286
|
|
|
283
|
-
const config = JSON.parse(
|
|
287
|
+
const config = JSON.parse(
|
|
288
|
+
await readFile(new URL('./config.json', import.meta.url))
|
|
289
|
+
);
|
|
284
290
|
|
|
285
291
|
importGtfs(config)
|
|
286
|
-
.then(() => {
|
|
287
|
-
|
|
288
|
-
})
|
|
289
|
-
.catch(err => {
|
|
290
|
-
|
|
291
|
-
});
|
|
292
|
+
.then(() => {
|
|
293
|
+
console.log('Import Successful');
|
|
294
|
+
})
|
|
295
|
+
.catch((err) => {
|
|
296
|
+
console.error(err);
|
|
297
|
+
});
|
|
292
298
|
```
|
|
293
299
|
|
|
294
300
|
Configuration can be a JSON object in your code
|
|
@@ -301,20 +307,18 @@ const config = {
|
|
|
301
307
|
agencies: [
|
|
302
308
|
{
|
|
303
309
|
url: 'http://countyconnection.com/GTFS/google_transit.zip',
|
|
304
|
-
exclude: [
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
]
|
|
310
|
+
exclude: ['shapes'],
|
|
311
|
+
},
|
|
312
|
+
],
|
|
309
313
|
};
|
|
310
314
|
|
|
311
315
|
importGtfs(config)
|
|
312
|
-
.then(() => {
|
|
313
|
-
|
|
314
|
-
})
|
|
315
|
-
.catch(err => {
|
|
316
|
-
|
|
317
|
-
});
|
|
316
|
+
.then(() => {
|
|
317
|
+
console.log('Import Successful');
|
|
318
|
+
})
|
|
319
|
+
.catch((err) => {
|
|
320
|
+
console.error(err);
|
|
321
|
+
});
|
|
318
322
|
```
|
|
319
323
|
|
|
320
324
|
## `gtfs-export` Script
|
|
@@ -338,11 +342,13 @@ By default, it will look for a `config.json` file in the project root. To specif
|
|
|
338
342
|
### Command Line options
|
|
339
343
|
|
|
340
344
|
#### Specify path to config JSON file
|
|
345
|
+
|
|
341
346
|
You can specify the path to a config file to be used by the export script.
|
|
342
347
|
|
|
343
348
|
gtfs-export --configPath /path/to/your/custom-config.json
|
|
344
349
|
|
|
345
350
|
#### Show help
|
|
351
|
+
|
|
346
352
|
Show all command line options
|
|
347
353
|
|
|
348
354
|
gtfs-export --help
|
|
@@ -359,20 +365,18 @@ const config = {
|
|
|
359
365
|
agencies: [
|
|
360
366
|
{
|
|
361
367
|
url: 'http://countyconnection.com/GTFS/google_transit.zip',
|
|
362
|
-
exclude: [
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
}
|
|
366
|
-
]
|
|
368
|
+
exclude: ['shapes'],
|
|
369
|
+
},
|
|
370
|
+
],
|
|
367
371
|
};
|
|
368
372
|
|
|
369
373
|
exportGtfs(config)
|
|
370
|
-
.then(() => {
|
|
371
|
-
|
|
372
|
-
})
|
|
373
|
-
.catch(err => {
|
|
374
|
-
|
|
375
|
-
});
|
|
374
|
+
.then(() => {
|
|
375
|
+
console.log('Export Successful');
|
|
376
|
+
})
|
|
377
|
+
.catch((err) => {
|
|
378
|
+
console.error(err);
|
|
379
|
+
});
|
|
376
380
|
```
|
|
377
381
|
|
|
378
382
|
## Query Methods
|
|
@@ -388,19 +392,15 @@ For example, to get a list of all routes with just `route_id`, `route_short_name
|
|
|
388
392
|
```js
|
|
389
393
|
import { openDb, getRoutes } from 'gtfs';
|
|
390
394
|
import { readFile } from 'fs/promises';
|
|
391
|
-
const config = JSON.parse(
|
|
395
|
+
const config = JSON.parse(
|
|
396
|
+
await readFile(new URL('./config.json', import.meta.url))
|
|
397
|
+
);
|
|
392
398
|
|
|
393
399
|
const db = await openDb(config);
|
|
394
400
|
const routes = await getRoutes(
|
|
395
401
|
{},
|
|
396
|
-
[
|
|
397
|
-
|
|
398
|
-
'route_short_name',
|
|
399
|
-
'route_color'
|
|
400
|
-
],
|
|
401
|
-
[
|
|
402
|
-
['route_short_name', 'ASC']
|
|
403
|
-
]
|
|
402
|
+
['route_id', 'route_short_name', 'route_color'],
|
|
403
|
+
[['route_short_name', 'ASC']]
|
|
404
404
|
);
|
|
405
405
|
```
|
|
406
406
|
|
|
@@ -409,16 +409,16 @@ To get a list of all trip_ids for a specific route:
|
|
|
409
409
|
```js
|
|
410
410
|
import { openDb, getTrips } from 'gtfs';
|
|
411
411
|
import { readFile } from 'fs/promises';
|
|
412
|
-
const config = JSON.parse(
|
|
412
|
+
const config = JSON.parse(
|
|
413
|
+
await readFile(new URL('./config.json', import.meta.url))
|
|
414
|
+
);
|
|
413
415
|
|
|
414
416
|
const db = await openDb(config);
|
|
415
417
|
const trips = await getTrips(
|
|
416
418
|
{
|
|
417
|
-
route_id: '123'
|
|
419
|
+
route_id: '123',
|
|
418
420
|
},
|
|
419
|
-
[
|
|
420
|
-
'trip_id'
|
|
421
|
-
]
|
|
421
|
+
['trip_id']
|
|
422
422
|
);
|
|
423
423
|
```
|
|
424
424
|
|
|
@@ -467,7 +467,7 @@ getAgencies();
|
|
|
467
467
|
|
|
468
468
|
// Get a specific agency
|
|
469
469
|
getAgencies({
|
|
470
|
-
agency_id: 'caltrain'
|
|
470
|
+
agency_id: 'caltrain',
|
|
471
471
|
});
|
|
472
472
|
```
|
|
473
473
|
|
|
@@ -483,7 +483,7 @@ getAttributions();
|
|
|
483
483
|
|
|
484
484
|
// Get a specific attribution
|
|
485
485
|
getAttributions({
|
|
486
|
-
attribution_id: '123'
|
|
486
|
+
attribution_id: '123',
|
|
487
487
|
});
|
|
488
488
|
```
|
|
489
489
|
|
|
@@ -495,17 +495,11 @@ Queries routes and returns a promise. The result of the promise is an array of r
|
|
|
495
495
|
import { getRoutes } from 'gtfs';
|
|
496
496
|
|
|
497
497
|
// Get all routes, sorted by route_short_name
|
|
498
|
-
getRoutes(
|
|
499
|
-
{},
|
|
500
|
-
[],
|
|
501
|
-
[
|
|
502
|
-
['route_short_name', 'ASC']
|
|
503
|
-
]
|
|
504
|
-
);
|
|
498
|
+
getRoutes({}, [], [['route_short_name', 'ASC']]);
|
|
505
499
|
|
|
506
500
|
// Get a specific route
|
|
507
501
|
getRoutes({
|
|
508
|
-
route_id: 'Lo-16APR'
|
|
502
|
+
route_id: 'Lo-16APR',
|
|
509
503
|
});
|
|
510
504
|
```
|
|
511
505
|
|
|
@@ -517,12 +511,10 @@ import { getRoutes } from 'gtfs';
|
|
|
517
511
|
// Get routes that serve a specific stop, sorted by `stop_name`.
|
|
518
512
|
getRoutes(
|
|
519
513
|
{
|
|
520
|
-
stop_id: '70011'
|
|
514
|
+
stop_id: '70011',
|
|
521
515
|
},
|
|
522
516
|
[],
|
|
523
|
-
[
|
|
524
|
-
['stop_name', 'ASC']
|
|
525
|
-
]
|
|
517
|
+
[['stop_name', 'ASC']]
|
|
526
518
|
);
|
|
527
519
|
```
|
|
528
520
|
|
|
@@ -538,7 +530,7 @@ getStops();
|
|
|
538
530
|
|
|
539
531
|
// Get a specific stop by stop_id
|
|
540
532
|
getStops({
|
|
541
|
-
stop_id: '70011'
|
|
533
|
+
stop_id: '70011',
|
|
542
534
|
});
|
|
543
535
|
```
|
|
544
536
|
|
|
@@ -549,7 +541,7 @@ import { getRoutes } from 'gtfs';
|
|
|
549
541
|
|
|
550
542
|
// Get all stops for a specific route
|
|
551
543
|
getStops({
|
|
552
|
-
route_id: 'Lo-16APR'
|
|
544
|
+
route_id: 'Lo-16APR',
|
|
553
545
|
});
|
|
554
546
|
```
|
|
555
547
|
|
|
@@ -560,7 +552,7 @@ import { getRoutes } from 'gtfs';
|
|
|
560
552
|
|
|
561
553
|
// Get all stops for a specific trip
|
|
562
554
|
getStops({
|
|
563
|
-
trip_id: '37a'
|
|
555
|
+
trip_id: '37a',
|
|
564
556
|
});
|
|
565
557
|
```
|
|
566
558
|
|
|
@@ -576,7 +568,7 @@ getStopsAsGeoJSON();
|
|
|
576
568
|
|
|
577
569
|
// Get all stops for a specific route as geoJSON
|
|
578
570
|
getStopsAsGeoJSON({
|
|
579
|
-
route_id: 'Lo-16APR'
|
|
571
|
+
route_id: 'Lo-16APR',
|
|
580
572
|
});
|
|
581
573
|
```
|
|
582
574
|
|
|
@@ -592,24 +584,22 @@ getStoptimes();
|
|
|
592
584
|
|
|
593
585
|
// Get all stoptimes for a specific stop
|
|
594
586
|
getStoptimes({
|
|
595
|
-
stop_id: '70011'
|
|
587
|
+
stop_id: '70011',
|
|
596
588
|
});
|
|
597
589
|
|
|
598
590
|
// Get all stoptimes for a specific trip, sorted by stop_sequence
|
|
599
591
|
getStoptimes(
|
|
600
592
|
{
|
|
601
|
-
trip_id: '37a'
|
|
593
|
+
trip_id: '37a',
|
|
602
594
|
},
|
|
603
595
|
[],
|
|
604
|
-
[
|
|
605
|
-
['stop_sequence', 'ASC']
|
|
606
|
-
]
|
|
596
|
+
[['stop_sequence', 'ASC']]
|
|
607
597
|
);
|
|
608
598
|
|
|
609
599
|
// Get all stoptimes for a specific stop and service_id
|
|
610
600
|
getStoptimes({
|
|
611
601
|
stop_id: '70011',
|
|
612
|
-
service_id: 'CT-16APR-Caltrain-Weekday-01'
|
|
602
|
+
service_id: 'CT-16APR-Caltrain-Weekday-01',
|
|
613
603
|
});
|
|
614
604
|
```
|
|
615
605
|
|
|
@@ -655,7 +645,7 @@ getShapes();
|
|
|
655
645
|
```
|
|
656
646
|
|
|
657
647
|
`getShapes` allows passing a `route_id` in the query and it will query trips to find all shapes served by that `route_id`.
|
|
658
|
-
|
|
648
|
+
|
|
659
649
|
```js
|
|
660
650
|
import { getShapes } from 'gtfs';
|
|
661
651
|
|
|
@@ -672,7 +662,7 @@ import { getShapes } from 'gtfs';
|
|
|
672
662
|
|
|
673
663
|
// Get all shapes for a specific trip_id
|
|
674
664
|
getShapes({
|
|
675
|
-
trip_id: '37a'
|
|
665
|
+
trip_id: '37a',
|
|
676
666
|
});
|
|
677
667
|
```
|
|
678
668
|
|
|
@@ -701,17 +691,17 @@ getShapesAsGeoJSON();
|
|
|
701
691
|
|
|
702
692
|
// Get geoJSON of stops along a specific route
|
|
703
693
|
getShapesAsGeoJSON({
|
|
704
|
-
route_id: 'Lo-16APR'
|
|
694
|
+
route_id: 'Lo-16APR',
|
|
705
695
|
});
|
|
706
696
|
|
|
707
697
|
// Get geoJSON of stops for a specific trip
|
|
708
698
|
getShapesAsGeoJSON({
|
|
709
|
-
trip_id: '37a'
|
|
699
|
+
trip_id: '37a',
|
|
710
700
|
});
|
|
711
701
|
|
|
712
702
|
// Get geoJSON of stops for a specific `service_id`
|
|
713
703
|
getShapesAsGeoJSON({
|
|
714
|
-
service_id: 'CT-16APR-Caltrain-Sunday-02'
|
|
704
|
+
service_id: 'CT-16APR-Caltrain-Sunday-02',
|
|
715
705
|
});
|
|
716
706
|
```
|
|
717
707
|
|
|
@@ -727,7 +717,7 @@ getCalendars();
|
|
|
727
717
|
|
|
728
718
|
// Get calendars for a specific `service_id`
|
|
729
719
|
getCalendars({
|
|
730
|
-
service_id: 'CT-16APR-Caltrain-Sunday-02'
|
|
720
|
+
service_id: 'CT-16APR-Caltrain-Sunday-02',
|
|
731
721
|
});
|
|
732
722
|
```
|
|
733
723
|
|
|
@@ -743,7 +733,7 @@ getCalendarDates();
|
|
|
743
733
|
|
|
744
734
|
// Get calendar_dates for a specific `service_id`
|
|
745
735
|
getCalendarDates({
|
|
746
|
-
service_id: 'CT-16APR-Caltrain-Sunday-02'
|
|
736
|
+
service_id: 'CT-16APR-Caltrain-Sunday-02',
|
|
747
737
|
});
|
|
748
738
|
```
|
|
749
739
|
|
|
@@ -759,7 +749,7 @@ getFareAttributes();
|
|
|
759
749
|
|
|
760
750
|
// Get `fare_attributes` for a specific `fare_id`
|
|
761
751
|
getFareAttributes({
|
|
762
|
-
fare_id: '123'
|
|
752
|
+
fare_id: '123',
|
|
763
753
|
});
|
|
764
754
|
```
|
|
765
755
|
|
|
@@ -775,7 +765,7 @@ getFareRules();
|
|
|
775
765
|
|
|
776
766
|
// Get fare_rules for a specific route
|
|
777
767
|
getFareRules({
|
|
778
|
-
route_id: 'Lo-16APR'
|
|
768
|
+
route_id: 'Lo-16APR',
|
|
779
769
|
});
|
|
780
770
|
```
|
|
781
771
|
|
|
@@ -802,7 +792,7 @@ getFrequencies();
|
|
|
802
792
|
|
|
803
793
|
// Get frequencies for a specific trip
|
|
804
794
|
getFrequencies({
|
|
805
|
-
trip_id: '1234'
|
|
795
|
+
trip_id: '1234',
|
|
806
796
|
});
|
|
807
797
|
```
|
|
808
798
|
|
|
@@ -840,7 +830,7 @@ getTransfers();
|
|
|
840
830
|
|
|
841
831
|
// Get transfers for a specific stop
|
|
842
832
|
getTransfers({
|
|
843
|
-
from_stop_id: '1234'
|
|
833
|
+
from_stop_id: '1234',
|
|
844
834
|
});
|
|
845
835
|
```
|
|
846
836
|
|
|
@@ -867,13 +857,13 @@ getDirections();
|
|
|
867
857
|
|
|
868
858
|
// Get directions for a specific route
|
|
869
859
|
getDirections({
|
|
870
|
-
route_id: '1234'
|
|
860
|
+
route_id: '1234',
|
|
871
861
|
});
|
|
872
862
|
|
|
873
863
|
// Get directions for a specific route and direction
|
|
874
864
|
getDirections({
|
|
875
865
|
route_id: '1234',
|
|
876
|
-
direction_id: 1
|
|
866
|
+
direction_id: 1,
|
|
877
867
|
});
|
|
878
868
|
```
|
|
879
869
|
|
|
@@ -889,7 +879,7 @@ getStopAttributes();
|
|
|
889
879
|
|
|
890
880
|
// Get stop attributes for specific stop
|
|
891
881
|
getStopAttributes({
|
|
892
|
-
stop_id: '1234'
|
|
882
|
+
stop_id: '1234',
|
|
893
883
|
});
|
|
894
884
|
```
|
|
895
885
|
|
|
@@ -905,7 +895,7 @@ getTimetables();
|
|
|
905
895
|
|
|
906
896
|
// Get a specific timetable
|
|
907
897
|
getTimetables({
|
|
908
|
-
timetable_id: '1'
|
|
898
|
+
timetable_id: '1',
|
|
909
899
|
});
|
|
910
900
|
```
|
|
911
901
|
|
|
@@ -921,7 +911,7 @@ getTimetableStopOrders();
|
|
|
921
911
|
|
|
922
912
|
// Get timetable_stop_orders for a specific timetable
|
|
923
913
|
getTimetableStopOrders({
|
|
924
|
-
timetable_id: '1'
|
|
914
|
+
timetable_id: '1',
|
|
925
915
|
});
|
|
926
916
|
```
|
|
927
917
|
|
|
@@ -937,7 +927,7 @@ getTimetablePages();
|
|
|
937
927
|
|
|
938
928
|
// Get a specific timetable_page
|
|
939
929
|
getTimetablePages({
|
|
940
|
-
timetable_page_id: '2'
|
|
930
|
+
timetable_page_id: '2',
|
|
941
931
|
});
|
|
942
932
|
```
|
|
943
933
|
|
|
@@ -953,7 +943,7 @@ getTimetableNotes();
|
|
|
953
943
|
|
|
954
944
|
// Get a specific timetable_note
|
|
955
945
|
getTimetableNotes({
|
|
956
|
-
note_id: '1'
|
|
946
|
+
note_id: '1',
|
|
957
947
|
});
|
|
958
948
|
```
|
|
959
949
|
|
|
@@ -969,7 +959,7 @@ getTimetableNotesReferences();
|
|
|
969
959
|
|
|
970
960
|
// Get all timetable_notes_references for a specific timetable
|
|
971
961
|
getTimetableNotesReferences({
|
|
972
|
-
timetable_id: '4'
|
|
962
|
+
timetable_id: '4',
|
|
973
963
|
});
|
|
974
964
|
```
|
|
975
965
|
|
|
@@ -987,7 +977,6 @@ To run a specific test:
|
|
|
987
977
|
|
|
988
978
|
NODE_ENV=test mocha ./test/mocha/gtfs.get-stoptimes.js
|
|
989
979
|
|
|
990
|
-
|
|
991
980
|
### Linting
|
|
992
981
|
|
|
993
982
|
npm run lint
|
package/bin/gtfs-export.js
CHANGED
|
@@ -13,15 +13,15 @@ const { argv } = yargs(hideBin(process.argv))
|
|
|
13
13
|
.option('c', {
|
|
14
14
|
alias: 'configPath',
|
|
15
15
|
describe: 'Path to config file',
|
|
16
|
-
type: 'string'
|
|
16
|
+
type: 'string',
|
|
17
17
|
})
|
|
18
18
|
.option('sqlitePath', {
|
|
19
19
|
describe: 'Path to SQLite database',
|
|
20
|
-
type: 'string'
|
|
20
|
+
type: 'string',
|
|
21
21
|
})
|
|
22
22
|
.option('exportPath', {
|
|
23
23
|
describe: 'Path where GTFS export should go',
|
|
24
|
-
type: 'string'
|
|
24
|
+
type: 'string',
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
const handleError = (error = 'Unknown Error') => {
|
|
@@ -35,5 +35,4 @@ const setupExport = async () => {
|
|
|
35
35
|
process.exit();
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
setupExport()
|
|
39
|
-
.catch(handleError);
|
|
38
|
+
setupExport().catch(handleError);
|
package/bin/gtfs-import.js
CHANGED
|
@@ -13,22 +13,22 @@ const { argv } = yargs(hideBin(process.argv))
|
|
|
13
13
|
.option('c', {
|
|
14
14
|
alias: 'configPath',
|
|
15
15
|
describe: 'Path to config file',
|
|
16
|
-
type: 'string'
|
|
16
|
+
type: 'string',
|
|
17
17
|
})
|
|
18
18
|
.option('gtfsPath', {
|
|
19
19
|
describe: 'Path to gtfs (zipped or unzipped)',
|
|
20
|
-
type: 'string'
|
|
20
|
+
type: 'string',
|
|
21
21
|
})
|
|
22
22
|
.option('gtfsUrl', {
|
|
23
23
|
describe: 'URL of gtfs file',
|
|
24
|
-
type: 'string'
|
|
24
|
+
type: 'string',
|
|
25
25
|
})
|
|
26
26
|
.option('sqlitePath', {
|
|
27
27
|
describe: 'Path to SQLite database',
|
|
28
|
-
type: 'string'
|
|
28
|
+
type: 'string',
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
const handleError = error => {
|
|
31
|
+
const handleError = (error) => {
|
|
32
32
|
const text = error || 'Unknown Error';
|
|
33
33
|
process.stdout.write(`\n${formatError(text)}\n`);
|
|
34
34
|
console.error(error);
|
|
@@ -41,5 +41,4 @@ const setupImport = async () => {
|
|
|
41
41
|
process.exit();
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
setupImport()
|
|
45
|
-
.catch(handleError);
|
|
44
|
+
setupImport().catch(handleError);
|
package/config-sample-full.json
CHANGED
|
@@ -2,16 +2,11 @@
|
|
|
2
2
|
"agencies": [
|
|
3
3
|
{
|
|
4
4
|
"url": "http://www.bart.gov/dev/schedules/google_transit.zip",
|
|
5
|
-
"exclude": [
|
|
6
|
-
"shapes"
|
|
7
|
-
]
|
|
5
|
+
"exclude": ["shapes"]
|
|
8
6
|
},
|
|
9
7
|
{
|
|
10
8
|
"path": "/path/to/gtfs.zip",
|
|
11
|
-
"exclude": [
|
|
12
|
-
"stop_times",
|
|
13
|
-
"shapes"
|
|
14
|
-
]
|
|
9
|
+
"exclude": ["stop_times", "shapes"]
|
|
15
10
|
}
|
|
16
11
|
],
|
|
17
12
|
"csvOptions": {
|