mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
parse more hints
[ci skip]
This commit is contained in:
parent
65f3603953
commit
a34999b1c5
1 changed files with 54 additions and 1 deletions
|
@ -1,5 +1,7 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
|
const trim = require('lodash/trim')
|
||||||
|
|
||||||
const hints = Object.assign(Object.create(null), {
|
const hints = Object.assign(Object.create(null), {
|
||||||
fb: {
|
fb: {
|
||||||
type: 'hint',
|
type: 'hint',
|
||||||
|
@ -26,6 +28,16 @@ const hints = Object.assign(Object.create(null), {
|
||||||
code: 'boarding-ramp',
|
code: 'boarding-ramp',
|
||||||
summary: 'vehicle-mounted boarding ramp available'
|
summary: 'vehicle-mounted boarding ramp available'
|
||||||
},
|
},
|
||||||
|
ro: {
|
||||||
|
type: 'hint',
|
||||||
|
code: 'wheelchairs-space',
|
||||||
|
summary: 'space for wheelchairs'
|
||||||
|
},
|
||||||
|
oa: {
|
||||||
|
type: 'hint',
|
||||||
|
code: 'wheelchairs-space-reservation',
|
||||||
|
summary: 'space for wheelchairs, subject to reservation'
|
||||||
|
},
|
||||||
wv: {
|
wv: {
|
||||||
type: 'hint',
|
type: 'hint',
|
||||||
code: 'wifi',
|
code: 'wifi',
|
||||||
|
@ -76,6 +88,11 @@ const hints = Object.assign(Object.create(null), {
|
||||||
code: 'childrens-area',
|
code: 'childrens-area',
|
||||||
summary: `children's area available`
|
summary: `children's area available`
|
||||||
},
|
},
|
||||||
|
kk: {
|
||||||
|
type: 'hint',
|
||||||
|
code: 'parents-childrens-compartment',
|
||||||
|
summary: `parent-and-children compartment available`
|
||||||
|
},
|
||||||
kr: {
|
kr: {
|
||||||
type: 'hint',
|
type: 'hint',
|
||||||
code: 'kids-service',
|
code: 'kids-service',
|
||||||
|
@ -121,6 +138,21 @@ const hints = Object.assign(Object.create(null), {
|
||||||
code: 'compulsory-reservation',
|
code: 'compulsory-reservation',
|
||||||
summary: 'compulsory seat reservation'
|
summary: 'compulsory seat reservation'
|
||||||
},
|
},
|
||||||
|
rm: {
|
||||||
|
type: 'hint',
|
||||||
|
code: 'optional-reservation',
|
||||||
|
summary: 'optional seat reservation'
|
||||||
|
},
|
||||||
|
scl: {
|
||||||
|
type: 'hint',
|
||||||
|
code: 'all-2nd-class-seats-reserved',
|
||||||
|
summary: 'all 2nd class seats reserved'
|
||||||
|
},
|
||||||
|
acl: {
|
||||||
|
type: 'hint',
|
||||||
|
code: 'all-seats-reserved',
|
||||||
|
summary: 'all seats reserved'
|
||||||
|
},
|
||||||
sk: {
|
sk: {
|
||||||
type: 'hint',
|
type: 'hint',
|
||||||
code: 'oversize-luggage-forbidden',
|
code: 'oversize-luggage-forbidden',
|
||||||
|
@ -146,6 +178,11 @@ const hints = Object.assign(Object.create(null), {
|
||||||
code: 'toilet',
|
code: 'toilet',
|
||||||
summary: 'toilet available'
|
summary: 'toilet available'
|
||||||
},
|
},
|
||||||
|
oc: {
|
||||||
|
type: 'hint',
|
||||||
|
code: 'wheelchair-accessible-toilet',
|
||||||
|
summary: 'wheelchair-accessible toilet available'
|
||||||
|
},
|
||||||
iz: {
|
iz: {
|
||||||
type: 'hint',
|
type: 'hint',
|
||||||
code: 'intercity-2',
|
code: 'intercity-2',
|
||||||
|
@ -160,6 +197,13 @@ const codesByIcon = Object.assign(Object.create(null), {
|
||||||
// todo: is passing in profile necessary?
|
// todo: is passing in profile necessary?
|
||||||
const parseHint = (profile, h, icons) => {
|
const parseHint = (profile, h, icons) => {
|
||||||
// todo: C
|
// todo: C
|
||||||
|
// todo:
|
||||||
|
// { type: 'Q',
|
||||||
|
// code: '',
|
||||||
|
// icoX: 11,
|
||||||
|
// txtN:
|
||||||
|
// 'RE 3132: Berlin Zoologischer Garten - Brandenburg Hbf: Information. A railway carriage is missing',
|
||||||
|
// sIdx: 4 }
|
||||||
|
|
||||||
const text = h.txtN && h.txtN.trim() || ''
|
const text = h.txtN && h.txtN.trim() || ''
|
||||||
const icon = 'number' === typeof h.icoX && icons[h.icoX] || null
|
const icon = 'number' === typeof h.icoX && icons[h.icoX] || null
|
||||||
|
@ -186,7 +230,14 @@ const parseHint = (profile, h, icons) => {
|
||||||
if (h.type === 'U' && text.toLowerCase() === 'stop cancelled') {
|
if (h.type === 'U' && text.toLowerCase() === 'stop cancelled') {
|
||||||
return {
|
return {
|
||||||
type: 'status',
|
type: 'status',
|
||||||
code: 'stop-cancelled',
|
code: 'stop-cancelled', // todo: change to stopover-cancelled
|
||||||
|
text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (h.type === 'U' && trim(text.toLowerCase(), ' ()') === 'additional stop') {
|
||||||
|
return {
|
||||||
|
type: 'status',
|
||||||
|
code: 'additional-stopover',
|
||||||
text
|
text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,12 +266,14 @@ const parseHint = (profile, h, icons) => {
|
||||||
|
|
||||||
if (h.type === 'D' || h.type === 'U' || h.type === 'R' || h.type === 'N') {
|
if (h.type === 'D' || h.type === 'U' || h.type === 'R' || h.type === 'N') {
|
||||||
// todo: how can we identify the individual types?
|
// todo: how can we identify the individual types?
|
||||||
|
// todo: does `D` mean "disturbance"?
|
||||||
return {
|
return {
|
||||||
type: 'status',
|
type: 'status',
|
||||||
code,
|
code,
|
||||||
text
|
text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue