parseCommon: parse polylines

This commit is contained in:
Jannis R 2019-08-23 15:39:42 +02:00
parent 6af8f6d5ec
commit 018fc84bf5
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
3 changed files with 15 additions and 16 deletions

View file

@ -81,7 +81,17 @@ const parseCommonData = (profile, opt, res) => {
}
res.polylines = []
if (opt.polylines && Array.isArray(c.polyL)) res.polylines = c.polyL
if (opt.polylines && Array.isArray(c.polyL)) {
const parse = profile.parsePolyline(profile, opt, res)
res.polylines = c.polyL.map(parse)
// todo: **.ani.poly -> parsePolyline()
findIdxRefs(res, '**.polyG.polyXL', (idxs, _, path) => {
const idx = idxs.find(idx => !!res.polylines[idx]) // find any given polyline
const jny = get(res, path.slice(0, -2))
jny.polyline = res.polylines[idx]
})
}
return res
}

View file

@ -37,7 +37,6 @@ const applyRemarks = (leg, refs) => {
}
const createParseJourneyLeg = (profile, opt, data) => {
const {polylines} = data
// todo: pt.status, pt.isPartCncl
// todo: pt.isRchbl, pt.chRatingRT, pt.chgDurR, pt.minChg
// todo: pt.dep.dProgType, pt.arr.dProgType
@ -76,12 +75,8 @@ const createParseJourneyLeg = (profile, opt, data) => {
res.arrivalDelay = Math.round((realtime - planned) / 1000)
}
if (pt.jny && pt.jny.polyG) {
let p = pt.jny.polyG.polyXL
p = Array.isArray(p) && polylines[p[0]]
// todo: there can be >1 polyline
const parse = profile.parsePolyline(profile, opt, data)
res.polyline = p && parse(p) || null
if (pt.jny && pt.jny.polyline) {
res.polyline = pt.jny.polyline || null
}
if (pt.type === 'WALK' || pt.type === 'TRSF') {

View file

@ -1,8 +1,6 @@
'use strict'
const createParseMovement = (profile, opt, data) => {
const {polylines} = data
// todo: what is m.dirGeo? maybe the speed?
// todo: what is m.stopL?
// todo: what is m.proc? wut?
@ -41,12 +39,8 @@ const createParseMovement = (profile, opt, data) => {
if (m.ani.poly) {
const parse = profile.parsePolyline(profile, opt, data)
res.polyline = parse(m.ani.poly)
} else if (m.ani.polyG) {
let p = m.ani.polyG.polyXL
p = Array.isArray(p) && polylines[p[0]]
// todo: there can be >1 polyline
const parse = profile.parsePolyline(profile, opt, data)
res.polyline = p && parse(p) || null
} else if (m.ani.polyline) {
res.polyline = m.ani.polyline
}
}
}