2017-11-11 22:35:41 +01:00
|
|
|
'use strict'
|
|
|
|
|
2018-06-11 11:29:32 +02:00
|
|
|
const findRemark = require('./find-remark')
|
2017-11-11 23:56:09 +01:00
|
|
|
|
2018-06-07 18:48:45 +02:00
|
|
|
const createParseJourney = (profile, stations, lines, hints, warnings, polylines) => {
|
|
|
|
const parseLeg = profile.parseJourneyLeg(profile, stations, lines, hints, warnings, polylines)
|
2017-11-11 22:35:41 +01:00
|
|
|
|
|
|
|
// todo: c.sDays
|
|
|
|
// todo: c.conSubscr
|
|
|
|
// todo: c.trfRes x vbb-parse-ticket
|
2017-11-12 01:23:34 +01:00
|
|
|
const parseJourney = (j) => {
|
2017-12-28 16:56:27 +01:00
|
|
|
const legs = j.secL.map(leg => parseLeg(j, leg))
|
2017-12-07 20:21:14 +01:00
|
|
|
const res = {
|
2018-03-02 00:35:54 +01:00
|
|
|
type: 'journey',
|
2018-03-21 01:15:43 +01:00
|
|
|
legs
|
2017-12-07 20:21:14 +01:00
|
|
|
}
|
|
|
|
|
2018-06-11 11:29:32 +02:00
|
|
|
if (Array.isArray(j.msgL)) {
|
|
|
|
res.remarks = []
|
|
|
|
for (let ref of j.msgL) {
|
|
|
|
const remark = findRemark(hints, warnings, ref)
|
|
|
|
if (remark) res.remarks.push(remark)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-07 20:21:14 +01:00
|
|
|
return res
|
2017-11-11 22:35:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return parseJourney
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = createParseJourney
|