gtfs 4.10.1 → 4.10.2
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/.github/workflows/nodejs.yml +1 -1
- package/CHANGELOG.md +11 -0
- package/lib/import.js +30 -13
- package/models/gtfs-realtime/vehicle-positions.js +38 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,17 @@ 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.10.2] - 2024-04-02
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Better error message for `gtfsrealtime-update` command
|
|
13
|
+
- Support additional fields for vehiclePosition GTFS-Realtime data
|
|
14
|
+
|
|
15
|
+
### Updated
|
|
16
|
+
|
|
17
|
+
- Dependency updates
|
|
18
|
+
|
|
8
19
|
## [4.10.1] - 2024-03-29
|
|
9
20
|
|
|
10
21
|
### Updated
|
package/lib/import.js
CHANGED
|
@@ -107,22 +107,39 @@ function getDescendantProp(obj, desc, defaultvalue) {
|
|
|
107
107
|
return obj;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
const markRealtimeDataStale = (config
|
|
111
|
-
const
|
|
110
|
+
const markRealtimeDataStale = (config) => {
|
|
111
|
+
const log = _log(config);
|
|
112
|
+
const logError = _logError(config);
|
|
112
113
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
114
|
+
try {
|
|
115
|
+
const db = openDb(config);
|
|
116
|
+
|
|
117
|
+
log(`Marking GTFS-Realtime data as stale`);
|
|
118
|
+
db.prepare(`UPDATE vehicle_positions SET is_updated=0`).run();
|
|
119
|
+
db.prepare(`UPDATE trip_updates SET is_updated=0`).run();
|
|
120
|
+
db.prepare(`UPDATE stop_time_updates SET is_updated=0`).run();
|
|
121
|
+
db.prepare(`UPDATE service_alerts SET is_updated=0`).run();
|
|
122
|
+
db.prepare(`UPDATE service_alert_targets SET is_updated=0`).run();
|
|
123
|
+
log(`Marked GTFS-Realtime data as stale\r`, true);
|
|
124
|
+
} catch (error) {
|
|
125
|
+
if (
|
|
126
|
+
error instanceof Error &&
|
|
127
|
+
error.code === 'SQLITE_ERROR' &&
|
|
128
|
+
error.message?.startsWith('no such table')
|
|
129
|
+
) {
|
|
130
|
+
logError(
|
|
131
|
+
'Run `gtfs-import` before running the `gtfsrealtime-update` command to set up tables.',
|
|
132
|
+
);
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
120
136
|
};
|
|
121
137
|
|
|
122
|
-
const cleanStaleRealtimeData = (config
|
|
138
|
+
const cleanStaleRealtimeData = (config) => {
|
|
139
|
+
const log = _log(config);
|
|
123
140
|
const db = openDb(config);
|
|
124
141
|
|
|
125
|
-
log(`Cleaning stale GTFS-RT data
|
|
142
|
+
log(`Cleaning stale GTFS-RT data`);
|
|
126
143
|
db.prepare(`DELETE FROM vehicle_positions WHERE is_updated=0`).run();
|
|
127
144
|
db.prepare(`DELETE FROM trip_updates WHERE is_updated=0`).run();
|
|
128
145
|
db.prepare(`DELETE FROM stop_time_updates WHERE is_updated=0`).run();
|
|
@@ -708,7 +725,7 @@ export async function updateGtfsRealtime(initialConfig) {
|
|
|
708
725
|
)} using SQLite database at ${config.sqlitePath}`,
|
|
709
726
|
);
|
|
710
727
|
|
|
711
|
-
markRealtimeDataStale(config
|
|
728
|
+
markRealtimeDataStale(config);
|
|
712
729
|
|
|
713
730
|
await Promise.all(
|
|
714
731
|
config.agencies.map(async (agency) => {
|
|
@@ -729,7 +746,7 @@ export async function updateGtfsRealtime(initialConfig) {
|
|
|
729
746
|
}),
|
|
730
747
|
);
|
|
731
748
|
|
|
732
|
-
cleanStaleRealtimeData(config
|
|
749
|
+
cleanStaleRealtimeData(config);
|
|
733
750
|
log(
|
|
734
751
|
`Completed GTFS-Realtime refresh for ${pluralize(
|
|
735
752
|
'agencies',
|
|
@@ -39,6 +39,12 @@ const model = {
|
|
|
39
39
|
source: 'vehicle.position.speed',
|
|
40
40
|
default: null,
|
|
41
41
|
},
|
|
42
|
+
{
|
|
43
|
+
name: 'current_stop_sequence',
|
|
44
|
+
type: 'integer',
|
|
45
|
+
source: 'vehicle.currentStopSequence',
|
|
46
|
+
default: null,
|
|
47
|
+
},
|
|
42
48
|
{
|
|
43
49
|
name: 'trip_id',
|
|
44
50
|
type: 'varchar(255)',
|
|
@@ -46,6 +52,20 @@ const model = {
|
|
|
46
52
|
source: 'vehicle.trip.tripId',
|
|
47
53
|
default: null,
|
|
48
54
|
},
|
|
55
|
+
{
|
|
56
|
+
name: 'trip_start_date',
|
|
57
|
+
type: 'varchar(255)',
|
|
58
|
+
index: true,
|
|
59
|
+
source: 'vehicle.trip.startDate',
|
|
60
|
+
default: null,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'trip_start_time',
|
|
64
|
+
type: 'varchar(255)',
|
|
65
|
+
index: true,
|
|
66
|
+
source: 'vehicle.trip.startTime',
|
|
67
|
+
default: null,
|
|
68
|
+
},
|
|
49
69
|
{
|
|
50
70
|
name: 'vehicle_id',
|
|
51
71
|
type: 'varchar(255)',
|
|
@@ -53,6 +73,24 @@ const model = {
|
|
|
53
73
|
source: 'vehicle.vehicle.id',
|
|
54
74
|
default: null,
|
|
55
75
|
},
|
|
76
|
+
{
|
|
77
|
+
name: 'congestion_level',
|
|
78
|
+
type: 'varchar(255)',
|
|
79
|
+
source: 'vehicle.congestionLevel',
|
|
80
|
+
default: null,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: 'occupancy_status',
|
|
84
|
+
type: 'varchar(255)',
|
|
85
|
+
source: 'vehicle.occupancyStatus',
|
|
86
|
+
default: null,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'occupancy_percentage',
|
|
90
|
+
type: 'integer',
|
|
91
|
+
source: 'vehicle.occupancyPercentage',
|
|
92
|
+
default: null,
|
|
93
|
+
},
|
|
56
94
|
{
|
|
57
95
|
name: 'timestamp',
|
|
58
96
|
type: 'varchar(255)',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gtfs",
|
|
3
|
-
"version": "4.10.
|
|
3
|
+
"version": "4.10.2",
|
|
4
4
|
"description": "Import GTFS transit data into SQLite and query routes, stops, times, fares and more",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"transit",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"@turf/helpers": "^6.5.0",
|
|
80
|
-
"better-sqlite3": "^9.4.
|
|
80
|
+
"better-sqlite3": "^9.4.4",
|
|
81
81
|
"csv-parse": "^5.5.5",
|
|
82
82
|
"csv-stringify": "^6.4.6",
|
|
83
83
|
"gtfs-realtime-bindings": "^1.1.1",
|