gtfs 4.15.2 → 4.15.3
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/README.md +54 -22
- package/dist/bin/gtfs-export.js +4 -0
- package/dist/bin/gtfs-export.js.map +1 -1
- package/dist/bin/gtfs-import.js +4 -0
- package/dist/bin/gtfs-import.js.map +1 -1
- package/dist/bin/gtfsrealtime-update.js +4 -0
- package/dist/bin/gtfsrealtime-update.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +76 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -148,18 +148,18 @@ Copy `config-sample.json` to `config.json` and then add your projects configurat
|
|
|
148
148
|
|
|
149
149
|
cp config-sample.json config.json
|
|
150
150
|
|
|
151
|
-
| option
|
|
152
|
-
|
|
|
153
|
-
| [`agencies`](#agencies)
|
|
154
|
-
| [`csvOptions`](#csvOptions)
|
|
155
|
-
| [`db`](#db)
|
|
156
|
-
| [`downloadTimeout`](#downloadtimeout)
|
|
157
|
-
| [`exportPath`](#exportPath)
|
|
151
|
+
| option | type | description |
|
|
152
|
+
| ----------------------------------------------------------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
153
|
+
| [`agencies`](#agencies) | array | An array of GTFS files to be imported, and which files to exclude. |
|
|
154
|
+
| [`csvOptions`](#csvOptions) | object | Options passed to `csv-parse` for parsing GTFS CSV files. Optional. |
|
|
155
|
+
| [`db`](#db) | database instance | An existing database instance to use instead of relying on node-gtfs to connect. Optional. |
|
|
156
|
+
| [`downloadTimeout`](#downloadtimeout) | integer | The number of milliseconds to wait before throwing an error when downloading GTFS. Optional. |
|
|
157
|
+
| [`exportPath`](#exportPath) | string | A path to a directory to put exported GTFS files. Optional, defaults to `gtfs-export/<agency_name>`. |
|
|
158
158
|
| [`gtfsRealtimeExpirationSeconds`](#gtfsrealtimeexpirationseconds) | integer | Amount of time in seconds to allow GTFS-Realtime data to be stored in database before allowing to be deleted. Optional, defaults to 0. |
|
|
159
|
-
| [`ignoreDuplicates`](#ignoreduplicates)
|
|
160
|
-
| [`ignoreErrors`](#ignoreerrors)
|
|
161
|
-
| [`sqlitePath`](#sqlitePath)
|
|
162
|
-
| [`verbose`](#verbose)
|
|
159
|
+
| [`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. |
|
|
160
|
+
| [`ignoreErrors`](#ignoreerrors) | boolean | Whether or not to ignore errors during the import process. If true, when importing multiple agencies, failed agencies will be skipped. Optional, defaults to false. |
|
|
161
|
+
| [`sqlitePath`](#sqlitePath) | string | A path to an SQLite database. Optional, defaults to using an in-memory database. |
|
|
162
|
+
| [`verbose`](#verbose) | boolean | Whether or not to print output to the console. Optional, defaults to true. |
|
|
163
163
|
|
|
164
164
|
### agencies
|
|
165
165
|
|
|
@@ -171,16 +171,16 @@ To find an agency's GTFS file, visit [transitfeeds.com](http://transitfeeds.com)
|
|
|
171
171
|
|
|
172
172
|
#### agencies options
|
|
173
173
|
|
|
174
|
-
| option
|
|
175
|
-
|
|
|
176
|
-
| `url`
|
|
177
|
-
| `path`
|
|
178
|
-
| `headers`
|
|
179
|
-
| `prefix`
|
|
180
|
-
| `exclude`
|
|
181
|
-
| `realtimeAlerts`
|
|
182
|
-
| `realtimeTripUpdates`
|
|
183
|
-
| `realtimeVehiclePositions`
|
|
174
|
+
| option | type | description |
|
|
175
|
+
| -------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
176
|
+
| `url` | string | The URL to a zipped GTFS file. Required if `path` not present. |
|
|
177
|
+
| `path` | string | A path to a zipped GTFS file or a directory of unzipped .txt files. Required if `url` is not present. |
|
|
178
|
+
| `headers` | object | An object of HTTP headers in key:value format to use when fetching GTFS from the `url` specified. Optional. |
|
|
179
|
+
| `prefix` | string | A prefix to be added to every ID field maintain uniqueness when importing multiple GTFS from multiple agencies. Optional. |
|
|
180
|
+
| `exclude` | array | An array of GTFS file names (without `.txt`) to exclude when importing. Optional. |
|
|
181
|
+
| `realtimeAlerts` | object | An object containing a `url` field for GTFS-Realtime alerts and a `headers` field in key:value format to use when fetching GTFS-Realtime data. Optional. |
|
|
182
|
+
| `realtimeTripUpdates` | object | An object containing a `url` field for GTFS-Realtime trip updates and a `headers` field in key:value format to use when fetching GTFS-Realtime data. Optional. |
|
|
183
|
+
| `realtimeVehiclePositions` | object | An object containing a `url` field for GTFS-Realtime vehicle positions and a `headers` field in key:value format to use when fetching GTFS-Realtime data. Optional. |
|
|
184
184
|
|
|
185
185
|
- Specify a `url` to download GTFS:
|
|
186
186
|
|
|
@@ -416,7 +416,6 @@ importGtfs({
|
|
|
416
416
|
}
|
|
417
417
|
```
|
|
418
418
|
|
|
419
|
-
|
|
420
419
|
### ignoreDuplicates
|
|
421
420
|
|
|
422
421
|
{Boolean} If you don't want node-GTFS to throw an error when it encounters a duplicate id on GTFS import. If `true`, it will skip importing duplicate records where unique constraints are violated, such as`trip_id`, `stop_id`, `calendar_id`. Useful if importing GTFS from multiple sources into one SQlite database that share routes or stops. Defaults to `false`.
|
|
@@ -952,6 +951,28 @@ const stoptimes = getStoptimes({
|
|
|
952
951
|
stop_id: '70011',
|
|
953
952
|
service_id: 'CT-16APR-Caltrain-Weekday-01',
|
|
954
953
|
});
|
|
954
|
+
|
|
955
|
+
/*
|
|
956
|
+
* `getStoptimes` allows passing a `date` in the query to return
|
|
957
|
+
* only stoptimes for a specific day.
|
|
958
|
+
*/
|
|
959
|
+
const stoptimes = getStoptimes({
|
|
960
|
+
stop_id: '70011',
|
|
961
|
+
date: 20160704
|
|
962
|
+
});
|
|
963
|
+
|
|
964
|
+
/*
|
|
965
|
+
* `getStoptimes` allows passing a `start_time` and/or and
|
|
966
|
+
* `end_time` in the query to return only stoptimes after
|
|
967
|
+
* start_time and before end_time. This can be combined with the
|
|
968
|
+
* `date` parameter to get upcoming stoptimes
|
|
969
|
+
*/
|
|
970
|
+
const stoptimes = getStoptimes({
|
|
971
|
+
stop_id: '70011',
|
|
972
|
+
date: 20160704,
|
|
973
|
+
start_time: 11:30:00,
|
|
974
|
+
end_time: 11:45:00
|
|
975
|
+
});
|
|
955
976
|
```
|
|
956
977
|
|
|
957
978
|
#### getTrips(query, fields, sortBy, options)
|
|
@@ -1066,6 +1087,17 @@ const calendars = getCalendars({
|
|
|
1066
1087
|
});
|
|
1067
1088
|
```
|
|
1068
1089
|
|
|
1090
|
+
#### getServiceIdsByDate(date, options)
|
|
1091
|
+
|
|
1092
|
+
Returns an array of service_ids for a specified date. It queries both calendars.txt and calendar_dates.txt to calculate which service_ids are effective for that date, including exceptions. The `date` field is an integer in yyyymmdd format.
|
|
1093
|
+
|
|
1094
|
+
```js
|
|
1095
|
+
import { getServiceIdsByDate } from 'gtfs';
|
|
1096
|
+
|
|
1097
|
+
// Get service_ids for a specifc date
|
|
1098
|
+
const serviceIds = getServiceIdsByDate(20240704);
|
|
1099
|
+
```
|
|
1100
|
+
|
|
1069
1101
|
#### getCalendarDates(query, fields, sortBy, options)
|
|
1070
1102
|
|
|
1071
1103
|
Returns an array of calendar_dates that match query parameters. [Details on calendar_dates.txt](https://gtfs.org/schedule/reference/#calendar_datestxt)
|
package/dist/bin/gtfs-export.js
CHANGED
|
@@ -3430,6 +3430,10 @@ import { featureCollection as featureCollection2 } from "@turf/helpers";
|
|
|
3430
3430
|
// src/lib/gtfs/stops.ts
|
|
3431
3431
|
import { omit as omit5, orderBy, pick as pick3 } from "lodash-es";
|
|
3432
3432
|
|
|
3433
|
+
// src/lib/gtfs/stop-times.ts
|
|
3434
|
+
import { omit as omit6 } from "lodash-es";
|
|
3435
|
+
import sqlString5 from "sqlstring-sqlite";
|
|
3436
|
+
|
|
3433
3437
|
// src/bin/gtfs-export.ts
|
|
3434
3438
|
var pe = new PrettyError();
|
|
3435
3439
|
var argv = yargs(hideBin(process.argv)).usage("Usage: $0 --configPath ./config.json").help().option("c", {
|