mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
location method: docs 📝
This commit is contained in:
parent
b79c2387dd
commit
3e0bb8e0c3
5 changed files with 90 additions and 0 deletions
86
docs/location.md
Normal file
86
docs/location.md
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
# `location(station)`
|
||||||
|
|
||||||
|
`station` must be in one of these formats:
|
||||||
|
|
||||||
|
```js
|
||||||
|
// a station ID, in a format compatible to the profile you use
|
||||||
|
'900000123456'
|
||||||
|
|
||||||
|
// an FPTF `station` object
|
||||||
|
{
|
||||||
|
type: 'station',
|
||||||
|
id: '900000123456',
|
||||||
|
name: 'foo station',
|
||||||
|
location: {
|
||||||
|
type: 'location',
|
||||||
|
latitude: 1.23,
|
||||||
|
longitude: 3.21
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 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')
|
||||||
|
|
||||||
|
const client = createClient(vbbProfile)
|
||||||
|
|
||||||
|
client.location('900000042101') // U Spichernstr.
|
||||||
|
.then(console.log)
|
||||||
|
.catch(console.error)
|
||||||
|
```
|
||||||
|
|
||||||
|
The response may look like this:
|
||||||
|
|
||||||
|
```js
|
||||||
|
{
|
||||||
|
type: 'station',
|
||||||
|
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',
|
||||||
|
name: 'U1',
|
||||||
|
public: true,
|
||||||
|
class: 2,
|
||||||
|
product: 'subway',
|
||||||
|
mode: 'train',
|
||||||
|
symbol: 'U',
|
||||||
|
nr: 1,
|
||||||
|
metro: false,
|
||||||
|
express: false,
|
||||||
|
night: false },
|
||||||
|
// …
|
||||||
|
{ type: 'line',
|
||||||
|
id: 'n9',
|
||||||
|
name: 'N9',
|
||||||
|
public: true,
|
||||||
|
class: 8,
|
||||||
|
product: 'bus',
|
||||||
|
mode: 'bus',
|
||||||
|
symbol: 'N',
|
||||||
|
nr: 9,
|
||||||
|
metro: false,
|
||||||
|
express: false,
|
||||||
|
night: true
|
||||||
|
} ]
|
||||||
|
}
|
||||||
|
```
|
|
@ -10,6 +10,7 @@ client.journeys('8011167', '8000261', {results: 1, tickets: true})
|
||||||
// client.departures('8011167', {duration: 1})
|
// client.departures('8011167', {duration: 1})
|
||||||
// client.locations('Berlin Jungfernheide')
|
// client.locations('Berlin Jungfernheide')
|
||||||
// client.locations('Atze Musiktheater', {poi: true, addressses: false, fuzzy: false})
|
// client.locations('Atze Musiktheater', {poi: true, addressses: false, fuzzy: false})
|
||||||
|
// client.location('8000309') // Regensburg Hbf
|
||||||
// client.nearby(52.4751309, 13.3656537, {results: 1})
|
// client.nearby(52.4751309, 13.3656537, {results: 1})
|
||||||
|
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
|
|
|
@ -9,6 +9,7 @@ const client = createClient(oebbProfile)
|
||||||
client.journeys('1291501', '8100002', {results: 1})
|
client.journeys('1291501', '8100002', {results: 1})
|
||||||
// client.departures('8100002', {duration: 1})
|
// client.departures('8100002', {duration: 1})
|
||||||
// client.locations('Salzburg', {results: 2})
|
// client.locations('Salzburg', {results: 2})
|
||||||
|
// client.location('8100173') // Graz Hbf
|
||||||
// client.nearby(47.812851, 13.045604, {distance: 60})
|
// client.nearby(47.812851, 13.045604, {distance: 60})
|
||||||
// client.radar(47.827203, 13.001261, 47.773278, 13.07562, {results: 10})
|
// client.radar(47.827203, 13.001261, 47.773278, 13.07562, {results: 10})
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ const client = createClient(vbbProfile)
|
||||||
client.journeys('900000003201', '900000024101', {results: 1})
|
client.journeys('900000003201', '900000024101', {results: 1})
|
||||||
// client.departures('900000013102', {duration: 1})
|
// client.departures('900000013102', {duration: 1})
|
||||||
// client.locations('Alexanderplatz', {results: 2})
|
// client.locations('Alexanderplatz', {results: 2})
|
||||||
|
// client.location('900000042101') // Spichernstr
|
||||||
// client.nearby(52.5137344, 13.4744798, {distance: 60})
|
// client.nearby(52.5137344, 13.4744798, {distance: 60})
|
||||||
// client.radar(52.52411, 13.41002, 52.51942, 13.41709, {results: 10})
|
// client.radar(52.52411, 13.41002, 52.51942, 13.41709, {results: 10})
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ npm install hafas-client
|
||||||
- [`journeyLeg(ref, lineName, [opt])`](docs/journey-leg.md) – get details for a leg of a journey
|
- [`journeyLeg(ref, lineName, [opt])`](docs/journey-leg.md) – get details for a leg of a journey
|
||||||
- [`departures(station, [opt])`](docs/departures.md) – query the next departures at a station
|
- [`departures(station, [opt])`](docs/departures.md) – query the next departures at a station
|
||||||
- [`locations(query, [opt])`](docs/locations.md) – find stations, POIs and addresses
|
- [`locations(query, [opt])`](docs/locations.md) – find stations, POIs and addresses
|
||||||
|
- [`location(id)`](docs/location.md) – get details about a location
|
||||||
- [`nearby(location, [opt])`](docs/nearby.md) – show stations & POIs around
|
- [`nearby(location, [opt])`](docs/nearby.md) – show stations & POIs around
|
||||||
- [`radar(query, [opt])`](docs/radar.md) – find all vehicles currently in a certain area
|
- [`radar(query, [opt])`](docs/radar.md) – find all vehicles currently in a certain area
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue