@transportme/load-ptv-gtfs 1.4.9 → 1.4.11

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.
@@ -57,7 +57,7 @@ export default class GTFSRoute {
57
57
  */
58
58
  static create(data, mode) {
59
59
  let { routeGTFSID } = data
60
- let routeTypes = [ RailGTFSRoute, NewGTFSRoute, SmartrakGTFSRoute, MTMRailRoute, GTFSRoute ]
60
+ let routeTypes = [ RailGTFSRoute, NewGTFSRoute, SmartrakGTFSRoute, GTFSRoute ]
61
61
  for (let type of routeTypes) {
62
62
  if (type.canProcess(routeGTFSID, mode)) return new type(data)
63
63
  }
@@ -121,22 +121,4 @@ class RailGTFSRoute extends NewGTFSRoute {
121
121
  return super.canProcess(routeGTFSID, mode) && (mode === TRANSIT_MODES.metroTrain || mode === TRANSIT_MODES.regionalTrain)
122
122
  }
123
123
 
124
- }
125
-
126
- class MTMRailRoute extends GTFSRoute {
127
-
128
- constructor(data) {
129
- super(data)
130
- this.routeName = 'Rail Replacement Bus'
131
- this.routeNumber = null
132
- }
133
-
134
- static canProcess(routeGTFSID, mode) {
135
- return !routeGTFSID.match(/^\d+-\w{1,3}/) && mode === 'metro train'
136
- }
137
-
138
- parseRouteID(routeGTFSID) {
139
- return '2-RRB'
140
- }
141
-
142
124
  }
@@ -50,7 +50,7 @@ export default class GTFSTrip {
50
50
  * @returns {GTFSTrip} A trip instance representing the data being passed in
51
51
  */
52
52
  static create(data, mode) {
53
- let types = [ SmartrakTrip, MetroTrip, MTMRailTrip, GTFSTrip ]
53
+ let types = [ SmartrakTrip, MetroTrip, GTFSTrip ]
54
54
  for (let type of types) {
55
55
  if (type.canProcess(data, mode)) return new type(data)
56
56
  }
@@ -183,38 +183,4 @@ export class MetroTrip extends GTFSTrip {
183
183
  return this.#runID
184
184
  }
185
185
 
186
- }
187
-
188
- export class MetroRRBTrip extends MetroTrip {
189
-
190
- constructor(data) {
191
- super(data)
192
- }
193
-
194
- static canProcess(data, mode) {
195
- return super.canProcess(data, mode) && data.id.match(/^02-\w{3}-R-/)
196
- }
197
-
198
- }
199
-
200
- export class MTMRailTrip extends GTFSTrip {
201
-
202
- constructor(data) {
203
- if (data.headsign && data.headsign.length === 6 && data.headsign.match(/[A-Z]{3}\d{3}/)) {
204
- data.block = data.headsign
205
- }
206
-
207
- super(data)
208
- }
209
-
210
- static canProcess(data, mode) {
211
- return mode === TRANSIT_MODES.metroTrain && data.routeGTFSID === '2-RRB'
212
- }
213
-
214
- getTripData() {
215
- return {
216
- ...super.getTripData(),
217
- isRailReplacementBus: true
218
- }
219
- }
220
186
  }
@@ -35,5 +35,5 @@ export default class GTFSRouteReader extends GTFSReader {
35
35
  }
36
36
 
37
37
  return GTFSRoute.create(routeData, this.getMode())
38
- }
38
+ }
39
39
  }
@@ -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, collectionName = 'gtfs-routes') {
29
- this.#routes = database.getCollection(collectionName)
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, collectionName = 'gtfs-routes') {
19
- this.#routes = database.getCollection(collectionName)
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, collectionName = 'gtfs-stops') {
27
- this.#stops = database.getCollection(collectionName)
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
- routeColl = 'gtfs-routes',
52
- stopColl = 'gtfs-stops',
53
- timetableColl = 'gtfs-gtfs timetables'
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transportme/load-ptv-gtfs",
3
- "version": "1.4.9",
3
+ "version": "1.4.11",
4
4
  "description": "",
5
5
  "main": "index.mjs",
6
6
  "scripts": {