From 2ae6a9a4ea6708546d52bff90566f339df9cd893 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Thu, 14 Jan 2021 23:34:48 +0100 Subject: [PATCH] add AVV profile --- p/avv/example.js | 53 +++++++++++++++++++++++ p/avv/index.js | 108 +++++++++++++++++++++++++++++++++++++++++++++++ p/avv/readme.md | 13 ++++++ readme.md | 1 + 4 files changed, 175 insertions(+) create mode 100644 p/avv/example.js create mode 100644 p/avv/index.js create mode 100644 p/avv/readme.md diff --git a/p/avv/example.js b/p/avv/example.js new file mode 100644 index 00000000..9829d989 --- /dev/null +++ b/p/avv/example.js @@ -0,0 +1,53 @@ +'use strict' + +const createClient = require('../..') +const vosProfile = require('.') + +const client = createClient(vosProfile, '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, leg.line.name, {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({ +// type: 'location', +// latitude: 50.770607, +// longitude: 6.104637, +// }, {distance: 500}) +// client.reachableFrom({ +// type: 'location', +// id: '990000745', +// address: 'Aachen, Charlottenstraße 11', +// latitude: 50.770607, +// longitude: 6.104637, +// }, { +// maxDuration: 8, +// }) + +.then((data) => { + console.log(require('util').inspect(data, {depth: null, colors: true})) +}) +.catch(console.error) diff --git a/p/avv/index.js b/p/avv/index.js new file mode 100644 index 00000000..46b7f2c5 --- /dev/null +++ b/p/avv/index.js @@ -0,0 +1,108 @@ +'use strict' + +const products = [{ + id: 'regional-train', + mode: 'train', + bitmasks: [1], + name: 'Regionalzug', + short: 'Regionalzug', + default: true, +}, { + id: 'long-distance-train', + mode: 'train', + bitmasks: [2], + name: 'Fernzug', + short: 'Fernzug', + default: true, +}, { + id: 'express-train', + mode: 'train', + bitmasks: [4], + name: 'ICE/Thalys', + short: 'ICE/Thalys', + default: true, +}, { + id: 'fernbus', + mode: 'bus', + bitmasks: [8], + name: 'Fernbus', + short: 'Fernbus', + default: true, +}, { + id: 'suburban-train', + mode: 'train', + bitmasks: [16], + name: 'S-Bahn', + short: 'S', + default: true, +}, { + id: 'subway', + mode: 'train', + bitmasks: [32], + name: 'U-Bahn', + short: 'U', + default: true, +}, { + id: 'tram', + mode: 'train', + bitmasks: [64], + name: 'Straßenbahn', + short: 'Straßenbahn', + default: true, +}, { + id: 'bus', + mode: 'bus', + bitmasks: [128], + name: 'Bus', + short: 'Bus', + default: true, +}, { + id: 'added-bus', + mode: 'bus', + bitmasks: [256], + name: 'Bus, Verstärkerfahrt', + short: 'Bus V', + default: true, +}, { + id: 'on-call', + mode: 'taxi', + bitmasks: [512], + name: 'Bedarfsverkehr', + short: 'Bedarfsverkehr', + default: true, +}, { + id: 'ferry', + mode: 'watercraft', + bitmasks: [1024], + name: 'Fähre', + short: 'Fähre', + default: true, +}] + +const avvProfile = { + locale: 'de-DE', + timezone: 'Europe/Berlin', + endpoint: 'https://auskunft.avv.de/bin/mgate.exe', + + auth: { + type: 'AID', + aid: '4vV1AcH3N511icH', + }, + client: { + id: 'AVV_AACHEN', + type: 'WEB', + name: 'webapp', + l: 'vs_avv', + }, + ver: '1.18', + + products, + + trip: true, + radar: true, + reachableFrom: true, + remarks: true, + remarksGetPolyline: false, +} + +module.exports = avvProfile diff --git a/p/avv/readme.md b/p/avv/readme.md new file mode 100644 index 00000000..dcfdd12a --- /dev/null +++ b/p/avv/readme.md @@ -0,0 +1,13 @@ +# AVV profile for `hafas-client` + +[*Aachener Verkehrsverbund (AVV)*](https://de.wikipedia.org/wiki/Aachener_Verkehrsverbund) is the local transport provider of [Aachen](https://en.wikipedia.org/wiki/Aachen). This profile adds *AVV* support to `hafas-client`. + +## Usage + +```js +const createClient = require('hafas-client') +const avvProfile = require('hafas-client/p/AVV') + +// create a client with AVV profile +const client = createClient(avvProfile, 'my-awesome-program') +``` diff --git a/readme.md b/readme.md index 5320f3d8..7871a36c 100644 --- a/readme.md +++ b/readme.md @@ -232,6 +232,7 @@ HAFAS endpoint | wrapper library | docs | example code | source code [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) [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) [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)