From ebe4fa64d871f711ced99d528c0171b180edc135 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Wed, 13 Jun 2018 20:39:33 +0200 Subject: [PATCH] opt.passedStations -> opt.stopovers :boom: --- docs/journey-leg.md | 2 +- docs/journeys.md | 4 ++-- index.js | 8 ++++---- parse/journey-leg.js | 6 ++++-- test/db.js | 6 ++++-- test/insa.js | 4 ++-- test/nahsh.js | 4 ++-- test/oebb.js | 6 +++--- test/vbb.js | 4 ++-- 9 files changed, 24 insertions(+), 20 deletions(-) diff --git a/docs/journey-leg.md b/docs/journey-leg.md index e98f93f5..6060b36a 100644 --- a/docs/journey-leg.md +++ b/docs/journey-leg.md @@ -25,7 +25,7 @@ With `opt`, you can override the default options, which look like this: ```js { when: new Date(), - passedStations: true, // return stations on the way? + stopovers: true, // return stations on the way? polyline: false // return a shape for the leg? } ``` diff --git a/docs/journeys.md b/docs/journeys.md index f104bd88..7a9e9131 100644 --- a/docs/journeys.md +++ b/docs/journeys.md @@ -48,7 +48,7 @@ With `opt`, you can override the default options, which look like this: laterThan: null, // ref to get journeys later than the last query results: 5, // how many journeys? via: null, // let journeys pass this station - passedStations: false, // return stations on the way? + stopovers: false, // return stations on the way? transfers: 5, // maximum of 5 transfers transferTime: 0, // minimum time for a single transfer in minutes accessibility: 'none', // 'none', 'partial' or 'complete' @@ -83,7 +83,7 @@ const client = createClient(vbbProfile) // Hauptbahnhof to Heinrich-Heine-Str. client.journeys('900000003201', '900000100008', { results: 1, - passedStations: true + stopovers: true }) .then(console.log) .catch(console.error) diff --git a/index.js b/index.js index cdd86fdc..d31dd065 100644 --- a/index.js +++ b/index.js @@ -90,7 +90,7 @@ const createClient = (profile, request = _request) => { opt = Object.assign({ results: 5, // how many journeys? via: null, // let journeys pass this station? - passedStations: false, // return stations on the way? + stopovers: false, // return stations on the way? transfers: 5, // maximum of 5 transfers transferTime: 0, // minimum time for a single transfer in minutes // todo: does this work with every endpoint? @@ -138,7 +138,7 @@ const createClient = (profile, request = _request) => { outDate: profile.formatDate(profile, when), outTime: profile.formatTime(profile, when), ctxScr: journeysRef, - getPasslist: !!opt.passedStations, + getPasslist: !!opt.stopovers, maxChg: opt.transfers, minChgTime: opt.transferTime, depLocL: [from], @@ -291,7 +291,7 @@ const createClient = (profile, request = _request) => { throw new Error('lineName must be a non-empty string.') } opt = Object.assign({ - passedStations: true, // return stations on the way? + stopovers: true, // return stations on the way? polyline: false }, opt) opt.when = new Date(opt.when || Date.now()) @@ -318,7 +318,7 @@ const createClient = (profile, request = _request) => { arr: maxBy(d.journey.stopL, 'idx'), jny: d.journey } - return parse(d.journey, leg, !!opt.passedStations) + return parse(d.journey, leg, !!opt.stopovers) }) } diff --git a/parse/journey-leg.js b/parse/journey-leg.js index 45038d02..d7e5eb77 100644 --- a/parse/journey-leg.js +++ b/parse/journey-leg.js @@ -13,7 +13,9 @@ const createParseJourneyLeg = (profile, stations, lines, remarks, polylines) => // todo: what is pt.jny.dirFlg? // todo: how does pt.freq work? // todo: what is pt.himL? - const parseJourneyLeg = (j, pt, passed = true) => { // j = journey, pt = part + + // j = journey, pt = part + const parseJourneyLeg = (j, pt, parseStopovers = true) => { const dep = profile.parseDateTime(profile, j.date, pt.dep.dTimeR || pt.dep.dTimeS) const arr = profile.parseDateTime(profile, j.date, pt.arr.aTimeR || pt.arr.aTimeS) const res = { @@ -56,7 +58,7 @@ const createParseJourneyLeg = (profile, stations, lines, remarks, polylines) => if (pt.dep.dPlatfS) res.departurePlatform = pt.dep.dPlatfS if (pt.arr.aPlatfS) res.arrivalPlatform = pt.arr.aPlatfS - if (passed && pt.jny.stopL) { + if (parseStopovers && pt.jny.stopL) { const parse = profile.parseStopover(profile, stations, lines, remarks, j.date) const stopovers = pt.jny.stopL.map(parse) // filter stations the train passes without stopping, as this doesn't comply with fptf (yet) diff --git a/test/db.js b/test/db.js index 2d183500..de2af4bf 100644 --- a/test/db.js +++ b/test/db.js @@ -76,7 +76,9 @@ const regensburgHbf = '8000309' test('journeys – Berlin Schwedter Str. to München Hbf', co(function* (t) { const journeys = yield client.journeys(blnSchwedterStr, münchenHbf, { - results: 3, departure: when, passedStations: true + results: 3, + departure: when, + stopovers: true }) yield testJourneysStationToStation({ @@ -160,7 +162,7 @@ test('journeys: via works – with detour', co(function* (t) { via: württembergallee, results: 1, departure: when, - passedStations: true + stopovers: true }) yield testJourneysWithDetour({ diff --git a/test/insa.js b/test/insa.js index 82bd9bfb..7f622154 100644 --- a/test/insa.js +++ b/test/insa.js @@ -44,7 +44,7 @@ test('journeys – Magdeburg Hbf to Magdeburg-Buckau', co(function* (t) { const journeys = yield client.journeys(magdeburgHbf, magdeburgBuckau, { results: 3, departure: when, - passedStations: true + stopovers: true }) yield testJourneysStationToStation({ @@ -125,7 +125,7 @@ test('journeys: via works – with detour', co(function* (t) { via: dessau, results: 1, departure: when, - passedStations: true + stopovers: true }) yield testJourneysWithDetour({ diff --git a/test/nahsh.js b/test/nahsh.js index 0e1d88a4..157b6afe 100644 --- a/test/nahsh.js +++ b/test/nahsh.js @@ -69,7 +69,7 @@ test('journeys – Kiel Hbf to Flensburg', co(function* (t) { const journeys = yield client.journeys(kielHbf, flensburg, { results: 3, departure: when, - passedStations: true + stopovers: true }) yield testJourneysStationToStation({ @@ -153,7 +153,7 @@ test('Husum to Lübeck Hbf with stopover at Kiel Hbf', co(function* (t) { via: kielHbf, results: 1, departure: when, - passedStations: true + stopovers: true }) validate(t, journeys, 'journeys', 'journeys') diff --git a/test/oebb.js b/test/oebb.js index 169aba61..62414cc7 100644 --- a/test/oebb.js +++ b/test/oebb.js @@ -62,7 +62,7 @@ test.skip('journeys – Salzburg Hbf to Wien Westbahnhof', co(function* (t) { const journeys = yield client.journeys(salzburgHbf, wienFickeystr, { results: 3, departure: when, - passedStations: true + stopovers: true }) yield testJourneysStationToStation({ @@ -150,7 +150,7 @@ test('journeys: via works – with detour', co(function* (t) { via: donauinsel, results: 1, departure: when, - passedStations: true + stopovers: true }) yield testJourneysWithDetour({ @@ -174,7 +174,7 @@ test('journeys: via works – without detour', co(function* (t) { via: museumsquartier, results: 1, departure: when, - passedStations: true + stopovers: true }) validate(t, journeys, 'journeys', 'journeys') diff --git a/test/vbb.js b/test/vbb.js index 8cebcb5f..f74eaf4a 100644 --- a/test/vbb.js +++ b/test/vbb.js @@ -113,7 +113,7 @@ test('journeys – Spichernstr. to Bismarckstr.', co(function* (t) { const journeys = yield client.journeys(spichernstr, bismarckstr, { results: 3, departure: when, - passedStations: true + stopovers: true }) yield testJourneysStationToStation({ @@ -252,7 +252,7 @@ test('journeys: via works – with detour', co(function* (t) { via: württembergallee, results: 1, departure: when, - passedStations: true + stopovers: true }) yield testJourneysWithDetour({