2018-11-21 19:54:59 +01:00
|
|
|
# `stop(id, [opt])`
|
2018-01-26 17:23:45 +01:00
|
|
|
|
2018-06-04 19:01:09 +02:00
|
|
|
`id` must be in one of these formats:
|
2018-01-26 17:23:45 +01:00
|
|
|
|
|
|
|
```js
|
2018-11-21 19:54:59 +01:00
|
|
|
// a stop/station ID, in a format compatible with the profile you use
|
2018-01-26 17:23:45 +01:00
|
|
|
'900000123456'
|
|
|
|
|
2018-11-21 19:54:59 +01:00
|
|
|
// an FPTF `stop`/`station` object
|
2018-01-26 17:23:45 +01:00
|
|
|
{
|
|
|
|
type: 'station',
|
|
|
|
id: '900000123456',
|
|
|
|
name: 'foo station',
|
|
|
|
location: {
|
|
|
|
type: 'location',
|
|
|
|
latitude: 1.23,
|
|
|
|
longitude: 3.21
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2018-06-28 13:00:33 +02:00
|
|
|
With `opt`, you can override the default options, which look like this:
|
|
|
|
|
|
|
|
```js
|
|
|
|
{
|
2020-03-18 20:04:39 +01:00
|
|
|
subStops: true, // parse & expose sub-stops of stations?
|
|
|
|
entrances: true, // parse & expose entrances of stops/stations?
|
2019-01-23 13:03:01 +08:00
|
|
|
linesOfStops: false, // parse & expose lines at the stop/station?
|
2018-07-09 12:40:38 +02:00
|
|
|
language: 'en' // language to get results in
|
2018-06-28 13:00:33 +02:00
|
|
|
}
|
2018-07-21 14:18:26 +02:00
|
|
|
```
|
2018-06-28 13:00:33 +02:00
|
|
|
|
2018-01-26 17:23:45 +01:00
|
|
|
## Response
|
|
|
|
|
|
|
|
As an example, we're going to use the [VBB profile](../p/vbb):
|
|
|
|
|
|
|
|
```js
|
|
|
|
const createClient = require('hafas-client')
|
|
|
|
const vbbProfile = require('hafas-client/p/vbb')
|
|
|
|
|
2018-07-19 21:55:03 +02:00
|
|
|
const client = createClient(vbbProfile, 'my-awesome-program')
|
2018-01-26 17:23:45 +01:00
|
|
|
|
2018-11-21 19:54:59 +01:00
|
|
|
client.stop('900000042101') // U Spichernstr.
|
2018-01-26 17:23:45 +01:00
|
|
|
.then(console.log)
|
|
|
|
.catch(console.error)
|
|
|
|
```
|
|
|
|
|
|
|
|
The response may look like this:
|
|
|
|
|
|
|
|
```js
|
|
|
|
{
|
2018-07-11 00:32:57 +02:00
|
|
|
type: 'stop',
|
2018-01-26 17:23:45 +01:00
|
|
|
id: '900000042101',
|
|
|
|
name: 'U Spichernstr.',
|
|
|
|
location: {
|
|
|
|
type: 'location',
|
|
|
|
latitude: 52.496581,
|
|
|
|
longitude: 13.330616
|
|
|
|
},
|
|
|
|
products: {
|
|
|
|
suburban: false,
|
|
|
|
subway: true,
|
|
|
|
tram: false,
|
|
|
|
bus: true,
|
|
|
|
ferry: false,
|
|
|
|
express: false,
|
|
|
|
regional: false
|
|
|
|
},
|
|
|
|
lines: [ {
|
|
|
|
type: 'line',
|
|
|
|
id: 'u1',
|
2018-07-16 12:39:13 +02:00
|
|
|
mode: 'train',
|
|
|
|
product: 'subway',
|
2018-01-26 17:23:45 +01:00
|
|
|
public: true,
|
2018-07-16 12:39:13 +02:00
|
|
|
name: 'U1',
|
2018-01-26 17:23:45 +01:00
|
|
|
symbol: 'U',
|
|
|
|
nr: 1,
|
|
|
|
metro: false,
|
|
|
|
express: false,
|
2018-07-16 12:39:13 +02:00
|
|
|
night: false
|
|
|
|
},
|
|
|
|
// …
|
|
|
|
{
|
|
|
|
type: 'line',
|
2018-01-26 17:23:45 +01:00
|
|
|
id: 'n9',
|
2018-07-16 12:39:13 +02:00
|
|
|
mode: 'bus',
|
|
|
|
product: 'bus',
|
2018-01-26 17:23:45 +01:00
|
|
|
public: true,
|
2018-07-16 12:39:13 +02:00
|
|
|
name: 'N9',
|
2018-01-26 17:23:45 +01:00
|
|
|
symbol: 'N',
|
|
|
|
nr: 9,
|
|
|
|
metro: false,
|
|
|
|
express: false,
|
|
|
|
night: true
|
|
|
|
} ]
|
|
|
|
}
|
|
|
|
```
|
2020-02-15 19:13:43 +00:00
|
|
|
|
|
|
|
If the endpoint returns a list of entrances for a station, the resulting station object will have an `entrances` array looking similar to this:
|
|
|
|
|
|
|
|
```js
|
|
|
|
[
|
|
|
|
{type: 'location', latitude: 47.411069, longitude: 10.277412},
|
|
|
|
{type: 'location', latitude: 47.410493, longitude: 10.277223},
|
|
|
|
{type: 'location', latitude: 47.410754, longitude: 10.278023}
|
|
|
|
]
|
|
|
|
```
|