cancelled flag for departures & passed stations

ported abf323d over from master
This commit is contained in:
Jannis R 2017-12-18 21:11:35 +01:00
parent 965d5393ef
commit f6077d5b6d
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
6 changed files with 38 additions and 11 deletions

View file

@ -95,8 +95,9 @@ The response may look like this:
journeyId: '1|30977|8|86|17122017', journeyId: '1|30977|8|86|17122017',
trip: 30977, trip: 30977,
station: { /* … */ }, station: { /* … */ },
when: '2017-12-17T19:35:00.000+01:00', when: null,
delay: 0, delay: null,
cancelled: true,
line: { line: {
type: 'line', type: 'line',
id: '16441', id: '16441',

View file

@ -92,6 +92,7 @@ The response looked like this:
} }
}, },
arrival: '2017-12-17T19:49:00.000+01:00', arrival: '2017-12-17T19:49:00.000+01:00',
arrivalPlatform: '2',
line: { line: {
type: 'line', type: 'line',
id: '18299', id: '18299',
@ -106,7 +107,6 @@ The response looked like this:
night: false, night: false,
productCode: 0 productCode: 0
}, },
arrivalPlatform: '2',
direction: 'S Spandau', direction: 'S Spandau',
passed: [ /* … */ ] passed: [ /* … */ ]
} }

View file

@ -154,8 +154,9 @@ The response may look like this:
location: { /* … */ }, location: { /* … */ },
products: { /* … */ } products: { /* … */ }
}, },
arrival: '2017-12-17T19:06:00.000+01:00', arrival: null,
departure: '2017-12-17T19:07:00.000+01:00' departure: null,
cancelled: true
}, { }, {
station: { station: {
type: 'station', type: 'station',
@ -234,3 +235,5 @@ If you pass `tickets: true`, each `journey` will have a tickets array that looks
amount: 4 amount: 4
} ] } ]
``` ```
If a journey leg has been cancelled, a `cancelled: true` will be added. Also, `departure`/`departureDelay`/`departurePlatform` and `arrival`/`arrivalDelay`/`arrivalPlatform` will be `null`.

View file

@ -1,7 +1,6 @@
'use strict' 'use strict'
// todos from derhuerst/hafas-client#2 // todos from derhuerst/hafas-client#2
// - stdStop.dCncl
// - stdStop.dPlatfS, stdStop.dPlatfR // - stdStop.dPlatfS, stdStop.dPlatfR
// todo: what is d.jny.dirFlg? // todo: what is d.jny.dirFlg?
// todo: d.stbStop.dProgType // todo: d.stbStop.dProgType
@ -29,6 +28,13 @@ const createParseDeparture = (profile, stations, lines, remarks) => {
res.delay = Math.round((realtime - planned) / 1000) res.delay = Math.round((realtime - planned) / 1000)
} else res.delay = null } else res.delay = null
// todo: follow public-transport/friendly-public-transport-format#27 here
// see also derhuerst/vbb-rest#19
if (pt.arr.aCncl || pt.dep.dCncl) {
res.cancelled = true
res.when = res.delay = null
}
return res return res
} }

View file

@ -66,11 +66,14 @@ const createParseJourneyPart = (profile, stations, lines, remarks) => {
// todo: follow public-transport/friendly-public-transport-format#27 here // todo: follow public-transport/friendly-public-transport-format#27 here
// see also derhuerst/vbb-rest#19 // see also derhuerst/vbb-rest#19
if (pt.arr.dCncl && pt.dep.dCncl) { if (pt.arr.aCncl) {
result.cancelled = true res.cancelled = true
result.departure = result.departurePlatform = null res.arrival = res.arrivalPlatform = null
result.arrival = result.arrivalPlatform = null }
result.delay = null if (pt.dep.dCncl) {
res.cancelled = true
res.departure = res.departurePlatform = null
res.delay = null
} }
return res return res

View file

@ -1,5 +1,7 @@
'use strict' 'use strict'
// todo: arrivalDelay, departureDelay or only delay ?
// todo: arrivalPlatform, departurePlatform
const createParseStopover = (profile, stations, lines, remarks, connection) => { const createParseStopover = (profile, stations, lines, remarks, connection) => {
const parseStopover = (st) => { const parseStopover = (st) => {
const res = { const res = {
@ -13,6 +15,18 @@ const createParseStopover = (profile, stations, lines, remarks, connection) => {
const dep = profile.parseDateTime(profile, connection.date, st.dTimeR || st.dTimeS) const dep = profile.parseDateTime(profile, connection.date, st.dTimeR || st.dTimeS)
res.departure = dep.toISO() res.departure = dep.toISO()
} }
// todo: follow public-transport/friendly-public-transport-format#27 here
// see also derhuerst/vbb-rest#19
if (st.aCncl) {
res.cancelled = true
res.arrival = null
}
if (st.dCncl) {
res.cancelled = true
res.departure = null
}
return res return res
} }