2024-02-06 22:58:49 +01:00
|
|
|
import {findRemarks} from './find-remarks.js';
|
2018-06-11 11:29:32 +02:00
|
|
|
|
2019-10-20 00:19:11 +02:00
|
|
|
const parseStopover = (ctx, st, date) => { // st = raw stopover
|
2024-02-06 22:58:49 +01:00
|
|
|
const {profile, opt} = ctx;
|
2019-10-20 00:19:11 +02:00
|
|
|
|
2024-02-06 22:58:49 +01:00
|
|
|
const arr = profile.parseWhen(ctx, date, st.aTimeS, st.aTimeR, st.aTZOffset, st.aCncl);
|
|
|
|
const arrPl = profile.parsePlatform(ctx, st.aPlatfS || st.aPltfS && st.aPltfS.txt || null, st.aPlatfR || st.aPltfR && st.aPltfR.txt || null, st.aCncl);
|
|
|
|
const dep = profile.parseWhen(ctx, date, st.dTimeS, st.dTimeR, st.dTZOffset, st.dCncl);
|
|
|
|
const depPl = profile.parsePlatform(ctx, st.dPlatfS || st.dPltfS && st.dPltfS.txt || null, st.dPlatfR || st.dPltfR && st.dPltfR.txt || null, st.dCncl);
|
2019-10-20 00:19:11 +02:00
|
|
|
|
|
|
|
const res = {
|
|
|
|
stop: st.location || null,
|
|
|
|
arrival: arr.when,
|
|
|
|
plannedArrival: arr.plannedWhen,
|
|
|
|
arrivalDelay: arr.delay,
|
|
|
|
arrivalPlatform: arrPl.platform,
|
2022-07-22 00:24:47 +02:00
|
|
|
arrivalPrognosisType: profile.parsePrognosisType(ctx, st.aProgType),
|
2019-10-20 00:19:11 +02:00
|
|
|
plannedArrivalPlatform: arrPl.plannedPlatform,
|
|
|
|
departure: dep.when,
|
|
|
|
plannedDeparture: dep.plannedWhen,
|
|
|
|
departureDelay: dep.delay,
|
|
|
|
departurePlatform: depPl.platform,
|
2022-07-22 00:24:47 +02:00
|
|
|
departurePrognosisType: profile.parsePrognosisType(ctx, st.dProgType),
|
2024-02-06 22:58:49 +01:00
|
|
|
plannedDeparturePlatform: depPl.plannedPlatform,
|
|
|
|
};
|
2017-11-11 22:35:41 +01:00
|
|
|
|
2024-02-06 22:58:49 +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;
|
|
|
|
}
|
2019-10-20 00:19:11 +02:00
|
|
|
|
|
|
|
// mark stations the train passes without stopping
|
2024-02-06 22:58:49 +01:00
|
|
|
if (st.dInS === false && st.aOutS === false) {
|
|
|
|
res.passBy = true;
|
|
|
|
}
|
2019-10-20 00:19:11 +02:00
|
|
|
|
|
|
|
if (st.aCncl || st.dCncl) {
|
2024-02-06 22:58:49 +01:00
|
|
|
res.cancelled = true;
|
|
|
|
Object.defineProperty(res, 'canceled', {value: true});
|
2019-10-20 00:19:11 +02:00
|
|
|
}
|
|
|
|
|
2024-02-06 22:58:49 +01:00
|
|
|
if (st.isAdd) {
|
|
|
|
res.additional = true;
|
|
|
|
}
|
2023-11-25 16:58:31 +01:00
|
|
|
|
2019-10-20 00:19:11 +02:00
|
|
|
if (opt.remarks && Array.isArray(st.msgL)) {
|
2024-02-06 22:58:49 +01:00
|
|
|
res.remarks = findRemarks(st.msgL)
|
|
|
|
.map(([remark]) => remark);
|
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 {
|
|
|
|
parseStopover,
|
2024-02-06 22:58:49 +01:00
|
|
|
};
|