more line info

This commit is contained in:
Jannis R 2017-12-11 14:51:09 +01:00
parent d77c450d11
commit 275c9e54d7
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
3 changed files with 19 additions and 5 deletions

View file

@ -2,6 +2,7 @@
const shorten = require('vbb-short-station-name') const shorten = require('vbb-short-station-name')
const {to12Digit, to9Digit} = require('vbb-translate-ids') const {to12Digit, to9Digit} = require('vbb-translate-ids')
const parseLineName = require('vbb-parse-line')
const _formatStation = require('../../format/station') const _formatStation = require('../../format/station')
const _parseLine = require('../../parse/line') const _parseLine = require('../../parse/line')
@ -34,6 +35,13 @@ const parseLine = (profile, l) => {
} }
} }
const details = parseLineName(l.name)
res.symbol = details.symbol
res.nr = details.nr
res.metro = details.metro
res.express = details.express
res.night = details.night
return res return res
} }

View file

@ -12,10 +12,7 @@ const parseLine = (profile, p) => {
} }
if (p.cls) res.class = p.cls if (p.cls) res.class = p.cls
if (p.prodCtx) { if (p.prodCtx) res.productCode = +p.prodCtx.catCode
res.productCode = +p.prodCtx.catCode
res.productName = p.prodCtx.catOutS
}
// todo: parse mode, remove from profiles // todo: parse mode, remove from profiles

View file

@ -15,7 +15,7 @@ const {
assertValidPoi, assertValidPoi,
assertValidAddress, assertValidAddress,
assertValidLocation, assertValidLocation,
assertValidLine, assertValidLine: _assertValidLine,
assertValidStopover, assertValidStopover,
hour, when, hour, when,
assertValidWhen assertValidWhen
@ -32,6 +32,15 @@ const assertValidStationProducts = (t, p) => {
t.equal(typeof p.regional, 'boolean') t.equal(typeof p.regional, 'boolean')
} }
const assertValidLine = (t, l) => {
_assertValidLine(t, l)
if (l.symbol !== null) t.equal(typeof l.symbol, 'string')
if (l.nr !== null) t.equal(typeof l.nr, 'number')
if (l.metro !== null) t.equal(typeof l.metro, 'boolean')
if (l.express !== null) t.equal(typeof l.express, 'boolean')
if (l.night !== null) t.equal(typeof l.night, 'boolean')
}
// todo // todo
const findStation = (query) => stations(query, true, false) const findStation = (query) => stations(query, true, false)