mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
journeyPart: passedStations option
This commit is contained in:
parent
374fd6120a
commit
aeac22b569
3 changed files with 8 additions and 4 deletions
|
@ -24,7 +24,8 @@ With `opt`, you can override the default options, which look like this:
|
|||
|
||||
```js
|
||||
{
|
||||
when: new Date()
|
||||
when: new Date(),
|
||||
passedStations: true // return stations on the way?
|
||||
}
|
||||
```
|
||||
|
||||
|
|
5
index.js
5
index.js
|
@ -159,6 +159,9 @@ const createClient = (profile) => {
|
|||
}
|
||||
|
||||
const journeyPart = (ref, lineName, opt = {}) => {
|
||||
opt = Object.assign({
|
||||
passedStations: true // return stations on the way?
|
||||
}, opt)
|
||||
opt.when = opt.when || new Date()
|
||||
|
||||
return request(profile, {
|
||||
|
@ -179,7 +182,7 @@ const createClient = (profile) => {
|
|||
arr: maxBy(d.journey.stopL, 'idx'),
|
||||
jny: d.journey
|
||||
}
|
||||
return parse(d.journey, part)
|
||||
return parse(d.journey, part, !!opt.passedStations)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ const createParseJourneyPart = (profile, stations, lines, remarks) => {
|
|||
// todo: what is pt.jny.dirFlg?
|
||||
// todo: how does pt.freq work?
|
||||
// todo: what is pt.himL?
|
||||
const parseJourneyPart = (j, pt) => { // j = journey, pt = part
|
||||
const parseJourneyPart = (j, pt, passed = true) => { // j = journey, pt = part
|
||||
const dep = profile.parseDateTime(profile, j.date, pt.dep.dTimeR || pt.dep.dTimeS)
|
||||
const arr = profile.parseDateTime(profile, j.date, pt.arr.aTimeR || pt.arr.aTimeS)
|
||||
const res = {
|
||||
|
@ -41,7 +41,7 @@ const createParseJourneyPart = (profile, stations, lines, remarks) => {
|
|||
if (pt.dep.dPlatfS) res.departurePlatform = pt.dep.dPlatfS
|
||||
if (pt.arr.aPlatfS) res.arrivalPlatform = pt.arr.aPlatfS
|
||||
|
||||
if (pt.jny.stopL) {
|
||||
if (passed && pt.jny.stopL) {
|
||||
const parse = profile.parseStopover(profile, stations, lines, remarks, j)
|
||||
res.passed = pt.jny.stopL.map(parse)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue