From 07c77f8cf9d376990d65b9998faf84c3ee1b27de Mon Sep 17 00:00:00 2001 From: Jannis R Date: Wed, 18 Mar 2020 20:04:39 +0100 Subject: [PATCH] add subStops & entrances options --- docs/departures.md | 2 ++ docs/journeys.md | 2 ++ docs/locations.md | 2 ++ docs/nearby.md | 2 ++ docs/radar.md | 2 ++ docs/reachable-from.md | 4 +++- docs/refresh-journey.md | 2 ++ docs/stop.md | 2 ++ docs/trip.md | 2 ++ index.js | 22 ++++++++++++++++++++-- 10 files changed, 39 insertions(+), 3 deletions(-) diff --git a/docs/departures.md b/docs/departures.md index 86ebf9a0..038b9edf 100644 --- a/docs/departures.md +++ b/docs/departures.md @@ -28,6 +28,8 @@ With `opt`, you can override the default options, which look like this: direction: null, // only show departures heading to this station 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? + entrances: true, // parse & expose entrances of stops/stations? linesOfStops: false, // parse & expose lines at the stop/station? remarks: true, // parse & expose hints & warnings? stopovers: false, // fetch & parse previous/next stopovers? diff --git a/docs/journeys.md b/docs/journeys.md index 45a7968b..735b5c4a 100644 --- a/docs/journeys.md +++ b/docs/journeys.md @@ -70,6 +70,8 @@ With `opt`, you can override the default options, which look like this: }, tickets: false, // return tickets? only available with some profiles polylines: false, // return a shape for each leg? + subStops: true, // parse & expose sub-stops of stations? + entrances: true, // parse & expose entrances of stops/stations? remarks: true, // parse & expose hints & warnings? scheduledDays: false, // parse which days each journey is valid on language: 'en', // language to get results in diff --git a/docs/locations.md b/docs/locations.md index 1b385762..f8ba31f2 100644 --- a/docs/locations.md +++ b/docs/locations.md @@ -11,6 +11,8 @@ With `opt`, you can override the default options, which look like this: , stops: true // return stops/stations? , addresses: true , poi: true // points of interest + , subStops: true // parse & expose sub-stops of stations? + , entrances: true // parse & expose entrances of stops/stations? , linesOfStops: false // parse & expose lines at each stop/station? , language: 'en' // language to get results in } diff --git a/docs/nearby.md b/docs/nearby.md index eb9ce2eb..6743159a 100644 --- a/docs/nearby.md +++ b/docs/nearby.md @@ -12,6 +12,8 @@ With `opt`, you can override the default options, which look like this: distance: null, // maximum walking distance in meters poi: false, // return points of interest? stops: true, // return stops/stations? + subStops: true, // parse & expose sub-stops of stations? + entrances: true, // parse & expose entrances of stops/stations? linesOfStops: false, // parse & expose lines at each stop/station? language: 'en' // language to get results in } diff --git a/docs/radar.md b/docs/radar.md index 6de41264..8eeec9ff 100644 --- a/docs/radar.md +++ b/docs/radar.md @@ -12,6 +12,8 @@ With `opt`, you can override the default options, which look like this: duration: 30, // compute frames for the next n seconds frames: 3, // nr of frames to compute polylines: true, // return a track shape for each vehicle? + subStops: true, // parse & expose sub-stops of stations? + entrances: true, // parse & expose entrances of stops/stations? language: 'en' // language to get results in } ``` diff --git a/docs/reachable-from.md b/docs/reachable-from.md index 7f9c51ad..b5308cf6 100644 --- a/docs/reachable-from.md +++ b/docs/reachable-from.md @@ -18,7 +18,9 @@ With `opt`, you can override the default options, which look like this: suburban: true, subway: true // … - } + }, + subStops: true, // parse & expose sub-stops of stations? + entrances: true, // parse & expose entrances of stops/stations? } ``` diff --git a/docs/refresh-journey.md b/docs/refresh-journey.md index 21694b0b..0462af85 100644 --- a/docs/refresh-journey.md +++ b/docs/refresh-journey.md @@ -9,6 +9,8 @@ With `opt`, you can override the default options, which look like this: stopovers: false, // return stations on the way? polylines: false, // return a shape for each leg? tickets: false, // return tickets? only available with some profiles + subStops: true, // parse & expose sub-stops of stations? + entrances: true, // parse & expose entrances of stops/stations? remarks: true, // parse & expose hints & warnings? language: 'en' // language to get results in } diff --git a/docs/stop.md b/docs/stop.md index 01206803..b96e519a 100644 --- a/docs/stop.md +++ b/docs/stop.md @@ -23,6 +23,8 @@ With `opt`, you can override the default options, which look like this: ```js { + subStops: true, // parse & expose sub-stops of stations? + entrances: true, // parse & expose entrances of stops/stations? linesOfStops: false, // parse & expose lines at the stop/station? language: 'en' // language to get results in } diff --git a/docs/trip.md b/docs/trip.md index 135fb9ea..bb0d1cf9 100644 --- a/docs/trip.md +++ b/docs/trip.md @@ -28,6 +28,8 @@ With `opt`, you can override the default options, which look like this: { stopovers: true, // return stations on the way? polyline: false, // return a shape for the trip? + subStops: true, // parse & expose sub-stops of stations? + entrances: true, // parse & expose entrances of stops/stations? remarks: true, // parse & expose hints & warnings? language: 'en' // language to get results in } diff --git a/index.js b/index.js index 83d0fc28..ab0ae1e7 100644 --- a/index.js +++ b/index.js @@ -53,6 +53,8 @@ const createClient = (profile, userAgent, opt = {}) => { direction: null, // only show departures stopping by this station 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? + entrances: true, // parse & expose entrances of stops/stations? linesOfStops: false, // parse & expose lines at the stop/station? remarks: true, // parse & expose hints & warnings? stopovers: false, // fetch & parse previous/next stopovers? @@ -126,6 +128,8 @@ const createClient = (profile, userAgent, opt = {}) => { startWithWalking: true, tickets: false, // return tickets? polylines: false, // return leg shapes? + subStops: true, // parse & expose sub-stops of stations? + entrances: true, // parse & expose entrances of stops/stations? remarks: true, // parse & expose hints & warnings? scheduledDays: false }, opt) @@ -249,6 +253,8 @@ const createClient = (profile, userAgent, opt = {}) => { stopovers: false, // return stations on the way? tickets: false, // return tickets? polylines: false, // return leg shapes? + subStops: true, // parse & expose sub-stops of stations? + entrances: true, // parse & expose entrances of stops/stations? remarks: true // parse & expose hints & warnings? }, opt) @@ -279,6 +285,8 @@ const createClient = (profile, userAgent, opt = {}) => { stops: true, // return stops/stations? addresses: true, poi: true, // points of interest + subStops: true, // parse & expose sub-stops of stations? + entrances: true, // parse & expose entrances of stops/stations? linesOfStops: false // parse & expose lines at each stop/station? }, opt) @@ -300,6 +308,8 @@ const createClient = (profile, userAgent, opt = {}) => { opt = Object.assign({ linesOfStops: false, // parse & expose lines at the stop/station? + subStops: true, // parse & expose sub-stops of stations? + entrances: true, // parse & expose entrances of stops/stations? remarks: true, // parse & expose hints & warnings? }, opt) @@ -331,6 +341,8 @@ const createClient = (profile, userAgent, opt = {}) => { distance: null, // maximum walking distance in meters poi: false, // return points of interest? stops: true, // return stops/stations? + subStops: true, // parse & expose sub-stops of stations? + entrances: true, // parse & expose entrances of stops/stations? linesOfStops: false // parse & expose lines at each stop/station? }, opt) @@ -355,6 +367,8 @@ const createClient = (profile, userAgent, opt = {}) => { opt = Object.assign({ stopovers: true, // return stations on the way? polyline: false, // return a track shape? + subStops: true, // parse & expose sub-stops of stations? + entrances: true, // parse & expose entrances of stops/stations? remarks: true // parse & expose hints & warnings? }, opt) @@ -391,7 +405,9 @@ const createClient = (profile, userAgent, opt = {}) => { // todo: what happens with `frames: 0`? frames: 3, // nr of frames to compute products: null, // optionally an object of booleans - polylines: true // return a track shape for each vehicle? + polylines: true, // return a track shape for each vehicle? + subStops: true, // parse & expose sub-stops of stations? + entrances: true, // parse & expose entrances of stops/stations? }, opt || {}) opt.when = new Date(opt.when || Date.now()) if (Number.isNaN(+opt.when)) throw new TypeError('opt.when is invalid') @@ -414,7 +430,9 @@ const createClient = (profile, userAgent, opt = {}) => { when: Date.now(), maxTransfers: 5, // maximum of 5 transfers maxDuration: 20, // maximum travel duration in minutes, pass `null` for infinite - products: {} + products: {}, + subStops: true, // parse & expose sub-stops of stations? + entrances: true, // parse & expose entrances of stops/stations? }, opt) if (Number.isNaN(+opt.when)) throw new TypeError('opt.when is invalid')