Skip to content

Commit

Permalink
add VVV 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 4a7422f commit e293223
Show file tree
Hide file tree
Showing 10 changed files with 250 additions and 1 deletion.
1 change: 1 addition & 0 deletions p/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ HAFAS endpoint | wrapper library | docs | example code | profile name
[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)
[*KΓ€rntner Linien/Verkehrsverbund KΓ€rnten (VKG/VVK)*](https://de.wikipedia.org/wiki/Verkehrsverbund_KΓ€rnten) | - | [docs](vkg/readme.md) | [example](vkg/example.js) | [`vkg`](vkg)
[Verkehrsverbund Vorarlberg (VVV)](https://de.wikipedia.org/wiki/Verkehrsverbund_Vorarlberg) | - | [docs](vvv/readme.md) | [example](vvv/example.js) | [`vvv`](vvv)
[*Transports publics genevois (TPG)*](https://en.wikipedia.org/wiki/Geneva_Public_Transport) (Geneva) | - | [docs](tpg/readme.md) | [example](tpg/example.js) | [`tpg`](tpg)
[*BLS AG*](https://en.wikipedia.org/wiki/BLS_AG) (Bern) | - | [docs](bls/readme.md) | [example](bls/example.js) | [`bls`](bls)
[ZΓΌrich public transport (ZVV)](https://en.wikipedia.org/wiki/ZΓΌrcher_Verkehrsverbund) | - | [docs](zvv/readme.md) | [example](zvv/example.js) | [`zvv`](zvv)
Expand Down
14 changes: 14 additions & 0 deletions p/vvv/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://fahrplan.vmobil.at/bin/mgate.exe",
"ext": "VAO.11",
"ver": "1.27",
"defaultLanguage": "de"
}
49 changes: 49 additions & 0 deletions p/vvv/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 bregenzLandeskrankenhaus = '480195700'
const bludenzGymnasium = '480031300'

// client.journeys(bregenzLandeskrankenhaus, bludenzGymnasium, {
// 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(bregenzLandeskrankenhaus, {duration: 1})
// client.arrivals(bregenzLandeskrankenhaus, {duration: 10, linesOfStops: true})

client.locations('krankenhaus', {results: 3})
// client.stop(bregenzLandeskrankenhaus, {linesOfStops: true})
// client.nearby({
// type: 'location',
// id: '980010311',
// address: 'Austraße 37, 6700 Bludenz',
// latitude: 47.149626,
// longitude: 9.822693,
// }, {distance: 1000})
// client.reachableFrom({
// type: 'location',
// id: '980010311',
// address: 'Austraße 37, 6700 Bludenz',
// latitude: 47.149626,
// longitude: 9.822693,
// }, {
// maxDuration: 30,
// })

.then((data) => {
console.log(require('util').inspect(data, {depth: null, colors: true}))
})
.catch(console.error)
98 changes: 98 additions & 0 deletions p/vvv/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
'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: {
aid: 'and20201hf7mcf9bv3nv8g5f',
type: 'USER',
user: 'mobile',
},
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/vvv/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# VVV profile for `hafas-client`

[*Verkehrsverbund Vorarlberg (VVV)*](https://de.wikipedia.org/wiki/Verkehrsverbund_Vorarlberg) is the local transport provider of [Vorarlberg](https://en.wikipedia.org/wiki/Vorarlberg) that runs its apps under the [*VMOBIL*](https://www.vmobil.at) brand. This profile adds *VVV*/*VMOBIL* support to `hafas-client`.

## Usage

```js
const createClient = require('hafas-client')
const vvvProfile = require('hafas-client/p/vvv')

// create a client with VVV profile
const client = createClient(vvvProfile, 'my-awesome-program')
```

Check out the [code examples](example.js).
1 change: 1 addition & 0 deletions test/e2e/fixtures/fb997e87e2c2921529ca6a49c7d9859d
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"ver":"1.27","ext":"VAO.11","lang":"deu","id":"zv4scgiqm2qcyg8x","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":{"remL":[{"type":"W","code":"WW","txtN":"WEBVIEW","url":"https://app.verkehrsauskunft.at/bin/query.exe/dn?tpl=webview_poi&performLocating=128&look_station=960076303&look_nv=get_infotext|yes|get_attributes|yes&look_stationpool=130"}],"icoL":[{"res":"prod_bus","txtS":"4","fg":{"r":255,"g":255,"b":255},"bg":{"r":0,"g":121,"b":58},"zIdx":1000},{"res":"PCAT_KRANKENANSTALT","zIdx":900},{"res":"prod_ic_bus","txtS":"11","fg":{"r":255,"g":255,"b":255},"bg":{"r":0,"g":121,"b":58},"zIdx":1000},{"res":"prod_bus","txtS":"1","fg":{"r":255,"g":255,"b":255},"bg":{"r":0,"g":121,"b":58},"zIdx":1000},{"res":"prod_ic_bus","txtS":"878","fg":{"r":255,"g":255,"b":255},"bg":{"r":0,"g":121,"b":58},"zIdx":1000}]},"match":{"field":"S","state":"L","locL":[{"lid":"A=1@O=Bregenz Landeskrankenhaus@X=9743201@Y=47497806@U=81@L=480195700@B=1@p=1628121247@","type":"S","name":"Bregenz Landeskrankenhaus","nameFormatted":{"text":"Bregenz Landeskrankenhaus"},"icoX":0,"extId":"480195700","state":"F","crd":{"x":9743201,"y":47497806,"floor":0},"meta":true,"pCls":192,"wt":191,"isMainMast":true,"gidL":["at:48:1957"]},{"lid":"A=4@O=Landeskrankenhaus Bregenz@X=9745287@Y=47496736@U=130@L=960076303@B=1@p=1628123037@","type":"P","name":"Landeskrankenhaus Bregenz","nameFormatted":{"text":"Landeskrankenhaus Bregenz"},"icoX":1,"extId":"960076303","state":"F","crd":{"x":9745287,"y":47496736,"floor":0},"mcpData":{"type":"P","occupancy":"N","mcpid":"0","externalId":"vao-betrieb_K803"},"msgL":[{"type":"REM","remX":0,"sty":"I","dspl":"U","tagL":["RES_LOC_WEB","RES_LOC_FLY_WEB"],"sort":684195840}]},{"lid":"A=1@O=Bregenz Gebietskrankenkasse@X=9731335@Y=47499819@U=81@L=480046500@B=1@p=1628121247@","type":"S","name":"Bregenz Gebietskrankenkasse","nameFormatted":{"text":"Bregenz Gebietskrankenkasse"},"icoX":2,"extId":"480046500","state":"F","crd":{"x":9731335,"y":47499819,"floor":0},"meta":true,"pCls":192,"wt":88,"isMainMast":true,"gidL":["at:48:465"]},{"lid":"A=1@O=Bludenz Krankenhaus@X=9821371@Y=47158993@U=81@L=480038800@B=1@p=1628121247@","type":"S","name":"Bludenz Krankenhaus","nameFormatted":{"text":"Bludenz Krankenhaus"},"icoX":3,"extId":"480038800","state":"F","crd":{"x":9821371,"y":47158993,"floor":0},"meta":true,"pCls":128,"wt":58,"isMainMast":true,"gidL":["at:48:388"]},{"lid":"A=1@O=Eggenburg Krankenhaus@X=15821365@Y=48646079@U=81@L=431557000@B=1@p=1628121247@","type":"S","name":"Eggenburg Krankenhaus","nameFormatted":{"text":"Eggenburg Krankenhaus"},"icoX":4,"extId":"431557000","state":"F","crd":{"x":15821365,"y":48646079,"floor":0},"meta":true,"pCls":64,"wt":10,"isMainMast":true,"gidL":["at:43:15570"]}]}}}]}
35 changes: 35 additions & 0 deletions test/e2e/fixtures/fb997e87e2c2921529ca6a49c7d9859d.headers
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"statusCode": 200,
"headers": {
"date": "Thu, 05 Aug 2021 18:09:48 GMT",
"server": "Apache",
"content-length": "1039",
"content-type": "application/json; charset=utf-8",
"connection": "close"
},
"url": "https://fahrplan.vmobil.at/bin/mgate.exe?mic=b612903e01707306710b6fbabc65bcee&mac=2287c0d8d5f08f184f1e71f246aee38c",
"time": 266,
"request": {
"method": "POST",
"headers": {
"Content-Type": [
"application/json"
],
"Accept-Encoding": [
"gzip, br, deflate"
],
"Accept": [
"application/json"
],
"user-agent": [
"pb8f7fad7961dublic-transport/hafas-client:test"
],
"Content-Length": [
"296"
],
"Connection": [
"close"
]
}
}
}
35 changes: 35 additions & 0 deletions test/e2e/vvv.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 vvvProfile = require('../../p/vvv')
const createValidate = require('./lib/validate-fptf-with')

const when = createWhen(vvvProfile.timezone, vvvProfile.locale)
const cfg = {
when,
stationCoordsOptional: false,
products: vvvProfile.products,
maxLatitude: 47.9504,
maxLongitude: 17.0892,
minLatitude: 45.7206,
minLongitude: 7.8635,
}
const validate = createValidate(cfg)

const client = createClient(vvvProfile, 'public-transport/hafas-client:test')

const bregenzLandeskrankenhaus = '480195700'

tap.test('locations named "bregenz krankenhaus"', async (t) => {
const locations = await client.locations('bregenz krankenhaus')

validate(t, locations, 'locations', 'locations')
t.ok(locations.some((l) => {
return l.station && l.station.id === bregenzLandeskrankenhaus || l.id === bregenzLandeskrankenhaus
}), 'Bregenz Landeskrankenhaus 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/vvt-hafas-mgate.json" >../p/vvt/base.json
node -p "$query" "$src/at/vvv-hafas-mgate.json" >../p/vvv/base.json
node -p "$query" "$src/ch/bls-hafas-mgate.json" >../p/bls/base.json
node -p "$query" "$src/ch/tpg-hafas-mgate.json" >../p/tpg/base.json
node -p "$query" "$src/ch/zvv-hafas-mgate.json" >../p/zvv/base.json
2 changes: 1 addition & 1 deletion tools/transport-apis

0 comments on commit e293223

Please sign in to comment.