forked from public-transport/hafas-client
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.js
53 lines (45 loc) · 1.54 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
48
49
50
51
52
53
import {inspect} from 'util'
import {createClient} from '../../index.js'
import {profile as cmtaProfile} from './index.js'
// Pick a descriptive user agent! hafas-client won't work with this string.
const client = createClient(cmtaProfile, 'hafas-client-example')
const broadieOaks = '000002370'
const domain = '000005919'
let data = await client.locations('Westgate', {results: 2})
// let data = await client.nearby({
// type: 'location',
// latitude: 30.266222,
// longitude: -97.746058
// }, {distance: 60})
// let data = await client.reachableFrom({
// type: 'location',
// address: '604 W 9TH ST, Austin, TX 78701',
// latitude: 30.272910,
// longitude: -97.747883
// }, {
// when: new Date('2018-08-27T10:00:00+0200'),
// maxDuration: 15
// })
// let data = await client.stop('000005534') // Downtown light rail station
// let data = await client.departures(broadieOaks, {duration: 1})
// let data = await client.arrivals(broadieOaks, {duration: 10, linesOfStops: true})
// let data = await client.journeys(broadieOaks, domain, {results: 1, polylines: true})
// {
// const [journey] = data.journeys
// data = await client.refreshJourney(journey.refreshToken, {
// stopovers: true,
// remarks: true,
// })
// }
// {
// const [journey] = data.journeys
// const leg = journey.legs[0]
// data = await client.trip(leg.tripId, {polyline: true})
// }
// let data = await client.radar({
// north: 30.240877,
// west: -97.804588,
// south: 30.225378,
// east: -97.786692
// }, {results: 10})
console.log(inspect(data, {depth: null, colors: true}))