@transportme/load-ptv-gtfs 1.1.0 → 1.1.1

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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transportme/load-ptv-gtfs",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "",
5
5
  "main": "index.mjs",
6
6
  "scripts": {
@@ -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')