mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
leg.alternatives: parse direction & delay
This commit is contained in:
parent
4b56f6608c
commit
8fac5fc0e0
1 changed files with 17 additions and 4 deletions
|
@ -130,12 +130,25 @@ const createParseJourneyLeg = (profile, opt, data) => {
|
||||||
|
|
||||||
if (freq.jnyL) {
|
if (freq.jnyL) {
|
||||||
const parseAlternative = (a) => {
|
const parseAlternative = (a) => {
|
||||||
const t = a.stopL[0].dTimeR || a.stopL[0].dTimeS
|
// todo: parse this just like a `leg` (breaking)
|
||||||
const when = profile.parseDateTime(profile, j.date, t)
|
// todo: parse `a.stopL`, `a.ctxRecon`, `a.msgL`
|
||||||
// todo: expose a.stopL[0]
|
const st0 = a.stopL[0]
|
||||||
|
|
||||||
|
let when = null, delay = null
|
||||||
|
if (st0) {
|
||||||
|
const planned = st0.dTimeS && profile.parseDateTime(profile, j.date, st0.dTimeS)
|
||||||
|
if (st0.dTimeR && planned) {
|
||||||
|
const realtime = profile.parseDateTime(profile, j.date, st0.dTimeR)
|
||||||
|
when = realtime.toISO()
|
||||||
|
delay = Math.round((realtime - planned) / 1000)
|
||||||
|
} else if (planned) when = planned.toISO()
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
tripId: a.jid,
|
||||||
line: lines[parseInt(a.prodX)] || null,
|
line: lines[parseInt(a.prodX)] || null,
|
||||||
when: when.toISO()
|
direction: a.dirTxt || null,
|
||||||
|
when, delay
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res.alternatives = freq.jnyL.map(parseAlternative)
|
res.alternatives = freq.jnyL.map(parseAlternative)
|
||||||
|
|
Loading…
Add table
Reference in a new issue