@transportme/load-ptv-gtfs 1.4.8 → 1.4.10
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/GTFSRouteReader.mjs +5 -1
- package/lib/gtfs-parser/readers/GTFSStopsReader.mjs +9 -1
- package/lib/gtfs-parser/readers/GTFSTripReader.mjs +23 -3
- package/lib/loader/RouteLoader.mjs +6 -3
- package/lib/loader/ShapeLoader.mjs +6 -3
- package/lib/loader/StopsLoader.mjs +6 -3
- package/lib/loader/TripLoader.mjs +16 -12
- package/package.json +1 -1
|
@@ -11,6 +11,10 @@ export default class GTFSRouteReader extends GTFSReader {
|
|
|
11
11
|
this.#mode = mode
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
getMode() {
|
|
15
|
+
return this.#mode
|
|
16
|
+
}
|
|
17
|
+
|
|
14
18
|
/**
|
|
15
19
|
* Converts a CSV row into a route object
|
|
16
20
|
*
|
|
@@ -30,6 +34,6 @@ export default class GTFSRouteReader extends GTFSReader {
|
|
|
30
34
|
routeName: data.route_long_name
|
|
31
35
|
}
|
|
32
36
|
|
|
33
|
-
return GTFSRoute.create(routeData, this
|
|
37
|
+
return GTFSRoute.create(routeData, this.getMode())
|
|
34
38
|
}
|
|
35
39
|
}
|
|
@@ -12,6 +12,14 @@ export default class GTFSStopsReader extends GTFSReader {
|
|
|
12
12
|
this.#suburbHook = suburbHook
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
getSuburbData() {
|
|
16
|
+
return this.#suburbData
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getSuburbHook() {
|
|
20
|
+
return this.#suburbHook
|
|
21
|
+
}
|
|
22
|
+
|
|
15
23
|
/**
|
|
16
24
|
* Converts a CSV row into a stop object
|
|
17
25
|
*
|
|
@@ -35,6 +43,6 @@ export default class GTFSStopsReader extends GTFSReader {
|
|
|
35
43
|
parentStopGTFSID: data.parent_station
|
|
36
44
|
}
|
|
37
45
|
|
|
38
|
-
return GTFSStop.create(stopData, this
|
|
46
|
+
return GTFSStop.create(stopData, this.getSuburbData(), this.getSuburbHook())
|
|
39
47
|
}
|
|
40
48
|
}
|
|
@@ -13,6 +13,10 @@ export default class GTFSTripReader extends GTFSReader {
|
|
|
13
13
|
this.#routeMappings = routeMappings
|
|
14
14
|
this.#mode = mode
|
|
15
15
|
}
|
|
16
|
+
|
|
17
|
+
getMode() {
|
|
18
|
+
return this.#mode
|
|
19
|
+
}
|
|
16
20
|
|
|
17
21
|
/**
|
|
18
22
|
* Sets the route ID mappings of the trip reader.
|
|
@@ -31,6 +35,22 @@ export default class GTFSTripReader extends GTFSReader {
|
|
|
31
35
|
this.#calendars = calendars
|
|
32
36
|
}
|
|
33
37
|
|
|
38
|
+
getRouteMappings() {
|
|
39
|
+
return this.#routeMappings
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
getCalendars() {
|
|
43
|
+
return this.#calendars
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
getRouteMapping(routeGTFSID) {
|
|
47
|
+
return this.getRouteMappings()[routeGTFSID]
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
getCalendar(calendarID) {
|
|
51
|
+
return this.getCalendars()[calendarID]
|
|
52
|
+
}
|
|
53
|
+
|
|
34
54
|
/**
|
|
35
55
|
* Converts a CSV row into a trip object
|
|
36
56
|
*
|
|
@@ -47,8 +67,8 @@ export default class GTFSTripReader extends GTFSReader {
|
|
|
47
67
|
*/
|
|
48
68
|
processEntity(data) {
|
|
49
69
|
let tripData = {
|
|
50
|
-
routeGTFSID: this
|
|
51
|
-
calendar: this
|
|
70
|
+
routeGTFSID: this.getRouteMapping(data.route_id),
|
|
71
|
+
calendar: this.getCalendar(data.service_id),
|
|
52
72
|
id: data.trip_id,
|
|
53
73
|
shapeID: data.shape_id,
|
|
54
74
|
headsign: data.trip_headsign,
|
|
@@ -56,6 +76,6 @@ export default class GTFSTripReader extends GTFSReader {
|
|
|
56
76
|
block: data.block_id
|
|
57
77
|
}
|
|
58
78
|
|
|
59
|
-
return GTFSTrip.create(tripData, this
|
|
79
|
+
return GTFSTrip.create(tripData, this.getMode())
|
|
60
80
|
}
|
|
61
81
|
}
|
|
@@ -23,15 +23,18 @@ export default class RouteLoader {
|
|
|
23
23
|
* @param {string} agencyFile The path for the agency.txt file
|
|
24
24
|
* @param {string} mode The route's mode
|
|
25
25
|
* @param {DatabaseConnection} database A database connection
|
|
26
|
-
* @param {string} collectionName The collection to store the routes in. Defaults to gtfs-routes
|
|
27
26
|
*/
|
|
28
|
-
constructor(routesFile, agencyFile, mode, database
|
|
29
|
-
this.#routes =
|
|
27
|
+
constructor(routesFile, agencyFile, mode, database) {
|
|
28
|
+
this.#routes = this.getRoutesDB(database)
|
|
30
29
|
this.#mode = mode
|
|
31
30
|
this.#routesReader = this.createRouteReader(routesFile, mode)
|
|
32
31
|
this.#agencyFile = agencyFile
|
|
33
32
|
}
|
|
34
33
|
|
|
34
|
+
getRoutesDB(db) {
|
|
35
|
+
return db.getCollection('gtfs-routes')
|
|
36
|
+
}
|
|
37
|
+
|
|
35
38
|
createRouteReader(routesFile, mode) {
|
|
36
39
|
return new GTFSRouteReader(routesFile, mode)
|
|
37
40
|
}
|
|
@@ -13,13 +13,16 @@ export default class ShapeLoader {
|
|
|
13
13
|
*
|
|
14
14
|
* @param {string} shapeFile The path for the shapes.txt file
|
|
15
15
|
* @param {DatabaseConnection} database A database connection
|
|
16
|
-
* @param {string} collectionName The collection to store the routes in. Defaults to gtfs-routes
|
|
17
16
|
*/
|
|
18
|
-
constructor(shapeFile, database
|
|
19
|
-
this.#routes =
|
|
17
|
+
constructor(shapeFile, database) {
|
|
18
|
+
this.#routes = this.getRoutesDB(database)
|
|
20
19
|
this.#shapeReader = this.createShapeReader(shapeFile)
|
|
21
20
|
}
|
|
22
21
|
|
|
22
|
+
getRoutesDB(db) {
|
|
23
|
+
return db.getCollection('gtfs-routes')
|
|
24
|
+
}
|
|
25
|
+
|
|
23
26
|
createShapeReader(shapeFile) {
|
|
24
27
|
return new GTFSShapeReader(shapeFile)
|
|
25
28
|
}
|
|
@@ -20,15 +20,18 @@ export default class StopsLoader {
|
|
|
20
20
|
* @param {string} mode The transit mode being loaded
|
|
21
21
|
* @param {DatabaseConnection} database A database connection
|
|
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
|
-
* @param {string} collectionName The collection to store the stops in. Defaults to gtfs-stops
|
|
24
23
|
*
|
|
25
24
|
*/
|
|
26
|
-
constructor(stopsFile, suburbs, mode, database, suburbHook
|
|
27
|
-
this.#stops =
|
|
25
|
+
constructor(stopsFile, suburbs, mode, database, suburbHook) {
|
|
26
|
+
this.#stops = this.getStopsDB(database)
|
|
28
27
|
this.#mode = mode
|
|
29
28
|
this.#stopsReader = this.createStopReader(stopsFile, suburbs, suburbHook)
|
|
30
29
|
}
|
|
31
30
|
|
|
31
|
+
getStopsDB(db) {
|
|
32
|
+
return db.getCollection('gtfs-stops')
|
|
33
|
+
}
|
|
34
|
+
|
|
32
35
|
createStopReader(stopsFile, suburbs, suburbHook) {
|
|
33
36
|
return new GTFSStopsReader(stopsFile, suburbs, suburbHook)
|
|
34
37
|
}
|
|
@@ -42,19 +42,11 @@ export default class TripLoader {
|
|
|
42
42
|
* @param {string} paths.calendarDatesFile The path for the calendar_dates.txt file
|
|
43
43
|
* @param {string} mode The transit mode being loaded
|
|
44
44
|
* @param {DatabaseConnection} database A database connection
|
|
45
|
-
* @param {Object} colls Used to specify the collection names to write into
|
|
46
|
-
* @param {string} colls.routeColl The collection to store the routes in. Defaults to gtfs-routes
|
|
47
|
-
* @param {string} colls.stopColl The collection to store the stops in. Defaults to gtfs-stops
|
|
48
|
-
* @param {string} colls.timetableColl The collection to store the timetables in. Defaults to gtfs-gtfs timetables
|
|
49
45
|
*/
|
|
50
|
-
constructor({ tripsFile, stopTimesFile, calendarFile, calendarDatesFile }, mode, database
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
} = {}) {
|
|
55
|
-
this.#routes = database.getCollection(routeColl)
|
|
56
|
-
this.#stops = database.getCollection(stopColl)
|
|
57
|
-
this.#trips = database.getCollection(timetableColl)
|
|
46
|
+
constructor({ tripsFile, stopTimesFile, calendarFile, calendarDatesFile }, mode, database) {
|
|
47
|
+
this.#routes = this.getRoutesDB(database)
|
|
48
|
+
this.#stops = this.getStopsDB(database)
|
|
49
|
+
this.#trips = this.getTripsDB(database)
|
|
58
50
|
|
|
59
51
|
this.#mode = mode
|
|
60
52
|
|
|
@@ -63,6 +55,18 @@ export default class TripLoader {
|
|
|
63
55
|
this.#calendarReader = this.createCalendarReader(calendarFile, calendarDatesFile)
|
|
64
56
|
}
|
|
65
57
|
|
|
58
|
+
getRoutesDB(db) {
|
|
59
|
+
return db.getCollection('gtfs-routes')
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
getStopsDB(db) {
|
|
63
|
+
return db.getCollection('gtfs-stops')
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
getTripsDB(db) {
|
|
67
|
+
return db.getCollection('gtfs-gtfs timetables')
|
|
68
|
+
}
|
|
69
|
+
|
|
66
70
|
createStopTimesReader(stopTimesFile, mode) {
|
|
67
71
|
return new GTFSStopTimesReader(stopTimesFile, mode)
|
|
68
72
|
}
|