mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
journeys: polylines option
This commit is contained in:
parent
629385599c
commit
49afc8a75b
3 changed files with 7 additions and 3 deletions
|
@ -60,7 +60,8 @@ With `opt`, you can override the default options, which look like this:
|
||||||
express: true,
|
express: true,
|
||||||
regional: true
|
regional: true
|
||||||
},
|
},
|
||||||
tickets: false // return tickets? only available with some profiles
|
tickets: false, // return tickets? only available with some profiles
|
||||||
|
polylines: false // return a shape for each leg?
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -277,3 +278,5 @@ client.journeys(hbf, heinrichHeineStr)
|
||||||
departure of last journey 2017-12-17T19:07:00.000+01:00
|
departure of last journey 2017-12-17T19:07:00.000+01:00
|
||||||
departure of first (later) journey 2017-12-17T19:19:00.000+01:00
|
departure of first (later) journey 2017-12-17T19:19:00.000+01:00
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you pass `polylines: true`, each journey leg will have a `polyline` field, containing an encoded shape. You can use e.g. [`@mapbox/polyline`](https://www.npmjs.com/package/@mapbox/polyline) to decode it.
|
||||||
|
|
3
index.js
3
index.js
|
@ -85,6 +85,7 @@ const createClient = (profile, request = _request) => {
|
||||||
accessibility: 'none', // 'none', 'partial' or 'complete'
|
accessibility: 'none', // 'none', 'partial' or 'complete'
|
||||||
bike: false, // only bike-friendly journeys
|
bike: false, // only bike-friendly journeys
|
||||||
tickets: false, // return tickets?
|
tickets: false, // return tickets?
|
||||||
|
polylines: false // return leg shapes?
|
||||||
}, opt)
|
}, opt)
|
||||||
if (opt.via) opt.via = profile.formatLocation(profile, opt.via)
|
if (opt.via) opt.via = profile.formatLocation(profile, opt.via)
|
||||||
opt.when = opt.when || new Date()
|
opt.when = opt.when || new Date()
|
||||||
|
@ -126,7 +127,7 @@ const createClient = (profile, request = _request) => {
|
||||||
getPT: true, // todo: what is this?
|
getPT: true, // todo: what is this?
|
||||||
outFrwd: true, // todo: what is this?
|
outFrwd: true, // todo: what is this?
|
||||||
getIV: false, // todo: walk & bike as alternatives?
|
getIV: false, // todo: walk & bike as alternatives?
|
||||||
getPolyline: false // todo: shape for displaying on a map?
|
getPolyline: !!opt.polylines
|
||||||
}
|
}
|
||||||
if (profile.journeysNumF) query.numF = opt.results
|
if (profile.journeysNumF) query.numF = opt.results
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ const vbbProfile = require('.')
|
||||||
const client = createClient(vbbProfile)
|
const client = createClient(vbbProfile)
|
||||||
|
|
||||||
// Hauptbahnhof to Charlottenburg
|
// Hauptbahnhof to Charlottenburg
|
||||||
client.journeys('900000003201', '900000024101', {results: 1})
|
client.journeys('900000003201', '900000024101', {results: 1, polylines: true})
|
||||||
// client.departures('900000013102', {duration: 1})
|
// client.departures('900000013102', {duration: 1})
|
||||||
// client.locations('Alexanderplatz', {results: 2})
|
// client.locations('Alexanderplatz', {results: 2})
|
||||||
// client.location('900000042101') // Spichernstr
|
// client.location('900000042101') // Spichernstr
|
||||||
|
|
Loading…
Add table
Reference in a new issue