@transportme/load-ptv-gtfs 1.3.3 → 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.
|
@@ -76,7 +76,7 @@ export default class StopsLoader {
|
|
|
76
76
|
|
|
77
77
|
updateStopName(stop) {
|
|
78
78
|
stop.cleanNames = stop.bays
|
|
79
|
-
.filter(bay => bay.stopType === STOP_TYPE[0])
|
|
79
|
+
.filter(bay => bay.stopType === STOP_TYPE[0] || bay.stopType === STOP_TYPE[1])
|
|
80
80
|
.map(bay => sanitiseName(bay.fullStopName))
|
|
81
81
|
.filter((e, i, a) => a.indexOf(e) === i)
|
|
82
82
|
|
|
@@ -93,17 +93,17 @@ export default class StopsLoader {
|
|
|
93
93
|
|
|
94
94
|
updateStopSuburb(stop) {
|
|
95
95
|
stop.cleanSuburbs = stop.bays
|
|
96
|
-
.filter(bay => bay.stopType === STOP_TYPE[0])
|
|
96
|
+
.filter(bay => bay.stopType === STOP_TYPE[0] || bay.stopType === STOP_TYPE[1])
|
|
97
97
|
.map(bay => sanitiseName(bay.suburb))
|
|
98
98
|
.filter((e, i, a) => a.indexOf(e) === i)
|
|
99
99
|
|
|
100
100
|
stop.suburb = stop.bays
|
|
101
|
-
.filter(bay => bay.stopType === STOP_TYPE[0])
|
|
101
|
+
.filter(bay => bay.stopType === STOP_TYPE[0] || bay.stopType === STOP_TYPE[1])
|
|
102
102
|
.map(bay => bay.suburb)
|
|
103
103
|
.filter((e, i, a) => a.indexOf(e) === i)
|
|
104
104
|
.sort()
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
stop.codedSuburbs = stop.cleanSuburbs
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
updateStopLocation(stop) {
|
|
@@ -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 () => {
|
|
@@ -342,4 +343,57 @@ describe('The GTFS Stops Loader', () => {
|
|
|
342
343
|
// TODO: Find out what the Connex stop is for
|
|
343
344
|
expect(stopData.cleanNames).to.deep.equal(['clifton-hill-railway-station', 'connex'])
|
|
344
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
|
+
|
|
364
|
+
it('Should use stop and station names and suburbs', async () => {
|
|
365
|
+
let database = new LokiDatabaseConnection('test-db')
|
|
366
|
+
let stops = await database.createCollection('stops')
|
|
367
|
+
|
|
368
|
+
let data = [{
|
|
369
|
+
"stop_id": "vic:rail:THL",
|
|
370
|
+
"stop_name": "Town Hall Railway Station (Melbourne)",
|
|
371
|
+
"stop_lat": "-37.815926",
|
|
372
|
+
"stop_lon": "144.967134",
|
|
373
|
+
"parent_station": "",
|
|
374
|
+
"location_type": "1",
|
|
375
|
+
"platform_code": ""
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
"stop_id": "vic:rail:TSC",
|
|
379
|
+
"stop_name": "Town Hall Railway Station (Melbourne)",
|
|
380
|
+
"stop_lat": "-37.815926",
|
|
381
|
+
"stop_lon": "144.967134",
|
|
382
|
+
"parent_station": "",
|
|
383
|
+
"location_type": "1",
|
|
384
|
+
"platform_code": ""
|
|
385
|
+
}]
|
|
386
|
+
|
|
387
|
+
let stopLoader = new StopsLoader('', suburbs, TRANSIT_MODES.metroTrain, database)
|
|
388
|
+
let reader = new GTFSStopsReader('', suburbs)
|
|
389
|
+
|
|
390
|
+
for (let stop of data) await stopLoader.loadStop(reader.processEntity(stop))
|
|
391
|
+
|
|
392
|
+
expect(await stops.countDocuments({})).to.equal(1)
|
|
393
|
+
let stopData = await stops.findDocument({})
|
|
394
|
+
expect(stopData.stopName).to.equal('Town Hall Railway Station')
|
|
395
|
+
expect(stopData.cleanNames).to.deep.equal(['town-hall-railway-station'])
|
|
396
|
+
expect(stopData.suburb).to.deep.equal(['Melbourne'])
|
|
397
|
+
expect(stopData.cleanSuburbs).to.deep.equal(['melbourne'])
|
|
398
|
+
})
|
|
345
399
|
})
|
|
@@ -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",""
|