diff --git a/parse/journey-part.js b/parse/journey-part.js index a86d40e8..f2483277 100644 --- a/parse/journey-part.js +++ b/parse/journey-part.js @@ -78,6 +78,15 @@ const createParseJourneyPart = (profile, stations, lines, remarks) => { } } + // todo: follow public-transport/friendly-public-transport-format#27 here + // see also derhuerst/vbb-rest#19 + if (pt.arr.dCncl && pt.dep.dCncl) { + result.cancelled = true + result.departure = result.departurePlatform = null + result.arrival = result.arrivalPlatform = null + result.delay = null + } + return res } diff --git a/parse/journey.js b/parse/journey.js index 11b1b56b..21d0f124 100644 --- a/parse/journey.js +++ b/parse/journey.js @@ -15,13 +15,19 @@ const createParseJourney = (profile, stations, lines, remarks) => { // todo: use computed information from part const parseJourney = (j) => { const parts = j.secL.map(part => parsePart(j, part)) - return { + const res = { parts, origin: parts[0].origin, destination: parts[parts.length - 1].destination, departure: parts[0].departure, arrival: parts[parts.length - 1].arrival } + if (parts.some(p => p.cancelled)) { + res.cancelled = true + res.departure = res.arrival = null + } + + return res } return parseJourney