Browse Source

Exclude unknown data from realtime

main
Mattéo Delabre 4 years ago
parent
commit
f054b11743
Signed by: matteo GPG Key ID: AE3FBD02DC583ABB
  1. 23
      src/tam/realtime.js
  2. 6
      src/tam/simulation.js

23
src/tam/realtime.js

@ -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))

6
src/tam/simulation.js

@ -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…
Cancel
Save