From 2853fb04083e9b1fece15942c93421a2e23f40a3 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Fri, 15 Jan 2021 00:58:07 +0100 Subject: [PATCH] add VVT profile --- p/vvt/example.js | 47 ++++++++++++++++++++++ p/vvt/index.js | 100 +++++++++++++++++++++++++++++++++++++++++++++++ p/vvt/readme.md | 13 ++++++ readme.md | 1 + 4 files changed, 161 insertions(+) create mode 100644 p/vvt/example.js create mode 100644 p/vvt/index.js create mode 100644 p/vvt/readme.md diff --git a/p/vvt/example.js b/p/vvt/example.js new file mode 100644 index 00000000..e9b2e141 --- /dev/null +++ b/p/vvt/example.js @@ -0,0 +1,47 @@ +'use strict' + +const createClient = require('../..') +const vvtProfile = require('.') + +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, leg.line.name, {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({ +// type: 'location', +// latitude: 53.554422, +// longitude: 9.977934 +// }, {distance: 500}) +// client.reachableFrom( { +// type: 'location', +// id: '980113702', +// address: 'Stadlweg 1, 6020 Innsbruck', +// latitude: 47.267106, +// longitude: 11.426701, +// }, { +// maxDuration: 8, +// }) + +.then((data) => { + console.log(require('util').inspect(data, {depth: null, colors: true})) +}) +.catch(console.error) diff --git a/p/vvt/index.js b/p/vvt/index.js new file mode 100644 index 00000000..8118b2f8 --- /dev/null +++ b/p/vvt/index.js @@ -0,0 +1,100 @@ +'use strict' + +const products = [{ // todo: what is `8`? + id: 'trains', + mode: 'train', + bitmasks: [1, 2], + name: 'Bahn & S-Bahn', + short: 'Bahn & S', + default: true, +}, { + id: 'subway', + mode: 'train', + bitmasks: [4], + name: 'U-Bahn', + short: 'U', + default: true, +}, { + id: 'tram', + mode: 'train', + bitmasks: [16], + name: 'Straßenbahn', + short: 'Straßenbahn', + default: true, +}, { + id: 'city-bus', + mode: 'bus', + bitmasks: [128], + name: 'Stadtbus', + short: 'Stadtbus', + default: true, +}, { + id: 'regional-bus', + mode: 'bus', + bitmasks: [64], + name: 'Regionalbus', + short: 'Regionalbus', + default: true, +}, { + id: 'long-distance-bus', + mode: 'bus', + bitmasks: [32], + name: 'Fernbus', + short: 'Fernbus', + default: true, +}, { + id: 'other-bus', + mode: 'bus', + bitmasks: [2048], + name: 'sonstige Busse', + short: 'sonstige Busse', + default: true, +}, { + id: 'aerial-lift', + mode: 'gondola', + bitmasks: [256], + name: 'Seil-/Zahnradbahn', + short: 'Seil-/Zahnradbahn', + default: true, +}, { + id: 'ferry', + mode: 'watercraft', + bitmasks: [512], + name: 'Schiff', + short: 'Schiff', + default: true, +}, { + id: 'on-call', + mode: 'taxi', + bitmasks: [1024], + name: 'Anrufsammeltaxi', + short: 'AST', + default: true, +}] + +const vvtProfile = { + locale: 'at-DE', + timezone: 'Europe/Vienna', + endpoint: 'https://smartride.vvt.at/bin/mgate.exe', + + auth: { + type: 'AID', + aid: 'wf7mcf9bv3nv8g5f', + }, + client: { + id: 'VAO', + type: 'WEB', + name: 'webapp', + l: 'vs_vvt', + }, + ver: '1.32', + // todo: lang + + products, + + trip: true, + refreshJourney: false, // todo: depends on 8615b85 from #204 + reachableFrom: true, +} + +module.exports = vvtProfile diff --git a/p/vvt/readme.md b/p/vvt/readme.md new file mode 100644 index 00000000..297dbad9 --- /dev/null +++ b/p/vvt/readme.md @@ -0,0 +1,13 @@ +# VVT profile for `hafas-client` + +[*Verkehrsverbund Tirol (VVT)*](https://de.wikipedia.org/wiki/Verkehrsverbund_Tirol) is the regional transport provider of [Tyrol](https://en.wikipedia.org/wiki/Tyrol). This profile adds *VVT* support to `hafas-client`. + +## Usage + +```js +const createClient = require('hafas-client') +const vvtProfile = require('hafas-client/p/vvt') + +// create a client with VVT profile +const client = createClient(vvtProfile, 'my-awesome-program') +``` diff --git a/readme.md b/readme.md index fdab5bcc..c2e0cbea 100644 --- a/readme.md +++ b/readme.md @@ -235,6 +235,7 @@ HAFAS endpoint | wrapper library | docs | example code | source code [Verkehrsgemeinschaft Osnabrück (VOS)](https://de.wikipedia.org/wiki/Verkehrsgemeinschaft_Osnabrück) | - | [docs](p/vos/readme.md) | [example code](p/vos/example.js) | [src](p/vos/index.js) [Aachener Verkehrsverbund (AVV)](https://de.wikipedia.org/wiki/Verkehrsgemeinschaft_Osnabrück) | - | [docs](p/avv/readme.md) | [example code](p/avv/example.js) | [src](p/avv/index.js) [Salzburg public transport (SVV)](https://de.wikipedia.org/wiki/Salzburger_Verkehrsverbund) | - | [docs](p/svv/readme.md) | [example code](p/svv/example.js) | [src](p/svv/index.js) +[Verkehrsverbund Tirol (VVT)](https://de.wikipedia.org/wiki/Verkehrsverbund_Tirol) | - | [docs](p/vvt/readme.md) | [example code](p/vvt/example.js) | [src](p/vvt/index.js) [Zürich public transport (ZVV)](https://en.wikipedia.org/wiki/Zürcher_Verkehrsverbund) | - | [docs](p/zvv/readme.md) | [example code](p/zvv/example.js) | [src](p/zvv/index.js) There are also libraries that use `hafas-client` and pass their own profile in: