From 581a47510d57e767eca8ceda51d66f482dae1e58 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Fri, 28 Jul 2023 21:35:56 +0200 Subject: [PATCH] =?UTF-8?q?profiles'=20examples:=20fixes,=20minor=20tweaks?= =?UTF-8?q?=20=F0=9F=90=9B=F0=9F=93=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - hafas.station() -> hafas.stop() 🐛 - put stop IDs into variables - .then/.catch -> async/await - consistent order of methods - minor reformatting for readability --- p/avv/example.js | 61 +++++++++++++++--------------- p/bart/example.js | 61 +++++++++++++++--------------- p/bls/example.js | 64 +++++++++++++++++--------------- p/bvg/example.js | 60 +++++++++++++++++------------- p/cfl/example.js | 60 +++++++++++++++--------------- p/cmta/example.js | 60 ++++++++++++++++-------------- p/dart/example.js | 54 ++++++++++++++------------- p/db-busradar-nrw/example.js | 48 +++++++++++++----------- p/db/example.js | 66 ++++++++++++++++++++------------- p/insa/example.js | 53 +++++++++++++------------- p/invg/example.js | 49 ++++++++++++------------ p/irish-rail/example.js | 43 ++++++++++++--------- p/ivb/example.js | 69 +++++++++++++++++----------------- p/kvb/example.js | 50 +++++++++++++------------ p/mobil-nrw/example.js | 57 +++++++++++++++------------- p/mobiliteit-lu/example.js | 61 +++++++++++++++--------------- p/nahsh/example.js | 53 ++++++++++++++------------ p/nvv/example.js | 63 +++++++++++++++++-------------- p/oebb/example.js | 60 +++++++++++++++++------------- p/ooevv/example.js | 50 +++++++++++++------------ p/pkp/example.js | 36 +++++++++--------- p/rejseplanen/example.js | 35 ++++++++++-------- p/rmv/example.js | 55 ++++++++++++++------------- p/rsag/example.js | 48 ++++++++++++------------ p/saarfahrplan/example.js | 64 +++++++++++++++++++------------- p/salzburg/example.js | 72 ++++++++++++++++++------------------ p/sbahn-muenchen/example.js | 59 +++++++++++++++-------------- p/sncb/example.js | 44 ++++++++++++---------- p/stv/example.js | 69 +++++++++++++++++----------------- p/svv/example.js | 45 +++++++++++----------- p/tpg/example.js | 64 +++++++++++++++++--------------- p/vbb/example.js | 65 ++++++++++++++++++-------------- p/vbn/example.js | 47 +++++++++++------------ p/vkg/example.js | 50 +++++++++++++------------ p/vmt/example.js | 42 +++++++++++---------- p/vor/example.js | 50 +++++++++++++------------ p/vos/example.js | 61 +++++++++++++++--------------- p/vrn/example.js | 51 +++++++++++++------------ p/vsn/example.js | 65 ++++++++++++++++++-------------- p/vvt/example.js | 54 +++++++++++++++------------ p/vvv/example.js | 53 ++++++++++++++------------ p/zvv/example.js | 66 ++++++++++++++++++--------------- 42 files changed, 1255 insertions(+), 1082 deletions(-) diff --git a/p/avv/example.js b/p/avv/example.js index dfce1c7f..3e5edd9a 100644 --- a/p/avv/example.js +++ b/p/avv/example.js @@ -2,41 +2,19 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as avvProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(avvProfile, 'hafas-client-example') const rwth = '1057' const kronenberg = '1397' -// client.journeys(rwth, kronenberg, {results: 1, stopovers: true}) - -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) - -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) - -// client.departures(rwth, {duration: 1}) -// client.arrivals(rwth, {duration: 10, linesOfStops: true}) -// client.radar({ -// north: 50.78141, -// west: 6.06031, -// south: 50.75022, -// east: 6.10316, -// }, {results: 10}) - -client.locations('kronenberg', {results: 3}) -// client.stop(rwth, {linesOfStops: true}) -// client.nearby({ +let data = await client.locations('kronenberg', {results: 3}) +// let data = await client.nearby({ // type: 'location', // latitude: 50.770607, // longitude: 6.104637, // }, {distance: 500}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // id: '990000745', // address: 'Aachen, Charlottenstraße 11', @@ -46,7 +24,30 @@ client.locations('kronenberg', {results: 3}) // maxDuration: 8, // }) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// let data = await client.stop(rwth, {linesOfStops: true}) + +// let data = await client.departures(rwth, {duration: 1}) +// let data = await client.arrivals(rwth, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(rwth, kronenberg, {results: 1, stopovers: 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: 50.78141, +// west: 6.06031, +// south: 50.75022, +// east: 6.10316, +// }, {results: 10}) + +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/bart/example.js b/p/bart/example.js index 9ac768ad..c9af7308 100644 --- a/p/bart/example.js +++ b/p/bart/example.js @@ -2,41 +2,19 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as bartProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(bartProfile, 'hafas-client-example') const fremont = '100013296' const embarcadero = '100013295' -// client.journeys(fremont, embarcadero, {results: 1, stopovers: true}) - -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) - -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) - -// client.departures(fremont, {duration: 1}) -// client.arrivals(fremont, {duration: 10, linesOfStops: true}) -// client.radar({ -// north: 37.8735, -// west: -122.5250, -// south: 37.6884, -// east: -122.2105, -// }, {results: 10}) - -client.locations('embarcadero', {results: 3}) -// client.stop(fremont, {linesOfStops: true}) -// client.nearby({ +let data = await client.locations('embarcadero', {results: 3}) +// let data = await client.nearby({ // type: 'location', // latitude: 38.554779, // longitude: -121.738798, // }, {distance: 500}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // id: '980557173', // address: '1000 Alice St, Davis, 95616', @@ -46,7 +24,30 @@ client.locations('embarcadero', {results: 3}) // maxDuration: 8, // }) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// let data = await client.stop(fremont, {linesOfStops: true}) + +// let data = await client.departures(fremont, {duration: 1}) +// let data = await client.arrivals(fremont, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(fremont, embarcadero, {results: 1, stopovers: 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: 37.8735, +// west: -122.5250, +// south: 37.6884, +// east: -122.2105, +// }, {results: 10}) + +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/bls/example.js b/p/bls/example.js index 6fe3b7ed..3c26e690 100644 --- a/p/bls/example.js +++ b/p/bls/example.js @@ -2,41 +2,19 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as blsProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(blsProfile, 'hafas-client-example') const bernDennigkofengässli = '8590093' const münsingenSpital = '8578932' -client.journeys(bernDennigkofengässli, münsingenSpital, {results: 1, stopovers: true}) - -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) - -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) - -// client.departures(bernDennigkofengässli, {duration: 1}) -// client.arrivals(bernDennigkofengässli, {duration: 10, linesOfStops: true}) -// client.radar({ -// north: 46.969, -// west: 7.3941, -// south: 46.921, -// east: 7.5141, -// }, {results: 10}) - -// client.locations('münsingen spital', {results: 3}) -// client.stop(bernDennigkofengässli, {linesOfStops: true}) -// client.nearby({ +let data = await client.locations('münsingen spital', {results: 3}) +// let data = await client.nearby({ // type: 'location', // latitude: 53.554422, // longitude: 9.977934 // }, {distance: 500}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // id: '990017698', // address: 'Bern, Schänzlihalde 17', @@ -46,7 +24,33 @@ client.journeys(bernDennigkofengässli, münsingenSpital, {results: 1, stopovers // maxDuration: 10, // }) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// let data = await client.stop(bernDennigkofengässli, {linesOfStops: true}) + +// let data = await client.departures(bernDennigkofengässli, {duration: 1}) +// let data = await client.arrivals(bernDennigkofengässli, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(bernDennigkofengässli, münsingenSpital, { +// results: 1, +// stopovers: 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: 46.969, +// west: 7.3941, +// south: 46.921, +// east: 7.5141, +// }, {results: 10}) + +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/bvg/example.js b/p/bvg/example.js index 8597926a..49b04cfe 100644 --- a/p/bvg/example.js +++ b/p/bvg/example.js @@ -2,26 +2,21 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as bvgProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(bvgProfile, 'hafas-client-example') -// Hauptbahnhof to Charlottenburg -client.journeys('900000003201', '900000024101', {results: 1, polylines: true}) -// client.departures('900000013102', {duration: 1}) -// client.arrivals('900000013102', {duration: 10, linesOfStops: true}) -// client.locations('Alexanderplatz', {results: 2}) -// client.stop('900000042101', {linesOfStops: true}) // Spichernstr -// client.nearby({ +const berlinHbf = '900003201' +const charlottenburg = '900024101' +const kottbusserTor = '900013102' +const spichernstr = '900042101' + +let data = await client.locations('Alexanderplatz', {results: 2}) +// let data = await client.nearby({ // type: 'location', // latitude: 52.5137344, // longitude: 13.4744798 // }, {distance: 60}) -// client.radar({ -// north: 52.52411, -// west: 13.41002, -// south: 52.51942, -// east: 13.41709 -// }, {results: 10}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // address: '13353 Berlin-Wedding, Torfstr. 17', // latitude: 52.541797, @@ -31,17 +26,30 @@ client.journeys('900000003201', '900000024101', {results: 1, polylines: true}) // maxDuration: 10 // }) -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) +// let data = await client.stop(spichernstr, {linesOfStops: true}) // Spichernstr -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) +// let data = await client.departures(kottbusserTor, {duration: 1}) +// let data = await client.arrivals(kottbusserTor, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(berlinHbf, charlottenburg, { +// results: 1, +// polylines: true, // }) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// { +// const [journey] = data.journeys +// const leg = journey.legs[0] +// data = await client.trip(leg.tripId, {polyline: true}) +// } +// { +// const [journey] = data.journeys +// data = await client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) +// } + +// let data = await client.radar({ +// north: 52.52411, +// west: 13.41002, +// south: 52.51942, +// east: 13.41709 +// }, {results: 10}) + +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/cfl/example.js b/p/cfl/example.js index d94446be..cf0e70d5 100644 --- a/p/cfl/example.js +++ b/p/cfl/example.js @@ -2,40 +2,19 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as cflProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(cflProfile, 'hafas-client-example') const mersch = '9864348' const bruxellesCentral = '8800003' -// from Mersch to Bruxelles Central -client.journeys(mersch, bruxellesCentral, {results: 1}) -// .then(({journeys}) => { -// const leg = journeys[0].legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) - -// client.locations('mersch', {results: 3}) -// client.stop(mersch) -// client.nearby({ +let data = await client.locations('mersch', {results: 3}) +// let data = await client.nearby({ // type: 'location', // latitude: 49.7523, // longitude: 6.1103 // }, {distance: 500}) - -// client.departures(mersch, {duration: 5}) -// client.arrivals(mersch, {duration: 10, linesOfStops: true}) - -// client.radar({ -// north: 49.9, -// west: 6.11, -// south: 49.7, -// east: 6.13 -// }, {results: 10}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // id: '980005067', // address: '7557 Mersch, Rue Mies 1', @@ -45,7 +24,30 @@ client.journeys(mersch, bruxellesCentral, {results: 1}) // maxDuration: 30, // }) -.then(data => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// let data = await client.stop(mersch) + +// let data = await client.departures(mersch, {duration: 5}) +// let data = await client.arrivals(mersch, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(mersch, bruxellesCentral, {results: 1}) +// { +// const [journey] = data.journeys +// const [leg] = journey.legs +// data = await client.trip(leg.tripId, {polyline: true}) +// } +// { +// const [journey] = journeys +// data = await client.refreshJourney(journey.refreshToken, { +// stopovers: true, +// remarks: true, +// }) +// } + +// let data = await client.radar({ +// north: 49.9, +// west: 6.11, +// south: 49.7, +// east: 6.13 +// }, {results: 10}) + +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/cmta/example.js b/p/cmta/example.js index a5cb3dda..e2ce82c3 100644 --- a/p/cmta/example.js +++ b/p/cmta/example.js @@ -2,26 +2,19 @@ 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') -// Broadie Oaks to Domain -client.journeys('000002370', '000005919', {results: 1, polylines: true}) -// client.departures('000002370', {duration: 1}) -// client.arrivals('000002370', {duration: 10, linesOfStops: true}) -// client.locations('Westgate', {results: 2}) -// client.stop('000005534') // Downtown light rail station -// client.nearby({ +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}) -// client.radar({ -// north: 30.240877, -// west: -97.804588, -// south: 30.225378, -// east: -97.786692 -// }, {results: 10}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // address: '604 W 9TH ST, Austin, TX 78701', // latitude: 30.272910, @@ -31,17 +24,30 @@ client.journeys('000002370', '000005919', {results: 1, polylines: true}) // maxDuration: 15 // }) -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) +// let data = await client.stop('000005534') // Downtown light rail station -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// 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})) diff --git a/p/dart/example.js b/p/dart/example.js index c37fa83d..778eb84b 100644 --- a/p/dart/example.js +++ b/p/dart/example.js @@ -2,37 +2,21 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as dartProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(dartProfile, 'hafas-client example') const mlkJrPkwyAdamsAveDsm2055 = '100002702' const se5thStEHackleyAveDsm2294 = '100004972' -// client.journeys(mlkJrPkwyAdamsAveDsm2055, se5thStEHackleyAveDsm2294, { -// results: 1, stopovers: true, -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs.find(l => !!l.line) -// return client.trip(leg.tripId, {polyline: true}) -// }) - -// client.departures(mlkJrPkwyAdamsAveDsm2055, {duration: 10}) -// client.arrivals(mlkJrPkwyAdamsAveDsm2055, {linesOfStops: true}) - -client.locations('adams ave', {results: 3}) -// client.stop(mlkJrPkwyAdamsAveDsm2055, {linesOfStops: true}) -// client.nearby({ +let data = await client.locations('adams ave', {results: 3}) +// let data = await client.nearby({ // type: 'location', // id: '980010311', // address: 'Austraße 37, 6700 Bludenz', // latitude: 41.6056, // longitude: -93.5916, // }, {distance: 1000}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // latitude: 41.613584, // longitude: -93.881803, @@ -40,14 +24,34 @@ client.locations('adams ave', {results: 3}) // }, { // maxDuration: 20, // }) -// client.radar({ + +// let data = await client.stop(mlkJrPkwyAdamsAveDsm2055, {linesOfStops: true}) + +// let data = await client.departures(mlkJrPkwyAdamsAveDsm2055, {duration: 10}) +// let data = await client.arrivals(mlkJrPkwyAdamsAveDsm2055, {linesOfStops: true}) + +// let data = await client.journeys(mlkJrPkwyAdamsAveDsm2055, se5thStEHackleyAveDsm2294, { +// results: 1, +// stopovers: true, +// }) +// { +// const [journey] = data.journeys +// data = await client.refreshJourney(journey.refreshToken, { +// stopovers: true, +// remarks: true, +// }) +// } +// { +// const [journey] = data.journeys +// const leg = journey.legs.find(l => !!l.line) +// data = await client.trip(leg.tripId, {polyline: true}) +// } + +// let data = await client.radar({ // north: 41.6266, // west: -93.7299, // south: 41.5503, // east: -93.5699, // }) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/db-busradar-nrw/example.js b/p/db-busradar-nrw/example.js index 217bfdee..fb904b6d 100644 --- a/p/db-busradar-nrw/example.js +++ b/p/db-busradar-nrw/example.js @@ -2,39 +2,43 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as dbbusradarnrwProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(dbbusradarnrwProfile, 'hafas-client-example') -// Hagen Bauhaus to Schwerte Bahnhof -// returns hafas error PARSE -client.journeys('3307002', '3357026', {results: 1}) -// .then(({journeys}) => { -// const leg = journeys[0].legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) +const hagenBauhaus = '3307002' +const schwerteBahnhof = '3357026' -// client.departures('3307002', {duration: 60}) -// client.arrivals('3307002', {duration: 30, linesOfStops: true}) -// client.locations('Hagen Vorhalle') -// client.stop('3307002') // Hagen Bauhaus - -// client.nearby({ +let data = await client.locations('Hagen Vorhalle') +// let data = await client.nearby({ // type: 'location', // latitude: 51.38, // longitude: 7.45 // }, {results: 1}) -// client.radar({ +// let data = await client.stop(hagenBauhaus) // Hagen Bauhaus + +// let data = await client.departures(hagenBauhaus, {duration: 60}) +// let data = await client.arrivals(hagenBauhaus, {duration: 30, linesOfStops: true}) + +// let data = await client.journeys(hagenBauhaus, schwerteBahnhof, {results: 1}) +// { +// 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: 51.5, // west: 7.2, // south: 51.2, // east: 7.8 // }, {results: 10}) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}, console.error) - +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/db/example.js b/p/db/example.js index 344a20a0..358f8c51 100644 --- a/p/db/example.js +++ b/p/db/example.js @@ -2,30 +2,25 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as dbProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(dbProfile, 'hafas-client-example') -// Berlin Jungfernheide to München Hbf -client.journeys('8011167', '8000261', {results: 1, tickets: true}) -// .then(({journeys}) => { -// const leg = journeys[0].legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) +const berlinJungfernheide = '8011167' +const münchenHbf = '8000261' +const regensburgHbf = '8000309' -// client.departures('8011167', {duration: 1}) -// client.arrivals('8011167', {duration: 10, linesOfStops: true}) -// client.locations('Berlin Jungfernheide') -// client.locations('Atze Musiktheater', {poi: true, addressses: false, fuzzy: false}) -// client.stop('8000309') // Regensburg Hbf -// client.nearby({ +let data = await client.locations('Berlin Jungfernheide') +// let data = await client.locations('Atze Musiktheater', { +// poi: true, +// addressses: false, +// fuzzy: false, +// }) +// let data = await client.nearby({ // type: 'location', // latitude: 52.4751309, // longitude: 13.3656537 // }, {results: 1}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // address: '13353 Berlin-Wedding, Torfstr. 17', // latitude: 52.541797, @@ -34,25 +29,46 @@ client.journeys('8011167', '8000261', {results: 1, tickets: true}) // when: new Date('2018-08-27T10:00:00+0200'), // maxDuration: 50 // }) -// client.radar({ + +// let data = await client.stop(regensburgHbf) + +// let data = await client.departures(berlinJungfernheide, {duration: 1}) +// let data = await client.arrivals(berlinJungfernheide, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(berlinJungfernheide, münchenHbf, { +// results: 1, +// tickets: true, +// }) +// { +// const [journey] = data.journeys +// const leg = journey.legs[0] +// data = await client.trip(leg.tripId, {polyline: true}) +// } +// { +// const [journey] = data.journeys +// data = await client.refreshJourney(journey.refreshToken, { +// stopovers: true, +// remarks: true, +// }) +// } + +// let data = await client.radar({ // north: 52.52411, // west: 13.41002, // south: 52.51942, // east: 13.41709 // }, {results: 10}) -// client.journeys('8011113', '8000261', { +// let data = await client.journeys('8011113', '8000261', { // departure: Date.now() - 2 * 60 * 60 * 1000, // results: 1, stopovers: true, transfers: 1 // }) -// .then(({journeys}) => { +// { // const leg = journeys[0].legs.find(l => l.line && l.line.product === 'nationalExpress') // const prevStopover = leg.stopovers.find((st) => { // return st.departure && Date.parse(st.departure) < Date.now() // }) -// return client.journeysFromTrip(leg.tripId, prevStopover, '8000207') -// }) +// data = await client.journeysFromTrip(leg.tripId, prevStopover, '8000207') +// } -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}, console.error) +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/insa/example.js b/p/insa/example.js index 4b6006e0..b93a68e8 100644 --- a/p/insa/example.js +++ b/p/insa/example.js @@ -2,8 +2,11 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as insaProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(insaProfile, 'hafas-client-example') +const magdeburgNeustadt = '008010226' +const magdeburgBuckau = '008013456' const hellestr1 = { type: 'location', id: '980801263', @@ -11,35 +14,35 @@ const hellestr1 = { latitude: 52.116706, longitude: 11.621821 } -// from Magdeburg-Neustadt to Magdeburg-Buckau -client.journeys('008010226', '008013456', {results: 1}) +let data = await client.locations('Magdeburg Hbf', {results: 2}) +// let data = await client.locations('Kunstmuseum Kloster Unser Lieben Frauen Magdeburg', {results: 2}) +// let data = await client.nearby(hellestr1) +// let data = await client.reachableFrom(hellestr1, {maxDuration: 10}) -// client.departures('008010226', { duration: 5 }) -// client.arrivals('8010226', {duration: 10, linesOfStops: true}) -// client.locations('Magdeburg Hbf', {results: 2}) -// client.locations('Kunstmuseum Kloster Unser Lieben Frauen Magdeburg', {results: 2}) -// client.stop('008010226') // Magdeburg-Neustadt -// client.nearby(hellestr1) -// client.radar({ +// let data = await client.stop(magdeburgNeustadt) + +// let data = await client.departures(magdeburgNeustadt, { duration: 5 }) +// let data = await client.arrivals('8010226', {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(magdeburgNeustadt, magdeburgBuckau, {results: 1}) +// { +// 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, leg.line.name) +// } + +// let data = await client.radar({ // north: 52.148364, // west: 11.600826, // south: 52.108486, // east: 11.651451 // }, {results: 10}) -// client.reachableFrom(hellestr1, {maxDuration: 10}) -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, leg.line.name) -// }) - -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) - -.then(data => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/invg/example.js b/p/invg/example.js index 0759de04..8c93a87f 100644 --- a/p/invg/example.js +++ b/p/invg/example.js @@ -2,43 +2,44 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as invgProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(invgProfile, 'hafas-client-example') const ingolstadtHbf = '8000183' const audiParkplatz = '84999' -client.journeys(ingolstadtHbf, audiParkplatz, {results: 1}) -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) - -// client.departures(ingolstadtHbf, {duration: 5}) -// client.arrivals(ingolstadtHbf, {duration: 10, stationLines: true}) - -// client.locations('tillystr 1', {results: 2}) -// client.station(audiParkplatz) // Audi Parkplatz -// client.nearby({ +let data = await client.locations('tillystr 1', {results: 2}) +// let data = await client.nearby({ // type: 'location', // latitude: 48.74453, // longitude: 11.43733 // }, {distance: 200}) +// // todo: `reachableFrom` with `Ingolstadt, Tillystraße 1` 48.745769 | 11.432814 -// client.radar({ +// let data = await client.stop(audiParkplatz) + +// let data = await client.departures(ingolstadtHbf, {duration: 5}) +// let data = await client.arrivals(ingolstadtHbf, {duration: 10, stationLines: true}) + +// let data = await client.journeys(ingolstadtHbf, audiParkplatz, {results: 1}) +// { +// 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: 48.74453, // west: 11.42733, // south: 48.73453, // east: 11.43733 // }, {results: 10}) -// todo: `reachableFrom` with `Ingolstadt, Tillystraße 1` 48.745769 | 11.432814 - -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/irish-rail/example.js b/p/irish-rail/example.js index 1cc60d9b..fbb681df 100644 --- a/p/irish-rail/example.js +++ b/p/irish-rail/example.js @@ -2,34 +2,41 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as irishProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(irishProfile, 'hafas-client example') -// from Dublin to Belfast Central -client.journeys('9909002', '9990840', {results: 1}) -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) +const dublin = '9909002' +const belfastCentral = '9990840' -// client.departures('9909002', {duration: 5}) -// client.arrivals('9909002', {duration: 10, linesOfStops: true}) -// client.locations('Dublin', {results: 2}) -// client.locations('Hochschule Dublin', {poi: true, addressses: false, fuzzy: false}) -// client.stop('9909002') // Dublin -// client.nearby({ +let data = await client.locations('Dublin', {results: 2}) +// let data = await client.locations('Hochschule Dublin', { +// poi: true, +// addressses: false, +// fuzzy: false, +// }) +// let data = await client.nearby({ // type: 'location', // latitude: 53.353, // longitude: -6.247 // }, {distance: 200}) -// client.radar({ + +// let data = await client.stop(dublin) // Dublin + +// let data = await client.departures(dublin, {duration: 5}) +// let data = await client.arrivals(dublin, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(dublin, belfastCentral, {results: 1}) +// { +// const [journey] = data.journeys +// const leg = journey.legs[0] +// data = await client.trip(leg.tripId, {polyline: true}) +// } + +// let data = await client.radar({ // north: 53.35, // west: -6.245, // south: 53.34, // east: -6.244 // }, {results: 10}) -.then(data => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/ivb/example.js b/p/ivb/example.js index 9b951594..cbce87f7 100644 --- a/p/ivb/example.js +++ b/p/ivb/example.js @@ -2,47 +2,44 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as ivbProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(ivbProfile, 'hafas-client example') const innsbruckGriesauweg = '476162400' const völsWest = '476431800' +const lönsstr9 = { + type: 'location', + id: '980076175', + address: 'Lönsstraße 9, 6020 Innsbruck', + latitude: 47.262765, + longitude: 11.419851, +} -// client.journeys(innsbruckGriesauweg, völsWest, { -// results: 1, stopovers: true, -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) - -// client.departures(innsbruckGriesauweg, {duration: 1}) -// client.arrivals(innsbruckGriesauweg, {duration: 10, linesOfStops: true}) - -client.locations('griesauweg', {results: 3}) -// client.stop(innsbruckGriesauweg, {linesOfStops: true}) -// client.nearby({ -// type: 'location', -// id: '980076175', -// address: 'Lönsstraße 9, 6020 Innsbruck', -// latitude: 47.262765, -// longitude: 11.419851, -// }, {distance: 1000}) -// client.reachableFrom({ -// type: 'location', -// id: '980076175', -// address: 'Lönsstraße 9, 6020 Innsbruck', -// latitude: 47.262765, -// longitude: 11.419851, -// }, { +let data = await client.locations('griesauweg', {results: 3}) +// let data = await client.nearby(lönsstr9, {distance: 1000}) +// let data = await client.reachableFrom(lönsstr9, { // maxDuration: 30, // }) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// let data = await client.stop(innsbruckGriesauweg, {linesOfStops: true}) + +// let data = await client.departures(innsbruckGriesauweg, {duration: 1}) +// let data = await client.arrivals(innsbruckGriesauweg, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(innsbruckGriesauweg, völsWest, { +// results: 1, stopovers: 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}) +// } + +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/kvb/example.js b/p/kvb/example.js index 326fb556..8a02f5ba 100644 --- a/p/kvb/example.js +++ b/p/kvb/example.js @@ -2,36 +2,20 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as kvbProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(kvbProfile, 'hafas-client example') const heumarkt = '900000001' const poststr = '900000003' -// client.journeys(heumarkt, poststr, { -// results: 1, stopovers: true, -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) - -// client.departures(heumarkt, {duration: 1}) -// client.arrivals(heumarkt, {duration: 10, linesOfStops: true}) - -client.locations('heumarkt', {results: 3}) -// client.stop(heumarkt, {linesOfStops: true}) -// client.nearby({ +let data = await client.locations('heumarkt', {results: 3}) +// let data = await client.nearby({ // type: 'location', // id: '991023531', // address: 'An den Dominikanern 27', // latitude: 50.942454, longitude: 6.954064, // }, {distance: 500}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // id: '991023531', // address: 'An den Dominikanern 27', @@ -40,7 +24,25 @@ client.locations('heumarkt', {results: 3}) // maxDuration: 15, // }) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// let data = await client.stop(heumarkt, {linesOfStops: true}) + +// let data = await client.departures(heumarkt, {duration: 1}) +// let data = await client.arrivals(heumarkt, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(heumarkt, poststr, { +// results: 1, stopovers: 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}) +// } + +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/mobil-nrw/example.js b/p/mobil-nrw/example.js index c80e1a12..1a57ae75 100644 --- a/p/mobil-nrw/example.js +++ b/p/mobil-nrw/example.js @@ -2,24 +2,19 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as mobilNrwProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(mobilNrwProfile, 'hafas-client-example') const soest = '8000076' const aachenHbf = '8000001' -client.journeys(soest, aachenHbf, {results: 1, stopovers: true}) -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) - -// client.locations('soest', {results: 3}) -// client.reachableFrom({ +let data = await client.locations('soest', {results: 3}) +// let data = await client.nearby({ +// type: 'location', +// latitude: 51.4503, +// longitude: 6.6581, +// }, {distance: 1200}) +// let data = await client.reachableFrom({ // type: 'location', // id: '980301639', // latitude: 51.387609, @@ -28,25 +23,35 @@ client.journeys(soest, aachenHbf, {results: 1, stopovers: true}) // }, { // maxDuration: 15, // }) -// client.nearby({ -// type: 'location', -// latitude: 51.4503, -// longitude: 6.6581, -// }, {distance: 1200}) -// client.station(soest) -// client.departures(soest, {duration: 20}) +// let data = await client.stop(soest) -// client.radar({ +// let data = await client.departures(soest, {duration: 20}) + +// let data = await client.journeys(soest, aachenHbf, { +// results: 1, +// stopovers: 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: 51.4358, // west: 6.7625, // south: 51.4214, // east: 6.7900, // }, {results: 10}) -// client.remarks() +// let data = await client.remarks() -.then(data => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/mobiliteit-lu/example.js b/p/mobiliteit-lu/example.js index 0da84ffc..6e9d96e9 100644 --- a/p/mobiliteit-lu/example.js +++ b/p/mobiliteit-lu/example.js @@ -2,41 +2,19 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as mobiliteitluProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(mobiliteitluProfile, 'hafas-client example') const mersch = '160904011' const luxembourgCentral = '200405060' -// from Mersch to Bruxelles Central -client.journeys(mersch, luxembourgCentral, {results: 1}) -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) - -// client.locations('mersch', {results: 3}) -// client.stop(mersch) -// client.nearby({ +let data = await client.locations('mersch', {results: 3}) +// let data = await client.nearby({ // type: 'location', // latitude: 49.7523, // longitude: 6.1103 // }, {distance: 500}) - -// client.departures(mersch, {duration: 5}) -// client.arrivals(mersch, {duration: 10, linesOfStops: true}) - -// client.radar({ -// north: 49.9, -// west: 6.11, -// south: 49.7, -// east: 6.13 -// }, {results: 10}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // id: '990005227', // address: 'Mersch, Rue Mies 1', @@ -45,7 +23,30 @@ client.journeys(mersch, luxembourgCentral, {results: 1}) // maxDuration: 30 // }) -.then(data => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// let data = await client.stop(mersch) + +// let data = await client.departures(mersch, {duration: 5}) +// let data = await client.arrivals(mersch, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(mersch, luxembourgCentral, {results: 1}) +// { +// const [journey] = data.journeys +// const leg = journey.legs[0] +// data = await client.trip(leg.tripId, {polyline: true}) +// } +// { +// const [journey] = data.journeys +// data = await client.refreshJourney(journey.refreshToken, { +// stopovers: true, +// remarks: true, +// }) +// } + +// let data = await client.radar({ +// north: 49.9, +// west: 6.11, +// south: 49.7, +// east: 6.13 +// }, {results: 10}) + +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/nahsh/example.js b/p/nahsh/example.js index 16cf3e5d..24be87b9 100644 --- a/p/nahsh/example.js +++ b/p/nahsh/example.js @@ -2,31 +2,19 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as nahshProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(nahshProfile, 'hafas-client-example') -// Flensburg Hbf to Kiel Hbf -client.journeys('8000103', '8000199', {results: 10, tickets: true}) -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) +const flensburgHbf = '8000103' +const kielHbf = '8000199' -// client.departures('8000199', {duration: 10}) -// client.arrivals('8000199', {duration: 5, linesOfStops: true}) -// client.trip('1|30161|5|100|14032018', 'Bus 52') -// client.locations('Schleswig', {results: 1}) -// client.stop('706990') // Kiel Holunderbusch -// client.nearby({ +let data = await client.locations('Schleswig', {results: 1}) +// let data = await client.nearby({ // type: 'location', // latitude: 54.295691, // longitude: 10.116424 // }, {distance: 60}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // address: 'Husum, Berliner Straße 80', // latitude: 54.488995, @@ -36,7 +24,29 @@ client.journeys('8000103', '8000199', {results: 10, tickets: true}) // maxDuration: 20 // }) -// client.radar({ +// let data = await client.stop('706990') // Kiel Holunderbusch + +// let data = await client.departures(kielHbf, {duration: 10}) +// let data = await client.arrivals(kielHbf, {duration: 5, linesOfStops: true}) + +// let data = await client.journeys(flensburgHbf, kielHbf, { +// results: 10, +// tickets: 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: 54.4, // west: 10.0, // south: 54.2, @@ -45,7 +55,4 @@ client.journeys('8000103', '8000199', {results: 10, tickets: true}) // results: 10, // }) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/nvv/example.js b/p/nvv/example.js index bf480835..2744dcdb 100644 --- a/p/nvv/example.js +++ b/p/nvv/example.js @@ -2,36 +2,19 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as nvvProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(nvvProfile, 'hafas-client-example') -// Scheidemannplatz to Auestadion -client.journeys('2200073', '2200042', {results: 1, polylines: true}) -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs.find(l => !!l.line) -// return client.trip(leg.tripId, {polyline: true}) -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) +const scheidemannplatz = '2200073' +const auestadion = '2200042' -// client.departures('2200005', {duration: 1}) -// client.arrivals('2200005', {duration: 10, linesOfStops: true}) -// client.locations('kirchweg', {results: 2}) -// client.stop('2200005', {linesOfStops: true}) // Kassel Kirchweg -// client.nearby({ +let data = await client.locations('kirchweg', {results: 2}) +// let data = await client.nearby({ // type: 'location', // latitude: 51.313, // longitude: 9.4654 // }, {distance: 400}) -// client.radar({ -// north: 51.320153, -// west: 9.458359, -// south: 51.304304, -// east: 9.493672 -// }, {results: 10}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // id: '990100251', // address: 'Kassel, Heckerstraße 2', @@ -42,7 +25,33 @@ client.journeys('2200073', '2200042', {results: 1, polylines: true}) // maxDuration: 10 // }) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// let data = await client.stop('2200005', {linesOfStops: true}) // Kassel Kirchweg + +// let data = await client.departures('2200005', {duration: 1}) +// let data = await client.arrivals('2200005', {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(scheidemannplatz, auestadion, { +// 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.find(l => !!l.line) +// data = await client.trip(leg.tripId, {polyline: true}) +// } + +// let data = await client.radar({ +// north: 51.320153, +// west: 9.458359, +// south: 51.304304, +// east: 9.493672 +// }, {results: 10}) + +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/oebb/example.js b/p/oebb/example.js index b27d4fe1..7e83e834 100644 --- a/p/oebb/example.js +++ b/p/oebb/example.js @@ -2,35 +2,20 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as oebbProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(oebbProfile, 'hafas-client-example') -// Wien Westbahnhof to Salzburg Hbf -client.journeys('1291501', '8100002', {results: 1}) -// .then(({journeys}) => { -// const leg = journeys[0].legs[0] -// return client.trip(leg.tripId, leg.line.name) -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) +const westbahnhof = '1291501' +const salzburgHbf = '8100002' +const grazHbf = '8100173' -// client.departures('8100002', {duration: 1}) -// client.arrivals('8100002', {duration: 10, linesOfStops: true}) -// client.locations('Salzburg', {results: 2}) -// client.stop('8100173') // Graz Hbf -// client.nearby({ +let data = await client.locations('Salzburg', {results: 2}) +// let data = await client.nearby({ // type: 'location', // latitude: 47.812851, // longitude: 13.045604 // }, {distance: 60}) -// client.radar({ -// north: 47.827203, -// west: 13.001261, -// south: 47.773278, -// east: 13.07562 -// }, {results: 10}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // id: '970053039', // name: 'Graz, BILLA, Hauptplatz', @@ -41,7 +26,30 @@ client.journeys('1291501', '8100002', {results: 1}) // maxDuration: 20 // }) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// let data = await client.stop(grazHbf) + +// let data = await client.departures(salzburgHbf, {duration: 1}) +// let data = await client.arrivals(salzburgHbf, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(westbahnhof, salzburgHbf, {results: 1}) +// { +// const [journey] = data.journeys +// data = await client.refreshJourney(journey.refreshToken, { +// stopovers: true, +// remarks: true, +// }) +// } +// { +// const [journey] = data.journeys +// const [leg] = journey.legs +// data = await client.trip(leg.tripId, leg.line.name) +// } + +// let data = await client.radar({ +// north: 47.827203, +// west: 13.001261, +// south: 47.773278, +// east: 13.07562 +// }, {results: 10}) + +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/ooevv/example.js b/p/ooevv/example.js index d5349644..621cef7a 100644 --- a/p/ooevv/example.js +++ b/p/ooevv/example.js @@ -2,37 +2,21 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as ooevvProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(ooevvProfile, 'hafas-client example') const linzTheatergasse = '444670100' const amstettenStadtbad = '431507400' -// client.journeys(linzTheatergasse, amstettenStadtbad, { -// results: 1, stopovers: true, -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs.find(l => !!l.line) -// return client.trip(leg.tripId, {polyline: true}) -// }) - -client.departures(linzTheatergasse, {duration: 12 * 60}) -// client.arrivals(linzTheatergasse, {duration: 10, linesOfStops: true}) - -// client.locations('theatergasse', {results: 3}) -// client.stop(linzTheatergasse, {linesOfStops: true}) -// client.nearby({ +let data = await client.locations('theatergasse', {results: 3}) +// let data = await client.nearby({ // type: 'location', // id: '980115190', // address: 'Steingasse 19, 4020 Linz', // latitude: 48.301181, // longitude: 14.284057, // }, {distance: 1000}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // id: '980115190', // address: 'Steingasse 19, 4020 Linz', @@ -42,7 +26,25 @@ client.departures(linzTheatergasse, {duration: 12 * 60}) // maxDuration: 30, // }) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// let data = await client.stop(linzTheatergasse, {linesOfStops: true}) + +// let data = await client.departures(linzTheatergasse, {duration: 12 * 60}) +// let data = await client.arrivals(linzTheatergasse, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(linzTheatergasse, amstettenStadtbad, { +// results: 1, stopovers: true, +// }) +// { +// const [journey] = data.journeys +// data = await client.refreshJourney(journey.refreshToken, { +// stopovers: true, +// remarks: true, +// }) +// } +// { +// const [journey] = data.journeys +// const leg = journey.legs.find(l => !!l.line) +// data = await client.trip(leg.tripId, {polyline: true}) +// } + +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/pkp/example.js b/p/pkp/example.js index cf356354..c8dad635 100644 --- a/p/pkp/example.js +++ b/p/pkp/example.js @@ -2,28 +2,26 @@ 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' -client.journeys(krakówGł, wrocławGł, {results: 1, polylines: true}) -// client.departures(krakówGł, {duration: 10}) -// client.arrivals(krakówGł, {duration: 10, linesOfStops: true}) -// client.locations('kraków', {results: 2}) -// client.stop(krakówGł, {linesOfStops: true}) -// client.nearby({ +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}) -// client.radar({ +// let data = await client.radar({ // north: 50.2, // west: 19.8, // south: 49.9, // east: 20.1 // }, {results: 10}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // address: 'Bydgoszcz, Dworcowa 100', // latitude: 53.1336648, @@ -33,13 +31,17 @@ client.journeys(krakówGł, wrocławGł, {results: 1, polylines: true}) // maxDuration: 20 // }) -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) +// let data = await client.departures(krakówGł, {duration: 10}) +// let data = await client.arrivals(krakówGł, {duration: 10, linesOfStops: true}) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// 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})) diff --git a/p/rejseplanen/example.js b/p/rejseplanen/example.js index a5202381..292fd601 100644 --- a/p/rejseplanen/example.js +++ b/p/rejseplanen/example.js @@ -2,32 +2,35 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as rejseplanenProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(rejseplanenProfile, 'hafas-client-example') -// from København Central to Aalborg -// client.journeys('8600626', '8600020', {results: 1}) -// .then(({journeys}) => { +const københavnCentral = '8600626' +const aalborg = '8600020' -// const leg = journeys[0].legs[0] -// return client.trip(leg.tripId, leg.line.name) -// }) - -client.departures('8600626', {duration: 5}) -// client.locations('KØbenhaven', {results: 2}) -// client.stop('8600626') // København Central -// client.nearby({ +let data = await client.locations('Københaven', {results: 2}) +// let data = await client.nearby({ // type: 'location', // latitude: 55.673, // longitude: 12.566 // }, {distance: 200}) -// client.radar({ + +// let data = await client.stop(københavnCentral) // København Central + +// let data = await client.departures(københavnCentral, {duration: 5}) + +// let data = await client.journeys(københavnCentral, aalborg, {results: 1}) +// { +// const [journey] = data.journeys +// const leg = journey.legs[0] +// data = await client.trip(leg.tripId, leg.line.name) +// } + +// let data = await client.radar({ // north: 55.673, // west: 12.566, // south: 55.672, // east: 12.567 // }, {results: 10}) -.then(data => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/rmv/example.js b/p/rmv/example.js index d9161788..9bc4bccf 100644 --- a/p/rmv/example.js +++ b/p/rmv/example.js @@ -2,6 +2,7 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as rmvProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(rmvProfile, 'hafas-client-example') const marburgHbf = '3010011' @@ -13,35 +14,37 @@ const offenbachLiebigstr = { latitude: 50.096326, longitude: 8.759979 } -client.journeys(marburgHbf, mainzGonsenheim, {results: 1}) -// client.departures(marburgHbf, {duration: 1}) -// client.arrivals(marburgHbf, {duration: 10, linesOfStops: true}) -// client.locations('wiesbaden igstadt', {results: 2}) -// client.stop(marburgHbf, {linesOfStops: true}) // Dammtor -// client.nearby(offenbachLiebigstr) -// client.radar({ +let data = await client.locations('wiesbaden igstadt', {results: 2}) +// let data = await client.nearby(offenbachLiebigstr) +// let data = await client.reachableFrom(offenbachLiebigstr, { +// when: new Date('2020-03-03T10:00:00+01:00'), +// maxDuration: 10 +// }) + +// let data = await client.stop(marburgHbf, {linesOfStops: true}) // Dammtor + +// let data = await client.departures(marburgHbf, {duration: 1}) +// let data = await client.arrivals(marburgHbf, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(marburgHbf, mainzGonsenheim, {results: 1}) +// { +// 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: 50.125, // west: 8.661, // south: 50.098, // east: 8.71 // }, {results: 10}) -// client.reachableFrom(offenbachLiebigstr, { -// when: new Date('2020-03-03T10:00:00+01:00'), -// maxDuration: 10 -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) - -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) - -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/rsag/example.js b/p/rsag/example.js index e1a3ac01..55b9fd12 100644 --- a/p/rsag/example.js +++ b/p/rsag/example.js @@ -2,6 +2,7 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as rsagProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(rsagProfile, 'hafas-client-example') const rostockHbf = '8010304' @@ -13,36 +14,37 @@ const albertEinsteinStr = { latitude: 54.077208, longitude: 12.108299 } -client.journeys(rostockHbf, güstrow, {results: 1}) - -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) +let data = await client.locations('güstrow', {results: 2}) +// let data = await client.nearby(albertEinsteinStr) +// let data = await client.reachableFrom(albertEinsteinStr, { +// when: new Date('2020-03-03T10:00:00+01:00'), +// maxDuration: 10 // }) -// .then(({journeys}) => { -// const [journey] = journeys +// let data = await client.stop(rostockHbf, {linesOfStops: true}) // Dammtor + +// let data = await client.departures(rostockHbf, {duration: 1}) +// let data = await client.arrivals(rostockHbf, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(rostockHbf, güstrow, {results: 1}) +// { +// const [journey] = data.journeys +// data = await client.refreshJourney(journey.refreshToken, { +// stopovers: true, +// remarks: true, +// }) +// } +// { +// const [journey] = data.journeys // const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) +// data = await client.trip(leg.tripId, {polyline: true}) +// } -// client.departures(rostockHbf, {duration: 1}) -// client.arrivals(rostockHbf, {duration: 10, linesOfStops: true}) -// client.locations('güstrow', {results: 2}) -// client.stop(rostockHbf, {linesOfStops: true}) // Dammtor -// client.nearby(albertEinsteinStr) -// client.radar({ +// let data = await client.radar({ // north: 54.177, // west: 11.959, // south: 54.074, // east: 12.258 // }, {results: 10}) -// client.reachableFrom(albertEinsteinStr, { -// when: new Date('2020-03-03T10:00:00+01:00'), -// maxDuration: 10 -// }) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/saarfahrplan/example.js b/p/saarfahrplan/example.js index 8fdf1617..200d1b59 100644 --- a/p/saarfahrplan/example.js +++ b/p/saarfahrplan/example.js @@ -2,35 +2,19 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as saarfahrplanProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(saarfahrplanProfile, 'hafas-client-example') -client.journeys('15541', '10609', {results: 1}) -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.id, leg.line.name, {polyline: true}) -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) +const heusweilerKirschhof = '15541' +const saarbrückenUhlandstr = '10609' -// client.departures('15541', {duration: 1}) -// client.arrivals('15541', {duration: 10, linesOfStops: true}) -// client.locations('uhlandstr', {results: 2}) -// client.station('10609') // Uhlandstr., Saarbrücken -// client.nearby({ +let data = await client.locations('uhlandstr', {results: 2}) +// let data = await client.nearby({ // type: 'location', // latitude: 49.229498, // longitude: 7.008609 // }, {distance: 400}) -// client.radar({ -// north: 49.244044, -// west: 6.987644, -// south: 49.235332, -// east: 7.006480 -// }, {results: 10}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // id: '009000763', // latitude: 49.235223, @@ -38,7 +22,35 @@ client.journeys('15541', '10609', {results: 1}) // name: 'Saarbrücken, Rathaus' // }, {maxDuration: 20}) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// let data = await client.stop(saarbrückenUhlandstr) + +// let data = await client.departures(heusweilerKirschhof, {duration: 1}) +// let data = await client.arrivals(heusweilerKirschhof, { +// duration: 10, +// linesOfStops: true, +// }) + +// let data = await client.journeys(heusweilerKirschhof, saarbrückenUhlandstr, { +// results: 1, +// }) +// { +// 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.id, leg.line.name, {polyline: true}) +// } + +// let data = await client.radar({ +// north: 49.244044, +// west: 6.987644, +// south: 49.235332, +// east: 7.006480 +// }, {results: 10}) + +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/salzburg/example.js b/p/salzburg/example.js index 0664c3cb..88ed74f7 100644 --- a/p/salzburg/example.js +++ b/p/salzburg/example.js @@ -2,47 +2,47 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as salzburgProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(salzburgProfile, 'hafas-client example') const salzburgGaswerkgasse = '455001300' const oberndorfKrankenhaus = '455110200' +const salzburgRupertgasse5 = { + type: 'location', + id: '980100611', + address: 'Rupertgasse 5, 5020 Salzburg', + latitude: 47.806891, + longitude: 13.050503, +} -// client.journeys(salzburgGaswerkgasse, oberndorfKrankenhaus, { -// results: 1, stopovers: true, -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) - -// client.departures(salzburgGaswerkgasse, {duration: 1}) -// client.arrivals(salzburgGaswerkgasse, {duration: 10, linesOfStops: true}) - -client.locations('krankenhaus', {results: 3}) -// client.stop(salzburgGaswerkgasse, {linesOfStops: true}) -// client.nearby({ -// type: 'location', -// id: '980100611', -// address: 'Rupertgasse 5, 5020 Salzburg', -// latitude: 47.806891, -// longitude: 13.050503, -// }, {distance: 1000}) -// client.reachableFrom({ -// type: 'location', -// id: '980100611', -// address: 'Rupertgasse 5, 5020 Salzburg', -// latitude: 47.806891, -// longitude: 13.050503, -// }, { +let data = await client.locations('krankenhaus', {results: 3}) +// let data = await client.nearby(salzburgRupertgasse5, {distance: 1000}) +// let data = await client.reachableFrom(salzburgRupertgasse5, { // maxDuration: 30, // }) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// let data = await client.stop(salzburgGaswerkgasse, {linesOfStops: true}) + +// let data = await client.departures(salzburgGaswerkgasse, {duration: 1}) +// let data = await client.arrivals(salzburgGaswerkgasse, { +// duration: 10, +// linesOfStops: true, +// }) + +// let data = await client.journeys(salzburgGaswerkgasse, oberndorfKrankenhaus, { +// results: 1, stopovers: 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}) +// } + +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/sbahn-muenchen/example.js b/p/sbahn-muenchen/example.js index 420ff6b1..32a3cfae 100644 --- a/p/sbahn-muenchen/example.js +++ b/p/sbahn-muenchen/example.js @@ -2,26 +2,19 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as sMuenchenProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(sMuenchenProfile, 'hafas-client-example') -// Mittersendling to Charlottenburg -// client.journeys('8004154', '0621790', {results: 1, polylines: true}) -client.departures('8004154', {duration: 5}) -// client.arrivals('8004154', {duration: 10, linesOfStops: true}) -// client.locations('mittersendling', {results: 5}) -// client.stop('8004154', {linesOfStops: true}) // Mittersendling -// client.nearby({ +const mittersendling = '8004154' +const charlottenburg = '0621790' + +let data = await client.locations('mittersendling', {results: 5}) +// let data = await client.nearby({ // type: 'location', // latitude: 48.153858, // longitude: 11.533059 // }, {distance: 750}) -// client.radar({ -// north: 48.145121, -// west: 11.543736, -// south: 48.138339, -// east: 11.553776 -// }, {results: 10}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // address: 'Pötschnerstraße 3, neuhausen', // latitude: 48.152499, @@ -31,20 +24,32 @@ client.departures('8004154', {duration: 5}) // maxDuration: 20 // }) -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs.find(leg => leg.line) -// return client.trip(leg.tripId, {polyline: true}) -// }) +// let data = await client.stop(mittersendling, {linesOfStops: true}) -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, { +// let data = await client.departures(mittersendling, {duration: 5}) +// let data = await client.arrivals(mittersendling, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(mittersendling, charlottenburg, { +// 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.find(leg => leg.line) +// data = await client.trip(leg.tripId, {polyline: true}) +// } -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// let data = await client.radar({ +// north: 48.145121, +// west: 11.543736, +// south: 48.138339, +// east: 11.553776 +// }, {results: 10}) + +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/sncb/example.js b/p/sncb/example.js index d4e16d99..1cdcc1a5 100644 --- a/p/sncb/example.js +++ b/p/sncb/example.js @@ -2,6 +2,7 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as sncbProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(sncbProfile, 'hafas-client-example') const gentStPieters = '8892007' @@ -12,29 +13,34 @@ const gentPaddenhoek = { latitude: 51.0517, longitude: 3.724878, } -client.journeys(gentStPieters, bruxellesMidi, {stopovers: true, remarks: true}) -// .then(({journeys}) => { -// const leg = journeys[0].legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) -// .then(({journeys}) => { -// return client.refreshJourney(journeys[0].refreshToken, {remarks: true}) -// }) +let data = await client.locations('gent') +// let data = await client.nearby(gentPaddenhoek) +// let data = await client.reachableFrom(gentPaddenhoek) -// client.departures(gentStPieters) -// client.arrivals(gentStPieters, {duration: 10, linesOfStops: true}) -// client.locations('gent') -// client.stop(gentStPieters, {linesOfStops: true}) -// client.nearby(gentPaddenhoek) -// client.radar({ +// let data = await client.stop(gentStPieters, {linesOfStops: true}) + +// let data = await client.departures(gentStPieters) +// let data = await client.arrivals(gentStPieters, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(gentStPieters, bruxellesMidi, { +// stopovers: true, +// remarks: true, +// }) +// { +// const [journey] = data.journeys +// const leg = journey.legs[0] +// data = await client.trip(leg.tripId, {polyline: true}) +// } +// { +// const [journey] = data.journeys +// data = await client.refreshJourney(journey.refreshToken, {remarks: true}) +// } + +// let data = await client.radar({ // north: 51.065, // west: 3.688, // south: 51.04, // east: 3.748 // }, {results: 10}) -// client.reachableFrom(gentPaddenhoek) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/stv/example.js b/p/stv/example.js index 3298ca3e..8ef624e6 100644 --- a/p/stv/example.js +++ b/p/stv/example.js @@ -2,47 +2,44 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as stvProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(stvProfile, 'hafas-client example') const grazSonnenhang = '460413500' const grazHödlweg = '460415400' +const grazEisengasse10 = { + type: 'location', + id: '980027564', + address: 'Eisengasse 10, 8020 Graz', + latitude: 47.076553, + longitude: 15.406064, +} -// client.journeys(grazSonnenhang, grazHödlweg, { -// results: 1, stopovers: true, -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) - -// client.departures(grazSonnenhang, {duration: 1}) -// client.arrivals(grazSonnenhang, {duration: 10, linesOfStops: true}) - -client.locations('sonnenhang', {results: 3}) -// client.stop(grazSonnenhang, {linesOfStops: true}) -// client.nearby({ -// type: 'location', -// id: '980027564', -// address: 'Eisengasse 10, 8020 Graz', -// latitude: 47.076553, -// longitude: 15.406064, -// }, {distance: 1000}) -// client.reachableFrom({ -// type: 'location', -// id: '980027564', -// address: 'Eisengasse 10, 8020 Graz', -// latitude: 47.076553, -// longitude: 15.406064, -// }, { +let data = await client.locations('sonnenhang', {results: 3}) +// let data = await client.nearby(grazEisengasse10, {distance: 1000}) +// let data = await client.reachableFrom(grazEisengasse10, { // maxDuration: 30, // }) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// let data = await client.stop(grazSonnenhang, {linesOfStops: true}) + +// let data = await client.departures(grazSonnenhang, {duration: 1}) +// let data = await client.arrivals(grazSonnenhang, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(grazSonnenhang, grazHödlweg, { +// results: 1, stopovers: 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}) +// } + +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/svv/example.js b/p/svv/example.js index d577b383..e5dfd9b2 100644 --- a/p/svv/example.js +++ b/p/svv/example.js @@ -2,6 +2,7 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as svvProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(svvProfile, 'hafas-client-example') const sam = '455086100' @@ -13,27 +14,29 @@ const zillnerstr2 = { latitude: 47.801434, longitude: 13.031006, } -client.journeys(sam, volksgarten, {results: 1, polylines: true}) -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) - -// client.departures(sam, {duration: 1}) -// client.arrivals(sam, {duration: 10, linesOfStops: true}) -// client.locations('salzburg sam', {results: 2}) -// client.stop(sam, {linesOfStops: true}) // Dammtor -// client.nearby(zillnerstr2) -// client.reachableFrom(zillnerstr2, { +let data = await client.locations('salzburg sam', {results: 2}) +// let data = await client.nearby(zillnerstr2) +// let data = await client.reachableFrom(zillnerstr2, { // when: new Date('2020-06-01T10:00:00+0200'), // }) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// let data = await client.stop(sam, {linesOfStops: true}) + +// let data = await client.departures(sam, {duration: 1}) +// let data = await client.arrivals(sam, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(sam, volksgarten, {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}) +// } + +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/tpg/example.js b/p/tpg/example.js index 24140fd0..b0323be6 100644 --- a/p/tpg/example.js +++ b/p/tpg/example.js @@ -2,41 +2,19 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as tpgProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(tpgProfile, 'hafas-client-example') const miremont = '100449' const moillebeau = '100451' -client.journeys(miremont, moillebeau, {results: 1, stopovers: true}) - -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) - -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) - -// client.departures(miremont, {duration: 1}) -// client.arrivals(miremont, {duration: 10, linesOfStops: true}) -// client.radar({ -// north: 46.1849, -// east: 6.1919, -// south: 46.2215, -// west: 6.1192, -// }, {results: 10}) - -// client.locations('miremont', {results: 3}) -// client.stop(miremont, {linesOfStops: true}) -// client.nearby({ +let data = await client.locations('miremont', {results: 3}) +// let data = await client.nearby({ // type: 'location', // latitude: 46.197768, // longitude: 6.148046, // }, {distance: 500}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // id: '990001624', // address: 'Cours des Bastions 10, 1205 Genève', @@ -46,7 +24,33 @@ client.journeys(miremont, moillebeau, {results: 1, stopovers: true}) // maxDuration: 10, // }) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// let data = await client.stop(miremont, {linesOfStops: true}) + +// let data = await client.departures(miremont, {duration: 1}) +// let data = await client.arrivals(miremont, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(miremont, moillebeau, { +// results: 1, +// stopovers: 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: 46.1849, +// east: 6.1919, +// south: 46.2215, +// west: 6.1192, +// }, {results: 10}) + +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/vbb/example.js b/p/vbb/example.js index b479a1d5..e7b58005 100644 --- a/p/vbb/example.js +++ b/p/vbb/example.js @@ -2,26 +2,21 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as vbnProfile} from './index.js' -const client = createClient(vbnProfile, 'hafas-client-example') +// Pick a descriptive user agent! hafas-client won't work with this string. +const client = createClient(vbnProfile, 'foo') -// Hauptbahnhof to Charlottenburg -// client.journeys('900000003201', '900000024101', {results: 1, polylines: true}) -// client.departures('900000013102', {duration: 1}) -// client.arrivals('900000013102', {duration: 10, linesOfStops: true}) -client.locations('hansaplatz', {results: 2}) -// client.stop('900000042101', {linesOfStops: true}) // Spichernstr -// client.nearby({ +const hauptbahnhof = '900003201' +const charlottenburg = '900024101' +const kottbusserTor = '900013102' +const spichernstr = '900042101' + +let data = await client.locations('hansaplatz', {results: 2}) +// let data = await client.nearby({ // type: 'location', // latitude: 52.5137344, // longitude: 13.4744798 // }, {distance: 60}) -// client.radar({ -// north: 52.52411, -// west: 13.41002, -// south: 52.51942, -// east: 13.41709 -// }, {results: 10}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // address: '13353 Berlin-Wedding, Torfstr. 17', // latitude: 52.541797, @@ -31,17 +26,33 @@ client.locations('hansaplatz', {results: 2}) // maxDuration: 10 // }) -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) +// let data = await client.stop(spichernstr, {linesOfStops: true}) // Spichernstr -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) +// let data = await client.departures(kottbusserTor, {duration: 1}) +// let data = await client.arrivals(kottbusserTor, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(hauptbahnhof, charlottenburg, { +// results: 1, +// polylines: true, // }) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// { +// 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: 52.52411, +// west: 13.41002, +// south: 52.51942, +// east: 13.41709 +// }, {results: 10}) + +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/vbn/example.js b/p/vbn/example.js index 538f35ff..6b511707 100644 --- a/p/vbn/example.js +++ b/p/vbn/example.js @@ -2,6 +2,7 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as vbnProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(vbnProfile, 'hafas-client-example') const bremerhavenHbf = '9014418' @@ -13,36 +14,36 @@ const bremenRutenstr = { latitude: 53.074165, longitude: 8.8184 } -client.journeys(bremerhavenHbf, verden, {results: 1}) - -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) +let data = await client.locations('oldenburg', {results: 2}) +// let data = await client.nearby(bremenRutenstr) +// let data = await client.reachableFrom(bremenRutenstr, { +// maxDuration: 10 // }) -// .then(({journeys}) => { -// const [journey] = journeys +// let data = await client.stop(bremerhavenHbf, {linesOfStops: true}) + +// let data = await client.departures(bremerhavenHbf, {duration: 1}) +// let data = await client.arrivals(bremerhavenHbf, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(bremerhavenHbf, verden, {results: 1}) +// { +// const [journey] = data.journeys +// data = await client.refreshJourney(journey.refreshToken, { +// stopovers: true, +// remarks: true, +// }) +// } +// { +// const [journey] = data.journeys // const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) +// data = await client.trip(leg.tripId, {polyline: true}) +// } -// client.departures(bremerhavenHbf, {duration: 1}) -// client.arrivals(bremerhavenHbf, {duration: 10, linesOfStops: true}) -// client.locations('oldenburg', {results: 2}) -// client.stop(bremerhavenHbf, {linesOfStops: true}) -// client.nearby(bremenRutenstr) -// client.radar({ +// let data = await client.radar({ // north: 53.087, // west: 8.777, // south: 53.072, // east: 8.835 // }, {results: 10}) -// client.reachableFrom(bremenRutenstr, { -// when: new Date('2020-03-03T10:00:00+01:00'), -// maxDuration: 10 -// }) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/vkg/example.js b/p/vkg/example.js index 5c6f9046..13e14ce4 100644 --- a/p/vkg/example.js +++ b/p/vkg/example.js @@ -2,35 +2,20 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as vkgProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(vkgProfile, 'hafas-client-example') const spittalMittelschule = '420512200' const klagenfurtSteingasse = '420649500' -// client.journeys(spittalMittelschule, klagenfurtSteingasse, {results: 1, stopovers: true}) - -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) - -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) - -// client.departures(spittalMittelschule, {duration: 1}) -// client.arrivals(spittalMittelschule, {duration: 10, linesOfStops: true}) - -client.locations('steingasse', {results: 3}) -// client.stop(spittalMittelschule, {linesOfStops: true}) -// client.nearby({ +let data = await client.locations('steingasse', {results: 3}) +// let data = await client.stop(spittalMittelschule, {linesOfStops: true}) +// let data = await client.nearby({ // type: 'location', // latitude: 46.617968, // longitude: 14.297595, // }, {distance: 500}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // id: '980025809', // address: 'Eckengasse 9, 9020 Klagenfurt am Wörthersee', @@ -40,7 +25,24 @@ client.locations('steingasse', {results: 3}) // maxDuration: 8, // }) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// let data = await client.departures(spittalMittelschule, {duration: 1}) +// let data = await client.arrivals(spittalMittelschule, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(spittalMittelschule, klagenfurtSteingasse, { +// results: 1, +// stopovers: 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}) +// } + +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/vmt/example.js b/p/vmt/example.js index 262d24e6..76ee0c76 100644 --- a/p/vmt/example.js +++ b/p/vmt/example.js @@ -2,22 +2,19 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as vmtProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(vmtProfile, 'hafas-client-example') const jena = '190014' const gothaZOB = '167280' -client.journeys(jena, gothaZOB, {results: 1}) -// client.departures(jena) -// client.arrivals(jena, {duration: 10, linesOfStops: true}) -// client.locations('ohrdruf', {results: 2}) -// client.stop(jena, {linesOfStops: true}) // Dammtor -// client.nearby({ +let data = await client.locations('ohrdruf', {results: 2}) +// let data = await client.nearby({ // type: 'location', // latitude: 50.975615, // longitude: 11.032374 // }) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // id: '980348376', // address: 'Erfurt, Grafengasse 12', @@ -26,18 +23,23 @@ client.journeys(jena, gothaZOB, {results: 1}) // when: new Date('2020-03-04T10:00:00+01:00') // }) -// .then(({journeys}) => { -// const [journey] = journeys +// let data = await client.stop(jena, {linesOfStops: true}) // Dammtor + +// let data = await client.departures(jena) +// let data = await client.arrivals(jena, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(jena, gothaZOB, {results: 1}) +// { +// const [journey] = data.journeys +// data = await client.refreshJourney(journey.refreshToken, { +// stopovers: true, +// remarks: true, +// }) +// } +// { +// const [journey] = data.journeys // const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) +// data = await client.trip(leg.tripId, {polyline: true}) +// } -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) - -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/vor/example.js b/p/vor/example.js index 5a704715..021bbcee 100644 --- a/p/vor/example.js +++ b/p/vor/example.js @@ -2,37 +2,21 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as vorProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(vorProfile, 'hafas-client example') const stPöltenLinzerTor = '431277900' const eisenstadtSchlossplatz = '415003300' -// client.journeys(stPöltenLinzerTor, eisenstadtSchlossplatz, { -// results: 1, stopovers: true, -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs.find(l => !!l.line) -// return client.trip(leg.tripId, {polyline: true}) -// }) - -// client.departures(stPöltenLinzerTor, {duration: 20}) -// client.arrivals(stPöltenLinzerTor, {duration: 10, linesOfStops: true}) - -client.locations('schlossplatz', {results: 3}) -// client.stop(stPöltenLinzerTor, {linesOfStops: true}) -// client.nearby({ +let data = await client.locations('schlossplatz', {results: 3}) +// let data = await client.nearby({ // type: 'location', // id: '980021284', // address: 'Christalniggasse 6, 2500 Baden', // latitude: 48.005516, // longitude: 16.241404, // }, {distance: 1000}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // id: '980021284', // address: 'Christalniggasse 6, 2500 Baden', @@ -42,7 +26,25 @@ client.locations('schlossplatz', {results: 3}) // maxDuration: 30, // }) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// let data = await client.stop(stPöltenLinzerTor, {linesOfStops: true}) + +// let data = await client.departures(stPöltenLinzerTor, {duration: 20}) +// let data = await client.arrivals(stPöltenLinzerTor, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(stPöltenLinzerTor, eisenstadtSchlossplatz, { +// results: 1, stopovers: true, +// }) +// { +// const [journey] = data.journeys +// data = await client.refreshJourney(journey.refreshToken, { +// stopovers: true, +// remarks: true, +// }) +// } +// { +// const [journey] = data.journeys +// const leg = journey.legs.find(l => !!l.line) +// data = await client.trip(leg.tripId, {polyline: true}) +// } + +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/vos/example.js b/p/vos/example.js index 9c4862d7..4fcb1c06 100644 --- a/p/vos/example.js +++ b/p/vos/example.js @@ -2,41 +2,19 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as vosProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(vosProfile, 'hafas-client-example') const saarplatz = '9071733' const finkenweg = '9071574' -// client.journeys(saarplatz, finkenweg, {results: 1, stopovers: true}) - -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) - -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) - -// client.departures(saarplatz, {duration: 1}) -// client.arrivals(saarplatz, {duration: 10, linesOfStops: true}) -// client.radar({ -// north: 52.283258, -// west: 8.039188, -// south: 52.263653, -// east: 8.07225, -// }, {results: 10}) - -// client.locations('finkenweg', {results: 3}) -// client.stop(saarplatz, {linesOfStops: true}) -// client.nearby({ +let data = await client.locations('finkenweg', {results: 3}) +// let data = await client.nearby({ // type: 'location', // latitude: 53.554422, // longitude: 9.977934 // }, {distance: 500}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // id: '990121407', // address: 'Osnabrück Sandstraße 20', @@ -46,7 +24,30 @@ const finkenweg = '9071574' // maxDuration: 8, // }) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// let data = await client.stop(saarplatz, {linesOfStops: true}) + +// let data = await client.departures(saarplatz, {duration: 1}) +// let data = await client.arrivals(saarplatz, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(saarplatz, finkenweg, {results: 1, stopovers: 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: 52.283258, +// west: 8.039188, +// south: 52.263653, +// east: 8.07225, +// }, {results: 10}) + +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/vrn/example.js b/p/vrn/example.js index e50fd2d5..32e3d8c7 100644 --- a/p/vrn/example.js +++ b/p/vrn/example.js @@ -2,34 +2,19 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as vrnProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(vrnProfile, 'hafas-client-example') const ludwigshafen = '8000236' const meckesheim = '8003932' -client.journeys(ludwigshafen, meckesheim, {results: 1, polylines: true}) -// .then(({journeys}) => { -// const leg = journeys[0].legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journeys[0].refreshToken, { -// stopovers: true, remarks: true -// }) -// }) - -// client.departures(ludwigshafen, {duration: 1}) -// client.arrivals(ludwigshafen, {duration: 10, linesOfStops: true}) - -// client.locations('meckesheim', {results: 2}) -// client.stop(ludwigshafen, {linesOfStops: true}) // Dammtor -// client.nearby({ +let data = await client.locations('meckesheim', {results: 2}) +// let data = await client.nearby({ // type: 'location', // latitude: 53.554422, // longitude: 9.977934 // }, {distance: 60}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // id: '980787337', // address: 'Ludwigshafen am Rhein - Mitte, Pestalozzistraße 2', @@ -39,14 +24,32 @@ client.journeys(ludwigshafen, meckesheim, {results: 1, polylines: true}) // maxDuration: 8, // }) -// client.radar({ +// let data = await client.stop(ludwigshafen, {linesOfStops: true}) + +// let data = await client.departures(ludwigshafen, {duration: 1}) +// let data = await client.arrivals(ludwigshafen, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(ludwigshafen, meckesheim, { +// 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: 49.4940, // west: 8.4560, // south: 49.4774, // east: 8.4834, // }, {results: 10}) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/vsn/example.js b/p/vsn/example.js index fc96a0f4..c9cf8145 100644 --- a/p/vsn/example.js +++ b/p/vsn/example.js @@ -2,37 +2,19 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as vsnProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(vsnProfile, 'hafas-client-example') -client.journeys('9033961', '9033962', {results: 1, polylines: true}) +const göttingenJugendherberge = '9033961' +const göttingenJüdenstr = '9033962' -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) - -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) - -// client.departures('9033961', {duration: 1}) -// client.arrivals('9033961', {duration: 10, linesOfStops: true}) -// client.locations('jugendherberge', {results: 2}) -// client.stop('9033961', {linesOfStops: true}) -// client.nearby({ +let data = await client.locations('jugendherberge', {results: 2}) +// let data = await client.nearby({ // type: 'location', // latitude: 53.554422, // longitude: 9.977934 // }, {distance: 60}) -// client.radar({ -// north: 53.55, -// west: 9.95, -// south: 52.51, -// east: 10 -// }, {results: 10}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // address: 'Hamburg, Holstenwall 9', // latitude: 53.553766, @@ -41,7 +23,34 @@ client.journeys('9033961', '9033962', {results: 1, polylines: true}) // when: new Date('2019-05-16T10:00:00+0200'), // maxDuration: 8 // }) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) + +// let data = await client.stop(göttingenJugendherberge, {linesOfStops: true}) + +// let data = await client.departures(göttingenJugendherberge, {duration: 1}) +// let data = await client.arrivals(göttingenJugendherberge, {duration: 10, linesOfStops: true}) + +// let data = await client.journeys(göttingenJugendherberge, göttingenJüdenstr, { +// 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: 53.55, +// west: 9.95, +// south: 52.51, +// east: 10 +// }, {results: 10}) + +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/vvt/example.js b/p/vvt/example.js index 17a1eea0..ce72b613 100644 --- a/p/vvt/example.js +++ b/p/vvt/example.js @@ -2,35 +2,19 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as vvtProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(vvtProfile, 'hafas-client-example') const innsbruckMitterweg = '476152300' const kufsteinListstr = '476603100' -// client.journeys(innsbruckMitterweg, kufsteinListstr, {results: 1, stopovers: true}) - -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) - -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) - -client.departures(innsbruckMitterweg, {duration: 1}) -// client.arrivals(innsbruckMitterweg, {duration: 10, linesOfStops: true}) - -// client.locations('liststr', {results: 3}) -// client.stop(innsbruckMitterweg, {linesOfStops: true}) -// client.nearby({ +let data = await client.locations('liststr', {results: 3}) +// let data = await client.nearby({ // type: 'location', // latitude: 53.554422, // longitude: 9.977934 // }, {distance: 500}) -// client.reachableFrom( { +// let data = await client.reachableFrom( { // type: 'location', // id: '980113702', // address: 'Stadlweg 1, 6020 Innsbruck', @@ -40,7 +24,29 @@ client.departures(innsbruckMitterweg, {duration: 1}) // maxDuration: 8, // }) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// let data = await client.stop(innsbruckMitterweg, {linesOfStops: true}) + +// let data = await client.departures(innsbruckMitterweg, {duration: 1}) +// let data = await client.arrivals(innsbruckMitterweg, { +// duration: 10, +// linesOfStops: true, +// }) + +// let data = await client.journeys(innsbruckMitterweg, kufsteinListstr, { +// results: 1, +// stopovers: 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}) +// } + +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/vvv/example.js b/p/vvv/example.js index f043edd6..13ffd2cb 100644 --- a/p/vvv/example.js +++ b/p/vvv/example.js @@ -2,37 +2,21 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as vvvProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(vvvProfile, 'hafas-client example') const bregenzLandeskrankenhaus = '480195700' const bludenzGymnasium = '480031300' -// client.journeys(bregenzLandeskrankenhaus, bludenzGymnasium, { -// results: 1, stopovers: true, -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) - -// client.departures(bregenzLandeskrankenhaus, {duration: 1}) -// client.arrivals(bregenzLandeskrankenhaus, {duration: 10, linesOfStops: true}) - -client.locations('krankenhaus', {results: 3}) -// client.stop(bregenzLandeskrankenhaus, {linesOfStops: true}) -// client.nearby({ +let data = await client.locations('krankenhaus', {results: 3}) +// let data = await client.nearby({ // type: 'location', // id: '980010311', // address: 'Austraße 37, 6700 Bludenz', // latitude: 47.149626, // longitude: 9.822693, // }, {distance: 1000}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // id: '980010311', // address: 'Austraße 37, 6700 Bludenz', @@ -42,7 +26,28 @@ client.locations('krankenhaus', {results: 3}) // maxDuration: 30, // }) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// let data = await client.stop(bregenzLandeskrankenhaus, {linesOfStops: true}) + +// let data = await client.departures(bregenzLandeskrankenhaus, {duration: 1}) +// let data = await client.arrivals(bregenzLandeskrankenhaus, { +// duration: 10, +// linesOfStops: true, +// }) + +// let data = await client.journeys(bregenzLandeskrankenhaus, bludenzGymnasium, { +// results: 1, stopovers: 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}) +// } + +console.log(inspect(data, {depth: null, colors: true})) diff --git a/p/zvv/example.js b/p/zvv/example.js index 6c272084..8f7a8b59 100644 --- a/p/zvv/example.js +++ b/p/zvv/example.js @@ -2,40 +2,18 @@ import {inspect} from 'util' import {createClient} from '../../index.js' import {profile as zvvProfile} from './index.js' +// Pick a descriptive user agent! hafas-client won't work with this string. const client = createClient(zvvProfile, 'hafas-client-example') const bürkliplatz = '8591105' -client.locations('bürkli', {results: 2}) -// client.nearby({ +let data = await client.locations('bürkli', {results: 2}) +// let data = await client.nearby({ // type: 'location', // latitude: 47.366, // longitude: 8.54, // }, {distance: 60}) - -// client.journeys(bürkliplatz, '8591123', {results: 1, polylines: true}) - -// .then(({journeys}) => { -// const [journey] = journeys -// const leg = journey.legs[0] -// return client.trip(leg.tripId, {polyline: true}) -// }) - -// .then(({journeys}) => { -// const [journey] = journeys -// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) -// }) - -// client.departures(bürkliplatz, {duration: 1}) -// client.arrivals(bürkliplatz, {duration: 10, linesOfStops: true}) -// client.stop(bürkliplatz, {linesOfStops: true}) // Dammtor -// client.radar({ -// north: 47.387, -// west: 8.514, -// south: 47.356, -// east: 8.568, -// }, {results: 10}) -// client.reachableFrom({ +// let data = await client.reachableFrom({ // type: 'location', // address: 'Talstrasse', // latitude: 47.366, @@ -45,7 +23,35 @@ client.locations('bürkli', {results: 2}) // maxDuration: 8 // }) -.then((data) => { - console.log(inspect(data, {depth: null, colors: true})) -}) -.catch(console.error) +// let data = await client.stop(bürkliplatz, { +// linesOfStops: true, +// }) + +// let data = await client.departures(bürkliplatz, {duration: 1}) +// let data = await client.arrivals(bürkliplatz, { +// duration: 10, +// linesOfStops: true, +// }) + +// let data = await client.journeys(bürkliplatz, '8591123', {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: 47.387, +// west: 8.514, +// south: 47.356, +// east: 8.568, +// }, {results: 10}) + +console.log(inspect(data, {depth: null, colors: true}))