WIP parse remarks

This commit is contained in:
Jannis R 2018-06-07 15:41:00 +02:00
parent 0775a27d1d
commit f3609ebd80
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5

View file

@ -3,9 +3,14 @@
const hints = Object.assign(Object.create(null), { const hints = Object.assign(Object.create(null), {
fb: { fb: {
type: 'hint', type: 'hint',
code: 'bicycle-con', code: 'bicycle-conveyance',
text: 'bicycles conveyed' text: 'bicycles conveyed'
}, },
nf: {
type: 'hint',
code: 'no-bicycle-conveyance',
text: 'bicycles not conveyed'
},
k2: { k2: {
type: 'hint', type: 'hint',
code: '2nd-class-only', code: '2nd-class-only',
@ -31,6 +36,11 @@ const hints = Object.assign(Object.create(null), {
code: 'barrier-free', code: 'barrier-free',
text: 'barrier-free' text: 'barrier-free'
}, },
rg: {
type: 'hint',
code: 'barrier-free-vehicle',
text: 'barrier-free vehicle'
},
bt: { bt: {
type: 'hint', type: 'hint',
code: 'on-board-bistro', code: 'on-board-bistro',
@ -66,9 +76,18 @@ const hints = Object.assign(Object.create(null), {
// todo: is passing in profile necessary? // todo: is passing in profile necessary?
const parseRemark = (profile, r) => { const parseRemark = (profile, r) => {
// todo: U "stop cancelled"? // todo: U "stop cancelled"?
// todo: P "journey cancelled", `r.sIdx`?
// todo: C // todo: C
if (t.type === 'L') {
// todo: find sth more reliable than this
if (r.type === 'P' && r.txtN.toLowerCase().trim() === 'journey cancelled') {
return {
type: 'status',
code: 'journey-cancelled',
text: r.txtN
// todo: `r.sIdx`
}
}
if (r.type === 'L') {
return { return {
type: 'status', type: 'status',
code: 'alternative-trip', code: 'alternative-trip',
@ -76,8 +95,10 @@ const parseRemark = (profile, r) => {
journeyId: r.jid journeyId: r.jid
} }
} }
if (t.type === 'A') return hints[r.code && r.code.trim()] || null if (r.type === 'A') {
if (t.type === 'R') { return hints[r.code && r.code.trim().toLowerCase()] || null
}
if (r.type === 'R') {
// todo: how can we identify the individual types? // todo: how can we identify the individual types?
return { return {
type: 'status', type: 'status',