@transportme/load-ptv-gtfs 1.1.5 → 1.1.7

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.
@@ -26,6 +26,7 @@ export default class TripLoader {
26
26
  #stopCache = {}
27
27
 
28
28
  #shapeIDMap = {}
29
+ #directionIDMap = {}
29
30
 
30
31
  #tripsToLoad = []
31
32
 
@@ -164,7 +165,9 @@ export default class TripLoader {
164
165
  if (!processedData) return
165
166
 
166
167
  this.#shapeIDMap[tripData.shapeID] = tripData.routeGTFSID
167
-
168
+ if (!this.#directionIDMap[tripData.routeGTFSID]) this.#directionIDMap[tripData.routeGTFSID] = {}
169
+ this.#directionIDMap[tripData.routeGTFSID][rawTripData.getHeadsign()] = rawTripData.getGTFSDirection()
170
+
168
171
  this.#tripsToLoad.push(processedData)
169
172
  }
170
173
 
@@ -211,4 +214,8 @@ export default class TripLoader {
211
214
  getShapeIDMap() {
212
215
  return this.#shapeIDMap
213
216
  }
217
+
218
+ getDirectionIDMap() {
219
+ return this.#directionIDMap
220
+ }
214
221
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transportme/load-ptv-gtfs",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "",
5
5
  "main": "index.mjs",
6
6
  "scripts": {
@@ -15,6 +15,8 @@ const __dirname = path.dirname(__filename)
15
15
 
16
16
  const stopsFile = path.join(__dirname, 'sample-data', 'gtfs-splitting', 'sample_stops.txt')
17
17
 
18
+ const generalStores = path.join(__dirname, 'sample-data', 'gtfs-splitting', 'general-stores.txt')
19
+
18
20
  const uniqueStopsBus = path.join(__dirname, 'sample-data', 'gtfs-splitting', 'force_unique_stops_bus.txt')
19
21
  const uniqueStopsTram = path.join(__dirname, 'sample-data', 'gtfs-splitting', 'force_unique_stops_tram.txt')
20
22
 
@@ -295,4 +297,15 @@ describe('The GTFS Stops Loader', () => {
295
297
  expect(huntingdale.bays[1].stopGTFSID).to.equal('51586')
296
298
  expect(huntingdale.bays[1].mode).to.equal(TRANSIT_MODES.regionalCoach)
297
299
  })
300
+
301
+ it('Should not merge stops with the same name that are located far away from one another', async () => {
302
+ let database = new LokiDatabaseConnection('test-db')
303
+ let stops = await database.createCollection('stops')
304
+
305
+ await (new StopsLoader(generalStores, suburbs, TRANSIT_MODES.bus, database)).loadStops()
306
+
307
+ expect((await stops.findDocument({ 'bays.stopGTFSID': '17124' })).bays.length).to.equal(2) // Piangil
308
+ expect((await stops.findDocument({ 'bays.stopGTFSID': '17977' })).bays.length).to.equal(2) // Tempy
309
+ expect((await stops.findDocument({ 'bays.stopGTFSID': '43916' })).bays.length).to.equal(1) // Coronet Bay
310
+ })
298
311
  })
@@ -109,4 +109,31 @@ describe('The TripLoader class', () => {
109
109
 
110
110
  expect(shapeIDMap['2-ALM-vpt-1.1.R']).to.equal('2-ALM')
111
111
  })
112
+
113
+ it('Should return a mapping of Route + GTFS Direction ID to PTV Direction Names', async () => {
114
+ let database = new LokiDatabaseConnection('test-db')
115
+ let stops = await database.createCollection('stops')
116
+ let routes = await database.createCollection('routes')
117
+ let trips = await database.createCollection('gtfs timetables')
118
+
119
+ let stopLoader = new StopsLoader(stopsFile, suburbs, TRANSIT_MODES.metroTrain, database)
120
+ await stopLoader.loadStops()
121
+
122
+ let routeLoader = new RouteLoader(routesFile, agencyFile, TRANSIT_MODES.metroTrain, database)
123
+ await routeLoader.loadRoutes()
124
+
125
+ let routeIDMap = routeLoader.getRouteIDMap()
126
+
127
+ let tripLoader = new TripLoader({
128
+ tripsFile, stopTimesFile,
129
+ calendarFile, calendarDatesFile
130
+ }, TRANSIT_MODES.metroTrain, database)
131
+
132
+ await tripLoader.loadTrips({ routeIDMap })
133
+ let directionIDMap = tripLoader.getDirectionIDMap()
134
+
135
+ expect(directionIDMap).to.deep.equal({
136
+ '2-ALM': { 'Alamein': 0, 'Camberwell': 1 }
137
+ })
138
+ })
112
139
  })
@@ -0,0 +1,19 @@
1
+ stop_id,stop_name,stop_lat,stop_lon
2
+ "15117","General Store/Murray Valley Hwy (Torrumbarry)","-36.0289328143973","144.516565858212"
3
+ "17124","General Store/Murray St (Piangil)","-35.0542205869387","143.310581971833"
4
+ "17125","General Store/Murray St (Piangil)","-35.0538456443862","143.310697481574"
5
+ "17729","General Store/Macs St (Peterborough)","-38.6070683334915","142.87719698365"
6
+ "17730","General Store/Macs St (Peterborough)","-38.6070003726619","142.877568193123"
7
+ "17977","General Store/Sunraysia Hwy (Tempy)","-35.3453146606652","142.424802508117"
8
+ "17978","General Store/Sunraysia Hwy (Tempy)","-35.344983598941","142.424623331801"
9
+ "36974","General Store/Monash Ave (Nyah West)","-35.1852359469295","143.345799631341"
10
+ "37899","General Store/Princes Hwy (Johnsonville)","-37.8200787799472","147.831089593645"
11
+ "37901","General Store/Princes Hwy (Swan Reach)","-37.8219848899712","147.856891682107"
12
+ "37902","General Store/Princes Hwy (Swan Reach)","-37.822175385113","147.85672345214"
13
+ "37921","General Store/Main St (Bruthen)","-37.7082084114992","147.832470628437"
14
+ "37987","General Store/Phillip Island Rd (Surf Beach)","-38.5078845836624","145.29112542319"
15
+ "38000","General Store/Phillip Island Rd (Surf Beach)","-38.5077808366616","145.291426050202"
16
+ "42284","General Store/Ararat - St Arnaud Rd (Navarre)","-36.8998475986824","143.113535821369"
17
+ "43916","General Store/Champ Elysees Esp (Coronet Bay)","-38.4376225731191","145.436193608845"
18
+ "44217","General Store/Great Ocean Rd (Nullawarre)","-38.469533626788","142.749879594372"
19
+ "47879","General Store/Ararat-St Arnaud Rd (Navarre)","-36.8998967921621","143.113387501491"