@transportme/load-ptv-gtfs 1.3.4 → 1.3.5
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.
|
@@ -158,16 +158,19 @@ export default class StopsLoader {
|
|
|
158
158
|
let stopData = this.generateDBStopData(processedData, mergeName)
|
|
159
159
|
let matchingStop = await this.findMatchingStop(processedData, mergeName)
|
|
160
160
|
|
|
161
|
+
let finalStop
|
|
161
162
|
if (matchingStop) {
|
|
162
163
|
await this.mergeStops(matchingStop, stopData)
|
|
164
|
+
finalStop = matchingStop
|
|
163
165
|
} else {
|
|
164
166
|
await this.#stops.createDocument(stopData)
|
|
167
|
+
finalStop = stopData
|
|
165
168
|
}
|
|
166
169
|
|
|
167
170
|
if (this.#parentHolding[stop.stopGTFSID]) {
|
|
168
171
|
for (let childStop of this.#parentHolding[stop.stopGTFSID]) {
|
|
169
|
-
let childStopData = this.generateDBStopData(childStop,
|
|
170
|
-
await this.mergeStops(
|
|
172
|
+
let childStopData = this.generateDBStopData(childStop, finalStop.mergeName)
|
|
173
|
+
await this.mergeStops(finalStop, childStopData)
|
|
171
174
|
}
|
|
172
175
|
delete this.#parentHolding[stop.stopGTFSID]
|
|
173
176
|
}
|
package/package.json
CHANGED
|
@@ -27,6 +27,7 @@ const specialHeader = path.join(__dirname, 'sample-data', 'gtfs-splitting', 'spe
|
|
|
27
27
|
const unionWithSpaces = path.join(__dirname, 'sample-data', 'gtfs-splitting', 'union_with_spaces.txt')
|
|
28
28
|
|
|
29
29
|
const parentStopsFile = path.join(__dirname, 'sample-data', 'parent-stop', 'stops.txt')
|
|
30
|
+
const multiParentStopFile = path.join(__dirname, 'sample-data', 'parent-stop', 'multi_stop.txt')
|
|
30
31
|
|
|
31
32
|
describe('The GTFS Stops Loader', () => {
|
|
32
33
|
it('Should process the stops and add them to the database', async () => {
|
|
@@ -343,6 +344,23 @@ describe('The GTFS Stops Loader', () => {
|
|
|
343
344
|
expect(stopData.cleanNames).to.deep.equal(['clifton-hill-railway-station', 'connex'])
|
|
344
345
|
})
|
|
345
346
|
|
|
347
|
+
it('Should handle the parent being part of a merged stop', async () => {
|
|
348
|
+
let database = new LokiDatabaseConnection('test-db')
|
|
349
|
+
let stops = await database.createCollection('stops')
|
|
350
|
+
|
|
351
|
+
await (new StopsLoader(multiParentStopFile, suburbs, TRANSIT_MODES.regionalCoach, database)).loadStops()
|
|
352
|
+
|
|
353
|
+
expect(await stops.countDocuments({})).to.equal(1)
|
|
354
|
+
let stopData = await stops.findDocument({})
|
|
355
|
+
expect(stopData.bays.find(bay => bay.stopGTFSID === '17799').mode).to.equal('regional coach')
|
|
356
|
+
expect(stopData.bays.find(bay => bay.stopGTFSID === '17799').stopType).to.equal('stop')
|
|
357
|
+
|
|
358
|
+
expect(stopData.bays.find(bay => bay.stopGTFSID === 'vic:rail:ART').stopType).to.equal('station')
|
|
359
|
+
expect(stopData.bays.find(bay => bay.stopGTFSID === 'vic:rail:ART').parentStopGTFSID).to.be.null
|
|
360
|
+
|
|
361
|
+
expect(stopData.bays.find(bay => bay.stopGTFSID === '20288').parentStopGTFSID).to.equal('vic:rail:ART')
|
|
362
|
+
})
|
|
363
|
+
|
|
346
364
|
it('Should use stop and station names and suburbs', async () => {
|
|
347
365
|
let database = new LokiDatabaseConnection('test-db')
|
|
348
366
|
let stops = await database.createCollection('stops')
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
stop_id,stop_name,stop_lat,stop_lon,location_type,parent_station,wheelchair_boarding,level_id
|
|
2
|
+
"17799","Ararat Railway Station/High St ","-37.28243901","142.93691236","","","0",""
|
|
3
|
+
"20288","Ararat Station","-37.28220485","142.93691370","","vic:rail:ART","1","Level 0"
|
|
4
|
+
"vic:rail:ART","Ararat Railway Station","-37.28224082","142.93691176","1","","1",""
|