forked from public-transport/hafas-client
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.js
47 lines (41 loc) · 1.33 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import {inspect} from 'util'
import {createClient} from '../../index.js'
import {profile as pkpProfile} from './index.js'
// Pick a descriptive user agent! hafas-client won't work with this string.
const client = createClient(pkpProfile, 'hafas-client-example')
const wrocławGł = '5100069'
const krakówGł = '5100028'
let data = await client.locations('kraków', {results: 2})
// let data = await client.stop(krakówGł, {linesOfStops: true})
// let data = await client.nearby({
// type: 'location',
// latitude: 50.067192,
// longitude: 19.947423
// }, {distance: 60})
// let data = await client.radar({
// north: 50.2,
// west: 19.8,
// south: 49.9,
// east: 20.1
// }, {results: 10})
// let data = await client.reachableFrom({
// type: 'location',
// address: 'Bydgoszcz, Dworcowa 100',
// latitude: 53.1336648,
// longitude: 17.9908571
// }, {
// when: new Date(),
// maxDuration: 20
// })
// let data = await client.departures(krakówGł, {duration: 10})
// let data = await client.arrivals(krakówGł, {duration: 10, linesOfStops: true})
// let data = await client.journeys(krakówGł, wrocławGł, {
// results: 1,
// polylines: true,
// })
// {
// const [journey] = data.journeys
// const leg = journey.legs[0]
// data = await client.trip(leg.tripId, {polyline: true})
// }
console.log(inspect(data, {depth: null, colors: true}))