(more) remarks for journeys, journey legs & stopovers

This commit is contained in:
Jannis R 2018-06-11 11:29:32 +02:00
parent fa2cdc5177
commit d3d23140fd
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
3 changed files with 34 additions and 11 deletions

View file

@ -5,17 +5,22 @@ const findRemark = require('./find-remark')
const clone = obj => Object.assign({}, obj) const clone = obj => Object.assign({}, obj)
const applyRemarksToStopovers = (stopovers, hints, warnings, refs) => { const applyRemarks = (leg, hints, warnings, refs) => {
for (let ref of refs) { for (let ref of refs) {
const remark = findRemark(hints, warnings, ref) const remark = findRemark(hints, warnings, ref)
if ('number' === typeof ref.fLocX && 'number' === typeof ref.tLocX) {
for (let i = ref.fLocX; i <= ref.tLocX; i++) { for (let i = ref.fLocX; i <= ref.tLocX; i++) {
const stopover = stopovers[i] const stopover = leg.passed[i]
if (Array.isArray(stopover.remarks)) { if (Array.isArray(stopover.remarks)) {
stopover.remarks.push(remark) stopover.remarks.push(remark)
} else { } else {
stopover.remarks = [remark] stopover.remarks = [remark]
} }
} }
} else {
if (Array.isArray(leg.remarks)) leg.remarks.push(remark)
else leg.remarks = [remark]
}
// todo: `ref.tagL` // todo: `ref.tagL`
} }
} }
@ -73,9 +78,9 @@ const createParseJourneyLeg = (profile, stations, lines, hints, warnings, polyli
// filter stations the train passes without stopping, as this doesn't comply with fptf (yet) // filter stations the train passes without stopping, as this doesn't comply with fptf (yet)
res.passed = passedStations.filter((x) => !x.passBy) res.passed = passedStations.filter((x) => !x.passBy)
// todo: pt.jny.remL // todo: is there a `pt.jny.remL`?
if (Array.isArray(j.msgL)) { if (Array.isArray(pt.jny.msgL)) {
applyRemarksToStopovers(passedStations, hints, warnings, j.msgL) applyRemarks(res, hints, warnings, pt.jny.msgL)
} }
} }

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const clone = obj => Object.assign({}, obj) const findRemark = require('./find-remark')
const createParseJourney = (profile, stations, lines, hints, warnings, polylines) => { const createParseJourney = (profile, stations, lines, hints, warnings, polylines) => {
const parseLeg = profile.parseJourneyLeg(profile, stations, lines, hints, warnings, polylines) const parseLeg = profile.parseJourneyLeg(profile, stations, lines, hints, warnings, polylines)
@ -15,6 +15,14 @@ const createParseJourney = (profile, stations, lines, hints, warnings, polylines
legs legs
} }
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)
}
}
return res return res
} }

View file

@ -1,5 +1,7 @@
'use strict' 'use strict'
const findRemark = require('./find-remark')
// todo: arrivalDelay, departureDelay or only delay ? // todo: arrivalDelay, departureDelay or only delay ?
// todo: arrivalPlatform, departurePlatform // todo: arrivalPlatform, departurePlatform
const createParseStopover = (profile, stations, lines, hints, warnings, date) => { const createParseStopover = (profile, stations, lines, hints, warnings, date) => {
@ -38,6 +40,14 @@ const createParseStopover = (profile, stations, lines, hints, warnings, date) =>
} }
} }
if (Array.isArray(st.msgL)) {
res.remarks = []
for (let ref of st.msgL) {
const remark = findRemark(hints, warnings, ref)
if (remark) res.remarks.push(remark)
}
}
return res return res
} }