mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
WIP parse remarks
This commit is contained in:
parent
0775a27d1d
commit
f3609ebd80
1 changed files with 26 additions and 5 deletions
|
@ -3,9 +3,14 @@
|
|||
const hints = Object.assign(Object.create(null), {
|
||||
fb: {
|
||||
type: 'hint',
|
||||
code: 'bicycle-con',
|
||||
code: 'bicycle-conveyance',
|
||||
text: 'bicycles conveyed'
|
||||
},
|
||||
nf: {
|
||||
type: 'hint',
|
||||
code: 'no-bicycle-conveyance',
|
||||
text: 'bicycles not conveyed'
|
||||
},
|
||||
k2: {
|
||||
type: 'hint',
|
||||
code: '2nd-class-only',
|
||||
|
@ -31,6 +36,11 @@ const hints = Object.assign(Object.create(null), {
|
|||
code: 'barrier-free',
|
||||
text: 'barrier-free'
|
||||
},
|
||||
rg: {
|
||||
type: 'hint',
|
||||
code: 'barrier-free-vehicle',
|
||||
text: 'barrier-free vehicle'
|
||||
},
|
||||
bt: {
|
||||
type: 'hint',
|
||||
code: 'on-board-bistro',
|
||||
|
@ -66,9 +76,18 @@ const hints = Object.assign(Object.create(null), {
|
|||
// todo: is passing in profile necessary?
|
||||
const parseRemark = (profile, r) => {
|
||||
// todo: U "stop cancelled"?
|
||||
// todo: P "journey cancelled", `r.sIdx`?
|
||||
// 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 {
|
||||
type: 'status',
|
||||
code: 'alternative-trip',
|
||||
|
@ -76,8 +95,10 @@ const parseRemark = (profile, r) => {
|
|||
journeyId: r.jid
|
||||
}
|
||||
}
|
||||
if (t.type === 'A') return hints[r.code && r.code.trim()] || null
|
||||
if (t.type === 'R') {
|
||||
if (r.type === 'A') {
|
||||
return hints[r.code && r.code.trim().toLowerCase()] || null
|
||||
}
|
||||
if (r.type === 'R') {
|
||||
// todo: how can we identify the individual types?
|
||||
return {
|
||||
type: 'status',
|
||||
|
|
Loading…
Add table
Reference in a new issue