Skip to content

Commit

Permalink
Merge pull request #138 from linkedconnections/development
Browse files Browse the repository at this point in the history
v2.1.5
  • Loading branch information
julianrojas87 committed Nov 13, 2022
2 parents 4f5f2a4 + 49dce62 commit ecd0d22
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/gtfs2connections.js
Original file line number Diff line number Diff line change
Expand Up @@ -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...');
Expand Down
16 changes: 8 additions & 8 deletions lib/stores/StoreManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit ecd0d22

Please sign in to comment.