diff --git a/lib/gtfs2connections.js b/lib/gtfs2connections.js index 2147aad..8224d84 100644 --- a/lib/gtfs2connections.js +++ b/lib/gtfs2connections.js @@ -47,7 +47,7 @@ Mapper.prototype.resultStream = async function (path, output, done) { // Step 2: Read all the required GTFS files and create reusable indexes console.error('Creating index stores...'); - const stores = await StoreManager(output, this._options.store); + const stores = await StoreManager(path, output, this._options.store); // Step 3: Produce (diff) connection rules based on available CPU cores console.error('Creating Connection rules...'); diff --git a/lib/stores/StoreManager.js b/lib/stores/StoreManager.js index 82ece91..02bf79a 100644 --- a/lib/stores/StoreManager.js +++ b/lib/stores/StoreManager.js @@ -3,21 +3,21 @@ const csv = require('fast-csv'); const Store = require('./Store'); const CalendarExpander = require('../services/CalendarExpander'); -module.exports = async function (outPath, storeType) { +module.exports = async function (sourcePath, outPath, storeType) { // Step 2: Read all the required GTFS files in a stream-fashion - const stops = fs.createReadStream(`${outPath}/stops.txt`, { encoding: 'utf8', objectMode: true }) + const stops = fs.createReadStream(`${sourcePath}/stops.txt`, { encoding: 'utf8', objectMode: true }) .pipe(csv.parse({ objectMode: true, headers: true })) .on('error', function (e) { console.error(e); }); - const routes = fs.createReadStream(`${outPath}/routes.txt`, { encoding: 'utf8', objectMode: true }) + const routes = fs.createReadStream(`${sourcePath}/routes.txt`, { encoding: 'utf8', objectMode: true }) .pipe(csv.parse({ objectMode: true, headers: true })) .on('error', function (e) { console.error(e); }); - const trips = fs.createReadStream(`${outPath}/trips.txt`, { encoding: 'utf8', objectMode: true }) + const trips = fs.createReadStream(`${sourcePath}/trips.txt`, { encoding: 'utf8', objectMode: true }) .pipe(csv.parse({ objectMode: true, headers: true })) .on('error', function (e) { console.error(e); @@ -48,17 +48,17 @@ module.exports = async function (outPath, storeType) { encoding: 'json', key: 'trip_id', }), - loadServiceDates(outPath, storeType) + loadServiceDates(sourcePath, outPath, storeType) ]); return { stopsDB, routesDB, tripsDB, servicesDB }; } -async function loadServiceDates(outPath, storeType) { +async function loadServiceDates(sourcePath, outPath, storeType) { // Load all calendar_dates in memory store const calendarDates = new Map(); - const calendarDatesStream = fs.createReadStream(`${outPath}/calendar_dates.txt`, { encoding: 'utf8', objectMode: true }) + const calendarDatesStream = fs.createReadStream(`${sourcePath}/calendar_dates.txt`, { encoding: 'utf8', objectMode: true }) .pipe(csv.parse({ objectMode: true, headers: true })) .on('error', function (e) { console.error(e); @@ -78,7 +78,7 @@ async function loadServiceDates(outPath, storeType) { } // Load and merge all expanded service dates in data store. - const calendar = fs.createReadStream(`${outPath}/calendar.txt`, { encoding: 'utf8', objectMode: true }) + const calendar = fs.createReadStream(`${sourcePath}/calendar.txt`, { encoding: 'utf8', objectMode: true }) .pipe(csv.parse({ objectMode: true, headers: true })) .pipe(new CalendarExpander(calendarDates)) .on('error', function (e) { diff --git a/package-lock.json b/package-lock.json index d73c811..a545053 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "gtfs2lc", - "version": "2.1.4", + "version": "2.1.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "gtfs2lc", - "version": "2.1.4", + "version": "2.1.5", "license": "MIT", "dependencies": { "commander": "^4.1.1", diff --git a/package.json b/package.json index b81bfe9..1876a94 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gtfs2lc", - "version": "2.1.4", + "version": "2.1.5", "description": "Mapping script from gtfs to (linked) connections", "main": "lib/gtfs2lc.js", "bin": {