arrival.direction = null 🐛

For arrivals, `d.dirTxt` didn't contain the direction, but the origin.
This commit is contained in:
Jannis R 2018-09-03 15:12:06 +02:00
parent ee7ad74fd3
commit 044a5ee816
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5

View file

@ -2,12 +2,15 @@
const findRemark = require('./find-remark')
const ARRIVAL = 'a'
const DEPARTURE = 'd'
// todo: what is d.jny.dirFlg?
// todo: d.stbStop.dProgType/d.stbStop.aProgType
const createParseArrOrDep = (profile, opt, data, prefix) => {
const {locations, lines, hints, warnings} = data
if (prefix !== 'a' && prefix !== 'd') throw new Error('invalid prefix')
if (prefix !== ARRIVAL && prefix !== DEPARTURE) throw new Error('invalid prefix')
const parseArrOrDep = (d) => {
const t = d.stbStop[prefix + 'TimeR'] || d.stbStop[prefix + 'TimeS']
@ -17,7 +20,8 @@ const createParseArrOrDep = (profile, opt, data, prefix) => {
tripId: d.jid,
stop: locations[parseInt(d.stbStop.locX)] || null,
when: when.toISO(),
direction: profile.parseStationName(d.dirTxt),
// todo: for arrivals, this is the *origin*, not the *direction*
direction: prefix === DEPARTURE && profile.parseStationName(d.dirTxt) || null,
line: lines[parseInt(d.prodX)] || null,
remarks: [],
// todo: res.trip from rawLine.prodCtx.num?