journey leg, departure, movement: journeyId -> tripId 💥

This commit is contained in:
Jannis R 2018-06-26 14:57:02 +02:00 committed by Jannis Redmann
parent f5eceafdf3
commit 00ea10d9c8
6 changed files with 10 additions and 9 deletions

View file

@ -18,6 +18,7 @@ This version is not fully backwords-compatible. Check out [the migration guide](
- 3e672ee `journeys()`/`journeyLeg()`: `stopover.station``stopover.stop` 💥
- 021ae45: `journeys()`/`journeyLeg()`: leg stopovers: parse & expose platforms
- 85e0bdf `journeys()`: `startWithWalking` option with default `true`
- 2e6aefe journey leg, departure, movement: `journeyId` -> `tripId` 💥
## `2.7.0`

View file

@ -34,7 +34,7 @@ With `opt`, you can override the default options, which look like this:
*Note:* As stated in the [*Friendly Public Transport Format* `1.0.1`](https://github.com/public-transport/friendly-public-transport-format/tree/1.0.1), the `when` field includes the current delay. The `delay` field, if present, expresses how much the former differs from the schedule.
You may pass the `journeyId` field into [`journeyLeg(ref, lineName, [opt])`](journey-leg.md) to get details on the vehicle's journey.
You may pass the `tripId` field into [`journeyLeg(ref, lineName, [opt])`](journey-leg.md) to get details on the vehicle's journey.
As an example, we're going to use the [VBB profile](../p/vbb):
@ -54,7 +54,7 @@ The response may look like this:
```js
[ {
journeyId: '1|31431|28|86|17122017',
tripId: '1|31431|28|86|17122017',
trip: 31431,
station: {
type: 'station',
@ -98,7 +98,7 @@ The response may look like this:
},
direction: 'S Spandau'
}, {
journeyId: '1|30977|8|86|17122017',
tripId: '1|30977|8|86|17122017',
trip: 30977,
station: { /* … */ },
when: null,
@ -121,7 +121,7 @@ The response may look like this:
},
direction: 'S Westkreuz'
}, {
journeyId: '1|28671|4|86|17122017',
tripId: '1|28671|4|86|17122017',
trip: 28671,
station: {
type: 'station',

View file

@ -14,7 +14,7 @@ const createParseDeparture = (profile, opt, data) => {
const parseDeparture = (d) => {
const when = profile.parseDateTime(profile, d.date, d.stbStop.dTimeR || d.stbStop.dTimeS)
const res = {
journeyId: d.jid,
tripId: d.jid,
station: locations[parseInt(d.stbStop.locX)] || null,
when: when.toISO(),
direction: profile.parseStationName(d.dirTxt),

View file

@ -151,7 +151,7 @@ const parseHint = (profile, h) => {
type: 'status',
code: 'alternative-trip',
text,
journeyId: h.jid
tripId: h.jid
}
}
if (h.type === 'A') {

View file

@ -14,7 +14,7 @@ const createParseMovement = (profile, opt, data) => {
const res = {
direction: profile.parseStationName(m.dirTxt),
journeyId: m.jid || null,
tripId: m.jid || null,
trip: m.jid && +m.jid.split('|')[1] || null, // todo: this seems brittle
line: lines[m.prodX] || null,
location: m.pos ? {

View file

@ -231,8 +231,8 @@ const createValidateDeparture = (cfg) => {
a.ok(isObj(dep), name + ' must be an object')
// todo: let hafas-client add a .type field
a.strictEqual(typeof dep.journeyId, 'string', name + '.journeyId must be a string')
a.ok(dep.journeyId, name + '.journeyId must not be empty')
a.strictEqual(typeof dep.tripId, 'string', name + '.tripId must be a string')
a.ok(dep.tripId, name + '.tripId must not be empty')
a.strictEqual(typeof dep.trip, 'number', name + '.trip must be a number')
val.station(val, dep.station, name + '.station')