@transportme/load-ptv-gtfs 1.4.18 → 1.4.20
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.
|
@@ -2,7 +2,7 @@ import { TRANSIT_MODES } from '../constants.mjs'
|
|
|
2
2
|
import GTFSCalendar from './GTFSCalendar.mjs'
|
|
3
3
|
|
|
4
4
|
export default class GTFSTrip {
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
#routeGTFSID
|
|
7
7
|
#calendarName
|
|
8
8
|
#operationDays
|
|
@@ -11,6 +11,7 @@ export default class GTFSTrip {
|
|
|
11
11
|
#headsign
|
|
12
12
|
#direction
|
|
13
13
|
#block
|
|
14
|
+
#stopData
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
*
|
|
@@ -102,6 +103,14 @@ export default class GTFSTrip {
|
|
|
102
103
|
getGTFSDirection() {
|
|
103
104
|
return parseInt(this.#direction)
|
|
104
105
|
}
|
|
106
|
+
|
|
107
|
+
setStopData(stopData) {
|
|
108
|
+
this.#stopData = stopData
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
getStopData() {
|
|
112
|
+
return this.#stopData
|
|
113
|
+
}
|
|
105
114
|
}
|
|
106
115
|
|
|
107
116
|
/**
|
|
@@ -151,6 +151,7 @@ export default class TripLoader {
|
|
|
151
151
|
return data
|
|
152
152
|
})
|
|
153
153
|
|
|
154
|
+
tripData.setStopData(stopTimings)
|
|
154
155
|
|
|
155
156
|
let dbTrip = {
|
|
156
157
|
mode: this.#mode,
|
|
@@ -200,6 +201,7 @@ export default class TripLoader {
|
|
|
200
201
|
this.updateStopServices(processedData)
|
|
201
202
|
|
|
202
203
|
this.#tripsToLoad.push(processedData)
|
|
204
|
+
this.#tripDetails[tripID] = null // Clear it from the cache once loaded to free up some memory
|
|
203
205
|
}
|
|
204
206
|
|
|
205
207
|
updateStopServices(trip) {
|
|
@@ -225,7 +227,7 @@ export default class TripLoader {
|
|
|
225
227
|
* @param {object} options.routeIDMap A mapping of full route IDs to their simplified IDs.
|
|
226
228
|
* @param {function} [options.processTrip] A function to modify trip data on a per-trip basis. It should return null to discard the trip.
|
|
227
229
|
*/
|
|
228
|
-
async loadTrips({ routeIDMap, processTrip }) {
|
|
230
|
+
async loadTrips({ routeIDMap, processTrip, onWrite = () => {} }) {
|
|
229
231
|
this.#routeIDMap = routeIDMap
|
|
230
232
|
|
|
231
233
|
await this.loadCalendarData()
|
|
@@ -241,11 +243,13 @@ export default class TripLoader {
|
|
|
241
243
|
if (this.#tripsToLoad.length === 5000) { // Flush the cache every 5000 trips
|
|
242
244
|
tripsLoaded += this.#tripsToLoad.length
|
|
243
245
|
await this.writeTrips()
|
|
246
|
+
onWrite(tripsLoaded)
|
|
244
247
|
}
|
|
245
248
|
}
|
|
246
249
|
|
|
247
250
|
tripsLoaded += this.#tripsToLoad.length
|
|
248
251
|
await this.writeTrips()
|
|
252
|
+
onWrite(tripsLoaded)
|
|
249
253
|
}
|
|
250
254
|
|
|
251
255
|
getTripsToLoad() {
|