2017-11-11 22:35:41 +01:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
const parseDateTime = require('./date-time')
|
2017-11-20 15:43:13 +01:00
|
|
|
const createParseJourneyPart = require('./journey-part')
|
2017-11-11 22:35:41 +01:00
|
|
|
|
2017-11-11 23:56:09 +01:00
|
|
|
const clone = obj => Object.assign({}, obj)
|
|
|
|
|
2017-11-12 01:23:34 +01:00
|
|
|
const createParseJourney = (profile, stations, lines, remarks) => {
|
2017-11-20 15:43:13 +01:00
|
|
|
const parsePart = createParseJourneyPart(profile, stations, lines, remarks)
|
2017-11-11 22:35:41 +01:00
|
|
|
|
|
|
|
// todo: c.sDays
|
|
|
|
// todo: c.dep.dProgType, c.arr.dProgType
|
|
|
|
// todo: c.conSubscr
|
|
|
|
// todo: c.trfRes x vbb-parse-ticket
|
|
|
|
// todo: use computed information from part
|
2017-11-12 01:23:34 +01:00
|
|
|
const parseJourney = (j) => {
|
|
|
|
const parts = j.secL.map(part => parsePart(j, part))
|
2017-11-11 22:35:41 +01:00
|
|
|
return {
|
2017-11-11 23:56:09 +01:00
|
|
|
parts,
|
|
|
|
origin: parts[0].origin,
|
|
|
|
destination: parts[parts.length - 1].destination,
|
|
|
|
departure: parts[0].departure,
|
|
|
|
arrival: parts[parts.length - 1].arrival
|
2017-11-11 22:35:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return parseJourney
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = createParseJourney
|