2022-05-07 16:17:37 +02:00
|
|
|
import {inspect} from 'util'
|
|
|
|
import {createClient} from '../../index.js'
|
2022-11-22 21:08:08 +01:00
|
|
|
import {profile as pkpProfile} from './index.js'
|
2020-03-11 20:00:54 +01:00
|
|
|
|
2023-07-28 21:35:56 +02:00
|
|
|
// Pick a descriptive user agent! hafas-client won't work with this string.
|
2022-11-22 21:08:08 +01:00
|
|
|
const client = createClient(pkpProfile, 'hafas-client-example')
|
2020-03-11 20:00:54 +01:00
|
|
|
|
|
|
|
const wrocławGł = '5100069'
|
|
|
|
const krakówGł = '5100028'
|
|
|
|
|
2023-07-28 21:35:56 +02:00
|
|
|
let data = await client.locations('kraków', {results: 2})
|
|
|
|
// let data = await client.stop(krakówGł, {linesOfStops: true})
|
|
|
|
// let data = await client.nearby({
|
2020-03-11 20:00:54 +01:00
|
|
|
// type: 'location',
|
|
|
|
// latitude: 50.067192,
|
|
|
|
// longitude: 19.947423
|
|
|
|
// }, {distance: 60})
|
2023-07-28 21:35:56 +02:00
|
|
|
// let data = await client.radar({
|
2020-03-11 20:00:54 +01:00
|
|
|
// north: 50.2,
|
|
|
|
// west: 19.8,
|
|
|
|
// south: 49.9,
|
|
|
|
// east: 20.1
|
|
|
|
// }, {results: 10})
|
2023-07-28 21:35:56 +02:00
|
|
|
// let data = await client.reachableFrom({
|
2020-03-11 20:00:54 +01:00
|
|
|
// type: 'location',
|
|
|
|
// address: 'Bydgoszcz, Dworcowa 100',
|
|
|
|
// latitude: 53.1336648,
|
|
|
|
// longitude: 17.9908571
|
|
|
|
// }, {
|
|
|
|
// when: new Date(),
|
|
|
|
// maxDuration: 20
|
|
|
|
// })
|
|
|
|
|
2023-07-28 21:35:56 +02:00
|
|
|
// 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,
|
2020-03-11 20:00:54 +01:00
|
|
|
// })
|
2023-07-28 21:35:56 +02:00
|
|
|
// {
|
|
|
|
// const [journey] = data.journeys
|
|
|
|
// const leg = journey.legs[0]
|
|
|
|
// data = await client.trip(leg.tripId, {polyline: true})
|
|
|
|
// }
|
2020-03-11 20:00:54 +01:00
|
|
|
|
2023-07-28 21:35:56 +02:00
|
|
|
console.log(inspect(data, {depth: null, colors: true}))
|