gtfs 4.17.4 → 4.17.6
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 +41 -6
- package/dist/bin/gtfs-export.js +10 -0
- package/dist/bin/gtfs-export.js.map +1 -1
- package/dist/bin/gtfs-import.js +10 -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 +1 -0
- package/dist/index.js +26 -1
- package/dist/index.js.map +1 -1
- package/dist/models/models.js +6 -0
- package/dist/models/models.js.map +1 -1
- package/package.json +38 -37
package/README.md
CHANGED
|
@@ -151,14 +151,14 @@ Copy `config-sample.json` to `config.json` and then add your projects configurat
|
|
|
151
151
|
| option | type | description |
|
|
152
152
|
| ----------------------------------------------------------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
153
153
|
| [`agencies`](#agencies) | array | An array of GTFS files to be imported, and which files to exclude. |
|
|
154
|
-
| [`csvOptions`](#
|
|
154
|
+
| [`csvOptions`](#csvoptions) | object | Options passed to `csv-parse` for parsing GTFS CSV files. Optional. |
|
|
155
155
|
| [`db`](#db) | database instance | An existing database instance to use instead of relying on node-gtfs to connect. Optional. |
|
|
156
156
|
| [`downloadTimeout`](#downloadtimeout) | integer | The number of milliseconds to wait before throwing an error when downloading GTFS. Optional. |
|
|
157
|
-
| [`exportPath`](#
|
|
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
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
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`](#
|
|
161
|
+
| [`sqlitePath`](#sqlitepath) | string | A path to an SQLite database. Optional, defaults to using an in-memory database. |
|
|
162
162
|
| [`verbose`](#verbose) | boolean | Whether or not to print output to the console. Optional, defaults to true. |
|
|
163
163
|
|
|
164
164
|
### agencies
|
|
@@ -951,8 +951,8 @@ const stoptimes = getStoptimes({
|
|
|
951
951
|
});
|
|
952
952
|
|
|
953
953
|
/*
|
|
954
|
-
* `getStoptimes` allows passing a `date` in the query to return
|
|
955
|
-
*
|
|
954
|
+
* `getStoptimes` allows passing a `date` in the query to return only
|
|
955
|
+
* stoptimes for a specific service date.
|
|
956
956
|
*/
|
|
957
957
|
const stoptimes = getStoptimes({
|
|
958
958
|
stop_id: '70011',
|
|
@@ -963,7 +963,7 @@ const stoptimes = getStoptimes({
|
|
|
963
963
|
* `getStoptimes` allows passing a `start_time` and/or and
|
|
964
964
|
* `end_time` in the query to return only stoptimes after
|
|
965
965
|
* start_time and before end_time. This can be combined with the
|
|
966
|
-
* `date` parameter to get upcoming stoptimes
|
|
966
|
+
* `date` parameter to get upcoming stoptimes.
|
|
967
967
|
*/
|
|
968
968
|
const stoptimes = getStoptimes({
|
|
969
969
|
stop_id: '70011',
|
|
@@ -971,6 +971,32 @@ const stoptimes = getStoptimes({
|
|
|
971
971
|
start_time: '11:30:00',
|
|
972
972
|
end_time: '11:45:00'
|
|
973
973
|
});
|
|
974
|
+
|
|
975
|
+
/*
|
|
976
|
+
* ⚠️ By default, when using the `date` parameter in a query, it will NOT
|
|
977
|
+
* include stoptimes for trips whose service date is the previous day but
|
|
978
|
+
* whose stoptimes occur after midnight (i.e., times greater than 24:00:00
|
|
979
|
+
* in GTFS, such as 25:15:00 for 1:15 AM the next day).
|
|
980
|
+
*
|
|
981
|
+
* To retrieve all stoptimes for a calendar date including those from
|
|
982
|
+
* trips assigned to the previous service date but occurring after
|
|
983
|
+
* midnight:
|
|
984
|
+
* 1. Call `getStoptimes` with the target date:
|
|
985
|
+
* 2. Call `getStoptimes` with the previous date and `start_time: '24:00:00'`:
|
|
986
|
+
* 3. Combine both results for a complete set of stoptimes for July 5th.
|
|
987
|
+
*
|
|
988
|
+
* This approach ensures you include:
|
|
989
|
+
* - All stoptimes for trips whose service date is July 4th but whose
|
|
990
|
+
* stoptimes occur after midnight (i.e., in the early hours of July 5th)
|
|
991
|
+
* - All stoptimes for trips whose service date is July 5th (which can
|
|
992
|
+
* include trips with stoptimes that occur on July 6th after midnight )
|
|
993
|
+
*/
|
|
994
|
+
const stoptimesToday = getStoptimes({ date: 20240705 });
|
|
995
|
+
const stoptimesYesterdayAfterMidnight = getStoptimes({ date: 20240704, start_time: '24:00:00' })
|
|
996
|
+
const mergedStoptimes = [
|
|
997
|
+
...stoptimesToday,
|
|
998
|
+
...stoptimesYesterdayAfterMidnight
|
|
999
|
+
];
|
|
974
1000
|
```
|
|
975
1001
|
|
|
976
1002
|
#### getTrips(query, fields, sortBy, options)
|
|
@@ -1001,6 +1027,15 @@ const trips = getTrips({
|
|
|
1001
1027
|
direction_id: 0,
|
|
1002
1028
|
service_id: '
|
|
1003
1029
|
});
|
|
1030
|
+
|
|
1031
|
+
/*
|
|
1032
|
+
* `getTrips` allows passing a `date` in the query to return only trips
|
|
1033
|
+
* for a specific service date.
|
|
1034
|
+
*/
|
|
1035
|
+
const trips = getTrips({
|
|
1036
|
+
route_id: 'Bu-16APR',
|
|
1037
|
+
date: 20170416
|
|
1038
|
+
});
|
|
1004
1039
|
```
|
|
1005
1040
|
|
|
1006
1041
|
#### getShapes(query, fields, sortBy, options)
|
package/dist/bin/gtfs-export.js
CHANGED
|
@@ -1626,6 +1626,12 @@ var trips = {
|
|
|
1626
1626
|
type: "integer",
|
|
1627
1627
|
min: 0,
|
|
1628
1628
|
max: 2
|
|
1629
|
+
},
|
|
1630
|
+
{
|
|
1631
|
+
name: "cars_allowed",
|
|
1632
|
+
type: "integer",
|
|
1633
|
+
min: 0,
|
|
1634
|
+
max: 2
|
|
1629
1635
|
}
|
|
1630
1636
|
]
|
|
1631
1637
|
};
|
|
@@ -4289,6 +4295,10 @@ import { omit as omit5, orderBy, pick as pick3 } from "lodash-es";
|
|
|
4289
4295
|
import { omit as omit6 } from "lodash-es";
|
|
4290
4296
|
import sqlString4 from "sqlstring-sqlite";
|
|
4291
4297
|
|
|
4298
|
+
// src/lib/gtfs/trips.ts
|
|
4299
|
+
import { omit as omit7 } from "lodash-es";
|
|
4300
|
+
import sqlString5 from "sqlstring-sqlite";
|
|
4301
|
+
|
|
4292
4302
|
// src/bin/gtfs-export.ts
|
|
4293
4303
|
var pe = new PrettyError();
|
|
4294
4304
|
var argv = yargs(hideBin(process.argv)).usage("Usage: $0 --configPath ./config.json").help().option("c", {
|