mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
journey legs: return polylines
This commit is contained in:
parent
49afc8a75b
commit
7c6e87afff
4 changed files with 18 additions and 6 deletions
8
index.js
8
index.js
|
@ -138,7 +138,13 @@ const createClient = (profile, request = _request) => {
|
|||
})
|
||||
.then((d) => {
|
||||
if (!Array.isArray(d.outConL)) return []
|
||||
const parse = profile.parseJourney(profile, d.locations, d.lines, d.remarks)
|
||||
|
||||
let polylines = []
|
||||
if (opt.polylines && Array.isArray(d.common.polyL)) {
|
||||
polylines = d.common.polyL.map(p => p.crdEncYX)
|
||||
}
|
||||
const parse = profile.parseJourney(profile, d.locations, d.lines, d.remarks, polylines)
|
||||
|
||||
if (!journeys.earlierRef) journeys.earlierRef = d.outCtxScrB
|
||||
|
||||
let latestDep = -Infinity
|
||||
|
|
|
@ -68,8 +68,8 @@ const parseLocation = (profile, l, lines) => {
|
|||
return res
|
||||
}
|
||||
|
||||
const createParseJourney = (profile, stations, lines, remarks) => {
|
||||
const parseJourney = _createParseJourney(profile, stations, lines, remarks)
|
||||
const createParseJourney = (profile, stations, lines, remarks, polylines) => {
|
||||
const parseJourney = _createParseJourney(profile, stations, lines, remarks, polylines)
|
||||
|
||||
const parseJourneyWithTickets = (j) => {
|
||||
const res = parseJourney(j)
|
||||
|
|
|
@ -4,7 +4,7 @@ const parseDateTime = require('./date-time')
|
|||
|
||||
const clone = obj => Object.assign({}, obj)
|
||||
|
||||
const createParseJourneyLeg = (profile, stations, lines, remarks) => {
|
||||
const createParseJourneyLeg = (profile, stations, lines, remarks, polylines) => {
|
||||
// todo: finish parse/remark.js first
|
||||
const applyRemark = (j, rm) => {}
|
||||
|
||||
|
@ -34,6 +34,12 @@ const createParseJourneyLeg = (profile, stations, lines, remarks) => {
|
|||
res.arrivalDelay = Math.round((realtime - planned) / 1000)
|
||||
}
|
||||
|
||||
if (pt.jny && pt.jny.polyG) {
|
||||
const p = pt.jny.polyG.polyXL
|
||||
// todo: there can be >1 polyline
|
||||
if (p && p.length > 0) res.polyline = polylines[p[0]] || null
|
||||
}
|
||||
|
||||
if (pt.type === 'WALK') {
|
||||
res.mode = 'walking'
|
||||
res.public = true
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
const clone = obj => Object.assign({}, obj)
|
||||
|
||||
const createParseJourney = (profile, stations, lines, remarks) => {
|
||||
const parseLeg = profile.parseJourneyLeg(profile, stations, lines, remarks)
|
||||
const createParseJourney = (profile, stations, lines, remarks, polylines) => {
|
||||
const parseLeg = profile.parseJourneyLeg(profile, stations, lines, remarks, polylines)
|
||||
|
||||
// todo: c.sDays
|
||||
// todo: c.dep.dProgType, c.arr.dProgType
|
||||
|
|
Loading…
Add table
Reference in a new issue