@transportme/load-ptv-gtfs 1.1.6 → 1.1.7
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.
|
@@ -26,6 +26,7 @@ export default class TripLoader {
|
|
|
26
26
|
#stopCache = {}
|
|
27
27
|
|
|
28
28
|
#shapeIDMap = {}
|
|
29
|
+
#directionIDMap = {}
|
|
29
30
|
|
|
30
31
|
#tripsToLoad = []
|
|
31
32
|
|
|
@@ -164,7 +165,9 @@ export default class TripLoader {
|
|
|
164
165
|
if (!processedData) return
|
|
165
166
|
|
|
166
167
|
this.#shapeIDMap[tripData.shapeID] = tripData.routeGTFSID
|
|
167
|
-
|
|
168
|
+
if (!this.#directionIDMap[tripData.routeGTFSID]) this.#directionIDMap[tripData.routeGTFSID] = {}
|
|
169
|
+
this.#directionIDMap[tripData.routeGTFSID][rawTripData.getHeadsign()] = rawTripData.getGTFSDirection()
|
|
170
|
+
|
|
168
171
|
this.#tripsToLoad.push(processedData)
|
|
169
172
|
}
|
|
170
173
|
|
|
@@ -211,4 +214,8 @@ export default class TripLoader {
|
|
|
211
214
|
getShapeIDMap() {
|
|
212
215
|
return this.#shapeIDMap
|
|
213
216
|
}
|
|
217
|
+
|
|
218
|
+
getDirectionIDMap() {
|
|
219
|
+
return this.#directionIDMap
|
|
220
|
+
}
|
|
214
221
|
}
|
package/package.json
CHANGED
|
@@ -109,4 +109,31 @@ describe('The TripLoader class', () => {
|
|
|
109
109
|
|
|
110
110
|
expect(shapeIDMap['2-ALM-vpt-1.1.R']).to.equal('2-ALM')
|
|
111
111
|
})
|
|
112
|
+
|
|
113
|
+
it('Should return a mapping of Route + GTFS Direction ID to PTV Direction Names', async () => {
|
|
114
|
+
let database = new LokiDatabaseConnection('test-db')
|
|
115
|
+
let stops = await database.createCollection('stops')
|
|
116
|
+
let routes = await database.createCollection('routes')
|
|
117
|
+
let trips = await database.createCollection('gtfs timetables')
|
|
118
|
+
|
|
119
|
+
let stopLoader = new StopsLoader(stopsFile, suburbs, TRANSIT_MODES.metroTrain, database)
|
|
120
|
+
await stopLoader.loadStops()
|
|
121
|
+
|
|
122
|
+
let routeLoader = new RouteLoader(routesFile, agencyFile, TRANSIT_MODES.metroTrain, database)
|
|
123
|
+
await routeLoader.loadRoutes()
|
|
124
|
+
|
|
125
|
+
let routeIDMap = routeLoader.getRouteIDMap()
|
|
126
|
+
|
|
127
|
+
let tripLoader = new TripLoader({
|
|
128
|
+
tripsFile, stopTimesFile,
|
|
129
|
+
calendarFile, calendarDatesFile
|
|
130
|
+
}, TRANSIT_MODES.metroTrain, database)
|
|
131
|
+
|
|
132
|
+
await tripLoader.loadTrips({ routeIDMap })
|
|
133
|
+
let directionIDMap = tripLoader.getDirectionIDMap()
|
|
134
|
+
|
|
135
|
+
expect(directionIDMap).to.deep.equal({
|
|
136
|
+
'2-ALM': { 'Alamein': 0, 'Camberwell': 1 }
|
|
137
|
+
})
|
|
138
|
+
})
|
|
112
139
|
})
|