@transportme/load-ptv-gtfs 1.1.4 → 1.1.6

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.
@@ -95,6 +95,10 @@ export default class StopsLoader {
95
95
  stop.codedSuburbs = stop.cleanSuburbs
96
96
  }
97
97
 
98
+ updateStopLocation(stop) {
99
+ stop.location.coordinates = stop.bays.map(bay => bay.location.coordinates)
100
+ }
101
+
98
102
  async mergeStops(matchingStop, stopData) {
99
103
  let newBay = stopData.bays[0]
100
104
  let hasIdenticalBay = matchingStop.bays.some(bay =>
@@ -107,6 +111,7 @@ export default class StopsLoader {
107
111
 
108
112
  this.updateStopSuburb(matchingStop)
109
113
  this.updateStopName(matchingStop)
114
+ this.updateStopLocation(matchingStop)
110
115
 
111
116
  await this.#stops.replaceDocument({
112
117
  _id: matchingStop._id
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transportme/load-ptv-gtfs",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
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
 
@@ -61,6 +63,11 @@ describe('The GTFS Stops Loader', () => {
61
63
  expect(wavWarrigal).to.not.be.null
62
64
  expect(wavWarrigal.stopName).to.equal('Waverley Road/Warrigal Road')
63
65
  expect(wavWarrigal.bays.length).to.equal(2)
66
+
67
+ expect(wavWarrigal.location.coordinates).to.deep.equal([
68
+ [145.091009789504, -37.879427459666],
69
+ [145.090653754117, -37.8795658733597]
70
+ ])
64
71
  })
65
72
 
66
73
  it('Should merge non street stops, and keep the secondary stop name if they are the same', async () => {
@@ -290,4 +297,15 @@ describe('The GTFS Stops Loader', () => {
290
297
  expect(huntingdale.bays[1].stopGTFSID).to.equal('51586')
291
298
  expect(huntingdale.bays[1].mode).to.equal(TRANSIT_MODES.regionalCoach)
292
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
+ })
293
311
  })
@@ -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"