mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
add NVV profile
This commit is contained in:
parent
ae4e592b00
commit
73ca349ee5
5 changed files with 167 additions and 0 deletions
49
p/nvv/example.js
Normal file
49
p/nvv/example.js
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const createClient = require('../..')
|
||||||
|
const nvvProfile = require('.')
|
||||||
|
|
||||||
|
const client = createClient(nvvProfile, 'hafas-client-example')
|
||||||
|
|
||||||
|
// Scheidemannplatz to Auestadion
|
||||||
|
client.journeys('2200073', '2200042', {results: 1, polylines: true})
|
||||||
|
// .then(({journeys}) => {
|
||||||
|
// const [journey] = journeys
|
||||||
|
// const leg = journey.legs.find(l => !!l.line)
|
||||||
|
// return client.trip(leg.tripId, leg.line.name, {polyline: true})
|
||||||
|
// })
|
||||||
|
// .then(({journeys}) => {
|
||||||
|
// const [journey] = journeys
|
||||||
|
// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true})
|
||||||
|
// })
|
||||||
|
|
||||||
|
// client.departures('2200005', {duration: 1, stopovers: true})
|
||||||
|
// client.arrivals('2200005', {duration: 10, linesOfStops: true})
|
||||||
|
// client.locations('kirchweg', {results: 2})
|
||||||
|
// client.stop('2200005', {linesOfStops: true}) // Kassel Kirchweg
|
||||||
|
// client.nearby({
|
||||||
|
// type: 'location',
|
||||||
|
// latitude: 51.313,
|
||||||
|
// longitude: 9.4654
|
||||||
|
// }, {distance: 400})
|
||||||
|
// client.radar({
|
||||||
|
// north: 51.320153,
|
||||||
|
// west: 9.458359,
|
||||||
|
// south: 51.304304,
|
||||||
|
// east: 9.493672
|
||||||
|
// }, {results: 10})
|
||||||
|
// client.reachableFrom({
|
||||||
|
// type: 'location',
|
||||||
|
// id: '990100251',
|
||||||
|
// address: 'Kassel, Heckerstraße 2',
|
||||||
|
// latitude: 51.308108,
|
||||||
|
// longitude: 9.475152
|
||||||
|
// }, {
|
||||||
|
// when: new Date('2019-04-02T10:00:00+0200'),
|
||||||
|
// maxDuration: 10
|
||||||
|
// })
|
||||||
|
|
||||||
|
.then((data) => {
|
||||||
|
console.log(require('util').inspect(data, {depth: null, colors: true}))
|
||||||
|
})
|
||||||
|
.catch(console.error)
|
38
p/nvv/index.js
Normal file
38
p/nvv/index.js
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const products = require('./products')
|
||||||
|
|
||||||
|
const transformReqBody = (body) => {
|
||||||
|
body.client = {
|
||||||
|
type: 'IPH',
|
||||||
|
id: 'NVV',
|
||||||
|
v: '5000300',
|
||||||
|
os: 'iOS 12.1.4',
|
||||||
|
name: 'NVVMobilPROD_APPSTORE'
|
||||||
|
}
|
||||||
|
body.ver = '1.18'
|
||||||
|
body.ext = 'NVV.6.0'
|
||||||
|
body.auth = {type: 'AID', aid: 'Kt8eNOH7qjVeSxNA'}
|
||||||
|
body.lang = 'de'
|
||||||
|
|
||||||
|
return body
|
||||||
|
}
|
||||||
|
|
||||||
|
const saarfahrplanProfile = {
|
||||||
|
locale: 'de-DE',
|
||||||
|
timezone: 'Europe/Berlin',
|
||||||
|
endpoint: 'https://auskunft.nvv.de/auskunft/bin/app/mgate.exe',
|
||||||
|
transformReqBody,
|
||||||
|
|
||||||
|
// Although the app uses `mic` & `mac`, they don't seem to be necessary.
|
||||||
|
// addMicMac: true
|
||||||
|
|
||||||
|
products: products,
|
||||||
|
|
||||||
|
departuresGetPasslist: true,
|
||||||
|
trip: true,
|
||||||
|
radar: true,
|
||||||
|
reachableFrom: true
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = saarfahrplanProfile
|
61
p/nvv/products.js
Normal file
61
p/nvv/products.js
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
module.exports = [
|
||||||
|
// todo: what is `256`?
|
||||||
|
{
|
||||||
|
id: 'express',
|
||||||
|
mode: 'train',
|
||||||
|
bitmasks: [1],
|
||||||
|
name: 'InterCityExpress',
|
||||||
|
short: 'ICE',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'national',
|
||||||
|
mode: 'train',
|
||||||
|
bitmasks: [2],
|
||||||
|
name: 'EuroCity/InterCity',
|
||||||
|
short: 'EC/IC',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'regional',
|
||||||
|
mode: 'train',
|
||||||
|
bitmasks: [4],
|
||||||
|
name: 'Regionalzug',
|
||||||
|
short: 'RE/RB',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'regiotram',
|
||||||
|
mode: 'train',
|
||||||
|
bitmasks: [1024, 16, 8], // it is `1048` actually
|
||||||
|
name: 'RegioTram',
|
||||||
|
short: 'RegioTram',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'tram',
|
||||||
|
mode: 'train',
|
||||||
|
bitmasks: [4, 32],
|
||||||
|
name: 'Tram',
|
||||||
|
short: 'Tram',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'bus',
|
||||||
|
mode: 'bus',
|
||||||
|
bitmasks: [128, 64], // it is `192` actually
|
||||||
|
name: 'Bus',
|
||||||
|
short: 'Bus',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'on-call',
|
||||||
|
mode: 'taxi', // todo: or `bus`?
|
||||||
|
bitmasks: [512],
|
||||||
|
name: 'AnrufSammelTaxi',
|
||||||
|
short: 'Sammeltaxi',
|
||||||
|
default: true
|
||||||
|
}
|
||||||
|
]
|
18
p/nvv/readme.md
Normal file
18
p/nvv/readme.md
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# NVV profile for `hafas-client`
|
||||||
|
|
||||||
|
[*Nordhessischer Verkehrsverbund (NVV)*](https://en.wikipedia.org/wiki/Nordhessischer_Verkehrsverbund) is a local transport association in [Hesse](https://en.wikipedia.org/wiki/Hesse). This profile adds *NVV*-specific customizations to `hafas-client`.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
const createClient = require('hafas-client')
|
||||||
|
const nvvProfile = require('hafas-client/p/nvv')
|
||||||
|
|
||||||
|
// create a client with NVV profile
|
||||||
|
const client = createClient(nvvProfile, 'my-awesome-program')
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Customisations
|
||||||
|
|
||||||
|
- parses *NVV*-specific products (such as *RegioTram*)
|
|
@ -15,6 +15,7 @@ HAFAS endpoint | wrapper library | docs | example code | source code
|
||||||
*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)
|
||||||
[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)
|
[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)
|
[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)
|
||||||
|
|
||||||
There are also client libraries that use the library, but contain their own customisations:
|
There are also client libraries that use the library, but contain their own customisations:
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue