From fa3146d706f07e8bee535e30e4be73568edbf837 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Mon, 23 Mar 2020 00:36:54 +0100 Subject: [PATCH] add SVV profile --- p/svv/example.js | 46 ++++++++++++++++++++++++++++++++ p/svv/index.js | 29 ++++++++++++++++++++ p/svv/products.js | 68 +++++++++++++++++++++++++++++++++++++++++++++++ p/svv/readme.md | 18 +++++++++++++ readme.md | 1 + 5 files changed, 162 insertions(+) create mode 100644 p/svv/example.js create mode 100644 p/svv/index.js create mode 100644 p/svv/products.js create mode 100644 p/svv/readme.md diff --git a/p/svv/example.js b/p/svv/example.js new file mode 100644 index 00000000..8c8aeff2 --- /dev/null +++ b/p/svv/example.js @@ -0,0 +1,46 @@ +'use strict' + +const createClient = require('../..') +const svvProfile = require('.') + +const client = createClient(svvProfile, 'hafas-client-example') + +const sam = '455086100' +const volksgarten = '455082100' +const zillnerstr2 = { + type: 'location', + id: '980133005', + address: 'Zillnerstraße 2, 5020 Salzburg', + 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, leg.line.name, {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.radar({ +// north: 47.815, +// west: 13.007, +// south: 47.792, +// east: 13.059 +// }, {results: 10}) +// client.reachableFrom(zillnerstr2, { +// when: new Date('2020-06-01T10:00:00+0200'), +// }) + +.then((data) => { + console.log(require('util').inspect(data, {depth: null, colors: true})) +}) +.catch(console.error) diff --git a/p/svv/index.js b/p/svv/index.js new file mode 100644 index 00000000..ae0d635f --- /dev/null +++ b/p/svv/index.js @@ -0,0 +1,29 @@ +'use strict' + +const products = require('./products') + +const transformReqBody = (ctx, body) => { + body.client = {type: 'WEB', id: 'VAO', name: 'webapp'} + body.ext = 'VAO.11' + body.ver = '1.20' + body.auth = {type: 'AID', aid: 'wf7mcf9bv3nv8g5f'} + return body +} + +const svvProfile = { + locale: 'at-DE', + timezone: 'Europe/Vienna', + endpoint: 'https://fahrplan.salzburg-verkehr.at/bin/mgate.exe', + + transformReqBody, + + products, + + trip: true, + refreshJourney: true, + reachableFrom: true, + departuresGetPasslist: false, + departuresStbFltrEquiv: false, +} + +module.exports = svvProfile diff --git a/p/svv/products.js b/p/svv/products.js new file mode 100644 index 00000000..edd53e29 --- /dev/null +++ b/p/svv/products.js @@ -0,0 +1,68 @@ +'use strict' + +module.exports = [ + { + id: 'bahn-s-bahn', + mode: 'train', + bitmasks: [1, 2], + name: 'Bahn & S-Bahn', + short: 'S/Zug', + default: true + }, + { + id: 'u-bahn', + mode: 'train', + bitmasks: [4], + name: 'U-Bahn', + short: 'U', + default: true + }, + { + id: 'strassenbahn', + mode: 'train', + bitmasks: [16], + name: 'Strassenbahn', + short: 'Str', + default: true + }, + { + id: 'fernbus', + mode: 'bus', + bitmasks: [32], + name: 'Fernbus', + short: 'Bus', + default: true + }, + { + id: 'regionalbus', + mode: 'bus', + bitmasks: [64], + name: 'Regionalbus', + short: 'Bus', + default: true + }, + { + id: 'stadtbus', + mode: 'bus', + bitmasks: [128], + name: 'Stadtbus', + short: 'Bus', + default: true + }, + { + id: 'seilbahn-zahnradbahn', + mode: 'gondola', + bitmasks: [256], + name: 'Seil-/Zahnradbahn', + short: 'Seil-/Zahnradbahn', + default: true + }, + { + id: 'schiff', + mode: 'watercraft', + bitmasks: [512], + name: 'Schiff', + short: 'F', + default: true + }, +] diff --git a/p/svv/readme.md b/p/svv/readme.md new file mode 100644 index 00000000..df5e53a4 --- /dev/null +++ b/p/svv/readme.md @@ -0,0 +1,18 @@ +# SVV profile for `hafas-client` + +[*Salzburger Verkehrsverbund (SVV)*](https://de.wikipedia.org/wiki/Salzburger_Verkehrsverbund) is the local transit authority of [Salzburg](https://en.wikipedia.org/wiki/Salzburg). This profile adds *SVV*-specific customizations to `hafas-client`. + +## Usage + +```js +const createClient = require('hafas-client') +const svvProfile = require('hafas-client/p/svv') + +// create a client with SVV profile +const client = createClient(svvProfile, 'my-awesome-program') +``` + + +## Customisations + +- parses *SVV*-specific products diff --git a/readme.md b/readme.md index 949405d8..6a79ef8e 100644 --- a/readme.md +++ b/readme.md @@ -226,6 +226,7 @@ HAFAS endpoint | wrapper library | docs | example code | source code [Verkehrsverbund Bremen/Niedersachsen (VBN)](https://de.wikipedia.org/wiki/Verkehrsverbund_Bremen/Niedersachsen) | - | [docs](p/vbn/readme.md) | [example code](p/vbn/example.js) | [src](p/vbn/index.js) [Rostocker Straßenbahn AG (RSAG)](https://de.wikipedia.org/wiki/Rostocker_Straßenbahn_AG) | - | [docs](p/rsag/readme.md) | [example code](p/rsag/example.js) | [src](p/rsag/index.js) [Verkehrsverbund Mittelthüringen (VMT)](https://en.wikipedia.org/wiki/Verkehrsverbund_Mittelthüringen) | - | [docs](p/vmt/readme.md) | [example code](p/vmt/example.js) | [src](p/vmt/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) There are also libraries that use `hafas-client` and pass their own profile in: