@transportme/load-ptv-gtfs 1.4.3 → 1.4.4
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.
|
@@ -21,10 +21,12 @@ export default class RouteLoader {
|
|
|
21
21
|
*
|
|
22
22
|
* @param {string} routesFile The path for the routes.txt file
|
|
23
23
|
* @param {string} agencyFile The path for the agency.txt file
|
|
24
|
+
* @param {string} mode The route's mode
|
|
24
25
|
* @param {DatabaseConnection} database A database connection
|
|
26
|
+
* @param {string} collectionName The collection to store the routes in. Defaults to gtfs-routes
|
|
25
27
|
*/
|
|
26
|
-
constructor(routesFile, agencyFile, mode, database) {
|
|
27
|
-
this.#routes = database.getCollection(
|
|
28
|
+
constructor(routesFile, agencyFile, mode, database, collectionName = 'gtfs-routes') {
|
|
29
|
+
this.#routes = database.getCollection(collectionName)
|
|
28
30
|
this.#mode = mode
|
|
29
31
|
this.#routesReader = new GTFSRouteReader(routesFile, mode)
|
|
30
32
|
this.#agencyFile = agencyFile
|
|
@@ -13,9 +13,10 @@ 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
|
|
16
17
|
*/
|
|
17
|
-
constructor(shapeFile, database) {
|
|
18
|
-
this.#routes = database.getCollection(
|
|
18
|
+
constructor(shapeFile, database, collectionName = 'gtfs-routes') {
|
|
19
|
+
this.#routes = database.getCollection(collectionName)
|
|
19
20
|
this.#shapeReader = new GTFSShapeReader(shapeFile)
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -20,9 +20,11 @@ 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
|
-
constructor(stopsFile, suburbs, mode, database, suburbHook) {
|
|
25
|
-
this.#stops = database.getCollection(
|
|
26
|
+
constructor(stopsFile, suburbs, mode, database, suburbHook, collectionName = 'gtfs-stops') {
|
|
27
|
+
this.#stops = database.getCollection(collectionName)
|
|
26
28
|
this.#mode = mode
|
|
27
29
|
this.#stopsReader = new GTFSStopsReader(stopsFile, suburbs, suburbHook)
|
|
28
30
|
}
|
|
@@ -42,11 +42,19 @@ 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
|
|
45
49
|
*/
|
|
46
|
-
constructor({ tripsFile, stopTimesFile, calendarFile, calendarDatesFile }, mode, database
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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)
|
|
50
58
|
|
|
51
59
|
this.#mode = mode
|
|
52
60
|
|
|
@@ -7,10 +7,19 @@ import { TRANSIT_MODES } from '../constants.mjs'
|
|
|
7
7
|
* Loads route stop data into the database. This is generated based off the timetable data.
|
|
8
8
|
*
|
|
9
9
|
* @param {DatabaseConnection} database The database connection to use
|
|
10
|
+
* @param {Object} directionsMap Used to store PTV API direction data
|
|
11
|
+
* @param {function} onMilestone Called for every 25 routes processed
|
|
12
|
+
* @param {Object} colls Used to specify the collection names to write into
|
|
13
|
+
* @param {string} colls.routeColl The collection to store the routes in. Defaults to gtfs-routes
|
|
14
|
+
* @param {string} colls.stopColl The collection to store the stops in. Defaults to gtfs-stops
|
|
15
|
+
* @param {string} colls.timetableColl The collection to store the timetables in. Defaults to gtfs-gtfs timetables
|
|
10
16
|
*/
|
|
11
|
-
export default async function setRouteStops(database, directionsMap, onMilestone = () => {}
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
export default async function setRouteStops(database, directionsMap, onMilestone = () => {}, {
|
|
18
|
+
routeColl = 'gtfs-routes',
|
|
19
|
+
timetableColl = 'gtfs-gtfs timetables'
|
|
20
|
+
} = {}) {
|
|
21
|
+
let gtfsTimetables = database.getCollection(timetableColl)
|
|
22
|
+
let routes = database.getCollection(routeColl)
|
|
14
23
|
|
|
15
24
|
let allRoutes = await routes.distinct('routeGTFSID')
|
|
16
25
|
|