@transportme/load-ptv-gtfs 1.1.7 → 1.1.8

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.
@@ -8,7 +8,7 @@ import { TRANSIT_MODES } from '../constants.mjs'
8
8
  *
9
9
  * @param {DatabaseConnection} database The database connection to use
10
10
  */
11
- export default async function setRouteStops(database) {
11
+ export default async function setRouteStops(database, directionsMap) {
12
12
  let gtfsTimetables = database.getCollection('gtfs timetables')
13
13
  let routes = database.getCollection('routes')
14
14
 
@@ -87,7 +87,8 @@ export default async function setRouteStops(database) {
87
87
  updateOne: {
88
88
  filter: { routeGTFSID },
89
89
  update: { $set: {
90
- directions: stopsByService[routeGTFSID].filter(Boolean) // Apparently some routes dont have GTFS Dir 0
90
+ directions: stopsByService[routeGTFSID].filter(Boolean), // Apparently some routes dont have GTFS Dir 0
91
+ ptvDirections: directionsMap[routeGTFSID]
91
92
  } }
92
93
  }
93
94
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transportme/load-ptv-gtfs",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "description": "",
5
5
  "main": "index.mjs",
6
6
  "scripts": {
@@ -44,12 +44,13 @@ let tripLoader = new TripLoader({
44
44
 
45
45
  await tripLoader.loadTrips({ routeIDMap })
46
46
  let shapeIDMap = tripLoader.getShapeIDMap()
47
+ let directionIDMap = tripLoader.getDirectionIDMap()
47
48
 
48
49
  let shapeLoader = new ShapeLoader(shapeFile, database)
49
50
 
50
51
  await shapeLoader.loadShapes({ shapeIDMap })
51
52
 
52
- await setRouteStops(database)
53
+ await setRouteStops(database, directionIDMap)
53
54
 
54
55
  describe('The GTFS Route stop merger', () => {
55
56
  describe('When processing Metro routes', () => {
@@ -95,5 +96,11 @@ describe('The GTFS Route stop merger', () => {
95
96
  expect(stonyPoint.stops[0].stopName).to.equal('Frankston Railway Station')
96
97
  expect(stonyPoint.stops[stonyPoint.stops.length - 1].stopName).to.equal('Stony Point Railway Station')
97
98
  })
99
+
100
+ it('Should mark the PTV Route direction', async () => {
101
+ let stonyPointRoute = await routes.findDocument({ routeGTFSID: '2-STY' })
102
+ expect(stonyPointRoute.ptvDirections['Stony Point']).to.equal(0)
103
+ expect(stonyPointRoute.ptvDirections['Frankston']).to.equal(1)
104
+ })
98
105
  })
99
106
  })