add RMV profile

This commit is contained in:
Jannis R 2020-03-03 01:39:16 +01:00 committed by Jannis Redmann
parent 8540f5f610
commit 3a9e548bcf
5 changed files with 181 additions and 0 deletions

48
p/rmv/example.js Normal file
View file

@ -0,0 +1,48 @@
'use strict'
const createClient = require('../..')
const rmvProfile = require('.')
const client = createClient(rmvProfile, 'hafas-client-example')
const marburgHbf = '3010011'
const mainzGonsenheim = '3011332'
const offenbachLiebigstr = {
type: 'location',
id: '990148095',
address: 'Offenbach am Main, Liebigstraße 22',
latitude: 50.096326, longitude: 8.759979
}
client.journeys(marburgHbf, mainzGonsenheim, {results: 1})
// client.departures(marburgHbf, {duration: 1})
// client.arrivals(marburgHbf, {duration: 10, linesOfStops: true})
// client.locations('wiesbaden igstadt', {results: 2})
// client.stop(marburgHbf, {linesOfStops: true}) // Dammtor
// client.nearby(offenbachLiebigstr)
// client.radar({
// north: 50.125,
// west: 8.661,
// south: 50.098,
// east: 8.71
// }, {results: 10})
// client.reachableFrom(offenbachLiebigstr, {
// when: new Date('2020-03-03T10:00:00+01:00'),
// maxDuration: 10
// })
// .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)

29
p/rmv/index.js Normal file
View file

@ -0,0 +1,29 @@
'use strict'
const products = require('./products')
const transformReqBody = (ctx, body) => {
body.client = {type: 'WEB', id: 'RMV', name: 'webapp'}
body.ext = 'RMV.1'
body.ver = '1.18'
body.auth = {type: 'AID', aid: 'x0k4ZR33ICN9CWmj'}
return body
}
const hvvProfile = {
locale: 'de-DE',
timezone: 'Europe/Berlin',
endpoint: 'https://www.rmv.de/auskunft/bin/jp/mgate.exe',
transformReqBody,
products,
trip: true,
radar: true,
refreshJourney: true,
reachableFrom: true
}
module.exports = hvvProfile

85
p/rmv/products.js Normal file
View file

@ -0,0 +1,85 @@
'use strict'
module.exports = [
{
id: 'express-train',
mode: 'train',
bitmasks: [1],
name: 'InterCityExpress/Fernzug',
short: 'ICE',
default: true
},
{
id: 'long-distance-train',
mode: 'train',
bitmasks: [2],
name: 'EuroCity/InterCity/EuroNight/InterRegio',
short: 'EC/IC/EN/IR',
default: true
},
{
id: 'regiona-train',
mode: 'train',
bitmasks: [4],
name: 'RegionalExpress/Regionalbahn',
short: 'RE/RB',
default: true
},
{
id: 's-bahn',
mode: 'train',
bitmasks: [16],
name: 'S-Bahn',
short: 'S',
default: true
},
{
id: 'u-bahn',
mode: 'train',
bitmasks: [32],
name: 'U-Bahn',
short: 'U',
default: true
},
{
id: 'tram',
mode: 'train',
bitmasks: [64],
name: 'Straßenbahn',
short: 'Tram',
default: true
},
{
id: 'bus',
mode: 'bus',
bitmasks: [128],
name: 'Bus',
short: 'Bus',
default: true
},
{
id: 'watercraft',
mode: 'watercraft',
bitmasks: [256],
name: 'Schiff',
short: 'Schiff',
default: true
},
{
id: 'ast',
mode: 'taxi', // todo: or `bus`?
bitmasks: [512],
name: 'Anruf-Sammel-Taxi',
short: 'AST',
default: true
},
{
id: 'cable-car',
mode: 'gondola',
bitmasks: [1024],
name: 'Seilbahn',
short: 'Seilbahn',
default: true
}
// todo: remaining bitmask `1015`
]

18
p/rmv/readme.md Normal file
View file

@ -0,0 +1,18 @@
# RMV profile for `hafas-client`
[*Rhein-Main-Verkehrsverbund (RMV)*](https://en.wikipedia.org/wiki/Rhein-Main-Verkehrsverbund) is a public transport authority in [Hesse](https://en.wikipedia.org/wiki/Hesse)/[Rhineland-Palatinate](https://en.wikipedia.org/wiki/Rhineland-Palatinate). This profile adds *RMV*-specific customizations to `hafas-client`.
## Usage
```js
const createClient = require('hafas-client')
const rmvProfile = require('hafas-client/p/rmv')
// create a client with RMV profile
const client = createClient(rmvProfile, 'my-awesome-program')
```
## Customisations
- parses *RMV*-specific products

View file

@ -212,6 +212,7 @@ HAFAS endpoint | wrapper library | docs | example code | source code
[Österreichische Bundesbahnen (ÖBB)](https://en.wikipedia.org/wiki/Austrian_Federal_Railways) | [`oebb-hafas`](https://github.com/juliuste/oebb-hafas) | [docs](p/oebb/readme.md) | [example code](p/oebb/example.js) | [src](p/oebb/index.js) [Österreichische Bundesbahnen (ÖBB)](https://en.wikipedia.org/wiki/Austrian_Federal_Railways) | [`oebb-hafas`](https://github.com/juliuste/oebb-hafas) | [docs](p/oebb/readme.md) | [example code](p/oebb/example.js) | [src](p/oebb/index.js)
[Nahverkehr Sachsen-Anhalt (NASA)](https://de.wikipedia.org/wiki/Nahverkehrsservice_Sachsen-Anhalt)/[INSA](https://insa.de) | [`insa-hafas`](https://github.com/derhuerst/insa-hafas) | [docs](p/insa/readme.md) | [example code](p/insa/example.js) | [src](p/insa/index.js) [Nahverkehr Sachsen-Anhalt (NASA)](https://de.wikipedia.org/wiki/Nahverkehrsservice_Sachsen-Anhalt)/[INSA](https://insa.de) | [`insa-hafas`](https://github.com/derhuerst/insa-hafas) | [docs](p/insa/readme.md) | [example code](p/insa/example.js) | [src](p/insa/index.js)
[Nahverkehrsverbund Schleswig-Holstein (NAH.SH)](https://de.wikipedia.org/wiki/Nahverkehrsverbund_Schleswig-Holstein) | [`nahsh-hafas`](https://github.com/juliuste/nahsh-hafas) | [docs](p/nahsh/readme.md) | [example code](p/nahsh/example.js) | [src](p/nahsh/index.js) [Nahverkehrsverbund Schleswig-Holstein (NAH.SH)](https://de.wikipedia.org/wiki/Nahverkehrsverbund_Schleswig-Holstein) | [`nahsh-hafas`](https://github.com/juliuste/nahsh-hafas) | [docs](p/nahsh/readme.md) | [example code](p/nahsh/example.js) | [src](p/nahsh/index.js)
[Rhein-Main-Verkehrsverbund (RMV)](https://en.wikipedia.org/wiki/Rhein-Main-Verkehrsverbund) | - | [docs](p/rmv/readme.md) | [example code](p/rmv/example.js) | [src](p/rmv/index.js)
[Austin, Texas (CMTA/*CapMetro*)](https://en.wikipedia.org/wiki/Capital_Metropolitan_Transportation_Authority) | - | [docs](p/cmta/readme.md) | [example code](p/cmta/example.js) | [src](p/cmta/index.js) [Austin, Texas (CMTA/*CapMetro*)](https://en.wikipedia.org/wiki/Capital_Metropolitan_Transportation_Authority) | - | [docs](p/cmta/readme.md) | [example code](p/cmta/example.js) | [src](p/cmta/index.js)
[*S-Bahn München*](https://en.wikipedia.org/wiki/Munich_S-Bahn) | - | [docs](p/sbahn-muenchen/readme.md) | [example code](p/sbahn-muenchen/example.js) | [src](p/sbahn-muenchen/index.js) [*S-Bahn München*](https://en.wikipedia.org/wiki/Munich_S-Bahn) | - | [docs](p/sbahn-muenchen/readme.md) | [example code](p/sbahn-muenchen/example.js) | [src](p/sbahn-muenchen/index.js)
*Saarfahrplan*/VGS ([Saarland](https://en.wikipedia.org/wiki/Saarland)) | - | [docs](p/saarfahrplan/readme.md) | [example code](p/saarfahrplan/example.js) | [src](p/saarfahrplan/index.js) *Saarfahrplan*/VGS ([Saarland](https://en.wikipedia.org/wiki/Saarland)) | - | [docs](p/saarfahrplan/readme.md) | [example code](p/saarfahrplan/example.js) | [src](p/saarfahrplan/index.js)