Add DB Busradar NRW profile (WIP)

This commit is contained in:
Kevin Arutyunyan 2019-08-20 23:47:12 +02:00 committed by Jannis R
parent c7a2813039
commit 56dee669a0
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
2 changed files with 151 additions and 0 deletions

View file

@ -0,0 +1,33 @@
'use strict'
const createClient = require('../../')
const dbbusradarnrwProfile = require('.')
const client = createClient(dbbusradarnrwProfile, 'hafas-client-example')
// Hagen Bauhaus to Schwerte Bahnhof
// returns hafas error PARSE
// client.journeys('3307002', '3357026', {results: 1})
// client.departures('3307002', {duration: 60})
// client.arrivals('3307002', {duration: 30, linesOfStops: true})
// client.locations('Hagen Vorhalle')
// client.stop('3307002') // Hagen Bauhaus
// client.nearby({
// type: 'location',
// latitude: 51.38,
// longitude: 7.45
// }, {results: 1})
// client.radar({
// north: 51.5,
// west: 7.2,
// south: 51.2,
// east: 7.8
// }, {results: 10})
.then((data) => {
console.log(require('util').inspect(data, {depth: null, colors: true}))
}, console.error)

118
p/db-busradar-nrw/index.js Normal file
View file

@ -0,0 +1,118 @@
'use strict'
// DB Busradar NRW app does not allow selecting specific modes of transport to filter results,
// so the bitmasks had to be determined by querying some stations and looking at the results..
const products = [
{
id: 'nationalExpress',
mode: 'train',
bitmasks: [1],
name: 'InterCityExpress',
short: 'ICE',
default: true
},
{
id: 'national',
mode: 'train',
bitmasks: [2],
name: 'InterCity & EuroCity',
short: 'IC/EC',
default: true
},
// 4: not always used, could not be confirmed..
{
id: 'regionalExp',
mode: 'train',
bitmasks: [4],
name: 'Regionalexpress',
short: 'RE',
default: true
},
{
id: 'regional',
mode: 'train',
bitmasks: [8],
name: 'Regionalzug',
short: 'RB/RE',
default: true
},
// 16: often appears together with 8 even when there are only S-Bahn trains at the station
{
id: 'suburban',
mode: 'train',
bitmasks: [16],
name: 'S-Bahn',
short: 'S',
default: true
},
{
id: 'bus',
mode: 'bus',
bitmasks: [32],
name: 'Bus',
short: 'Bus',
default: true
},
// 64, 128, 256: could not be confirmed
{
id: 'ferry',
mode: 'watercraft',
bitmasks: [64],
name: 'Ferry',
short: 'F',
default: true
},
{
id: 'subway',
mode: 'train',
bitmasks: [128],
name: 'U-Bahn',
short: 'U',
default: true
},
{
id: 'tram',
mode: 'train',
bitmasks: [256],
name: 'Tram',
short: 'T',
default: true
},
{
id: 'taxi',
mode: 'taxi',
bitmasks: [512],
name: 'AnrufSammelTaxi',
short: 'AST',
default: true
}
]
const transformReqBody = (body) => {
body.client = {
id: 'DB-REGIO',
name: 'DB Busradar NRW',
os: 'Android 9',
type: 'AND',
v: 100021
}
body.ext = 'DB.REGIO.1'
body.ver = '1.10'
body.auth = {type: 'AID', aid: 'OGBAqytjHhCvr0J4'}
return body
}
const dbBusradarNrwProfile = {
locale: 'de-DE',
timezone: 'Europe/Berlin',
endpoint: 'http://db-regio.hafas.de/bin/hci/mgate.exe',
transformReqBody,
products: products,
trip: true,
radar: true
}
module.exports = dbBusradarNrwProfile