mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
let parseMovement use parseStopover 🐛
This commit is contained in:
parent
f96131423f
commit
6ba617b1bc
4 changed files with 8 additions and 33 deletions
|
@ -99,8 +99,8 @@ const createParseJourney = (profile, stations, lines, remarks) => {
|
||||||
return parseJourneyWithTickets
|
return parseJourneyWithTickets
|
||||||
}
|
}
|
||||||
|
|
||||||
const createParseStopover = (profile, stations, lines, remarks, connection) => {
|
const createParseStopover = (profile, stations, lines, remarks, date) => {
|
||||||
const parseStopover = _createParseStopover(profile, stations, lines, remarks, connection)
|
const parseStopover = _createParseStopover(profile, stations, lines, remarks, date)
|
||||||
|
|
||||||
const parseStopoverWithShorten = (st) => {
|
const parseStopoverWithShorten = (st) => {
|
||||||
const res = parseStopover(st)
|
const res = parseStopover(st)
|
||||||
|
|
|
@ -47,7 +47,7 @@ const createParseJourneyLeg = (profile, stations, lines, remarks) => {
|
||||||
if (pt.arr.aPlatfS) res.arrivalPlatform = pt.arr.aPlatfS
|
if (pt.arr.aPlatfS) res.arrivalPlatform = pt.arr.aPlatfS
|
||||||
|
|
||||||
if (passed && pt.jny.stopL) {
|
if (passed && pt.jny.stopL) {
|
||||||
const parse = profile.parseStopover(profile, stations, lines, remarks, j)
|
const parse = profile.parseStopover(profile, stations, lines, remarks, j.date)
|
||||||
const passedStations = pt.jny.stopL.map(parse)
|
const passedStations = pt.jny.stopL.map(parse)
|
||||||
// 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)
|
||||||
|
|
|
@ -9,32 +9,7 @@ const createParseMovement = (profile, locations, lines, remarks) => {
|
||||||
// todo: what is m.ani.proc[n]? wut?
|
// todo: what is m.ani.proc[n]? wut?
|
||||||
// todo: how does m.ani.poly work?
|
// todo: how does m.ani.poly work?
|
||||||
const parseMovement = (m) => {
|
const parseMovement = (m) => {
|
||||||
const parseNextStop = (s) => {
|
const pStopover = profile.parseStopover(profile, locations, lines, remarks, m.date)
|
||||||
const dep = s.dTimeR || s.dTimeS
|
|
||||||
? profile.parseDateTime(profile, m.date, s.dTimeR || s.dTimeS)
|
|
||||||
: null
|
|
||||||
const arr = s.aTimeR || s.aTimeS
|
|
||||||
? profile.parseDateTime(profile, m.date, s.aTimeR || s.aTimeS)
|
|
||||||
: null
|
|
||||||
|
|
||||||
const res = {
|
|
||||||
station: locations[s.locX],
|
|
||||||
departure: dep ? dep.toISO() : null,
|
|
||||||
arrival: arr ? arr.toISO() : null
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m.dTimeR && m.dTimeS) {
|
|
||||||
const plannedDep = profile.parseDateTime(profile, m.date, s.dTimeS)
|
|
||||||
res.departureDelay = Math.round((dep - plannedDep) / 1000)
|
|
||||||
} else res.departureDelay = null
|
|
||||||
|
|
||||||
if (m.aTimeR && m.aTimeS) {
|
|
||||||
const plannedArr = profile.parseDateTime(profile, m.date, s.aTimeS)
|
|
||||||
res.arrivalDelay = Math.round((arr - plannedArr) / 1000)
|
|
||||||
} else res.arrivalDelay = null
|
|
||||||
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
const res = {
|
const res = {
|
||||||
direction: profile.parseStationName(m.dirTxt),
|
direction: profile.parseStationName(m.dirTxt),
|
||||||
|
@ -45,7 +20,7 @@ const createParseMovement = (profile, locations, lines, remarks) => {
|
||||||
latitude: m.pos.y / 1000000,
|
latitude: m.pos.y / 1000000,
|
||||||
longitude: m.pos.x / 1000000
|
longitude: m.pos.x / 1000000
|
||||||
} : null,
|
} : null,
|
||||||
nextStops: m.stopL.map(parseNextStop),
|
nextStops: m.stopL.map(pStopover),
|
||||||
frames: []
|
frames: []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
|
|
||||||
// todo: arrivalDelay, departureDelay or only delay ?
|
// todo: arrivalDelay, departureDelay or only delay ?
|
||||||
// todo: arrivalPlatform, departurePlatform
|
// todo: arrivalPlatform, departurePlatform
|
||||||
const createParseStopover = (profile, stations, lines, remarks, connection) => {
|
const createParseStopover = (profile, stations, lines, remarks, date) => {
|
||||||
const parseStopover = (st) => {
|
const parseStopover = (st) => {
|
||||||
const res = {
|
const res = {
|
||||||
station: stations[parseInt(st.locX)] || null
|
station: stations[parseInt(st.locX)] || null
|
||||||
}
|
}
|
||||||
if (st.aTimeR || st.aTimeS) {
|
if (st.aTimeR || st.aTimeS) {
|
||||||
const arr = profile.parseDateTime(profile, connection.date, st.aTimeR || st.aTimeS)
|
const arr = profile.parseDateTime(profile, date, st.aTimeR || st.aTimeS)
|
||||||
res.arrival = arr.toISO()
|
res.arrival = arr.toISO()
|
||||||
}
|
}
|
||||||
if (st.dTimeR || st.dTimeS) {
|
if (st.dTimeR || st.dTimeS) {
|
||||||
const dep = profile.parseDateTime(profile, connection.date, st.dTimeR || st.dTimeS)
|
const dep = profile.parseDateTime(profile, date, st.dTimeR || st.dTimeS)
|
||||||
res.departure = dep.toISO()
|
res.departure = dep.toISO()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue