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)
{
const len = geolib.getPreciseDistance(
...[points[i - 1], points[i]]
.map(({lat, lon}) => ({
latitude: lat,
longitude: lon
})),
);
points[i].distance = points[i - 1].distance + len;
points[i].distance = geolib.getPreciseDistance(
points[i - 1],
points[i],
) + points[i - 1].distance;
}
}

View File

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

View File

@ -1,19 +1,26 @@
const tam = require('./sources/tam');
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 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) =>
{
if (nextUpdate !== null && Date.now() < nextUpdate)