mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
remarks for journey legs
This commit is contained in:
parent
d2257c26ff
commit
b6e37595a5
2 changed files with 26 additions and 4 deletions
|
@ -1,5 +1,7 @@
|
|||
'use strict'
|
||||
|
||||
const findRemark = require('./find-remark')
|
||||
|
||||
// todos from public-transport/hafas-client#2
|
||||
// - stdStop.dPlatfS, stdStop.dPlatfR
|
||||
// todo: what is d.jny.dirFlg?
|
||||
|
@ -7,8 +9,6 @@
|
|||
// todo: d.freq, d.freq.jnyL, see https://github.com/public-transport/hafas-client/blob/9203ed1481f08baacca41ac5e3c19bf022f01b0b/parse.js#L115
|
||||
|
||||
const createParseDeparture = (profile, stations, lines, hints) => {
|
||||
const findHint = rm => hints[parseInt(rm.remX)] || null
|
||||
|
||||
const parseDeparture = (d) => {
|
||||
const when = profile.parseDateTime(profile, d.date, d.stbStop.dTimeR || d.stbStop.dTimeS)
|
||||
const res = {
|
||||
|
@ -17,7 +17,10 @@ const createParseDeparture = (profile, stations, lines, hints) => {
|
|||
when: when.toISO(),
|
||||
direction: profile.parseStationName(d.dirTxt),
|
||||
line: lines[parseInt(d.prodX)] || null,
|
||||
remarks: d.remL ? d.remL.map(findHint) : [],
|
||||
remarks: (d.remL
|
||||
? d.remL.map(ref => findRemark(hints, ref))
|
||||
: []
|
||||
),
|
||||
trip: +d.jid.split('|')[1] // todo: this seems brittle
|
||||
}
|
||||
// todo: res.trip from rawLine.prodCtx.num?
|
||||
|
|
|
@ -1,9 +1,25 @@
|
|||
'use strict'
|
||||
|
||||
const parseDateTime = require('./date-time')
|
||||
const findRemark = require('./find-remark')
|
||||
|
||||
const clone = obj => Object.assign({}, obj)
|
||||
|
||||
const applyRemarksToStopovers = (stopovers, hints, refs) => {
|
||||
for (let ref of refs) {
|
||||
const remark = findRemark(hints, ref)
|
||||
for (let i = ref.fLocX; i <= ref.tLocX; i++) {
|
||||
const stopover = stopovers[i]
|
||||
if (Array.isArray(stopover.remarks)) {
|
||||
stopover.remarks.push(remark)
|
||||
} else {
|
||||
stopover.remarks = [remark]
|
||||
}
|
||||
}
|
||||
// todo: `ref.tagL`
|
||||
}
|
||||
}
|
||||
|
||||
const createParseJourneyLeg = (profile, stations, lines, hints, polylines) => {
|
||||
// todo: pt.sDays
|
||||
// todo: pt.dep.dProgType, pt.arr.dProgType
|
||||
|
@ -57,7 +73,10 @@ const createParseJourneyLeg = (profile, stations, lines, hints, polylines) => {
|
|||
// filter stations the train passes without stopping, as this doesn't comply with fptf (yet)
|
||||
res.passed = passedStations.filter((x) => !x.passBy)
|
||||
|
||||
// todo: pt.jny.remL, j.msgL
|
||||
// todo: pt.jny.remL
|
||||
if (Array.isArray(j.msgL)) {
|
||||
applyRemarksToStopovers(passedStations, hints, j.msgL)
|
||||
}
|
||||
}
|
||||
|
||||
const freq = pt.jny.freq || {}
|
||||
|
|
Loading…
Add table
Reference in a new issue