From 26124949701cc448caa831164b13a72bd9bd88c0 Mon Sep 17 00:00:00 2001 From: Leo Maroni Date: Sat, 1 Aug 2020 16:51:42 +0200 Subject: [PATCH] =?UTF-8?q?fix=20platform=20parsing=20with=20some=20profil?= =?UTF-8?q?es=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #187 --- parse/arrival-or-departure.js | 4 ++-- parse/journey-leg.js | 5 ++--- parse/stopover.js | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/parse/arrival-or-departure.js b/parse/arrival-or-departure.js index 6da0c078..945ffb01 100644 --- a/parse/arrival-or-departure.js +++ b/parse/arrival-or-departure.js @@ -19,8 +19,8 @@ const createParseArrOrDep = (prefix) => { const tPrognosed = d.stbStop[prefix + 'TimeR'] const tzOffset = d.stbStop[prefix + 'TZOffset'] || null const cancelled = !!d.stbStop[prefix + 'Cncl'] - const plPlanned = d.stbStop[prefix + 'PlatfS'] - const plPrognosed = d.stbStop[prefix + 'PlatfR'] + const plPlanned = d.stbStop[prefix + 'PlatfS'] || (d.stbStop[prefix + 'PltfS'] && d.stbStop[prefix + 'PltfS'].txt) || null + const plPrognosed = d.stbStop[prefix + 'PlatfR'] || (d.stbStop[prefix + 'PltfR'] && d.stbStop[prefix + 'PltfR'].txt) || null const res = { tripId: d.jid, diff --git a/parse/journey-leg.js b/parse/journey-leg.js index 7b8ffe10..90b27673 100644 --- a/parse/journey-leg.js +++ b/parse/journey-leg.js @@ -89,13 +89,12 @@ const parseJourneyLeg = (ctx, pt, date) => { // pt = raw leg res.tripId = pt.jny.jid res.line = pt.jny.line || null res.direction = pt.jny.dirTxt && profile.parseStationName(ctx, pt.jny.dirTxt) || null - - const arrPl = profile.parsePlatform(ctx, pt.arr.aPlatfS, pt.arr.aPlatfR, pt.arr.aCncl) + const arrPl = profile.parsePlatform(ctx, pt.arr.aPlatfS || (pt.arr.aPltfS !== undefined ? pt.arr.aPltfS.txt : null), pt.arr.aPlatfR || (pt.arr.aPltfR !== undefined ? pt.arr.aPltfR.txt : null), pt.arr.aCncl) res.arrivalPlatform = arrPl.platform res.plannedArrivalPlatform = arrPl.plannedPlatform if (arrPl.prognosedPlatform) res.prognosedArrivalPlatform = arrPl.prognosedPlatform - const depPl = profile.parsePlatform(ctx, pt.dep.dPlatfS, pt.dep.dPlatfR, pt.dep.dCncl) + const depPl = profile.parsePlatform(ctx, pt.dep.dPlatfS || (pt.dep.dPltfS !== undefined ? pt.dep.dPltfS.txt : null), pt.dep.dPlatfR || (pt.dep.dPltfR !== undefined ? pt.dep.dPltfR.txt : null), pt.dep.dCncl) res.departurePlatform = depPl.platform res.plannedDeparturePlatform = depPl.plannedPlatform if (depPl.prognosedPlatform) res.prognosedDeparturePlatform = depPl.prognosedPlatform diff --git a/parse/stopover.js b/parse/stopover.js index 8237c726..b651fc31 100644 --- a/parse/stopover.js +++ b/parse/stopover.js @@ -6,9 +6,9 @@ const parseStopover = (ctx, st, date) => { // st = raw stopover const {profile, opt} = ctx const arr = profile.parseWhen(ctx, date, st.aTimeS, st.aTimeR, st.aTZOffset, st.aCncl) - const arrPl = profile.parsePlatform(ctx, st.aPlatfS, st.aPlatfR, 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.dPlatfR, 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) const res = { stop: st.location || null,