Compare commits

...

3 Commits

3 changed files with 42 additions and 22 deletions

View File

@ -407,15 +407,10 @@ different sequence of nodes in two or more lines.`);
for (let i = 1; i < points.length; ++i) for (let i = 1; i < points.length; ++i)
{ {
const len = geolib.getPreciseDistance( points[i].distance = geolib.getPreciseDistance(
...[points[i - 1], points[i]] points[i - 1],
.map(({lat, lon}) => ({ points[i],
latitude: lat, ) + points[i - 1].distance;
longitude: lon
})),
);
points[i].distance = points[i - 1].distance + len;
} }
} }

View File

@ -972,6 +972,14 @@
"2" "2"
] ]
}, },
"42265": {
"lat": 43.5719919,
"lon": 3.8444363,
"name": "La Condamine",
"lines": [
"2"
]
},
"42267": { "42267": {
"lat": 43.5708971, "lat": 43.5708971,
"lon": 3.837919, "lon": 3.837919,
@ -1613,7 +1621,7 @@
"42257", "42257",
"42259", "42259",
"42263", "42263",
"42105", "42265",
"42267", "42267",
"42269" "42269"
] ]
@ -6885,6 +6893,11 @@
"lon": 3.8441514, "lon": 3.8441514,
"distance": 530 "distance": 530
}, },
{
"lat": 43.5719919,
"lon": 3.8444363,
"distance": 557
},
{ {
"lat": 43.5719919, "lat": 43.5719919,
"lon": 3.8444363, "lon": 3.8444363,
@ -14751,7 +14764,7 @@
"2" "2"
] ]
}, },
"42263-42105": { "42263-42265": {
"points": [ "points": [
{ {
"lat": 43.5751577, "lat": 43.5751577,
@ -14808,6 +14821,11 @@
"lon": 3.8453333, "lon": 3.8453333,
"distance": 469 "distance": 469
}, },
{
"lat": 43.5719919,
"lon": 3.8444363,
"distance": 557
},
{ {
"lat": 43.5719919, "lat": 43.5719919,
"lon": 3.8444363, "lon": 3.8444363,
@ -14818,7 +14836,7 @@
"2" "2"
] ]
}, },
"42105-42267": { "42265-42267": {
"points": [ "points": [
{ {
"lat": 43.5719919, "lat": 43.5719919,

View File

@ -1,19 +1,26 @@
const tam = require('./sources/tam'); const tam = require('./sources/tam');
const util = require('../util'); const util = require('../util');
/**
* Fetch real-time information about courses in the TaM network.
*
* New data will only be fetched from the TaM server if necessary, otherwise
* pulling from the in-memory cache.
*
* @return Mapping from active course IDs to current information about the
* course, including its line number, next stop and next stop estimated
* time of arrival (ETA).
*/
let nextUpdate = null; let nextUpdate = null;
let currentCourses = null; let currentCourses = null;
/**
* Fetch real-time information about active courses in the TaM network.
*
* New data will only be fetched from the TaM server once every minute,
* otherwise pulling from the in-memory cache.
*
* The following information is provided for each active course:
*
* - `id`: Unique identifier for the course.
* - `line`: Line number.
* - `nextStop`: Identifier of the next stop of the course.
* - `arrivalTime`: Timestamp at which the vehicle is predicted to arrive
* to the next stop.
* - `finalStop`: The final stop to which the course is headed.
*
* @return Mapping from active course IDs to information about each course.
*/
const getCourses = () => new Promise((res, rej) => const getCourses = () => new Promise((res, rej) =>
{ {
if (nextUpdate !== null && Date.now() < nextUpdate) if (nextUpdate !== null && Date.now() < nextUpdate)