@transportme/load-ptv-gtfs 1.3.11 → 1.4.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.
- package/lib/gtfs-parser/readers/line-reader.mjs +7 -1
- package/lib/loader/RouteLoader.mjs +1 -1
- package/lib/loader/ShapeLoader.mjs +1 -1
- package/lib/loader/StopsLoader.mjs +1 -1
- package/lib/loader/TripLoader.mjs +3 -3
- package/lib/post-processing/set-route-stops.mjs +7 -2
- package/package.json +1 -1
- package/test/gtfs-route-loader.test.mjs +8 -8
- package/test/gtfs-shapes-loader.test.mjs +6 -6
- package/test/gtfs-stop-loader.test.mjs +17 -17
- package/test/gtfs-trip-loader.test.mjs +12 -12
- package/test/line-reader.test.mjs +26 -0
- package/test/merge-stops-full.test.mjs +15 -3
- package/test/new-metro-loader-test.test.mjs +12 -12
- package/test/new-tram-format.test.mjs +2 -2
- package/test/newer-metro-loader-test.test.mjs +4 -4
- package/test/newer-tram-format.test.mjs +3 -3
- package/test/sample-data/merge/shapes.txt +3 -1
- package/test/sample-data/merge/stop_times.txt +7 -1
- package/test/sample-data/merge/trips.txt +2 -1
- package/test/sample-data/mtm-rail/stops.txt +4 -0
- package/test/sample-data/routes/metro_lines.txt +2 -1
|
@@ -58,7 +58,13 @@ export default class CSVLineReader {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
#setHeaders(line) {
|
|
61
|
-
let parts
|
|
61
|
+
let parts
|
|
62
|
+
if (line.includes('"')) {
|
|
63
|
+
parts = line.match(/"([^"]*)"/g).map(f => f.slice(1, -1))
|
|
64
|
+
} else {
|
|
65
|
+
parts = line.split(',')
|
|
66
|
+
}
|
|
67
|
+
|
|
62
68
|
return this.#headers.reduce((acc, header, i) => {
|
|
63
69
|
acc[header] = parts[i]
|
|
64
70
|
return acc
|
|
@@ -24,7 +24,7 @@ export default class RouteLoader {
|
|
|
24
24
|
* @param {DatabaseConnection} database A database connection
|
|
25
25
|
*/
|
|
26
26
|
constructor(routesFile, agencyFile, mode, database) {
|
|
27
|
-
this.#routes = database.getCollection('routes')
|
|
27
|
+
this.#routes = database.getCollection('gtfs-routes')
|
|
28
28
|
this.#mode = mode
|
|
29
29
|
this.#routesReader = new GTFSRouteReader(routesFile, mode)
|
|
30
30
|
this.#agencyFile = agencyFile
|
|
@@ -15,7 +15,7 @@ export default class ShapeLoader {
|
|
|
15
15
|
* @param {DatabaseConnection} database A database connection
|
|
16
16
|
*/
|
|
17
17
|
constructor(shapeFile, database) {
|
|
18
|
-
this.#routes = database.getCollection('routes')
|
|
18
|
+
this.#routes = database.getCollection('gtfs-routes')
|
|
19
19
|
this.#shapeReader = new GTFSShapeReader(shapeFile)
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -22,7 +22,7 @@ export default class StopsLoader {
|
|
|
22
22
|
* @param {function} [suburbHook] A hook that returns the stop's suburb, or null if unavailable. This function is called before processing from the stop's name or location
|
|
23
23
|
*/
|
|
24
24
|
constructor(stopsFile, suburbs, mode, database, suburbHook) {
|
|
25
|
-
this.#stops = database.getCollection('stops')
|
|
25
|
+
this.#stops = database.getCollection('gtfs-stops')
|
|
26
26
|
this.#mode = mode
|
|
27
27
|
this.#stopsReader = new GTFSStopsReader(stopsFile, suburbs, suburbHook)
|
|
28
28
|
}
|
|
@@ -44,9 +44,9 @@ export default class TripLoader {
|
|
|
44
44
|
* @param {DatabaseConnection} database A database connection
|
|
45
45
|
*/
|
|
46
46
|
constructor({ tripsFile, stopTimesFile, calendarFile, calendarDatesFile }, mode, database) {
|
|
47
|
-
this.#routes = database.getCollection('routes')
|
|
48
|
-
this.#stops = database.getCollection('stops')
|
|
49
|
-
this.#trips = database.getCollection('gtfs timetables')
|
|
47
|
+
this.#routes = database.getCollection('gtfs-routes')
|
|
48
|
+
this.#stops = database.getCollection('gtfs-stops')
|
|
49
|
+
this.#trips = database.getCollection('gtfs-gtfs timetables')
|
|
50
50
|
|
|
51
51
|
this.#mode = mode
|
|
52
52
|
|
|
@@ -9,8 +9,8 @@ import { TRANSIT_MODES } from '../constants.mjs'
|
|
|
9
9
|
* @param {DatabaseConnection} database The database connection to use
|
|
10
10
|
*/
|
|
11
11
|
export default async function setRouteStops(database, directionsMap, onMilestone = () => {}) {
|
|
12
|
-
let gtfsTimetables = database.getCollection('gtfs timetables')
|
|
13
|
-
let routes = database.getCollection('routes')
|
|
12
|
+
let gtfsTimetables = database.getCollection('gtfs-gtfs timetables')
|
|
13
|
+
let routes = database.getCollection('gtfs-routes')
|
|
14
14
|
|
|
15
15
|
let allRoutes = await routes.distinct('routeGTFSID')
|
|
16
16
|
|
|
@@ -73,6 +73,11 @@ export default async function setRouteStops(database, directionsMap, onMilestone
|
|
|
73
73
|
if (routeData.routeName === 'Stony Point') {
|
|
74
74
|
isUp = currentDir.includes('Frankston')
|
|
75
75
|
directionName = directionName.slice(0, -16)
|
|
76
|
+
} else if (routeData.routeName === 'City Circle') {
|
|
77
|
+
isUp = false
|
|
78
|
+
let directionStops = stopsByService[routeGTFSID][gtfsDirection]
|
|
79
|
+
let isClockwise = directionStops.stops[1].stopName === 'Southern Cross Railway Station'
|
|
80
|
+
directionName = `City Circle (${isClockwise ? 'Clockwise' : 'Anti-Clockwise'})`
|
|
76
81
|
} else {
|
|
77
82
|
directionName = isUp ? 'City' : routeData.routeName
|
|
78
83
|
}
|
package/package.json
CHANGED
|
@@ -37,7 +37,7 @@ describe('The GTFS Agency Reader', () => {
|
|
|
37
37
|
describe('The GTFS Routes Loader', () => {
|
|
38
38
|
it('Should process the routes and add them to the database', async () => {
|
|
39
39
|
let database = new LokiDatabaseConnection('test-db')
|
|
40
|
-
let routes = await database.createCollection('routes')
|
|
40
|
+
let routes = await database.createCollection('gtfs-routes')
|
|
41
41
|
|
|
42
42
|
let loader = new RouteLoader(regionalRoutesFile, agencyFile, TRANSIT_MODES.bus, database)
|
|
43
43
|
await loader.loadRoutes()
|
|
@@ -53,7 +53,7 @@ describe('The GTFS Routes Loader', () => {
|
|
|
53
53
|
|
|
54
54
|
it('Should open the agency.txt file and load all operators', async () => {
|
|
55
55
|
let database = new LokiDatabaseConnection('test-db')
|
|
56
|
-
await database.createCollection('routes')
|
|
56
|
+
await database.createCollection('gtfs-routes')
|
|
57
57
|
|
|
58
58
|
let loader = new RouteLoader(regionalRoutesFile, agencyFile, TRANSIT_MODES.bus, database)
|
|
59
59
|
await loader.loadAgencies()
|
|
@@ -66,7 +66,7 @@ describe('The GTFS Routes Loader', () => {
|
|
|
66
66
|
|
|
67
67
|
it('Should handle smartrak routes', async () => {
|
|
68
68
|
let database = new LokiDatabaseConnection('test-db')
|
|
69
|
-
let routes = await database.createCollection('routes')
|
|
69
|
+
let routes = await database.createCollection('gtfs-routes')
|
|
70
70
|
|
|
71
71
|
let loader = new RouteLoader(metroRoutesFile, agencyFile, TRANSIT_MODES.bus, database)
|
|
72
72
|
await loader.loadRoutes()
|
|
@@ -83,7 +83,7 @@ describe('The GTFS Routes Loader', () => {
|
|
|
83
83
|
|
|
84
84
|
it('Should handle metro train routes', async () => {
|
|
85
85
|
let database = new LokiDatabaseConnection('test-db')
|
|
86
|
-
let routes = await database.createCollection('routes')
|
|
86
|
+
let routes = await database.createCollection('gtfs-routes')
|
|
87
87
|
|
|
88
88
|
let loader = new RouteLoader(metroLinesFile, agencyFile, TRANSIT_MODES.metroTrain, database)
|
|
89
89
|
await loader.loadRoutes()
|
|
@@ -101,7 +101,7 @@ describe('The GTFS Routes Loader', () => {
|
|
|
101
101
|
|
|
102
102
|
it('Should allow for custom route rewriting', async () => {
|
|
103
103
|
let database = new LokiDatabaseConnection('test-db')
|
|
104
|
-
let routes = await database.createCollection('routes')
|
|
104
|
+
let routes = await database.createCollection('gtfs-routes')
|
|
105
105
|
|
|
106
106
|
let loader = new RouteLoader(wgtFile, agencyFile, TRANSIT_MODES.bus, database)
|
|
107
107
|
await loader.loadRoutes({
|
|
@@ -146,7 +146,7 @@ describe('The GTFS Routes Loader', () => {
|
|
|
146
146
|
|
|
147
147
|
it('Should return a route ID map', async () => {
|
|
148
148
|
let database = new LokiDatabaseConnection('test-db')
|
|
149
|
-
let routes = await database.createCollection('routes')
|
|
149
|
+
let routes = await database.createCollection('gtfs-routes')
|
|
150
150
|
|
|
151
151
|
let loader = new RouteLoader(wgtFile, agencyFile, TRANSIT_MODES.bus, database)
|
|
152
152
|
await loader.loadRoutes({
|
|
@@ -167,7 +167,7 @@ describe('The GTFS Routes Loader', () => {
|
|
|
167
167
|
|
|
168
168
|
it('Should allow for dropping of unwanted routes', async () => {
|
|
169
169
|
let database = new LokiDatabaseConnection('test-db')
|
|
170
|
-
let routes = await database.createCollection('routes')
|
|
170
|
+
let routes = await database.createCollection('gtfs-routes')
|
|
171
171
|
|
|
172
172
|
let loader = new RouteLoader(vlineFile, agencyFile, TRANSIT_MODES.regionalTrain, database)
|
|
173
173
|
await loader.loadRoutes({
|
|
@@ -193,7 +193,7 @@ describe('The GTFS Routes Loader', () => {
|
|
|
193
193
|
|
|
194
194
|
it('Should handle invalid agency references', async () => {
|
|
195
195
|
let database = new LokiDatabaseConnection('test-db')
|
|
196
|
-
let routes = await database.createCollection('routes')
|
|
196
|
+
let routes = await database.createCollection('gtfs-routes')
|
|
197
197
|
|
|
198
198
|
let loader = new RouteLoader(badRoutesFile_NoAgency, agencyFile, TRANSIT_MODES.bus, database)
|
|
199
199
|
await loader.loadRoutes()
|
|
@@ -26,9 +26,9 @@ const shapeFile = path.join(__dirname, 'sample-data', 'shapes', 'shapes.txt')
|
|
|
26
26
|
describe('The ShapeLoader class', () => {
|
|
27
27
|
it('Should process the shapes and append it to the route data', async () => {
|
|
28
28
|
let database = new LokiDatabaseConnection('test-db')
|
|
29
|
-
let stops = await database.createCollection('stops')
|
|
30
|
-
let routes = await database.createCollection('routes')
|
|
31
|
-
let trips = await database.createCollection('gtfs timetables')
|
|
29
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
30
|
+
let routes = await database.createCollection('gtfs-routes')
|
|
31
|
+
let trips = await database.createCollection('gtfs-gtfs timetables')
|
|
32
32
|
|
|
33
33
|
let stopLoader = new StopsLoader(stopsFile, suburbs, TRANSIT_MODES.metroBus, database)
|
|
34
34
|
await stopLoader.loadStops()
|
|
@@ -65,9 +65,9 @@ describe('The ShapeLoader class', () => {
|
|
|
65
65
|
|
|
66
66
|
it('Should merge duplicate shapes with the same length and start/end coordinates', async () => {
|
|
67
67
|
let database = new LokiDatabaseConnection('test-db')
|
|
68
|
-
let stops = await database.createCollection('stops')
|
|
69
|
-
let routes = await database.createCollection('routes')
|
|
70
|
-
let trips = await database.createCollection('gtfs timetables')
|
|
68
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
69
|
+
let routes = await database.createCollection('gtfs-routes')
|
|
70
|
+
let trips = await database.createCollection('gtfs-gtfs timetables')
|
|
71
71
|
|
|
72
72
|
let stopLoader = new StopsLoader(stopsFile, suburbs, TRANSIT_MODES.metroBus, database)
|
|
73
73
|
await stopLoader.loadStops()
|
|
@@ -32,7 +32,7 @@ const multiParentStopFile = path.join(__dirname, 'sample-data', 'parent-stop', '
|
|
|
32
32
|
describe('The GTFS Stops Loader', () => {
|
|
33
33
|
it('Should process the stops and add them to the database', async () => {
|
|
34
34
|
let database = new LokiDatabaseConnection('test-db')
|
|
35
|
-
let stops = await database.createCollection('stops')
|
|
35
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
36
36
|
|
|
37
37
|
let loader = new StopsLoader(stopsFile, suburbs, TRANSIT_MODES.bus, database)
|
|
38
38
|
await loader.loadStops()
|
|
@@ -46,7 +46,7 @@ describe('The GTFS Stops Loader', () => {
|
|
|
46
46
|
|
|
47
47
|
it('Should merge street-level stops matching with the exact same name', async () => {
|
|
48
48
|
let database = new LokiDatabaseConnection('test-db')
|
|
49
|
-
let stops = await database.createCollection('stops')
|
|
49
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
50
50
|
|
|
51
51
|
let loader = new StopsLoader(stopsFile, suburbs, TRANSIT_MODES.bus, database)
|
|
52
52
|
await loader.loadStops()
|
|
@@ -77,7 +77,7 @@ describe('The GTFS Stops Loader', () => {
|
|
|
77
77
|
|
|
78
78
|
it('Should merge non street stops, and keep the secondary stop name if they are the same', async () => {
|
|
79
79
|
let database = new LokiDatabaseConnection('test-db')
|
|
80
|
-
let stops = await database.createCollection('stops')
|
|
80
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
81
81
|
|
|
82
82
|
let loader = new StopsLoader(stopsFile, suburbs, TRANSIT_MODES.bus, database)
|
|
83
83
|
await loader.loadStops()
|
|
@@ -93,7 +93,7 @@ describe('The GTFS Stops Loader', () => {
|
|
|
93
93
|
|
|
94
94
|
it('Should merge non street stops, and discard the secondary stop name if they are different', async () => {
|
|
95
95
|
let database = new LokiDatabaseConnection('test-db')
|
|
96
|
-
let stops = await database.createCollection('stops')
|
|
96
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
97
97
|
|
|
98
98
|
let loader = new StopsLoader(stopsFile, suburbs, TRANSIT_MODES.bus, database)
|
|
99
99
|
await loader.loadStops()
|
|
@@ -109,7 +109,7 @@ describe('The GTFS Stops Loader', () => {
|
|
|
109
109
|
|
|
110
110
|
it('Should update the suburb list as well', async () => {
|
|
111
111
|
let database = new LokiDatabaseConnection('test-db')
|
|
112
|
-
let stops = await database.createCollection('stops')
|
|
112
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
113
113
|
|
|
114
114
|
let loader = new StopsLoader(stopsFile, suburbs, TRANSIT_MODES.bus, database)
|
|
115
115
|
await loader.loadStops()
|
|
@@ -126,7 +126,7 @@ describe('The GTFS Stops Loader', () => {
|
|
|
126
126
|
|
|
127
127
|
it('Should not merge stops that are forced to be unique and would otherwise be merged', async () => {
|
|
128
128
|
let database = new LokiDatabaseConnection('test-db')
|
|
129
|
-
let stops = await database.createCollection('stops')
|
|
129
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
130
130
|
|
|
131
131
|
function getMergeName(stop) {
|
|
132
132
|
if (uniqueStops.includes(stop.fullStopName)) return stop.fullStopName
|
|
@@ -162,7 +162,7 @@ describe('The GTFS Stops Loader', () => {
|
|
|
162
162
|
|
|
163
163
|
it('Should override stop names if required', async () => {
|
|
164
164
|
let database = new LokiDatabaseConnection('test-db')
|
|
165
|
-
let stops = await database.createCollection('stops')
|
|
165
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
166
166
|
|
|
167
167
|
await (new StopsLoader(stopNameOverrides, suburbs, TRANSIT_MODES.bus, database)).loadStops({
|
|
168
168
|
processStop: stop => {
|
|
@@ -185,7 +185,7 @@ describe('The GTFS Stops Loader', () => {
|
|
|
185
185
|
|
|
186
186
|
it('Should handle CSV blank spaces and other unicode junk', async () => {
|
|
187
187
|
let database = new LokiDatabaseConnection('test-db')
|
|
188
|
-
let stops = await database.createCollection('stops')
|
|
188
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
189
189
|
|
|
190
190
|
await (new StopsLoader(specialHeader, suburbs, TRANSIT_MODES.bus, database)).loadStops()
|
|
191
191
|
|
|
@@ -199,7 +199,7 @@ describe('The GTFS Stops Loader', () => {
|
|
|
199
199
|
|
|
200
200
|
it('Should allow for a custom suburb hook', async () => {
|
|
201
201
|
let database = new LokiDatabaseConnection('test-db')
|
|
202
|
-
let stops = await database.createCollection('stops')
|
|
202
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
203
203
|
|
|
204
204
|
let testSuburbs = ['A', 'B', 'C', null, 'D']
|
|
205
205
|
|
|
@@ -215,7 +215,7 @@ describe('The GTFS Stops Loader', () => {
|
|
|
215
215
|
|
|
216
216
|
it('Should allow for individual stops to be loaded in', async () => {
|
|
217
217
|
let database = new LokiDatabaseConnection('test-db')
|
|
218
|
-
let stops = await database.createCollection('stops')
|
|
218
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
219
219
|
|
|
220
220
|
let loader = new StopsLoader(specialHeader, suburbs, TRANSIT_MODES.bus, database)
|
|
221
221
|
let reader = new GTFSStopsReader('')
|
|
@@ -251,7 +251,7 @@ describe('The GTFS Stops Loader', () => {
|
|
|
251
251
|
|
|
252
252
|
it('Should not load duplicate stops with the same mode in', async () => {
|
|
253
253
|
let database = new LokiDatabaseConnection('test-db')
|
|
254
|
-
let stops = await database.createCollection('stops')
|
|
254
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
255
255
|
|
|
256
256
|
let loader = new StopsLoader(specialHeader, suburbs, TRANSIT_MODES.bus, database)
|
|
257
257
|
let reader = new GTFSStopsReader('')
|
|
@@ -284,7 +284,7 @@ describe('The GTFS Stops Loader', () => {
|
|
|
284
284
|
|
|
285
285
|
it('Should load duplicate stops with the different mode in', async () => {
|
|
286
286
|
let database = new LokiDatabaseConnection('test-db')
|
|
287
|
-
let stops = await database.createCollection('stops')
|
|
287
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
288
288
|
|
|
289
289
|
let busLoader = new StopsLoader(specialHeader, suburbs, TRANSIT_MODES.bus, database)
|
|
290
290
|
let coachLoader = new StopsLoader(specialHeader, suburbs, TRANSIT_MODES.regionalCoach, database)
|
|
@@ -321,7 +321,7 @@ describe('The GTFS Stops Loader', () => {
|
|
|
321
321
|
|
|
322
322
|
it('Should not merge stops with the same name that are located far away from one another', async () => {
|
|
323
323
|
let database = new LokiDatabaseConnection('test-db')
|
|
324
|
-
let stops = await database.createCollection('stops')
|
|
324
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
325
325
|
|
|
326
326
|
await (new StopsLoader(generalStores, suburbs, TRANSIT_MODES.bus, database)).loadStops()
|
|
327
327
|
|
|
@@ -332,7 +332,7 @@ describe('The GTFS Stops Loader', () => {
|
|
|
332
332
|
|
|
333
333
|
it('Should handle extra spaces within the stop name', async () => {
|
|
334
334
|
let database = new LokiDatabaseConnection('test-db')
|
|
335
|
-
let stops = await database.createCollection('stops')
|
|
335
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
336
336
|
|
|
337
337
|
await (new StopsLoader(unionWithSpaces, suburbs, TRANSIT_MODES.bus, database)).loadStops()
|
|
338
338
|
|
|
@@ -342,7 +342,7 @@ describe('The GTFS Stops Loader', () => {
|
|
|
342
342
|
|
|
343
343
|
it('Should merge stops into their designated parent stops even if the names do not match', async () => {
|
|
344
344
|
let database = new LokiDatabaseConnection('test-db')
|
|
345
|
-
let stops = await database.createCollection('stops')
|
|
345
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
346
346
|
|
|
347
347
|
await (new StopsLoader(parentStopsFile, suburbs, TRANSIT_MODES.metroTrain, database)).loadStops()
|
|
348
348
|
|
|
@@ -362,7 +362,7 @@ describe('The GTFS Stops Loader', () => {
|
|
|
362
362
|
|
|
363
363
|
it('Should handle the parent being part of a merged stop', async () => {
|
|
364
364
|
let database = new LokiDatabaseConnection('test-db')
|
|
365
|
-
let stops = await database.createCollection('stops')
|
|
365
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
366
366
|
|
|
367
367
|
await (new StopsLoader(multiParentStopFile, suburbs, TRANSIT_MODES.regionalCoach, database)).loadStops()
|
|
368
368
|
|
|
@@ -379,7 +379,7 @@ describe('The GTFS Stops Loader', () => {
|
|
|
379
379
|
|
|
380
380
|
it('Should use stop and station names and suburbs', async () => {
|
|
381
381
|
let database = new LokiDatabaseConnection('test-db')
|
|
382
|
-
let stops = await database.createCollection('stops')
|
|
382
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
383
383
|
|
|
384
384
|
let data = [{
|
|
385
385
|
"stop_id": "vic:rail:THL",
|
|
@@ -24,9 +24,9 @@ const tripsFile = path.join(__dirname, 'sample-data', 'trips', 'trips.txt')
|
|
|
24
24
|
describe('The TripLoader class', () => {
|
|
25
25
|
it('Should process the trip and add it to the database', async () => {
|
|
26
26
|
let database = new LokiDatabaseConnection('test-db')
|
|
27
|
-
let stops = await database.createCollection('stops')
|
|
28
|
-
let routes = await database.createCollection('routes')
|
|
29
|
-
let trips = await database.createCollection('gtfs timetables')
|
|
27
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
28
|
+
let routes = await database.createCollection('gtfs-routes')
|
|
29
|
+
let trips = await database.createCollection('gtfs-gtfs timetables')
|
|
30
30
|
|
|
31
31
|
let stopLoader = new StopsLoader(stopsFile, suburbs, TRANSIT_MODES.metroTrain, database)
|
|
32
32
|
await stopLoader.loadStops()
|
|
@@ -90,9 +90,9 @@ describe('The TripLoader class', () => {
|
|
|
90
90
|
|
|
91
91
|
it('It should return a mapping of Shape IDs to Route IDs', async () => {
|
|
92
92
|
let database = new LokiDatabaseConnection('test-db')
|
|
93
|
-
let stops = await database.createCollection('stops')
|
|
94
|
-
let routes = await database.createCollection('routes')
|
|
95
|
-
let trips = await database.createCollection('gtfs timetables')
|
|
93
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
94
|
+
let routes = await database.createCollection('gtfs-routes')
|
|
95
|
+
let trips = await database.createCollection('gtfs-gtfs timetables')
|
|
96
96
|
|
|
97
97
|
let stopLoader = new StopsLoader(stopsFile, suburbs, TRANSIT_MODES.metroTrain, database)
|
|
98
98
|
await stopLoader.loadStops()
|
|
@@ -115,9 +115,9 @@ describe('The TripLoader class', () => {
|
|
|
115
115
|
|
|
116
116
|
it('Should return a mapping of Route + GTFS Direction ID to PTV Direction Names', async () => {
|
|
117
117
|
let database = new LokiDatabaseConnection('test-db')
|
|
118
|
-
let stops = await database.createCollection('stops')
|
|
119
|
-
let routes = await database.createCollection('routes')
|
|
120
|
-
let trips = await database.createCollection('gtfs timetables')
|
|
118
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
119
|
+
let routes = await database.createCollection('gtfs-routes')
|
|
120
|
+
let trips = await database.createCollection('gtfs-gtfs timetables')
|
|
121
121
|
|
|
122
122
|
let stopLoader = new StopsLoader(stopsFile, suburbs, TRANSIT_MODES.metroTrain, database)
|
|
123
123
|
await stopLoader.loadStops()
|
|
@@ -142,9 +142,9 @@ describe('The TripLoader class', () => {
|
|
|
142
142
|
|
|
143
143
|
it('Should return a mapping stop services', async () => {
|
|
144
144
|
let database = new LokiDatabaseConnection('test-db')
|
|
145
|
-
let stops = await database.createCollection('stops')
|
|
146
|
-
let routes = await database.createCollection('routes')
|
|
147
|
-
let trips = await database.createCollection('gtfs timetables')
|
|
145
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
146
|
+
let routes = await database.createCollection('gtfs-routes')
|
|
147
|
+
let trips = await database.createCollection('gtfs-gtfs timetables')
|
|
148
148
|
|
|
149
149
|
let stopLoader = new StopsLoader(stopsFile, suburbs, TRANSIT_MODES.metroTrain, database)
|
|
150
150
|
await stopLoader.loadStops()
|
|
@@ -9,6 +9,8 @@ const __dirname = path.dirname(__filename)
|
|
|
9
9
|
const stopsFile = path.join(__dirname, 'sample-data', 'gtfs-splitting', 'line_reader_test.txt')
|
|
10
10
|
const oneLineFile = path.join(__dirname, 'sample-data', 'one_line.csv')
|
|
11
11
|
|
|
12
|
+
const noQuotesFile = path.join(__dirname, 'sample-data', 'mtm-rail', 'stops.txt')
|
|
13
|
+
|
|
12
14
|
describe('The CSVLineReader class', () => {
|
|
13
15
|
it('Should open a CSV file and identify the headers', async () => {
|
|
14
16
|
let reader = new CSVLineReader(stopsFile)
|
|
@@ -21,6 +23,30 @@ describe('The CSVLineReader class', () => {
|
|
|
21
23
|
await reader.close()
|
|
22
24
|
})
|
|
23
25
|
|
|
26
|
+
it('Can handle files that are not quoted', async () => {
|
|
27
|
+
let reader = new CSVLineReader(noQuotesFile)
|
|
28
|
+
await reader.open()
|
|
29
|
+
|
|
30
|
+
let line = await reader.nextLine()
|
|
31
|
+
expect(line).to.deep.equal({
|
|
32
|
+
stop_id: '77945',
|
|
33
|
+
stop_code: '',
|
|
34
|
+
stop_name: 'Alamein_Up',
|
|
35
|
+
stop_desc: '',
|
|
36
|
+
stop_lat: '-37.868383',
|
|
37
|
+
stop_lon: '145.079837',
|
|
38
|
+
zone_id: '',
|
|
39
|
+
stop_url: '',
|
|
40
|
+
location_type: '0',
|
|
41
|
+
parent_station: '',
|
|
42
|
+
stop_timezone: '',
|
|
43
|
+
wheelchair_boarding: '',
|
|
44
|
+
platform_code: '',
|
|
45
|
+
tts_stop_name: ''
|
|
46
|
+
})
|
|
47
|
+
await reader.close()
|
|
48
|
+
})
|
|
49
|
+
|
|
24
50
|
it('Should return the first line of the CSV, with the fields mapped to their headers', async () => {
|
|
25
51
|
let reader = new CSVLineReader(stopsFile)
|
|
26
52
|
await reader.open()
|
|
@@ -25,9 +25,9 @@ const tripsFile = path.join(__dirname, 'sample-data', 'merge', 'trips.txt')
|
|
|
25
25
|
const shapeFile = path.join(__dirname, 'sample-data', 'merge', 'shapes.txt')
|
|
26
26
|
|
|
27
27
|
let database = new LokiDatabaseConnection('test-db')
|
|
28
|
-
let stops = await database.createCollection('stops')
|
|
29
|
-
let routes = await database.createCollection('routes')
|
|
30
|
-
let trips = await database.createCollection('gtfs timetables')
|
|
28
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
29
|
+
let routes = await database.createCollection('gtfs-routes')
|
|
30
|
+
let trips = await database.createCollection('gtfs-gtfs timetables')
|
|
31
31
|
|
|
32
32
|
let stopLoader = new StopsLoader(stopsFile, suburbs, TRANSIT_MODES.metroTrain, database)
|
|
33
33
|
await stopLoader.loadStops()
|
|
@@ -97,6 +97,18 @@ describe('The GTFS Route stop merger', () => {
|
|
|
97
97
|
expect(stonyPoint.stops[stonyPoint.stops.length - 1].stopName).to.equal('Stony Point Railway Station')
|
|
98
98
|
})
|
|
99
99
|
|
|
100
|
+
it('Should set City Circle trips as Down', async () => {
|
|
101
|
+
let cityCircleRoute = await routes.findDocument({ routeGTFSID: '2-CCL' })
|
|
102
|
+
expect(cityCircleRoute).to.not.be.null
|
|
103
|
+
|
|
104
|
+
let direction = cityCircleRoute.directions.find(dir => dir.directionName === 'City Circle (Clockwise)')
|
|
105
|
+
expect(direction).to.not.be.undefined
|
|
106
|
+
expect(direction.trainDirection).to.equal('Down')
|
|
107
|
+
expect(direction.stops[0].stopName).to.equal('Flinders Street Railway Station')
|
|
108
|
+
expect(direction.stops[direction.stops.length - 2].stopName).to.equal('Parliament Railway Station')
|
|
109
|
+
expect(direction.stops[direction.stops.length - 1].stopName).to.equal('Flinders Street Railway Station')
|
|
110
|
+
})
|
|
111
|
+
|
|
100
112
|
it('Should mark the PTV Route direction', async () => {
|
|
101
113
|
let stonyPointRoute = await routes.findDocument({ routeGTFSID: '2-STY' })
|
|
102
114
|
expect(stonyPointRoute.ptvDirections['Stony Point']).to.equal(0)
|
|
@@ -30,7 +30,7 @@ describe('The GTFS Loaders with the new Metro data', () => {
|
|
|
30
30
|
describe('The stop loader', () => {
|
|
31
31
|
it('Should process the stops and add them to the database', async () => {
|
|
32
32
|
let database = new LokiDatabaseConnection('test-db')
|
|
33
|
-
let stops = await database.createCollection('stops')
|
|
33
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
34
34
|
|
|
35
35
|
let loader = new StopsLoader(simpleStopsFile, suburbs, TRANSIT_MODES.metroTrain, database)
|
|
36
36
|
await loader.loadStops()
|
|
@@ -44,7 +44,7 @@ describe('The GTFS Loaders with the new Metro data', () => {
|
|
|
44
44
|
|
|
45
45
|
it('Should label the individual platforms with their platform numbers', async () => {
|
|
46
46
|
let database = new LokiDatabaseConnection('test-db')
|
|
47
|
-
let stops = await database.createCollection('stops')
|
|
47
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
48
48
|
|
|
49
49
|
let loader = new StopsLoader(simpleStopsFile, suburbs, TRANSIT_MODES.metroTrain, database)
|
|
50
50
|
await loader.loadStops()
|
|
@@ -67,7 +67,7 @@ describe('The GTFS Loaders with the new Metro data', () => {
|
|
|
67
67
|
describe('The route loader', () => {
|
|
68
68
|
it('Should convert the updated route ID format to the legacy format', async () => {
|
|
69
69
|
let database = new LokiDatabaseConnection('test-db')
|
|
70
|
-
let routes = await database.createCollection('routes')
|
|
70
|
+
let routes = await database.createCollection('gtfs-routes')
|
|
71
71
|
|
|
72
72
|
let routeLoader = new RouteLoader(routesFile, agencyFile, TRANSIT_MODES.metroTrain, database)
|
|
73
73
|
await routeLoader.loadRoutes()
|
|
@@ -82,9 +82,9 @@ describe('The GTFS Loaders with the new Metro data', () => {
|
|
|
82
82
|
describe('The trip loader', () => {
|
|
83
83
|
it('It should accept trip IDs in the new format and extract the TDN from there', async () => {
|
|
84
84
|
let database = new LokiDatabaseConnection('test-db')
|
|
85
|
-
let stops = await database.createCollection('stops')
|
|
86
|
-
let routes = await database.createCollection('routes')
|
|
87
|
-
let trips = await database.createCollection('gtfs timetables')
|
|
85
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
86
|
+
let routes = await database.createCollection('gtfs-routes')
|
|
87
|
+
let trips = await database.createCollection('gtfs-gtfs timetables')
|
|
88
88
|
|
|
89
89
|
let stopLoader = new StopsLoader(stopsFile, suburbs, TRANSIT_MODES.metroTrain, database)
|
|
90
90
|
await stopLoader.loadStops()
|
|
@@ -131,9 +131,9 @@ describe('The GTFS Loaders with the new Metro data', () => {
|
|
|
131
131
|
|
|
132
132
|
it('It identify a rail replacement bus trip and mark it as such', async () => {
|
|
133
133
|
let database = new LokiDatabaseConnection('test-db')
|
|
134
|
-
let stops = await database.createCollection('stops')
|
|
135
|
-
let routes = await database.createCollection('routes')
|
|
136
|
-
let trips = await database.createCollection('gtfs timetables')
|
|
134
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
135
|
+
let routes = await database.createCollection('gtfs-routes')
|
|
136
|
+
let trips = await database.createCollection('gtfs-gtfs timetables')
|
|
137
137
|
|
|
138
138
|
let stopLoader = new StopsLoader(stopsFile, suburbs, TRANSIT_MODES.metroTrain, database)
|
|
139
139
|
await stopLoader.loadStops()
|
|
@@ -169,9 +169,9 @@ describe('The GTFS Loaders with the new Metro data', () => {
|
|
|
169
169
|
|
|
170
170
|
it('Should wrap times past midnight back to 00:00 NEXT DAY in the trip times', async () => {
|
|
171
171
|
let database = new LokiDatabaseConnection('test-db')
|
|
172
|
-
let stops = await database.createCollection('stops')
|
|
173
|
-
let routes = await database.createCollection('routes')
|
|
174
|
-
let trips = await database.createCollection('gtfs timetables')
|
|
172
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
173
|
+
let routes = await database.createCollection('gtfs-routes')
|
|
174
|
+
let trips = await database.createCollection('gtfs-gtfs timetables')
|
|
175
175
|
|
|
176
176
|
let stopLoader = new StopsLoader(stopsFile, suburbs, TRANSIT_MODES.metroTrain, database)
|
|
177
177
|
await stopLoader.loadStops()
|
|
@@ -19,7 +19,7 @@ describe('The GTFS Loaders with the new Tram data', () => {
|
|
|
19
19
|
describe('The stop loader', () => {
|
|
20
20
|
it('Should process the stops and add them to the database', async () => {
|
|
21
21
|
let database = new LokiDatabaseConnection('test-db')
|
|
22
|
-
let stops = await database.createCollection('stops')
|
|
22
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
23
23
|
|
|
24
24
|
let loader = new StopsLoader(stopsFile, suburbs, TRANSIT_MODES.tram, database)
|
|
25
25
|
await loader.loadStops()
|
|
@@ -35,7 +35,7 @@ describe('The GTFS Loaders with the new Tram data', () => {
|
|
|
35
35
|
describe('The route loader', () => {
|
|
36
36
|
it('Should convert the updated route ID format to the legacy format', async () => {
|
|
37
37
|
let database = new LokiDatabaseConnection('test-db')
|
|
38
|
-
let routes = await database.createCollection('routes')
|
|
38
|
+
let routes = await database.createCollection('gtfs-routes')
|
|
39
39
|
|
|
40
40
|
let routeLoader = new RouteLoader(routesFile, agencyFile, TRANSIT_MODES.tram, database)
|
|
41
41
|
await routeLoader.loadRoutes()
|
|
@@ -26,7 +26,7 @@ describe('The GTFS Loaders with the new 230525 Metro data', () => {
|
|
|
26
26
|
describe('The route loader', () => {
|
|
27
27
|
it('Should convert the updated route ID format to the legacy format', async () => {
|
|
28
28
|
let database = new LokiDatabaseConnection('test-db')
|
|
29
|
-
let routes = await database.createCollection('routes')
|
|
29
|
+
let routes = await database.createCollection('gtfs-routes')
|
|
30
30
|
|
|
31
31
|
let routeLoader = new RouteLoader(routesFile, agencyFile, TRANSIT_MODES.metroTrain, database)
|
|
32
32
|
await routeLoader.loadRoutes()
|
|
@@ -41,9 +41,9 @@ describe('The GTFS Loaders with the new 230525 Metro data', () => {
|
|
|
41
41
|
describe('The trip loader', () => {
|
|
42
42
|
it('It identify a rail replacement bus trip and mark it as such', async () => {
|
|
43
43
|
let database = new LokiDatabaseConnection('test-db')
|
|
44
|
-
let stops = await database.createCollection('stops')
|
|
45
|
-
let routes = await database.createCollection('routes')
|
|
46
|
-
let trips = await database.createCollection('gtfs timetables')
|
|
44
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
45
|
+
let routes = await database.createCollection('gtfs-routes')
|
|
46
|
+
let trips = await database.createCollection('gtfs-gtfs timetables')
|
|
47
47
|
|
|
48
48
|
let stopLoader = new StopsLoader(stopsFile, suburbs, TRANSIT_MODES.metroTrain, database)
|
|
49
49
|
await stopLoader.loadStops()
|
|
@@ -19,7 +19,7 @@ describe('The GTFS Loaders with the new Tram data', () => {
|
|
|
19
19
|
describe('The stop loader', () => {
|
|
20
20
|
it('Should process the stops and add them to the database', async () => {
|
|
21
21
|
let database = new LokiDatabaseConnection('test-db')
|
|
22
|
-
let stops = await database.createCollection('stops')
|
|
22
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
23
23
|
|
|
24
24
|
let loader = new StopsLoader(stopsFile, suburbs, TRANSIT_MODES.tram, database)
|
|
25
25
|
await loader.loadStops()
|
|
@@ -34,7 +34,7 @@ describe('The GTFS Loaders with the new Tram data', () => {
|
|
|
34
34
|
|
|
35
35
|
it('Should clean up extra spaces', async () => {
|
|
36
36
|
let database = new LokiDatabaseConnection('test-db')
|
|
37
|
-
let stops = await database.createCollection('stops')
|
|
37
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
38
38
|
|
|
39
39
|
let loader = new StopsLoader(stopsFile, suburbs, TRANSIT_MODES.tram, database)
|
|
40
40
|
await loader.loadStops()
|
|
@@ -50,7 +50,7 @@ describe('The GTFS Loaders with the new Tram data', () => {
|
|
|
50
50
|
|
|
51
51
|
it('Should remove half suburbs in the name', async () => {
|
|
52
52
|
let database = new LokiDatabaseConnection('test-db')
|
|
53
|
-
let stops = await database.createCollection('stops')
|
|
53
|
+
let stops = await database.createCollection('gtfs-stops')
|
|
54
54
|
|
|
55
55
|
let loader = new StopsLoader(stopsFile, suburbs, TRANSIT_MODES.tram, database)
|
|
56
56
|
await loader.loadStops()
|
|
@@ -1219,4 +1219,6 @@ shape_id,shape_pt_lat,shape_pt_lon,shape_pt_sequence,shape_dist_traveled
|
|
|
1219
1219
|
"2-STY-vpt-1.2.H","-38.3735310845842","145.218832701718","146","30453.97"
|
|
1220
1220
|
"2-STY-vpt-1.2.H","-38.3738969985651","145.219785272927","147","30546.45"
|
|
1221
1221
|
"2-STY-vpt-1.2.H","-38.3742189306907","145.221402857812","148","30691.93"
|
|
1222
|
-
"2-STY-vpt-1.2.H","-38.3742345364979","145.221837462187","149","30729.86"
|
|
1222
|
+
"2-STY-vpt-1.2.H","-38.3742345364979","145.221837462187","149","30729.86"
|
|
1223
|
+
"2-CCL-vpt-38.5.H","-37.81853876","144.96484870","1","0.00"
|
|
1224
|
+
"2-CCL-vpt-38.5.H","-37.81922050","144.96266539","2","206.22"
|
|
@@ -94,4 +94,10 @@ trip_id,arrival_time,departure_time,stop_id,stop_sequence,stop_headsign,pickup_t
|
|
|
94
94
|
"02-STY--12-T5-8501","14:33:00","14:33:00","19830","7","","0","0","24765.17"
|
|
95
95
|
"02-STY--12-T5-8501","14:36:00","14:36:00","19829","8","","0","0","27053.40"
|
|
96
96
|
"02-STY--12-T5-8501","14:39:00","14:39:00","19828","9","","0","0","28905.48"
|
|
97
|
-
"02-STY--12-T5-8501","14:43:00","14:43:00","19827","10","","0","0","30729.86"
|
|
97
|
+
"02-STY--12-T5-8501","14:43:00","14:43:00","19827","10","","0","0","30729.86"
|
|
98
|
+
"02-CCL--38-T5_cw-0837","23:51:00","23:51:00","19854","1","","0","0","0.00"
|
|
99
|
+
"02-CCL--38-T5_cw-0837","23:54:00","23:54:00","22180","2","","0","0","1363.56"
|
|
100
|
+
"02-CCL--38-T5_cw-0837","23:56:00","23:56:00","19841","3","","0","0","2443.56"
|
|
101
|
+
"02-CCL--38-T5_cw-0837","23:58:00","23:58:00","19842","4","","0","0","3052.86"
|
|
102
|
+
"02-CCL--38-T5_cw-0837","24:00:00","24:00:00","19843","5","","0","0","4168.05"
|
|
103
|
+
"02-CCL--38-T5_cw-0837","24:03:00","24:03:00","19854","6","","0","0","5603.97"
|
|
@@ -3,4 +3,5 @@ route_id,service_id,trip_id,shape_id,trip_headsign,direction_id,block_id
|
|
|
3
3
|
"aus:vic:vic-02-PKM:","T2_2","02-PKM--12-T5-C001","2-PKM-vpt-1.3.H","East Pakenham","0","10867"
|
|
4
4
|
"aus:vic:vic-02-PKM:","T2_2","02-PKM--12-T5-C002","2-PKM-vpt-1.12.R","Flinders Street","1",""
|
|
5
5
|
"aus:vic:vic-02-STY:","T2_2","02-STY--12-T5-8500","2-STY-vpt-1.1.R","Frankston","1",""
|
|
6
|
-
"aus:vic:vic-02-STY:","T2_2","02-STY--12-T5-8501","2-STY-vpt-1.2.H","Stony Point","0",""
|
|
6
|
+
"aus:vic:vic-02-STY:","T2_2","02-STY--12-T5-8501","2-STY-vpt-1.2.H","Stony Point","0",""
|
|
7
|
+
"aus:vic:vic-02-CCL:","T2_2","02-CCL--38-T5_cw-0837","2-CCL-vpt-38.5.H","Flinders Street via City Loop","0",""
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
stop_id,stop_code,stop_name,stop_desc,stop_lat,stop_lon,zone_id,stop_url,location_type,parent_station,stop_timezone,wheelchair_boarding,platform_code,tts_stop_name
|
|
2
|
+
77945,,Alamein_Up,,-37.868383,145.079837,,,0,,,,,
|
|
3
|
+
77949,,Ashburton_Up,,-37.862461,145.081537,,,0,,,,,
|
|
4
|
+
77972,,Burwood_Up,,-37.851461,145.081497,,,0,,,,,
|
|
@@ -4,4 +4,5 @@ route_id,agency_id,route_short_name,route_long_name,route_type,route_color,route
|
|
|
4
4
|
"aus:vic:vic-02-RCE:","3","Flemington Racecourse","City","2","95979A","000000"
|
|
5
5
|
"aus:vic:vic-02-STY:","3","Stony Point","Stony Point - Frankston","2","028430","FFFFFF"
|
|
6
6
|
"aus:vic:vic-02-PKM:","3","Pakenham","Pakenham - City","2","279FD5","000000"
|
|
7
|
-
"aus:vic:vic-02-PKM:","3","Pakenham","Pakenham - City","2","279FD5","000000"
|
|
7
|
+
"aus:vic:vic-02-PKM:","3","Pakenham","Pakenham - City","2","279FD5","000000"
|
|
8
|
+
"aus:vic:vic-02-CCL:","","City Circle","","2","0072CE","FFFFFF"
|