db-vendo-client/parse/stopover.js

63 lines
1.7 KiB
JavaScript
Raw Normal View History

2024-12-07 16:16:31 +00:00
import {parseRemarks, isStopCancelled} from './remarks.js';
const parseStopover = (ctx, st, date) => { // st = raw stopover
const {profile, opt} = ctx;
2024-12-07 16:16:31 +00:00
const cancelled = isStopCancelled(st);
const arr = profile.parseWhen(ctx, date, st.ankunftsZeitpunkt, st.ezAnkunftsZeitpunkt, cancelled);
const arrPl = profile.parsePlatform(ctx, st.gleis, st.ezGleis);
const dep = profile.parseWhen(ctx, date, st.abfahrtsZeitpunkt, st.ezAbfahrtsZeitpunkt, cancelled);
const depPl = profile.parsePlatform(ctx, st.gleis, st.ezGleis);
const res = {
stop: st.location || null,
arrival: arr.when,
plannedArrival: arr.plannedWhen,
arrivalDelay: arr.delay,
arrivalPlatform: arrPl.platform,
2024-12-07 16:16:31 +00:00
arrivalPrognosisType: null, // TODO
plannedArrivalPlatform: arrPl.plannedPlatform,
departure: dep.when,
plannedDeparture: dep.plannedWhen,
departureDelay: dep.delay,
departurePlatform: depPl.platform,
2024-12-07 16:16:31 +00:00
departurePrognosisType: null, // TODO
plannedDeparturePlatform: depPl.plannedPlatform,
};
2017-11-11 22:35:41 +01:00
if (arr.prognosedWhen) {
res.prognosedArrival = arr.prognosedWhen;
}
if (arrPl.prognosedPlatform) {
res.prognosedArrivalPlatform = arrPl.prognosedPlatform;
}
if (dep.prognosedWhen) {
res.prognosedDeparture = dep.prognosedWhen;
}
if (depPl.prognosedPlatform) {
res.prognosedDeparturePlatform = depPl.prognosedPlatform;
}
2024-12-07 16:16:31 +00:00
res.loadFactor = profile.parseLoadFactor(opt, st.auslastungsmeldungen);
// mark stations the train passes without stopping
2024-12-07 16:16:31 +00:00
// TODO risNotizen key text.realtime.stop.exit.disabled?
2024-12-07 16:16:31 +00:00
if (cancelled) {
res.cancelled = true;
Object.defineProperty(res, 'canceled', {value: true});
}
2024-12-07 16:16:31 +00:00
// TODO res.additional = true;
2024-12-07 16:16:31 +00:00
if (opt.remarks) {
res.remarks = parseRemarks(ctx, st);
}
return res;
};
2017-11-11 22:35:41 +01:00
2022-05-07 16:17:37 +02:00
export {
parseStopover,
};