mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-22 22:59:35 +02:00
add mobil.nrw profile
This commit is contained in:
parent
86bf3b46f0
commit
ad6cfd2288
5 changed files with 186 additions and 0 deletions
49
p/mobil-nrw/example.js
Normal file
49
p/mobil-nrw/example.js
Normal file
|
@ -0,0 +1,49 @@
|
|||
'use strict'
|
||||
|
||||
const {inspect} = require('util')
|
||||
const createClient = require('../..')
|
||||
const cflProfile = require('.')
|
||||
|
||||
const client = createClient(cflProfile, 'hafas-client-example')
|
||||
|
||||
const soest = '8000076'
|
||||
const aachenHbf = '8000001'
|
||||
|
||||
client.journeys(soest, aachenHbf, {results: 1, stopovers: true})
|
||||
// .then(({journeys}) => {
|
||||
// const leg = journeys[0].legs[0]
|
||||
// return client.trip(leg.tripId, leg.line.name)
|
||||
// })
|
||||
|
||||
// client.locations('soest', {results: 3})
|
||||
// client.reachableFrom({
|
||||
// type: 'location',
|
||||
// id: '980301639',
|
||||
// latitude: 51.387609,
|
||||
// longitude: 6.684019,
|
||||
// address: 'Duisburg, Am Mühlenberg 1',
|
||||
// }, {
|
||||
// maxDuration: 15,
|
||||
// })
|
||||
// client.nearby({
|
||||
// type: 'location',
|
||||
// latitude: 51.4503,
|
||||
// longitude: 6.6581,
|
||||
// }, {distance: 1200})
|
||||
|
||||
// client.station(soest)
|
||||
// client.departures(soest, {duration: 20})
|
||||
|
||||
// client.radar({
|
||||
// north: 51.4358,
|
||||
// west: 6.7625,
|
||||
// south: 51.4214,
|
||||
// east: 6.7900,
|
||||
// }, {results: 10})
|
||||
|
||||
// client.remarks()
|
||||
|
||||
.then(data => {
|
||||
console.log(inspect(data, {depth: null, colors: true}))
|
||||
})
|
||||
.catch(console.error)
|
40
p/mobil-nrw/index.js
Normal file
40
p/mobil-nrw/index.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
'use strict'
|
||||
|
||||
const products = require('./products')
|
||||
|
||||
const transformReqBody = (ctx, body) => {
|
||||
body.client = {
|
||||
id: 'DB-REGIO-NRW',
|
||||
name: 'NRW',
|
||||
os: 'iOS 12.4.9',
|
||||
type: 'IPH',
|
||||
v: '6000300',
|
||||
}
|
||||
body.ver = '1.24'
|
||||
body.auth = {
|
||||
type: 'AID',
|
||||
aid: 'Kdf0LNRWYg5k3499'
|
||||
}
|
||||
body.lang = 'de'
|
||||
// body.ext = 'DB.R19.04.a'
|
||||
|
||||
return body
|
||||
}
|
||||
|
||||
const cflProfile = {
|
||||
locale: 'de-DE',
|
||||
timezone: 'Europe/Berlin',
|
||||
endpoint: 'https://nrw.hafas.de/bin/mgate.exe',
|
||||
transformReqBody,
|
||||
|
||||
products,
|
||||
|
||||
departuresGetPasslist: false,
|
||||
departuresStbFltrEquiv: false,
|
||||
trip: true,
|
||||
radar: true,
|
||||
reachableFrom: true,
|
||||
remarks: true,
|
||||
}
|
||||
|
||||
module.exports = cflProfile;
|
78
p/mobil-nrw/products.js
Normal file
78
p/mobil-nrw/products.js
Normal file
|
@ -0,0 +1,78 @@
|
|||
'use strict'
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
id: 'regional-train',
|
||||
mode: 'train',
|
||||
bitmasks: [8],
|
||||
// todo: specify explicitly which
|
||||
name: 'regional train',
|
||||
short: 'regional train',
|
||||
default: true,
|
||||
},
|
||||
{
|
||||
id: 'urban-train',
|
||||
mode: 'train',
|
||||
bitmasks: [16],
|
||||
name: 'urban train',
|
||||
short: 'urban train',
|
||||
default: true,
|
||||
},
|
||||
{
|
||||
id: 'subway',
|
||||
mode: 'train',
|
||||
bitmasks: [128],
|
||||
name: 'subway',
|
||||
short: 'subway',
|
||||
default: true,
|
||||
},
|
||||
{
|
||||
id: 'tram',
|
||||
mode: 'train',
|
||||
bitmasks: [256],
|
||||
name: 'tram',
|
||||
short: 'tram',
|
||||
default: true,
|
||||
},
|
||||
{
|
||||
id: 'bus',
|
||||
mode: 'bus',
|
||||
bitmasks: [32],
|
||||
name: 'bus',
|
||||
short: 'bus',
|
||||
default: true,
|
||||
},
|
||||
{
|
||||
id: 'dial-a-ride',
|
||||
mode: 'taxi',
|
||||
bitmasks: [512],
|
||||
name: 'dial-a-ride',
|
||||
short: 'dial-a-ride',
|
||||
default: true,
|
||||
},
|
||||
{
|
||||
id: 'long-distance-train',
|
||||
mode: 'train',
|
||||
bitmasks: [4],
|
||||
// todo: specify explicitly which
|
||||
name: 'long-distance train',
|
||||
short: 'long-distance train',
|
||||
default: true,
|
||||
},
|
||||
{
|
||||
id: 'express-train',
|
||||
mode: 'train',
|
||||
bitmasks: [1],
|
||||
name: 'ICE',
|
||||
short: 'ICE',
|
||||
default: true,
|
||||
},
|
||||
{
|
||||
id: 'ec-ic',
|
||||
mode: 'ec-ic',
|
||||
bitmasks: [2],
|
||||
name: 'EC/IC',
|
||||
short: 'EC/IC',
|
||||
default: true,
|
||||
}
|
||||
]
|
18
p/mobil-nrw/readme.md
Normal file
18
p/mobil-nrw/readme.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
# *mobil.nrw* profile for `hafas-client`
|
||||
|
||||
[*mobil.nrw*](https://www.mobil.nrw) is the name of the travel planning service of the [*NRW-Tarif*](https://de.wikipedia.org/wiki/NRW-Tarif). This profile adds *mobil.nrw*-specific customisations to `hafas-client`.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const createClient = require('hafas-client')
|
||||
const mobilNrwProfile = require('hafas-client/p/mobil-nrw')
|
||||
|
||||
// create a client with mobil.nrw profile
|
||||
const client = createClient(mobilNrwProfile)
|
||||
```
|
||||
|
||||
|
||||
## Customisations
|
||||
|
||||
- *mobil.nrw*-specific products
|
|
@ -223,6 +223,7 @@ HAFAS endpoint | wrapper library | docs | example code | source code
|
|||
[Société Nationale des Chemins de Fer Luxembourgeois (CFL)](https://en.wikipedia.org/wiki/Société_Nationale_des_Chemins_de_Fer_Luxembourgeois) | - | [docs](p/cfl/readme.md) | [example code](p/cfl/example.js) | [src](p/cfl/index.js)
|
||||
[Hamburg public transport (HVV)](https://en.wikipedia.org/wiki/Hamburger_Verkehrsverbund) | - | [docs](p/hvv/readme.md) | [example code](p/hvv/example.js) | [src](p/hvv/index.js)
|
||||
[*Nordhessischer Verkehrsverbund (NVV)*](https://en.wikipedia.org/wiki/Nordhessischer_Verkehrsverbund) ([Hesse](https://en.wikipedia.org/wiki/Hesse)) | - | [docs](p/nvv/readme.md) | [example code](p/nvv/example.js) | [src](p/nvv/index.js)
|
||||
[*mobil.nrw*](https://www.mobil.nrw) | - | [docs](p/mobil-nrw/readme.md) | [example code](p/mobil-nrw/example.js) | [src](p/mobil-nrw/index.js)
|
||||
*DB Busradar NRW* ([DB Regio Bus](https://en.wikipedia.org/wiki/DB_Regio#Bus_division_(DB_Regio_Bus))) | - | [docs](p/db-busradar-nrw/readme.md) | [example code](p/db-busradar-nrw/example.js) | [src](p/db-busradar-nrw/index.js)
|
||||
[Verkehrsverbund Süd-Niedersachsen (VSN)](https://de.wikipedia.org/wiki/Verkehrsverbund_S%C3%BCd-Niedersachsen) | - | [docs](p/vsn/readme.md) | [example code](p/vsn/example.js) | [src](p/vsn/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)
|
||||
|
|
Loading…
Add table
Reference in a new issue