parseLine: prodCtx.lineId as id, nameS as name

This commit is contained in:
Jannis R 2018-09-03 15:13:23 +02:00
parent 044a5ee816
commit b37bedba26
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5

View file

@ -12,21 +12,21 @@ const createParseLine = (profile, opt, {operators}) => {
const parseLine = (p) => {
if (!p) return null // todo: handle this upstream
const name = p.line || p.nameS || p.name || null
const res = {
type: 'line',
id: null,
// This is terrible, but FPTF demands an ID. Let's pray for HAFAS.
id: (
p.prodCtx && p.prodCtx.lineId && slugg(p.prodCtx.lineId.trim())
|| name && slugg(name.trim())
|| null
),
fahrtNr: p.prodCtx && p.prodCtx.num || null,
name: p.line || p.name,
name,
public: true
}
// todo: what is p.prodCtx && p.prodCtx.num?
// todo: what is p.number?
// This is terrible, but FPTF demands an ID. Let's pray for HaCon to expose an ID.
// todo: find a better way
if (p.line) res.id = slugg(p.line.trim())
else if (p.name) res.id = slugg(p.name.trim())
if (p.cls) res.class = p.cls
if (p.prodCtx && p.prodCtx.catCode !== undefined) {
res.productCode = +p.prodCtx.catCode