mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-22 22:59:35 +02:00
arrivals/departures: opt.stopovers for previous/next stopovers, docs 📝
This commit is contained in:
parent
c70a851249
commit
e867dac2ab
3 changed files with 11 additions and 1 deletions
|
@ -29,6 +29,7 @@ With `opt`, you can override the default options, which look like this:
|
|||
duration: 10, // show departures for the next n minutes
|
||||
stationLines: false, // parse & expose lines of the station?
|
||||
remarks: true, // parse & expose hints & warnings?
|
||||
stopovers: false, // fetch & parse previous/next stopovers?
|
||||
// departures at related stations
|
||||
// e.g. those that belong together on the metro map.
|
||||
includeRelatedStations: true,
|
||||
|
|
3
index.js
3
index.js
|
@ -54,6 +54,7 @@ const createClient = (profile, userAgent, request = _request) => {
|
|||
duration: 10, // show departures for the next n minutes
|
||||
stationLines: false, // parse & expose lines of the station?
|
||||
remarks: true, // parse & expose hints & warnings?
|
||||
stopovers: false, // fetch & parse previous/next stopovers?
|
||||
// departures at related stations
|
||||
// e.g. those that belong together on the metro map.
|
||||
includeRelatedStations: true
|
||||
|
@ -73,7 +74,7 @@ const createClient = (profile, userAgent, request = _request) => {
|
|||
dirLoc: dir,
|
||||
jnyFltrL: [products],
|
||||
dur: opt.duration,
|
||||
getPasslist: false, // todo
|
||||
getPasslist: !!opt.stopovers,
|
||||
stbFltrEquiv: !opt.includeRelatedStations
|
||||
}
|
||||
})
|
||||
|
|
|
@ -63,6 +63,14 @@ const createParseArrOrDep = (profile, opt, data, prefix) => {
|
|||
.filter(rem => !!rem) // filter unparsable
|
||||
}
|
||||
|
||||
if (opt.stopovers && d.stopL) {
|
||||
const parse = profile.parseStopover(profile, opt, data, d.date)
|
||||
// Filter stations the train passes without stopping, as this doesn't comply with FPTF (yet).
|
||||
const stopovers = d.stopL.map(parse).filter(st => !st.passBy)
|
||||
if (prefix === ARRIVAL) res.previousStopovers = stopovers
|
||||
else if (prefix === DEPARTURE) res.nextStopovers = stopovers
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue