From 649a7ec060fc4fb48eaf7e1ffe179046373683c7 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Thu, 5 Aug 2021 19:32:41 +0200 Subject: [PATCH] =?UTF-8?q?add=20O=C3=96VV=20profile=20=E2=9C=85?= =?UTF-8?q?=F0=9F=93=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit part of #207 --- p/ooevv/base.json | 14 +++ p/ooevv/example.js | 49 +++++++++ p/ooevv/index.js | 100 ++++++++++++++++++ p/ooevv/readme.md | 15 +++ p/readme.md | 1 + .../fixtures/75f51a885c609c1376bbfefeb1fec20a | 1 + .../75f51a885c609c1376bbfefeb1fec20a.headers | 35 ++++++ test/e2e/ooevv.js | 35 ++++++ tools/pull-profile-base-data.sh | 1 + 9 files changed, 251 insertions(+) create mode 100644 p/ooevv/base.json create mode 100644 p/ooevv/example.js create mode 100644 p/ooevv/index.js create mode 100644 p/ooevv/readme.md create mode 100644 test/e2e/fixtures/75f51a885c609c1376bbfefeb1fec20a create mode 100644 test/e2e/fixtures/75f51a885c609c1376bbfefeb1fec20a.headers create mode 100644 test/e2e/ooevv.js diff --git a/p/ooevv/base.json b/p/ooevv/base.json new file mode 100644 index 00000000..073a733f --- /dev/null +++ b/p/ooevv/base.json @@ -0,0 +1,14 @@ +{ + "auth": { + "type": "AID", + "aid": "and20201hf7mcf9bv3nv8g5f" + }, + "client": { + "type": "AND", + "id": "VAO" + }, + "endpoint": "https://app.verkehrsauskunft.at/bin/mgate.exe", + "ext": "VAO.11", + "ver": "1.27", + "defaultLanguage": "de" +} diff --git a/p/ooevv/example.js b/p/ooevv/example.js new file mode 100644 index 00000000..f0bec3e9 --- /dev/null +++ b/p/ooevv/example.js @@ -0,0 +1,49 @@ +'use strict' + +const createClient = require('../..') +const vvvProfile = require('.') + +const client = createClient(vvvProfile, '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, leg.line.name, {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({ +// type: 'location', +// id: '980115190', +// address: 'Steingasse 19, 4020 Linz', +// latitude: 48.301181, +// longitude: 14.284057, +// }, {distance: 1000}) +// client.reachableFrom({ +// type: 'location', +// id: '980115190', +// address: 'Steingasse 19, 4020 Linz', +// latitude: 48.301181, +// longitude: 14.284057, +// }, { +// maxDuration: 30, +// }) + +.then((data) => { + console.log(require('util').inspect(data, {depth: null, colors: true})) +}) +.catch(console.error) diff --git a/p/ooevv/index.js b/p/ooevv/index.js new file mode 100644 index 00000000..3a89742a --- /dev/null +++ b/p/ooevv/index.js @@ -0,0 +1,100 @@ +'use strict' + +const baseProfile = require('./base.json') + +const products = [{ + id: 'train-and-s-bahn', + mode: 'train', + bitmasks: [1, 2], + name: 'Bahn & S-Bahn', + short: 'Bahn & S-Bahn', + default: true, +}, { + id: 'u-bahn', + mode: 'train', + bitmasks: [4], + name: 'U-Bahn', + short: 'U-Bahn', + 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 vosProfile = { + ...baseProfile, + auth: { + type: 'USER', + aid: 'and20201hf7mcf9bv3nv8g5f', + user: 'mobile', + pw: '87a6f8ZbnBih32', + }, + addMicMac: true, + salt: '6633673735743766726667323938336A', + + locale: 'at-DE', + timezone: 'Europe/Vienna', + + products, + + departuresGetPasslist: false, + departuresStbFltrEquiv: false, + refreshJourneyUseOutReconL: true, + trip: true, + reachableFrom: true, +} + +module.exports = vosProfile diff --git a/p/ooevv/readme.md b/p/ooevv/readme.md new file mode 100644 index 00000000..8727bcb5 --- /dev/null +++ b/p/ooevv/readme.md @@ -0,0 +1,15 @@ +# OÖVV profile for `hafas-client` + +[*Oberösterreichischer Verkehrsverbund (OÖVV)*](https://de.wikipedia.org/wiki/Oberösterreichischer_Verkehrsverbund) is the local transport provider of [Upper Austria](https://en.wikipedia.org/wiki/Upper_Austria). This profile adds *OÖVV* support to `hafas-client`. + +## Usage + +```js +const createClient = require('hafas-client') +const oövvProfile = require('hafas-client/p/ooevv') + +// create a client with OÖVV profile +const client = createClient(oövvProfile, 'my-awesome-program') +``` + +Check out the [code examples](example.js). diff --git a/p/readme.md b/p/readme.md index deb20381..95b754ea 100644 --- a/p/readme.md +++ b/p/readme.md @@ -39,6 +39,7 @@ HAFAS endpoint | wrapper library | docs | example code | profile name [Aachener Verkehrsverbund (AVV)](https://de.wikipedia.org/wiki/Verkehrsgemeinschaft_Osnabrück) | - | [docs](avv/readme.md) | [example](avv/example.js) | [`avv`](avv) [Rejseplanen in Denmark](http://www.rejseplanen.dk) | - | [docs](rejseplanen/readme.md) | [example](rejseplanen/example.js) | [`rejseplanen`](rejseplanen) [Innsbrucker Verkehrsbetriebe (IVB)](https://de.wikipedia.org/wiki/Innsbrucker_Verkehrsbetriebe_und_Stubaitalbahn) | - | [docs](ivb/readme.md) | [example](ivb/example.js) | [`ivb`](ivb) +[Oberösterreichischer Verkehrsverbund (OÖVV)](https://de.wikipedia.org/wiki/Oberösterreichischer_Verkehrsverbund) | - | [docs](ooevv/readme.md) | [example](ooevv/example.js) | [`ooevv`](ooevv) [Steirischer Verkehrsverbund (STV)](https://de.wikipedia.org/wiki/Steirischer_Verkehrsverbund) | - | [docs](stv/readme.md) | [example](stv/example.js) | [`stv`](stv) [Salzburg public transport (SVV)](https://de.wikipedia.org/wiki/Salzburger_Verkehrsverbund) | - | [docs](svv/readme.md) | [example](svv/example.js) | [`svv`](svv) [Verkehrsverbund Tirol (VVT)](https://de.wikipedia.org/wiki/Verkehrsverbund_Tirol) | - | [docs](vvt/readme.md) | [example](vvt/example.js) | [`vvt`](vvt) diff --git a/test/e2e/fixtures/75f51a885c609c1376bbfefeb1fec20a b/test/e2e/fixtures/75f51a885c609c1376bbfefeb1fec20a new file mode 100644 index 00000000..e22ace0f --- /dev/null +++ b/test/e2e/fixtures/75f51a885c609c1376bbfefeb1fec20a @@ -0,0 +1 @@ +{"ver":"1.27","ext":"VAO.11","lang":"deu","id":"u8ggsg6xk2ahxw8x","err":"OK","cInfo":{"code":"OK","url":"","msg":""},"graph":{"id":"standard","index":0},"subGraph":{"id":"global","index":0},"view":{"id":"standard","index":0,"type":"WGS84"},"svcResL":[{"meth":"LocMatch","err":"OK","res":{"common":{"txtInstL":[{"id":"street","type":"NONE","mode":"ADD"},{"id":"city","type":"NONE","mode":"ADD"}],"icoL":[{"res":"ADR"},{"res":"prod_bus","txtS":"192","fg":{"r":255,"g":255,"b":255},"bg":{"r":0,"g":121,"b":58},"zIdx":1000}]},"match":{"field":"S","state":"L","locL":[{"lid":"A=2@O=Theatergasse, 4020 Linz@X=14284902@Y=48303994@U=103@b=980119291@B=1@p=1626331592@","type":"A","name":"Theatergasse, 4020 Linz","nameFormatted":{"text":"Theatergasse, 4020 Linz","textInstructionIntervalL":[{"startIndex":0,"endIndex":12,"textInstructionX":0},{"startIndex":12,"endIndex":23,"textInstructionX":1}]},"icoX":0,"state":"F","crd":{"x":14284902,"y":48303994}},{"lid":"A=1@O=Linz/Donau Theatergasse@X=14284111@Y=48303913@U=81@L=444670100@B=1@p=1628121247@","type":"S","name":"Linz/Donau Theatergasse","nameFormatted":{"text":"Linz/Donau Theatergasse"},"icoX":1,"extId":"444670100","state":"F","crd":{"x":14284111,"y":48303913,"floor":0},"meta":true,"pCls":128,"wt":9,"isMainMast":true,"gidL":["at:44:46701"]},{"lid":"A=2@O=Theatergasse, 4810 Gmunden@X=13799314@Y=47918510@U=103@b=980119292@B=1@p=1626331592@","type":"A","name":"Theatergasse, 4810 Gmunden","nameFormatted":{"text":"Theatergasse, 4810 Gmunden","textInstructionIntervalL":[{"startIndex":0,"endIndex":12,"textInstructionX":0},{"startIndex":12,"endIndex":26,"textInstructionX":1}]},"icoX":0,"state":"F","crd":{"x":13799314,"y":47918510}},{"lid":"A=2@O=Theatergasse, 5020 Salzburg@X=13043528@Y=47802441@U=103@b=980119293@B=1@p=1626331592@","type":"A","name":"Theatergasse, 5020 Salzburg","nameFormatted":{"text":"Theatergasse, 5020 Salzburg","textInstructionIntervalL":[{"startIndex":0,"endIndex":12,"textInstructionX":0},{"startIndex":12,"endIndex":27,"textInstructionX":1}]},"icoX":0,"state":"F","crd":{"x":13043528,"y":47802441}},{"lid":"A=2@O=Theatergasse, 6330 Kufstein@X=12170675@Y=47583787@U=103@b=980119295@B=1@p=1626331592@","type":"A","name":"Theatergasse, 6330 Kufstein","nameFormatted":{"text":"Theatergasse, 6330 Kufstein","textInstructionIntervalL":[{"startIndex":0,"endIndex":12,"textInstructionX":0},{"startIndex":12,"endIndex":27,"textInstructionX":1}]},"icoX":0,"state":"F","crd":{"x":12170675,"y":47583787}}]}}}]} \ No newline at end of file diff --git a/test/e2e/fixtures/75f51a885c609c1376bbfefeb1fec20a.headers b/test/e2e/fixtures/75f51a885c609c1376bbfefeb1fec20a.headers new file mode 100644 index 00000000..58833732 --- /dev/null +++ b/test/e2e/fixtures/75f51a885c609c1376bbfefeb1fec20a.headers @@ -0,0 +1,35 @@ +{ + "statusCode": 200, + "headers": { + "date": "Thu, 05 Aug 2021 18:10:27 GMT", + "transfer-encoding": "chunked", + "content-type": "application/json; charset=utf-8", + "connection": "close", + "strict-transport-security": "max-age=15552000; includeSubDomains" + }, + "url": "https://app.verkehrsauskunft.at/bin/mgate.exe?mic=252230314636b9e1ed51d8665c761a48&mac=874447bb7da6b7fee876ab7d61583ba6", + "time": 282, + "request": { + "method": "POST", + "headers": { + "Content-Type": [ + "application/json" + ], + "Accept-Encoding": [ + "gzip, br, deflate" + ], + "Accept": [ + "application/json" + ], + "user-agent": [ + "public-tr52c19d463253ansport/hafas-client:test" + ], + "Content-Length": [ + "311" + ], + "Connection": [ + "close" + ] + } + } +} \ No newline at end of file diff --git a/test/e2e/ooevv.js b/test/e2e/ooevv.js new file mode 100644 index 00000000..aa8d4338 --- /dev/null +++ b/test/e2e/ooevv.js @@ -0,0 +1,35 @@ +'use strict' + +const tap = require('tap') + +const {createWhen} = require('./lib/util') +const createClient = require('../..') +const oövvProfile = require('../../p/ooevv') +const createValidate = require('./lib/validate-fptf-with') + +const when = createWhen(oövvProfile.timezone, oövvProfile.locale) +const cfg = { + when, + stationCoordsOptional: false, + products: oövvProfile.products, + maxLatitude: 49.7921, + maxLongitude: 17.0892, + minLatitude: 45.7206, + minLongitude: 7.8635, +} +const validate = createValidate(cfg) + +const client = createClient(oövvProfile, 'public-transport/hafas-client:test') + +const linzTheatergasse = '444670100' + +tap.test('locations named "theatergasse"', async (t) => { + const locations = await client.locations('theatergasse') + + validate(t, locations, 'locations', 'locations') + t.ok(locations.some((l) => { + return l.station && l.station.id === linzTheatergasse || l.id === linzTheatergasse + }), 'Linz Theatergasse not found') + + t.end() +}) diff --git a/tools/pull-profile-base-data.sh b/tools/pull-profile-base-data.sh index 5b0f581a..d4646608 100755 --- a/tools/pull-profile-base-data.sh +++ b/tools/pull-profile-base-data.sh @@ -61,6 +61,7 @@ node -p "$query" "$src/de/vos-hafas-mgate.json" >../p/vos/base.json node -p "$query" "$src/de/vrn-hafas-mgate.json" >../p/vrn/base.json node -p "$query" "$src/de/vsn-hafas-mgate.json" >../p/vsn/base.json node -p "$query" "$src/at/ivb-hafas-mgate.json" >../p/ivb/base.json +node -p "$query" "$src/at/ooevv-hafas-mgate.json" >../p/ooevv/base.json node -p "$query" "$src/at/stv-hafas-mgate.json" >../p/stv/base.json node -p "$query" "$src/at/vvt-hafas-mgate.json" >../p/vvt/base.json node -p "$query" "$src/at/vvv-hafas-mgate.json" >../p/vvv/base.json