departures/arrivals: add line option

This commit is contained in:
Jannis R 2020-03-09 21:59:17 +01:00 committed by Jannis Redmann
parent 53e10f73b7
commit e6bc8c6f86
3 changed files with 10 additions and 3 deletions

View file

@ -26,6 +26,7 @@ With `opt`, you can override the default options, which look like this:
// todo: products
when: new Date(),
direction: null, // only show departures heading to this station
line: null, // filter by line ID
duration: 10, // show departures for the next n minutes
results: null, // max. number of results; `null` means "whatever HAFAS wants"
subStops: true, // parse & expose sub-stops of stations?

View file

@ -3,15 +3,20 @@
const formatStationBoardReq = (ctx, station, type) => {
const {profile, opt} = ctx
const jnyFltrL = [
profile.formatProductsFilter(ctx, opt.products || {})
]
if (opt.line !== null) {
jnyFltrL.push({type: 'LINEID', mode: 'INC', value: opt.line})
}
const req = {
type,
date: profile.formatDate(profile, opt.when),
time: profile.formatTime(profile, opt.when),
stbLoc: station,
dirLoc: opt.direction ? profile.formatStation(opt.direction) : null,
jnyFltrL: [
profile.formatProductsFilter(ctx, opt.products || {})
],
jnyFltrL,
dur: opt.duration
}
if (opt.results !== null) {

View file

@ -56,6 +56,7 @@ const createClient = (profile, userAgent, opt = {}) => {
opt = Object.assign({
// todo: for arrivals(), this is actually a station it *has already* stopped by
direction: null, // only show departures stopping by this station
line: null, // filter by line ID
duration: 10, // show departures for the next n minutes
results: null, // max. number of results; `null` means "whatever HAFAS wants"
subStops: true, // parse & expose sub-stops of stations?