mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
walking legs: expose distance
This commit is contained in:
parent
31973431ff
commit
bb6e42a662
3 changed files with 9 additions and 1 deletions
|
@ -12,6 +12,7 @@ This version is not fully backwords-compatible. Check out [the migration guide](
|
|||
- 021ae45 `journeys()`/`journeyLeg()`: leg stopovers: parse & expose platforms
|
||||
- 84bce0c `arrivals()`/`departures()`: parse & expose platforms
|
||||
- 85e0bdf `journeys()`: `startWithWalking` option with default `true`
|
||||
- f6ae29c journey legs with `type: 'walking'` now have a `distance` in meters
|
||||
|
||||
### breaking changes 💥
|
||||
|
||||
|
|
|
@ -80,6 +80,7 @@ const createParseJourneyLeg = (profile, opt, data) => {
|
|||
if (pt.type === 'WALK') {
|
||||
res.mode = 'walking'
|
||||
res.public = true
|
||||
res.distance = pt.gis && pt.gis.dist || null
|
||||
} else if (pt.type === 'JNY') {
|
||||
// todo: pull `public` value from `profile.products`
|
||||
res.id = pt.jny.jid
|
||||
|
|
|
@ -191,7 +191,13 @@ const createValidateJourneyLeg = (cfg) => {
|
|||
}
|
||||
}
|
||||
|
||||
if (leg.mode !== 'walking') {
|
||||
if (leg.mode === 'walking') {
|
||||
if (leg.distance !== null) {
|
||||
const msg = name + '.distance must be '
|
||||
a.strictEqual(typeof leg.distance, 'number', msg + 'a number')
|
||||
a.ok(leg.distance > 0, msg + '> 0')
|
||||
}
|
||||
} else {
|
||||
const msg = name + '.direction must be a string'
|
||||
a.strictEqual(typeof leg.direction, 'string', msg)
|
||||
a.ok(leg.direction, name + '.direction must not be empty')
|
||||
|
|
Loading…
Add table
Reference in a new issue