mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
parent
dd52c4ade2
commit
e871c80900
11 changed files with 14 additions and 14 deletions
|
@ -53,7 +53,7 @@ client.departures('900000024101', {products: {tram: false, ferry: false}})
|
||||||
|
|
||||||
## Response
|
## Response
|
||||||
|
|
||||||
*Note:* As stated in the [*Friendly Public Transport Format* `1.2.0`](https://github.com/public-transport/friendly-public-transport-format/tree/1.2.0), the `when` field includes the current delay. The `delay` field, if present, expresses how much the former differs from the schedule.
|
*Note:* As stated in the [*Friendly Public Transport Format* v2 draft spec](https://github.com/public-transport/friendly-public-transport-format/blob/3bd36faa721e85d9f5ca58fb0f38cdbedb87bbca/spec/readme.md), 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 [`trip(id, lineName, [opt])`](trip.md) to get details on the vehicle's trip.
|
You may pass the `tripId` field into [`trip(id, lineName, [opt])`](trip.md) to get details on the vehicle's trip.
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# `journeysFromTrip(tripId, previousStopover, to, [opt])`
|
# `journeysFromTrip(tripId, previousStopover, to, [opt])`
|
||||||
|
|
||||||
`to` must be an *Friendly Public Transport Format* (FPTF) `1.2.1` [`stop`](https://github.com/public-transport/friendly-public-transport-format/blob/1.2.1/spec/readme.md#stop) or [`station`](https://github.com/public-transport/friendly-public-transport-format/blob/1.2.1/spec/readme.md#station). See [`journeys()`](journeys.md) for details.
|
`to` must be an [*Friendly Public Transport Format* (FPTF) `stop`](https://github.com/public-transport/friendly-public-transport-format/blob/3bd36faa721e85d9f5ca58fb0f38cdbedb87bbca/spec/readme.md#stop) or [`station`](https://github.com/public-transport/friendly-public-transport-format/blob/3bd36faa721e85d9f5ca58fb0f38cdbedb87bbca/spec/readme.md#station). See [`journeys()`](journeys.md) for details.
|
||||||
|
|
||||||
With `opt`, you can override the default options, which look like this:
|
With `opt`, you can override the default options, which look like this:
|
||||||
|
|
||||||
|
@ -42,4 +42,4 @@ const previousStopover = leg.stopovers.find(st => st.departure && new Date(st.de
|
||||||
const journeys = await client.journeysFromTrip(leg.id, previousStopover, kölnHbf)
|
const journeys = await client.journeysFromTrip(leg.id, previousStopover, kölnHbf)
|
||||||
```
|
```
|
||||||
|
|
||||||
`journeys` will be an array of [FPTF `1.2.1` `journey`s](https://github.com/public-transport/friendly-public-transport-format/blob/1.2.1/spec/readme.md#journey), as documented in [`journeys()`](journeys.md).
|
`journeys` will be an array of [FPTF `journey`s](https://github.com/public-transport/friendly-public-transport-format/blob/3bd36faa721e85d9f5ca58fb0f38cdbedb87bbca/spec/readme.md#journey), as documented in [`journeys()`](journeys.md).
|
||||||
|
|
|
@ -80,7 +80,7 @@ With `opt`, you can override the default options, which look like this:
|
||||||
|
|
||||||
## Response
|
## Response
|
||||||
|
|
||||||
*Note:* As stated in the [*Friendly Public Transport Format* `1.2.0`](https://github.com/public-transport/friendly-public-transport-format/tree/1.2.0), the returned `departure` and `arrival` times include the current delay. The `departureDelay`/`arrivalDelay` fields express how much they differ from the schedule.
|
*Note:* As stated in the [*Friendly Public Transport Format* v2 draft spec](https://github.com/public-transport/friendly-public-transport-format/blob/3bd36faa721e85d9f5ca58fb0f38cdbedb87bbca/spec/readme.md), the returned `departure` and `arrival` times include the current delay. The `departureDelay`/`arrivalDelay` fields express how much they differ from the schedule.
|
||||||
|
|
||||||
As an example, we're going to use the [VBB profile](../p/vbb):
|
As an example, we're going to use the [VBB profile](../p/vbb):
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
This method can be used to find stations close to a location. Note that it is not supported by every profile/endpoint.
|
This method can be used to find stations close to a location. Note that it is not supported by every profile/endpoint.
|
||||||
|
|
||||||
`location` must be an [*FPTF* `location` object](https://github.com/public-transport/friendly-public-transport-format/blob/1.2.0/spec/readme.md#location-objects).
|
`location` must be an [*FPTF* `location` object](https://github.com/public-transport/friendly-public-transport-format/blob/3bd36faa721e85d9f5ca58fb0f38cdbedb87bbca/spec/readme.md#location-objects).
|
||||||
|
|
||||||
With `opt`, you can override the default options, which look like this:
|
With `opt`, you can override the default options, which look like this:
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ With `opt`, you can override the default options, which look like this:
|
||||||
|
|
||||||
## Response
|
## Response
|
||||||
|
|
||||||
*Note:* As stated in the [*Friendly Public Transport Format* `1.2.0`](https://github.com/public-transport/friendly-public-transport-format/tree/1.2.0), the returned `departure` and `arrival` times include the current delay. The `departureDelay`/`arrivalDelay` fields express how much they differ from the schedule.
|
*Note:* As stated in the [*Friendly Public Transport Format* v2 draft spec](https://github.com/public-transport/friendly-public-transport-format/blob/3bd36faa721e85d9f5ca58fb0f38cdbedb87bbca/spec/readme.md), the returned `departure` and `arrival` times include the current delay. The `departureDelay`/`arrivalDelay` fields express how much they differ from the schedule.
|
||||||
|
|
||||||
As an example, we're going to use the [VBB profile](../p/vbb):
|
As an example, we're going to use the [VBB profile](../p/vbb):
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ This method can be used to get stations reachable within a certain time from an
|
||||||
|
|
||||||
*Note*: It appears that HAFAS cannot generate actual isochrones, but only the list of reachable stations, which you can estimate the isochrone(s) from.
|
*Note*: It appears that HAFAS cannot generate actual isochrones, but only the list of reachable stations, which you can estimate the isochrone(s) from.
|
||||||
|
|
||||||
`address` must be an [*FPTF* `location` object](https://github.com/public-transport/friendly-public-transport-format/blob/1.2.0/spec/readme.md#location-objects).
|
`address` must be an [*FPTF* `location` object](https://github.com/public-transport/friendly-public-transport-format/blob/3bd36faa721e85d9f5ca58fb0f38cdbedb87bbca/spec/readme.md#location-objects).
|
||||||
|
|
||||||
With `opt`, you can override the default options, which look like this:
|
With `opt`, you can override the default options, which look like this:
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ With `opt`, you can override the default options, which look like this:
|
||||||
|
|
||||||
## Response
|
## Response
|
||||||
|
|
||||||
`reachableFrom(address, [opt])` returns an array, in which each item has a `duration` and an array of [*Friendly Public Transport Format* `1.2.0`](https://github.com/public-transport/friendly-public-transport-format/tree/1.2.0) stations.
|
`reachableFrom(address, [opt])` returns an array, in which each item has a `duration` and an array of [*Friendly Public Transport Format* `station`s](https://github.com/public-transport/friendly-public-transport-format/blob/3bd36faa721e85d9f5ca58fb0f38cdbedb87bbca/spec/readme.md#station).
|
||||||
|
|
||||||
As an example, we're going to use the [VBB profile](../p/vbb):
|
As an example, we're going to use the [VBB profile](../p/vbb):
|
||||||
|
|
||||||
|
|
|
@ -37,4 +37,4 @@ client.journeys('900000003201', '900000100008', {results: 1})
|
||||||
.catch(console.error)
|
.catch(console.error)
|
||||||
```
|
```
|
||||||
|
|
||||||
`refreshJourney()` will return a *single* [*Friendly Public Transport Format* `1.2.0`](https://github.com/public-transport/friendly-public-transport-format/tree/1.2.0) `journey`, in the same format as with `journeys()`.
|
`refreshJourney()` will return a *single* [*Friendly Public Transport Format* v2 draft](https://github.com/public-transport/friendly-public-transport-format/blob/3bd36faa721e85d9f5ca58fb0f38cdbedb87bbca/spec/readme.md) `journey`, in the same format as with `journeys()`.
|
||||||
|
|
|
@ -37,7 +37,7 @@ With `opt`, you can override the default options, which look like this:
|
||||||
|
|
||||||
## Response
|
## Response
|
||||||
|
|
||||||
*Note:* As stated in the [*Friendly Public Transport Format* `1.2.0`](https://github.com/public-transport/friendly-public-transport-format/tree/1.2.0), the returned `departure` and `arrival` times include the current delay. The `departureDelay`/`arrivalDelay` fields express how much they differ from the schedule.
|
*Note:* As stated in the [*Friendly Public Transport Format* v2 draft spec](https://github.com/public-transport/friendly-public-transport-format/blob/3bd36faa721e85d9f5ca58fb0f38cdbedb87bbca/spec/readme.md), the returned `departure` and `arrival` times include the current delay. The `departureDelay`/`arrivalDelay` fields express how much they differ from the schedule.
|
||||||
|
|
||||||
As an example, we're going to use the [VBB profile](../p/vbb):
|
As an example, we're going to use the [VBB profile](../p/vbb):
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ You may want to start with the [profile boilerplate](profile-boilerplate.js).
|
||||||
|
|
||||||
In `hafas-client`, there's a distinction between the `mode` and the `product` fields:
|
In `hafas-client`, there's a distinction between the `mode` and the `product` fields:
|
||||||
|
|
||||||
- The `mode` field describes the mode of transport in general. [Standardised by the *Friendly Public Transport Format* `1.2.1`](https://github.com/public-transport/friendly-public-transport-format/blob/1.2.1/spec/readme.md#modes), it is on purpose limited to a very small number of possible values, e.g. `train` or `bus`.
|
- The `mode` field describes the mode of transport in general. [Standardised by the *Friendly Public Transport Format*](https://github.com/public-transport/friendly-public-transport-format/blob/3bd36faa721e85d9f5ca58fb0f38cdbedb87bbca/spec/readme.md#modes), it is on purpose limited to a very small number of possible values, e.g. `train` or `bus`.
|
||||||
- The value for `product` relates to how a means of transport "works" *in local context*. Example: Even though [*S-Bahn*](https://en.wikipedia.org/wiki/Berlin_S-Bahn) and [*U-Bahn*](https://en.wikipedia.org/wiki/Berlin_U-Bahn) in Berlin are both `train`s, they have different operators, service patterns, stations and look different. Therefore, they are two distinct `product`s `subway` and `suburban`.
|
- The value for `product` relates to how a means of transport "works" *in local context*. Example: Even though [*S-Bahn*](https://en.wikipedia.org/wiki/Berlin_S-Bahn) and [*U-Bahn*](https://en.wikipedia.org/wiki/Berlin_U-Bahn) in Berlin are both `train`s, they have different operators, service patterns, stations and look different. Therefore, they are two distinct `product`s `subway` and `suburban`.
|
||||||
|
|
||||||
**Specify `product`s that appear in the app** you recorded requests of. For a fictional transit network, this may look like this:
|
**Specify `product`s that appear in the app** you recorded requests of. For a fictional transit network, this may look like this:
|
||||||
|
@ -128,7 +128,7 @@ const products = [
|
||||||
Let's break this down:
|
Let's break this down:
|
||||||
|
|
||||||
- `id`: A sensible, [camelCased](https://en.wikipedia.org/wiki/Camel_case#Variations_and_synonyms), alphanumeric identifier. Use it for the key in the `products` array as well.
|
- `id`: A sensible, [camelCased](https://en.wikipedia.org/wiki/Camel_case#Variations_and_synonyms), alphanumeric identifier. Use it for the key in the `products` array as well.
|
||||||
- `mode`: A [valid *Friendly Public Transport Format* `1.2.1` mode](https://github.com/public-transport/friendly-public-transport-format/blob/1.2.1/spec/readme.md#modes).
|
- `mode`: A [valid *Friendly Public Transport Format* mode](https://github.com/public-transport/friendly-public-transport-format/blob/3bd36faa721e85d9f5ca58fb0f38cdbedb87bbca/spec/readme.md#modes).
|
||||||
- `bitmasks`: HAFAS endpoints work with a [bitmask](https://en.wikipedia.org/wiki/Mask_(computing)#Arguments_to_functions) that toggles the individual products. It should be an array of values that toggle the appropriate bit(s) in the bitmask (see below).
|
- `bitmasks`: HAFAS endpoints work with a [bitmask](https://en.wikipedia.org/wiki/Mask_(computing)#Arguments_to_functions) that toggles the individual products. It should be an array of values that toggle the appropriate bit(s) in the bitmask (see below).
|
||||||
- `name`: A short, but distinct name for the means of transport, *just precise enough in local context*, and in the local language. In Berlin, `S-Bahn-Schnellzug` would be too much, because everyone knows what `S-Bahn` means.
|
- `name`: A short, but distinct name for the means of transport, *just precise enough in local context*, and in the local language. In Berlin, `S-Bahn-Schnellzug` would be too much, because everyone knows what `S-Bahn` means.
|
||||||
- `short`: The shortest possible symbol that identifies the product.
|
- `short`: The shortest possible symbol that identifies the product.
|
||||||
|
|
|
@ -16,4 +16,4 @@ const client = createClient(oebbProfile, 'my-awesome-program')
|
||||||
## Customisations
|
## Customisations
|
||||||
|
|
||||||
- parses *ÖBB*-specific products (such as *RailJet*)
|
- parses *ÖBB*-specific products (such as *RailJet*)
|
||||||
- parses invalid empty stations from the API as [`location`](https://github.com/public-transport/friendly-public-transport-format/blob/1.2.0/spec/readme.md#location-objects)s
|
- parses invalid empty stations from the API as [`location`](https://github.com/public-transport/friendly-public-transport-format/blob/3bd36faa721e85d9f5ca58fb0f38cdbedb87bbca/spec/readme.md#location-objects)s
|
||||||
|
|
|
@ -69,7 +69,7 @@ const res = await client.journeys('8011167', '8000261', {results: 1})
|
||||||
console.log(res)
|
console.log(res)
|
||||||
```
|
```
|
||||||
|
|
||||||
`journeys()` returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/promise) that will resolve with an object with an array `journeys` that contains one [*Friendly Public Transport Format* (*FPTF*) `1.2.1` `journey`](https://github.com/public-transport/friendly-public-transport-format/blob/1.2.1/spec/readme.md#journey).
|
`journeys()` returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/promise) that will resolve with an object with an array `journeys` that contains one [*Friendly Public Transport Format* (*FPTF*) v2 draft `journey`](https://github.com/public-transport/friendly-public-transport-format/blob/3bd36faa721e85d9f5ca58fb0f38cdbedb87bbca/spec/readme.md#journey).
|
||||||
|
|
||||||
```js
|
```js
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue