mark journeys & journey parts as cancelled

see derhuerst/vbb-gtfs#19
see public-transport/friend-public-transport-format#27
This commit is contained in:
Jannis R 2017-12-07 20:21:14 +01:00
parent 817f44ea39
commit 658d67e3b2
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
2 changed files with 16 additions and 1 deletions

View file

@ -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 return res
} }

View file

@ -15,13 +15,19 @@ const createParseJourney = (profile, stations, lines, remarks) => {
// todo: use computed information from part // todo: use computed information from part
const parseJourney = (j) => { const parseJourney = (j) => {
const parts = j.secL.map(part => parsePart(j, part)) const parts = j.secL.map(part => parsePart(j, part))
return { const res = {
parts, parts,
origin: parts[0].origin, origin: parts[0].origin,
destination: parts[parts.length - 1].destination, destination: parts[parts.length - 1].destination,
departure: parts[0].departure, departure: parts[0].departure,
arrival: parts[parts.length - 1].arrival arrival: parts[parts.length - 1].arrival
} }
if (parts.some(p => p.cancelled)) {
res.cancelled = true
res.departure = res.arrival = null
}
return res
} }
return parseJourney return parseJourney