mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-22 22:59:35 +02:00
opt.passedStations -> opt.stopovers 💥
This commit is contained in:
parent
6611f262bf
commit
ebe4fa64d8
9 changed files with 24 additions and 20 deletions
|
@ -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?
|
||||
}
|
||||
```
|
||||
|
|
|
@ -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)
|
||||
|
|
8
index.js
8
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)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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({
|
||||
|
|
|
@ -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({
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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({
|
||||
|
|
Loading…
Add table
Reference in a new issue