@transportme/load-ptv-gtfs 1.2.1 → 1.2.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.
|
@@ -2,6 +2,7 @@ import GTFSRouteReader from '../gtfs-parser/readers/GTFSRouteReader.mjs'
|
|
|
2
2
|
import GTFSAgencyReader from '../gtfs-parser/readers/GTFSAgencyReader.mjs'
|
|
3
3
|
import { STOP_UTILS } from '@transportme/transportvic-utils'
|
|
4
4
|
import GTFSRoute from '../gtfs-parser/GTFSRoute.mjs'
|
|
5
|
+
import GTFSAgency from '../gtfs-parser/GTFSAgency.mjs'
|
|
5
6
|
|
|
6
7
|
const { sanitiseName } = STOP_UTILS
|
|
7
8
|
|
|
@@ -109,7 +110,9 @@ export default class RouteLoader {
|
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
getOperator(id) {
|
|
112
|
-
|
|
113
|
+
let operator = this.#operators[id]
|
|
114
|
+
if (operator) return operator
|
|
115
|
+
return GTFSAgency.UNKNOWN_AGENCY
|
|
113
116
|
}
|
|
114
117
|
|
|
115
118
|
getRouteIDMap() {
|
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@ import { TRANSIT_MODES } from '../lib/constants.mjs'
|
|
|
7
7
|
import path from 'path'
|
|
8
8
|
import url from 'url'
|
|
9
9
|
import { expect } from 'chai'
|
|
10
|
+
import GTFSAgency from '../lib/gtfs-parser/GTFSAgency.mjs'
|
|
10
11
|
|
|
11
12
|
const __filename = url.fileURLToPath(import.meta.url)
|
|
12
13
|
const __dirname = path.dirname(__filename)
|
|
@@ -18,6 +19,8 @@ const agencyFile = path.join(__dirname, 'sample-data', 'routes', 'agency.txt')
|
|
|
18
19
|
const wgtFile = path.join(__dirname, 'sample-data', 'routes', 'west_gipp_transit.txt')
|
|
19
20
|
const vlineFile = path.join(__dirname, 'sample-data', 'routes', 'vline.txt')
|
|
20
21
|
|
|
22
|
+
const badRoutesFile_NoAgency = path.join(__dirname, 'sample-data', 'routes', 'bad_routes.txt')
|
|
23
|
+
|
|
21
24
|
describe('The GTFS Agency Reader', () => {
|
|
22
25
|
it('Should read the agencies one line at a time', async () => {
|
|
23
26
|
let reader = new GTFSAgencyReader(agencyFile)
|
|
@@ -187,4 +190,19 @@ describe('The GTFS Routes Loader', () => {
|
|
|
187
190
|
expect(traralgon.routeName).to.equal('Traralgon - Melbourne Via Pakenham, Moe & Morwell')
|
|
188
191
|
expect(traralgon.operators).to.have.members(['V/Line'])
|
|
189
192
|
})
|
|
193
|
+
|
|
194
|
+
it('Should handle invalid agency references', async () => {
|
|
195
|
+
let database = new LokiDatabaseConnection('test-db')
|
|
196
|
+
let routes = await database.createCollection('routes')
|
|
197
|
+
|
|
198
|
+
let loader = new RouteLoader(badRoutesFile_NoAgency, agencyFile, TRANSIT_MODES.bus, database)
|
|
199
|
+
await loader.loadRoutes()
|
|
200
|
+
|
|
201
|
+
let skybus = await routes.findDocument({
|
|
202
|
+
routeGTFSID: '11-SKY'
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
expect(skybus).to.not.be.null
|
|
206
|
+
expect(skybus.operators).to.deep.equal([GTFSAgency.UNKNOWN_AGENCY.name])
|
|
207
|
+
})
|
|
190
208
|
})
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
route_id,agency_id,route_short_name,route_long_name,route_type,route_color,route_text_color
|
|
2
|
+
"11-SK4-mjp-1","","","Frankston - Melbourne Airport","3","ED1C24","FFFFFF"
|
|
3
|
+
"11-Ska-mjp-1","","","Melbourne City - Avalon Airport","3","ED1C24","FFFFFF"
|
|
4
|
+
"11-SKY-mjp-1","","","City - Melbourne Airport","3","ED1C24","FFFFFF"
|