VBB: add (anti)clockwise symbols to Ringbahn

This commit is contained in:
Jannis R 2017-12-12 18:31:41 +01:00
parent 81c9411cfe
commit 040ed41de7
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
2 changed files with 25 additions and 1 deletions

View file

@ -10,6 +10,7 @@ const _parseLine = require('../../parse/line')
const _parseLocation = require('../../parse/location')
const _createParseJourney = require('../../parse/journey')
const _createParseStopover = require('../../parse/stopover')
const _createParseDeparture = require('../../parse/departure')
const _formatStation = require('../../format/station')
const createParseBitmask = require('../../parse/products-bitmask')
const createFormatBitmask = require('../../format/products-bitmask')
@ -107,6 +108,26 @@ const createParseStopover = (profile, stations, lines, remarks, connection) => {
return parseStopoverWithShorten
}
const createParseDeparture = (profile, stations, lines, remarks) => {
const parseDeparture = _createParseDeparture(profile, stations, lines, remarks)
const ringbahnClockwise = /^ringbahn s\s?41$/i
const ringbahnAnticlockwise = /^ringbahn s\s?42$/i
const parseDepartureRenameRingbahn = (j) => {
const res = parseDeparture(j)
if (res.line && res.line.product === 'suburban') {
const d = res.direction && res.direction.trim()
if (ringbahnClockwise.test(d)) res.direction = 'Ringbahn S41 ⟳'
else if (ringbahnAnticlockwise.test(d)) res.direction = 'Ringbahn S42 ⟲'
}
return res
}
return parseDepartureRenameRingbahn
}
const isIBNR = /^\d{9,}$/
const formatStation = (id) => {
if (!isIBNR.test(id)) throw new Error('station ID must be an IBNR.')
@ -145,6 +166,7 @@ const vbbProfile = {
parseLine,
parseProducts: createParseBitmask(modes.bitmasks),
parseJourney: createParseJourney,
parseDeparture: createParseDeparture,
parseStopover: createParseStopover,
formatStation,

View file

@ -11,7 +11,9 @@ const parseLine = (profile, p) => {
}
if (p.cls) res.class = p.cls
if (p.prodCtx) res.productCode = +p.prodCtx.catCode
if (p.prodCtx && p.prodCtx.catCode !== undefined) {
res.productCode = +p.prodCtx.catCode
}
// todo: parse mode, remove from profiles