mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 23:29:35 +02:00
parseCommon: parse polylines
This commit is contained in:
parent
6af8f6d5ec
commit
018fc84bf5
3 changed files with 15 additions and 16 deletions
|
@ -81,7 +81,17 @@ const parseCommonData = (profile, opt, res) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
res.polylines = []
|
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
|
return res
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,6 @@ const applyRemarks = (leg, refs) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const createParseJourneyLeg = (profile, opt, data) => {
|
const createParseJourneyLeg = (profile, opt, data) => {
|
||||||
const {polylines} = data
|
|
||||||
// todo: pt.status, pt.isPartCncl
|
// todo: pt.status, pt.isPartCncl
|
||||||
// todo: pt.isRchbl, pt.chRatingRT, pt.chgDurR, pt.minChg
|
// todo: pt.isRchbl, pt.chRatingRT, pt.chgDurR, pt.minChg
|
||||||
// todo: pt.dep.dProgType, pt.arr.dProgType
|
// todo: pt.dep.dProgType, pt.arr.dProgType
|
||||||
|
@ -76,12 +75,8 @@ const createParseJourneyLeg = (profile, opt, data) => {
|
||||||
res.arrivalDelay = Math.round((realtime - planned) / 1000)
|
res.arrivalDelay = Math.round((realtime - planned) / 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pt.jny && pt.jny.polyG) {
|
if (pt.jny && pt.jny.polyline) {
|
||||||
let p = pt.jny.polyG.polyXL
|
res.polyline = pt.jny.polyline || null
|
||||||
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.type === 'WALK' || pt.type === 'TRSF') {
|
if (pt.type === 'WALK' || pt.type === 'TRSF') {
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const createParseMovement = (profile, opt, data) => {
|
const createParseMovement = (profile, opt, data) => {
|
||||||
const {polylines} = data
|
|
||||||
|
|
||||||
// todo: what is m.dirGeo? maybe the speed?
|
// todo: what is m.dirGeo? maybe the speed?
|
||||||
// todo: what is m.stopL?
|
// todo: what is m.stopL?
|
||||||
// todo: what is m.proc? wut?
|
// todo: what is m.proc? wut?
|
||||||
|
@ -41,12 +39,8 @@ const createParseMovement = (profile, opt, data) => {
|
||||||
if (m.ani.poly) {
|
if (m.ani.poly) {
|
||||||
const parse = profile.parsePolyline(profile, opt, data)
|
const parse = profile.parsePolyline(profile, opt, data)
|
||||||
res.polyline = parse(m.ani.poly)
|
res.polyline = parse(m.ani.poly)
|
||||||
} else if (m.ani.polyG) {
|
} else if (m.ani.polyline) {
|
||||||
let p = m.ani.polyG.polyXL
|
res.polyline = m.ani.polyline
|
||||||
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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue