mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
Rejseplanen profile
This commit is contained in:
parent
a621fd6df4
commit
4d0605737f
4 changed files with 124 additions and 0 deletions
34
p/rejseplanen/example.js
Normal file
34
p/rejseplanen/example.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
'use strict'
|
||||
|
||||
const createClient = require('../..')
|
||||
const rejseplanenProfile = require('.')
|
||||
|
||||
const client = createClient(rejseplanenProfile, 'hafas-client-example')
|
||||
|
||||
// from København Central to Aalborg
|
||||
// client.journeys('8600626', '8600020', {results: 1})
|
||||
// .then(({journeys}) => {
|
||||
|
||||
// const leg = journeys[0].legs[0]
|
||||
// return client.trip(leg.tripId, leg.line.name)
|
||||
// })
|
||||
|
||||
client.departures('8600626', {duration: 5})
|
||||
// client.locations('KØbenhaven', {results: 2})
|
||||
// client.stop('8600626') // København Central
|
||||
// client.nearby({
|
||||
// type: 'location',
|
||||
// latitude: 55.673,
|
||||
// longitude: 12.566
|
||||
// }, {distance: 200})
|
||||
// client.radar({
|
||||
// north: 55.673,
|
||||
// west: 12.566,
|
||||
// south: 55.672,
|
||||
// east: 12.567
|
||||
// }, {results: 10})
|
||||
|
||||
.then(data => {
|
||||
console.log(require('util').inspect(data, {depth: null, colors: true}))
|
||||
})
|
||||
.catch(console.error)
|
28
p/rejseplanen/index.js
Normal file
28
p/rejseplanen/index.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
'use strict'
|
||||
|
||||
const products = require('./products')
|
||||
|
||||
const transformReqBody = (ctx, body) => {
|
||||
body.ext = 'DK.9'
|
||||
body.client = {type: 'AND', id: 'DK'}
|
||||
body.ver = '1.21'
|
||||
body.auth = {type: 'AID', aid: 'irkmpm9mdznstenr-android'}
|
||||
|
||||
return body
|
||||
}
|
||||
|
||||
const rejseplanenProfile = {
|
||||
locale: 'da-DK',
|
||||
timezone: 'Europe/Copenhagen',
|
||||
endpoint: 'https://mobilapps.rejseplanen.dk/bin/iphone.exe',
|
||||
transformReqBody,
|
||||
|
||||
products: products,
|
||||
|
||||
departuresGetPasslist: false,
|
||||
departuresStbFltrEquiv: false,
|
||||
trip: true,
|
||||
radar: true,
|
||||
}
|
||||
|
||||
module.exports = rejseplanenProfile;
|
44
p/rejseplanen/products.js
Normal file
44
p/rejseplanen/products.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
'use strict'
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
id: 'national-train',
|
||||
mode: 'train',
|
||||
bitmasks: [1],
|
||||
name: 'InterCity',
|
||||
short: 'IC',
|
||||
default: true,
|
||||
},
|
||||
{
|
||||
id: 'national-train-2',
|
||||
mode: 'train',
|
||||
bitmasks: [2],
|
||||
name: 'ICL', // todo: find proper name
|
||||
short: 'ICL',
|
||||
default: true,
|
||||
},
|
||||
{
|
||||
id: 'local-train',
|
||||
mode: 'train',
|
||||
bitmasks: [4],
|
||||
name: 'Regional',
|
||||
short: 'RE',
|
||||
default: true,
|
||||
},
|
||||
{
|
||||
id: 'o',
|
||||
mode: 'train', // todo: correct?
|
||||
bitmasks: [8],
|
||||
name: 'Ø', // todo: find proper name
|
||||
short: 'Ø',
|
||||
default: true,
|
||||
},
|
||||
{
|
||||
id: 's-tog',
|
||||
mode: 'train',
|
||||
bitmasks: [16],
|
||||
name: 'S-Tog A/B/Bx/C/E/F/H',
|
||||
short: 'S',
|
||||
default: true,
|
||||
}
|
||||
]
|
18
p/rejseplanen/readme.md
Normal file
18
p/rejseplanen/readme.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Rejseplanen profile for `hafas-client`
|
||||
|
||||
[*Rejseplanen*](https://da.wikipedia.org/wiki/Rejseplanen) is a Danish website for finding public transport connections throughout Denmark. This profile adds *Rejseplanen*-specific customisations to `hafas-client`.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const createClient = require('hafas-client')
|
||||
const rejseplanenProfile = require('hafas-client/p/rejseplanen')
|
||||
|
||||
// create a client with Rejseplanen profile
|
||||
const client = createClient(rejseplanenProfile)
|
||||
```
|
||||
|
||||
|
||||
## Customisations
|
||||
|
||||
- parses Denmark-specific products (such as *S-Tog*)
|
Loading…
Add table
Reference in a new issue