mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
S-Bahn Munich profile
This commit is contained in:
parent
eddacd0091
commit
b7b5843d46
5 changed files with 171 additions and 0 deletions
49
p/sbahn-munich/example.js
Normal file
49
p/sbahn-munich/example.js
Normal file
|
@ -0,0 +1,49 @@
|
|||
'use strict'
|
||||
|
||||
const createClient = require('../..')
|
||||
const vbbProfile = require('.')
|
||||
|
||||
const client = createClient(vbbProfile, 'hafas-client-example')
|
||||
|
||||
// Mittersendling to Charlottenburg
|
||||
// client.journeys('8004154', '0621790', {results: 1, polylines: true})
|
||||
client.departures('8004154', {duration: 5})
|
||||
// client.arrivals('8004154', {duration: 10, stationLines: true})
|
||||
// client.locations('mittersendling', {results: 5})
|
||||
// client.station('8004154', {stationLines: true}) // Mittersendling
|
||||
// client.nearby({
|
||||
// type: 'location',
|
||||
// latitude: 48.153858,
|
||||
// longitude: 11.533059
|
||||
// }, {distance: 750})
|
||||
// client.radar({
|
||||
// north: 48.145121,
|
||||
// west: 11.543736,
|
||||
// south: 48.138339,
|
||||
// east: 11.553776
|
||||
// }, {results: 10})
|
||||
// client.reachableFrom({
|
||||
// type: 'location',
|
||||
// address: 'Pötschnerstraße 3, neuhausen',
|
||||
// latitude: 48.152499,
|
||||
// longitude: 11.531695
|
||||
// }, {
|
||||
// when: new Date('2018-08-27T10:00:00+0200'),
|
||||
// maxDuration: 20
|
||||
// })
|
||||
|
||||
// .then(([journey]) => {
|
||||
// const leg = journey.legs.find(leg => leg.line)
|
||||
// return client.trip(leg.id, leg.line.name, {polyline: true})
|
||||
// })
|
||||
|
||||
// .then(([journey]) => {
|
||||
// return client.refreshJourney(journey.refreshToken, {
|
||||
// stopovers: true, remarks: true
|
||||
// })
|
||||
// })
|
||||
|
||||
.then((data) => {
|
||||
console.log(require('util').inspect(data, {depth: null}))
|
||||
})
|
||||
.catch(console.error)
|
31
p/sbahn-munich/index.js
Normal file
31
p/sbahn-munich/index.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
'use strict'
|
||||
|
||||
const products = require('./products')
|
||||
|
||||
const transformReqBody = (body) => {
|
||||
body.client = {type: 'IPA', id: 'DB-REGIO-MVV', name: 'RegioNavigator', v: '1000030'}
|
||||
body.ext = 'DB.R15.12.a'
|
||||
body.ver = '1.15'
|
||||
body.auth = {type: 'AID', aid: 'd491MVVhz9ZZts23'}
|
||||
|
||||
return body
|
||||
}
|
||||
|
||||
const sBahnMunichProfile = {
|
||||
locale: 'de-DE',
|
||||
timezone: 'Europe/Berlin',
|
||||
endpoint: 'https://s-bahn-muenchen.hafas.de/bin/540/mgate.exe',
|
||||
|
||||
salt: Buffer.from('ggnvMVV8RTt67gh1', 'utf8'),
|
||||
addMicMac: true,
|
||||
transformReqBody,
|
||||
|
||||
products,
|
||||
|
||||
trip: true,
|
||||
radar: true,
|
||||
refreshJourney: true,
|
||||
reachableFrom: true
|
||||
}
|
||||
|
||||
module.exports = sBahnMunichProfile
|
77
p/sbahn-munich/products.js
Normal file
77
p/sbahn-munich/products.js
Normal file
|
@ -0,0 +1,77 @@
|
|||
'use strict'
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
id: 'ice',
|
||||
mode: 'train',
|
||||
bitmasks: [1],
|
||||
name: 'InterCityExpress',
|
||||
short: 'ICE',
|
||||
default: true
|
||||
},
|
||||
{
|
||||
id: 'ic-ec',
|
||||
mode: 'train',
|
||||
bitmasks: [2],
|
||||
name: 'InterCity/EuroCity',
|
||||
short: 'IC/EC',
|
||||
default: true
|
||||
},
|
||||
{
|
||||
id: 'ir-d',
|
||||
mode: 'train',
|
||||
bitmasks: [4],
|
||||
name: 'Interregio/Schnellzug',
|
||||
short: 'IRE',
|
||||
default: true
|
||||
},
|
||||
{
|
||||
id: 'region',
|
||||
mode: 'train',
|
||||
bitmasks: [8],
|
||||
name: 'Regio- und Nahverkehr',
|
||||
short: 'RE/RB',
|
||||
default: true
|
||||
},
|
||||
{
|
||||
id: 'sbahn',
|
||||
mode: 'train',
|
||||
bitmasks: [16],
|
||||
name: 'S-Bahn',
|
||||
short: 'S',
|
||||
default: true
|
||||
},
|
||||
{
|
||||
id: 'bus',
|
||||
mode: 'bus',
|
||||
bitmasks: [32],
|
||||
name: 'Bus',
|
||||
short: 'Bus',
|
||||
default: true
|
||||
},
|
||||
// todo: 64
|
||||
{
|
||||
id: 'ubahn',
|
||||
mode: 'train',
|
||||
bitmasks: [128],
|
||||
name: 'U-Bahn',
|
||||
short: 'U',
|
||||
default: true
|
||||
},
|
||||
{
|
||||
id: 'tram',
|
||||
mode: 'train',
|
||||
bitmasks: [256],
|
||||
name: 'Straßenbahn',
|
||||
short: 'Tram',
|
||||
default: true
|
||||
},
|
||||
{
|
||||
id: 'on-call',
|
||||
mode: 'taxi', // todo: or `bus`?
|
||||
bitmasks: [512],
|
||||
name: 'Anrufsammeltaxi',
|
||||
short: 'Sammeltaxi',
|
||||
default: true
|
||||
}
|
||||
]
|
13
p/sbahn-munich/readme.md
Normal file
13
p/sbahn-munich/readme.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
# S-Bahn München profile for `hafas-client`
|
||||
|
||||
[*S-Bahn München*](https://en.wikipedia.org/wiki/Munich_S-Bahn) runs commuter trains in [Munich](https://en.wikipedia.org/wiki/Munich). This profile adapts `hafas-client` to their HAFAS endpoint.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const createClient = require('hafas-client')
|
||||
const sMunichProfile = require('hafas-client/p/sbahn-munich')
|
||||
|
||||
// create a client with S-Bahn München profile
|
||||
const client = createClient(sMunichProfile, 'my-awesome-program')
|
||||
```
|
|
@ -11,6 +11,7 @@ HAFAS endpoint | wrapper library | docs | example code | source code
|
|||
[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)
|
||||
[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* Munich](https://en.wikipedia.org/wiki/Munich_S-Bahn) | - | [docs](p/sbahn-munich/readme.md) | [example code](p/sbahn-munich/example.js) | [src](p/sbahn-munich/index.js)
|
||||
|
||||
[](https://www.npmjs.com/package/hafas-client)
|
||||
[](https://travis-ci.org/public-transport/hafas-client)
|
||||
|
|
Loading…
Add table
Reference in a new issue