mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 23:29:35 +02:00
journey leg passed stations: parse & expose delays
backporting 21c273c
to master
This commit is contained in:
parent
92310ebdab
commit
49186ae2d1
3 changed files with 23 additions and 1 deletions
|
@ -30,6 +30,8 @@ const createParseDeparture = (profile, stations, lines, remarks) => {
|
|||
res.delay = Math.round((realtime - planned) / 1000)
|
||||
} else res.delay = null
|
||||
|
||||
// todo: DRY with parseStopover
|
||||
// todo: DRY with parseJourneyLeg
|
||||
if (d.stbStop.aCncl || d.stbStop.dCncl) {
|
||||
res.cancelled = true
|
||||
Object.defineProperty(res, 'canceled', {value: true})
|
||||
|
|
|
@ -23,6 +23,8 @@ const createParseJourneyLeg = (profile, stations, lines, remarks, polylines) =>
|
|||
arrival: arr.toISO()
|
||||
}
|
||||
|
||||
// todo: DRY with parseDeparture
|
||||
// todo: DRY with parseStopover
|
||||
if (pt.dep.dTimeR && pt.dep.dTimeS) {
|
||||
const realtime = profile.parseDateTime(profile, j.date, pt.dep.dTimeR)
|
||||
const planned = profile.parseDateTime(profile, j.date, pt.dep.dTimeS)
|
||||
|
|
|
@ -5,16 +5,34 @@
|
|||
const createParseStopover = (profile, stations, lines, remarks, date) => {
|
||||
const parseStopover = (st) => {
|
||||
const res = {
|
||||
station: stations[parseInt(st.locX)] || null
|
||||
station: stations[parseInt(st.locX)] || null,
|
||||
arrival: null,
|
||||
arrivalDelay: null,
|
||||
departure: null,
|
||||
departureDelay: null
|
||||
}
|
||||
|
||||
// todo: DRY with parseDeparture
|
||||
// todo: DRY with parseJourneyLeg
|
||||
if (st.aTimeR || st.aTimeS) {
|
||||
const arr = profile.parseDateTime(profile, date, st.aTimeR || st.aTimeS)
|
||||
res.arrival = arr.toISO()
|
||||
}
|
||||
if (st.aTimeR && st.aTimeS) {
|
||||
const realtime = profile.parseDateTime(profile, date, st.aTimeR)
|
||||
const planned = profile.parseDateTime(profile, date, st.aTimeS)
|
||||
res.arrivalDelay = Math.round((realtime - planned) / 1000)
|
||||
}
|
||||
|
||||
if (st.dTimeR || st.dTimeS) {
|
||||
const dep = profile.parseDateTime(profile, date, st.dTimeR || st.dTimeS)
|
||||
res.departure = dep.toISO()
|
||||
}
|
||||
if (st.dTimeR && st.dTimeS) {
|
||||
const realtime = profile.parseDateTime(profile, date, st.dTimeR)
|
||||
const planned = profile.parseDateTime(profile, date, st.dTimeS)
|
||||
res.departureDelay = Math.round((realtime - planned) / 1000)
|
||||
}
|
||||
|
||||
// mark stations the train passes without stopping
|
||||
if(st.dInS === false && st.aOutS === false) res.passBy = true
|
||||
|
|
Loading…
Add table
Reference in a new issue