docs: journeyLeg() -> trip() 📝

This commit is contained in:
Jannis R 2018-06-29 14:42:40 +02:00 committed by Jannis Redmann
parent 2a6f1f9183
commit 86fc27e340
5 changed files with 13 additions and 11 deletions

View file

@ -36,7 +36,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 `tripId` field into [`journeyLeg(ref, lineName, [opt])`](journey-leg.md) to get details on the vehicle's journey.
You may pass the `tripId` field into [`trip(id, lineName, [opt])`](trip.md) to get details on the vehicle's trip.
As an example, we're going to use the [VBB profile](../p/vbb):

View file

@ -272,4 +272,4 @@ 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
```
If you pass `polylines: true`, each journey leg will have a `polyline` field. Refer to [the section in the `journeyLeg()` docs](journey-leg.md#polyline-option) for details.
If you pass `polylines: true`, each journey leg will have a `polyline` field. Refer to [the section in the `trip()` docs](trip.md#polyline-option) for details.

View file

@ -163,4 +163,4 @@ The response may look like this:
}, /* … */ ]
```
If you pass `polylines: true`, each journey leg will have a `polyline` field, as documented in [the corresponding section in the `journeyLeg()` docs](journey-leg.md#polyline-option), with the exception that station info is missing.
If you pass `polylines: true`, each movement will have a `polyline` field, as documented in [the corresponding section in the `trip()` docs](trip.md#polyline-option), with the exception that station info is missing.

View file

@ -1,7 +1,7 @@
# API documentation
- [`journeys(from, to, [opt])`](journeys.md) get journeys between locations
- [`journeyLeg(ref, lineName, [opt])`](journey-leg.md) get details for a leg of a journey
- [`trip(id, lineName, [opt])`](trip.md) get details for a trip
- [`departures(station, [opt])`](departures.md) query the next departures at a station
- [`arrivals(station, [opt])`](arrivals.md) query the next arrivals at a station
- [`locations(query, [opt])`](locations.md) find stations, POIs and addresses

View file

@ -1,8 +1,10 @@
# `journeyLeg(ref, lineName, [opt])`
# `trip(id, lineName, [opt])`
This method can be used to refetch information about a leg of a journey. Note that it is not supported by every profile/endpoint.
This method can be used to refetch information about a trip  a vehicle stopping at a set of stops at specific times.
Let's say you used [`journeys`](journeys.md) and now want to get more up-to-date data about the arrival/departure of a leg. You'd pass in a journey leg `id` like `'1|24983|22|86|18062017'`. `lineName` must be the name of the journey leg's `line.name`. You can get them like this:
*Note*: This method is not supported by every profile/endpoint.
Let's say you used [`journeys`](journeys.md) and now want to get more up-to-date data about the arrival/departure of a leg. You'd pass in the trip ID from `leg.id`, e.g. `'1|24983|22|86|18062017'`, and the name of the line from `leg.line.name` like this:
```js
const createClient = require('hafas-client')
@ -14,7 +16,7 @@ const client = createClient(vbbProfile)
client.journeys('900000003201', '900000100008', {results: 1})
.then(([journey]) => {
const leg = journey.legs[0]
return client.journeyLeg(leg.id, leg.line.name)
return client.trip(leg.id, leg.line.name)
})
.then(console.log)
.catch(console.error)
@ -26,7 +28,7 @@ With `opt`, you can override the default options, which look like this:
{
when: new Date(),
stopovers: true, // return stations on the way?
polyline: false, // return a shape for the leg?
polyline: false, // return a shape for the trip?
remarks: true // parse & expose hints & warnings?
}
```
@ -43,7 +45,7 @@ const vbbProfile = require('hafas-client/p/vbb')
const client = createClient(vbbProfile)
client.journeyLeg('1|31431|28|86|17122017', 'S9', {when: 1513534689273})
client.trip('1|31431|28|86|17122017', 'S9', {when: 1513534689273})
.then(console.log)
.catch(console.error)
```
@ -121,7 +123,7 @@ The response looked like this:
### `polyline` option
If you pass `polyline: true`, the leg will have a `polyline` field, containing a [GeoJSON](http://geojson.org) [`FeatureCollection`](https://tools.ietf.org/html/rfc7946#section-3.3) of [`Point`s](https://tools.ietf.org/html/rfc7946#appendix-A.1). Every `Point` next to a station will have `properties` containing the station's metadata.
If you pass `polyline: true`, the trip will have a `polyline` field, containing a [GeoJSON](http://geojson.org) [`FeatureCollection`](https://tools.ietf.org/html/rfc7946#section-3.3) of [`Point`s](https://tools.ietf.org/html/rfc7946#appendix-A.1). Every `Point` next to a station will have `properties` containing the station's metadata.
We'll look at an example for *U6* from *Alt-Mariendorf* to *Alt-Tegel*, taken from the [VBB profile](../p/vbb):