mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
add VMT profile
This commit is contained in:
parent
522248b908
commit
86ddf2c290
5 changed files with 135 additions and 0 deletions
44
p/vmt/example.js
Normal file
44
p/vmt/example.js
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const createClient = require('../..')
|
||||||
|
const vmtProfile = require('.')
|
||||||
|
|
||||||
|
const client = createClient(vmtProfile, 'hafas-client-example')
|
||||||
|
|
||||||
|
const jena = '190014'
|
||||||
|
const gothaZOB = '167049'
|
||||||
|
|
||||||
|
client.journeys(jena, gothaZOB, {results: 1})
|
||||||
|
// client.departures(jena)
|
||||||
|
// client.arrivals(jena, {duration: 10, linesOfStops: true})
|
||||||
|
// client.locations('ohrdruf', {results: 2})
|
||||||
|
// client.stop(jena, {linesOfStops: true}) // Dammtor
|
||||||
|
// client.nearby({
|
||||||
|
// type: 'location',
|
||||||
|
// latitude: 50.975615,
|
||||||
|
// longitude: 11.032374
|
||||||
|
// })
|
||||||
|
// client.reachableFrom({
|
||||||
|
// type: 'location',
|
||||||
|
// id: '980348376',
|
||||||
|
// address: 'Erfurt, Grafengasse 12',
|
||||||
|
// latitude: 50.975993, longitude: 11.031553
|
||||||
|
// }, {
|
||||||
|
// when: new Date('2020-03-04T10:00:00+01:00')
|
||||||
|
// })
|
||||||
|
|
||||||
|
// .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})
|
||||||
|
// })
|
||||||
|
|
||||||
|
.then((data) => {
|
||||||
|
console.log(require('util').inspect(data, {depth: null, colors: true}))
|
||||||
|
})
|
||||||
|
.catch(console.error)
|
35
p/vmt/index.js
Normal file
35
p/vmt/index.js
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const products = require('./products')
|
||||||
|
|
||||||
|
const transformReqBody = (ctx, body) => {
|
||||||
|
body.client = {type: 'IPH', id: 'HAFAS', name: 'VMT', v: '2040100'}
|
||||||
|
body.ver = '1.18'
|
||||||
|
body.auth = {type: 'AID', aid: 't2h7u1e6r4i8n3g7e0n'}
|
||||||
|
|
||||||
|
return body
|
||||||
|
}
|
||||||
|
|
||||||
|
const hvvProfile = {
|
||||||
|
locale: 'de-DE',
|
||||||
|
timezone: 'Europe/Berlin',
|
||||||
|
// todo: what about `https://vmt.hafas.de/bin/mgate.exe`?
|
||||||
|
endpoint: 'https://vmt.hafas.de/bin/ticketing/mgate.exe',
|
||||||
|
|
||||||
|
// https://runkit.com/derhuerst/hafas-decrypt-encrypted-mac-salt
|
||||||
|
// https://gist.github.com/derhuerst/b20adde9f614ceb6b2a8b9c7f4487da8#file-hafas-config-L31-L32
|
||||||
|
salt: Buffer.from('7x8d3n2a5m1b3c6z', 'utf-8'),
|
||||||
|
addMicMac: true,
|
||||||
|
|
||||||
|
transformReqBody,
|
||||||
|
|
||||||
|
products,
|
||||||
|
|
||||||
|
trip: true,
|
||||||
|
refreshJourney: true,
|
||||||
|
reachableFrom: true,
|
||||||
|
// fails with `CGI_READ_FAILED`
|
||||||
|
// radar: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = hvvProfile
|
38
p/vmt/products.js
Normal file
38
p/vmt/products.js
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
module.exports = [ // todo: what is `512`?
|
||||||
|
{
|
||||||
|
id: 'long-distance-train',
|
||||||
|
mode: 'train',
|
||||||
|
bitmasks: [1, 2, 4],
|
||||||
|
name: 'long-distance train',
|
||||||
|
short: 'ICE/IC/EC',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'regional-train',
|
||||||
|
mode: 'train',
|
||||||
|
// 8 is *not* always RB, 16 is *not* always RE!
|
||||||
|
bitmasks: [8, 16],
|
||||||
|
name: 'regional train',
|
||||||
|
short: 'RE/RB',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'tram',
|
||||||
|
mode: 'train',
|
||||||
|
bitmasks: [32],
|
||||||
|
name: 'tram',
|
||||||
|
short: 'tram',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
// todo: what are `64` & `128`?
|
||||||
|
{
|
||||||
|
id: 'bus',
|
||||||
|
mode: 'bus',
|
||||||
|
bitmasks: [256],
|
||||||
|
name: 'bus',
|
||||||
|
short: 'bus',
|
||||||
|
default: true
|
||||||
|
}
|
||||||
|
]
|
17
p/vmt/readme.md
Normal file
17
p/vmt/readme.md
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# VMT profile for `hafas-client`
|
||||||
|
|
||||||
|
[*Verkehrsverbund Mittelthüringen (VMT)*](https://en.wikipedia.org/wiki/Verkehrsverbund_Mittelthüringen) is a major local transport authority in [Thuringia](https://en.wikipedia.org/wiki/Thuringia). This profile adds *VMT*-specific customizations to `hafas-client`.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
const createClient = require('hafas-client')
|
||||||
|
const vmtProfile = require('hafas-client/p/vmt')
|
||||||
|
|
||||||
|
// create a client with VMT profile
|
||||||
|
const client = createClient(vmtProfile, 'my-awesome-program')
|
||||||
|
```
|
||||||
|
|
||||||
|
## Customisations
|
||||||
|
|
||||||
|
- parses *VMT*-specific products
|
|
@ -224,6 +224,7 @@ HAFAS endpoint | wrapper library | docs | example code | source code
|
||||||
[Ingolstädter Verkehrsgesellschaft (INVG)](https://de.wikipedia.org/wiki/Ingolstädter_Verkehrsgesellschaft) | - | [docs](p/invg/readme.md) | [example code](p/invg/example.js) | [src](p/invg/index.js)
|
[Ingolstädter Verkehrsgesellschaft (INVG)](https://de.wikipedia.org/wiki/Ingolstädter_Verkehrsgesellschaft) | - | [docs](p/invg/readme.md) | [example code](p/invg/example.js) | [src](p/invg/index.js)
|
||||||
[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)
|
[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)
|
[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)
|
||||||
|
|
||||||
There are also libraries that use `hafas-client` and pass their own profile in:
|
There are also libraries that use `hafas-client` and pass their own profile in:
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue