Exclude unknown data from realtime
This commit is contained in:
parent
76a187bbb6
commit
f054b11743
|
@ -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))
|
||||
|
|
|
@ -71,12 +71,6 @@ const updateFromTam = async (courses) =>
|
|||
|
||||
for (let [id, course] of Object.entries(currentCourses))
|
||||
{
|
||||
// Only track selected lines
|
||||
if (!['1', '2', '3', '4'].includes(course.line))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Find out the next stop, ignoring the ones that are in the past
|
||||
let nextStop = null;
|
||||
let arrivalTime = null;
|
||||
|
|
Loading…
Reference in New Issue