2019-10-20 00:19:11 +02:00
|
|
|
// todo: what is m.dirGeo? maybe the speed?
|
|
|
|
// todo: what is m.stopL?
|
|
|
|
// todo: what is m.proc? wut?
|
|
|
|
// todo: what is m.pos?
|
|
|
|
// todo: what is m.ani.dirGeo[n]? maybe the speed?
|
|
|
|
// todo: what is m.ani.proc[n]? wut?
|
|
|
|
const parseMovement = (ctx, m) => { // m = raw movement
|
2024-02-06 22:58:49 +01:00
|
|
|
const {profile, opt} = ctx;
|
2017-11-11 23:56:09 +01:00
|
|
|
|
2019-10-20 00:19:11 +02:00
|
|
|
const res = {
|
2024-02-06 22:58:49 +01:00
|
|
|
direction: m.dirTxt
|
|
|
|
? profile.parseStationName(ctx, m.dirTxt)
|
|
|
|
: null,
|
2019-10-20 00:19:11 +02:00
|
|
|
tripId: m.jid || null,
|
|
|
|
line: m.line || null,
|
2024-02-06 22:58:49 +01:00
|
|
|
location: m.pos
|
|
|
|
? {
|
|
|
|
type: 'location',
|
|
|
|
latitude: m.pos.y / 1000000,
|
|
|
|
longitude: m.pos.x / 1000000,
|
|
|
|
}
|
|
|
|
: null,
|
2019-10-20 00:19:11 +02:00
|
|
|
// todo: stopL[0] is the first of the trip! -> filter out
|
2024-02-06 22:58:49 +01:00
|
|
|
nextStopovers:
|
2020-05-22 16:08:50 +02:00
|
|
|
m.stopL
|
2024-02-06 22:58:49 +01:00
|
|
|
.filter(s => Boolean(s.location))
|
|
|
|
.map(s => profile.parseStopover(ctx, s, m.date)),
|
|
|
|
frames: [],
|
|
|
|
};
|
2017-11-11 22:35:41 +01:00
|
|
|
|
2019-10-20 00:19:11 +02:00
|
|
|
if (m.ani) {
|
2021-01-26 22:12:09 +01:00
|
|
|
// todo: ani.dirGeo, ani.fLocX, ani.proc, ani.procAbs, ani.state, ani.stcOutputX
|
|
|
|
|
2019-10-20 00:19:11 +02:00
|
|
|
if (Array.isArray(m.ani.mSec)) {
|
|
|
|
for (let i = 0; i < m.ani.mSec.length; i++) {
|
|
|
|
res.frames.push({
|
|
|
|
origin: m.ani.fromLocations[i] || null,
|
|
|
|
destination: m.ani.toLocations[i] || null,
|
2024-02-06 22:58:49 +01:00
|
|
|
t: m.ani.mSec[i],
|
|
|
|
});
|
2018-05-15 19:39:28 +02:00
|
|
|
}
|
2019-10-20 00:19:11 +02:00
|
|
|
}
|
2018-05-15 19:39:28 +02:00
|
|
|
|
2019-10-20 00:19:11 +02:00
|
|
|
if (opt.polylines) {
|
|
|
|
if (m.ani.poly) {
|
2024-02-06 22:58:49 +01:00
|
|
|
res.polyline = profile.parsePolyline(ctx, m.ani.poly);
|
2019-10-20 00:19:11 +02:00
|
|
|
} else if (m.ani.polyline) {
|
2024-02-06 22:58:49 +01:00
|
|
|
res.polyline = m.ani.polyline;
|
2017-11-11 22:35:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-20 00:19:11 +02:00
|
|
|
|
2024-02-06 22:58:49 +01:00
|
|
|
return res;
|
|
|
|
};
|
2017-11-11 22:35:41 +01:00
|
|
|
|
2022-05-07 16:17:37 +02:00
|
|
|
export {
|
|
|
|
parseMovement,
|
2024-02-06 22:58:49 +01:00
|
|
|
};
|