gtfs 4.10.0 → 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.
@@ -7,7 +7,7 @@ jobs:
7
7
  runs-on: ubuntu-latest
8
8
  strategy:
9
9
  matrix:
10
- node: [ 18, 20 ]
10
+ node: [ 20, 21 ]
11
11
  name: Use Node.js ${{ matrix.node }}
12
12
  steps:
13
13
  - uses: actions/checkout@v4
package/CHANGELOG.md CHANGED
@@ -5,6 +5,23 @@ 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
+
19
+ ## [4.10.1] - 2024-03-29
20
+
21
+ ### Updated
22
+
23
+ - Dependency updates
24
+
8
25
  ## [4.10.0] - 2024-03-29
9
26
 
10
27
  ### Added
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, log) => {
111
- const db = openDb(config);
110
+ const markRealtimeDataStale = (config) => {
111
+ const log = _log(config);
112
+ const logError = _logError(config);
112
113
 
113
- log(`Marking GTFS-Realtime data as stale..`);
114
- db.prepare(`UPDATE vehicle_positions SET is_updated=0`).run();
115
- db.prepare(`UPDATE trip_updates SET is_updated=0`).run();
116
- db.prepare(`UPDATE stop_time_updates SET is_updated=0`).run();
117
- db.prepare(`UPDATE service_alerts SET is_updated=0`).run();
118
- db.prepare(`UPDATE service_alert_targets SET is_updated=0`).run();
119
- log(`Marked GTFS-Realtime data as stale\r`, true);
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, log) => {
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, log);
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, log);
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.0",
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.3",
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",
@@ -100,7 +100,7 @@
100
100
  "devDependencies": {
101
101
  "husky": "^9.0.11",
102
102
  "lint-staged": "^15.2.2",
103
- "mocha": "^10.3.0",
103
+ "mocha": "^10.4.0",
104
104
  "prettier": "^3.2.5",
105
105
  "should": "^13.2.3"
106
106
  },