Skip to content

Commit

Permalink
add OÖVV profile ✅📝
Browse files Browse the repository at this point in the history
part of #207
  • Loading branch information
derhuerst committed Aug 5, 2021
1 parent 0ae13b0 commit 649a7ec
Show file tree
Hide file tree
Showing 9 changed files with 251 additions and 0 deletions.
14 changes: 14 additions & 0 deletions p/ooevv/base.json
Original file line number Diff line number Diff line change
@@ -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"
}
49 changes: 49 additions & 0 deletions p/ooevv/example.js
Original file line number Diff line number Diff line change
@@ -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)
100 changes: 100 additions & 0 deletions p/ooevv/index.js
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions p/ooevv/readme.md
Original file line number Diff line number Diff line change
@@ -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).
1 change: 1 addition & 0 deletions p/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions test/e2e/fixtures/75f51a885c609c1376bbfefeb1fec20a
Original file line number Diff line number Diff line change
@@ -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}}]}}}]}
35 changes: 35 additions & 0 deletions test/e2e/fixtures/75f51a885c609c1376bbfefeb1fec20a.headers
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
}
35 changes: 35 additions & 0 deletions test/e2e/ooevv.js
Original file line number Diff line number Diff line change
@@ -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()
})
1 change: 1 addition & 0 deletions tools/pull-profile-base-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 649a7ec

Please sign in to comment.