@transportme/load-ptv-gtfs 1.1.0 → 1.1.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.
|
@@ -156,13 +156,19 @@ export class MetroTrip extends GTFSTrip {
|
|
|
156
156
|
return mode === TRANSIT_MODES.metroTrain && data.id.match(/^02-\w{3}-.*-(\w{1,2}\d{3})$/)
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
getTrainDirection() {
|
|
160
|
+
let runID = this.getRunID()
|
|
161
|
+
return (parseInt(runID[runID.length - 1]) % 2 === 0) ? 'Up' : 'Down'
|
|
162
|
+
}
|
|
163
|
+
|
|
159
164
|
getTripData() {
|
|
160
165
|
let runID = this.getRunID()
|
|
161
166
|
|
|
162
167
|
return {
|
|
163
168
|
...super.getTripData(),
|
|
164
169
|
runID,
|
|
165
|
-
isRailReplacementBus: runID.length === 5 && runID[0] === 'B'
|
|
170
|
+
isRailReplacementBus: runID.length === 5 && runID[0] === 'B',
|
|
171
|
+
direction: this.getTrainDirection()
|
|
166
172
|
}
|
|
167
173
|
}
|
|
168
174
|
|
|
@@ -96,7 +96,14 @@ export default class StopsLoader {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
async mergeStops(matchingStop, stopData) {
|
|
99
|
-
|
|
99
|
+
let newBay = stopData.bays[0]
|
|
100
|
+
let hasIdenticalBay = matchingStop.bays.some(bay =>
|
|
101
|
+
bay.mode === newBay.mode && bay.stopGTFSID === newBay.stopGTFSID
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
if (hasIdenticalBay) return
|
|
105
|
+
|
|
106
|
+
matchingStop.bays.push(newBay)
|
|
100
107
|
|
|
101
108
|
this.updateStopSuburb(matchingStop)
|
|
102
109
|
this.updateStopName(matchingStop)
|
package/package.json
CHANGED
|
@@ -220,4 +220,74 @@ describe('The GTFS Stops Loader', () => {
|
|
|
220
220
|
expect(huntingdale).to.not.be.null
|
|
221
221
|
expect(huntingdale.stopName).to.equal('Huntingdale Railway Station')
|
|
222
222
|
})
|
|
223
|
+
|
|
224
|
+
it('Should not load duplicate stops with the same mode in', async () => {
|
|
225
|
+
let database = new LokiDatabaseConnection('test-db')
|
|
226
|
+
let stops = await database.createCollection('stops')
|
|
227
|
+
|
|
228
|
+
let loader = new StopsLoader(specialHeader, suburbs, TRANSIT_MODES.bus, database)
|
|
229
|
+
let reader = new GTFSStopsReader('')
|
|
230
|
+
|
|
231
|
+
await loader.loadStop(reader.processEntity({
|
|
232
|
+
stop_id: '51586',
|
|
233
|
+
stop_name: 'Huntingdale Station/Haughton Road (Oakleigh)',
|
|
234
|
+
stop_lat: '-37.9111998619901',
|
|
235
|
+
stop_lon: '145.103064853799'
|
|
236
|
+
}))
|
|
237
|
+
|
|
238
|
+
let huntingdale = await stops.findDocument({
|
|
239
|
+
'bays.stopGTFSID': '51586'
|
|
240
|
+
})
|
|
241
|
+
expect(huntingdale.bays.length).to.equal(1)
|
|
242
|
+
expect(huntingdale.bays[0].stopGTFSID).to.equal('51586')
|
|
243
|
+
|
|
244
|
+
await loader.loadStop(reader.processEntity({
|
|
245
|
+
stop_id: '51586',
|
|
246
|
+
stop_name: 'Huntingdale Station/Haughton Road (Oakleigh)',
|
|
247
|
+
stop_lat: '-37.9111998619901',
|
|
248
|
+
stop_lon: '145.103064853799'
|
|
249
|
+
}))
|
|
250
|
+
|
|
251
|
+
huntingdale = await stops.findDocument({
|
|
252
|
+
'bays.stopGTFSID': '51586'
|
|
253
|
+
})
|
|
254
|
+
expect(huntingdale.bays.length).to.equal(1)
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
it('Should load duplicate stops with the different mode in', async () => {
|
|
258
|
+
let database = new LokiDatabaseConnection('test-db')
|
|
259
|
+
let stops = await database.createCollection('stops')
|
|
260
|
+
|
|
261
|
+
let busLoader = new StopsLoader(specialHeader, suburbs, TRANSIT_MODES.bus, database)
|
|
262
|
+
let coachLoader = new StopsLoader(specialHeader, suburbs, TRANSIT_MODES.regionalCoach, database)
|
|
263
|
+
let reader = new GTFSStopsReader('')
|
|
264
|
+
|
|
265
|
+
await busLoader.loadStop(reader.processEntity({
|
|
266
|
+
stop_id: '51586',
|
|
267
|
+
stop_name: 'Huntingdale Station/Haughton Road (Oakleigh)',
|
|
268
|
+
stop_lat: '-37.9111998619901',
|
|
269
|
+
stop_lon: '145.103064853799'
|
|
270
|
+
}))
|
|
271
|
+
|
|
272
|
+
let huntingdale = await stops.findDocument({
|
|
273
|
+
'bays.stopGTFSID': '51586'
|
|
274
|
+
})
|
|
275
|
+
expect(huntingdale.bays.length).to.equal(1)
|
|
276
|
+
expect(huntingdale.bays[0].stopGTFSID).to.equal('51586')
|
|
277
|
+
expect(huntingdale.bays[0].mode).to.equal(TRANSIT_MODES.bus)
|
|
278
|
+
|
|
279
|
+
await coachLoader.loadStop(reader.processEntity({
|
|
280
|
+
stop_id: '51586',
|
|
281
|
+
stop_name: 'Huntingdale Station/Haughton Road (Oakleigh)',
|
|
282
|
+
stop_lat: '-37.9111998619901',
|
|
283
|
+
stop_lon: '145.103064853799'
|
|
284
|
+
}))
|
|
285
|
+
|
|
286
|
+
huntingdale = await stops.findDocument({
|
|
287
|
+
'bays.stopGTFSID': '51586'
|
|
288
|
+
})
|
|
289
|
+
expect(huntingdale.bays.length).to.equal(2)
|
|
290
|
+
expect(huntingdale.bays[1].stopGTFSID).to.equal('51586')
|
|
291
|
+
expect(huntingdale.bays[1].mode).to.equal(TRANSIT_MODES.regionalCoach)
|
|
292
|
+
})
|
|
223
293
|
})
|
|
@@ -107,6 +107,7 @@ describe('The GTFS Loaders with the new Metro data', () => {
|
|
|
107
107
|
expect(trip.routeGTFSID).to.equal('2-PKM')
|
|
108
108
|
expect(trip.block).to.equal('3347')
|
|
109
109
|
expect(trip.isRailReplacementBus).to.be.false
|
|
110
|
+
expect(trip.direction).to.equal('Up')
|
|
110
111
|
|
|
111
112
|
expect(trip.stopTimings[0].stopName).to.equal('East Pakenham Railway Station')
|
|
112
113
|
expect(trip.stopTimings[0].platform).to.equal('1')
|
|
@@ -119,13 +120,14 @@ describe('The GTFS Loaders with the new Metro data', () => {
|
|
|
119
120
|
|
|
120
121
|
let nextTrip = await trips.findDocument({ block: '3347', runID: { $ne: 'C000' } })
|
|
121
122
|
expect(nextTrip.runID).to.equal('C005')
|
|
123
|
+
expect(nextTrip.direction).to.equal('Down')
|
|
122
124
|
expect(trip.isRailReplacementBus).to.be.false
|
|
123
125
|
|
|
124
126
|
expect(nextTrip.stopTimings[0].stopName).to.equal('Flinders Street Railway Station')
|
|
125
127
|
expect(nextTrip.stopTimings[0].platform).to.equal('7')
|
|
126
128
|
})
|
|
127
129
|
|
|
128
|
-
it('It identify rail replacement bus trip', async () => {
|
|
130
|
+
it('It identify a rail replacement bus trip and mark it as such', async () => {
|
|
129
131
|
let database = new LokiDatabaseConnection('test-db')
|
|
130
132
|
let stops = await database.createCollection('stops')
|
|
131
133
|
let routes = await database.createCollection('routes')
|
|
@@ -154,6 +156,7 @@ describe('The GTFS Loaders with the new Metro data', () => {
|
|
|
154
156
|
expect(trip.routeGTFSID).to.equal('2-LIL')
|
|
155
157
|
expect(trip.block).to.equal(null)
|
|
156
158
|
expect(trip.isRailReplacementBus).to.be.true
|
|
159
|
+
expect(trip.direction).to.equal('Up')
|
|
157
160
|
|
|
158
161
|
expect(trip.stopTimings[0].stopName).to.equal('Burnley Railway Station')
|
|
159
162
|
expect(trip.stopTimings[0].platform).to.equal('RRB')
|