From f8210c55154302658f2a9d4dd64439b088b14080 Mon Sep 17 00:00:00 2001 From: philipp lange Date: Thu, 25 Oct 2018 16:11:19 +0200 Subject: [PATCH] journeys: add walkingSpeed option --- index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 90bd0747..bf033778 100644 --- a/index.js +++ b/index.js @@ -144,6 +144,7 @@ const createClient = (profile, userAgent, request = _request) => { tickets: false, // return tickets? polylines: false, // return leg shapes? remarks: true, // parse & expose hints & warnings? + walkingSpeed: 'normal', // 'slow', 'normal', 'fast' // Consider walking to nearby stations at the beginning of a journey? startWithWalking: true, scheduledDays: false @@ -178,6 +179,15 @@ const createClient = (profile, userAgent, request = _request) => { filters.push(profile.filters.accessibility[opt.accessibility]) } + if (!['slow','normal','fast'].includes(opt.walkingSpeed)) { + throw new Error('opt.walkingSpeed must be one of these values: "slow", "normal", "fast".') + } + const gisFltrL = [{ + meta: 'foot_speed_' + opt.walkingSpeed, + mode: 'FB', + type: 'M' + }] + // With protocol version `1.16`, the VBB endpoint *used to* fail with // `CGI_READ_FAILED` if you pass `numF`, the parameter for the number // of results. To circumvent this, we loop here, collecting journeys @@ -197,12 +207,12 @@ const createClient = (profile, userAgent, request = _request) => { viaLocL: opt.via ? [{loc: opt.via}] : null, arrLocL: [to], jnyFltrL: filters, + gisFltrL, getTariff: !!opt.tickets, // todo: this is actually "take additional stations nearby the given start and destination station into account" // see rest.exe docs ushrp: !!opt.startWithWalking, - // todo: what is req.gisFltrL? getPT: true, // todo: what is this? getIV: false, // todo: walk & bike as alternatives? getPolyline: !!opt.polylines