diff --git a/docs/departures.md b/docs/departures.md index 038b9edf..e92583a7 100644 --- a/docs/departures.md +++ b/docs/departures.md @@ -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? diff --git a/format/station-board-req.js b/format/station-board-req.js index b81918ea..f29ab01c 100644 --- a/format/station-board-req.js +++ b/format/station-board-req.js @@ -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) { diff --git a/index.js b/index.js index f41c769b..b3c3bf12 100644 --- a/index.js +++ b/index.js @@ -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?