|
|
@ -1,5 +1,6 @@ |
|
|
|
const tam = require('./sources/tam'); |
|
|
|
const util = require('../util'); |
|
|
|
const network = require('./network.json'); |
|
|
|
|
|
|
|
/** |
|
|
|
* Comparison function between two stop passings. |
|
|
@ -57,6 +58,28 @@ const getCourses = () => new Promise((res, rej) => |
|
|
|
|
|
|
|
if (!util.isObject(entry)) |
|
|
|
{ |
|
|
|
// Filter courses to only keep those referring to known data
|
|
|
|
for (let courseId of Object.keys(courses)) |
|
|
|
{ |
|
|
|
const course = courses[courseId]; |
|
|
|
|
|
|
|
if (!(course.line in network.lines)) |
|
|
|
{ |
|
|
|
delete courses[courseId]; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
for (let passing of course.nextPassings) |
|
|
|
{ |
|
|
|
if (!(passing.stopId in network.stops)) |
|
|
|
{ |
|
|
|
delete courses[courseId]; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// End of courses information stream. Sort next stops by increasing
|
|
|
|
// arrival time in each course then save result in memory cache
|
|
|
|
for (let course of Object.values(courses)) |
|
|
|