mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
CFL profile ✨
This commit is contained in:
parent
26069806e0
commit
3e01303e43
6 changed files with 132 additions and 1 deletions
33
p/cfl/example.js
Normal file
33
p/cfl/example.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const createClient = require('../..')
|
||||||
|
const cflProfile = require('.')
|
||||||
|
|
||||||
|
const client = createClient(cflProfile)
|
||||||
|
|
||||||
|
// from Mersch to Pfaffenthal-Kirchberg
|
||||||
|
// client.journeys('009864348', '008200102', {results: 1})
|
||||||
|
client.departures('009864348', { duration: 5 })
|
||||||
|
// client.locations('Pfaffenthal Kirchberg', {results: 2})
|
||||||
|
// client.station('009864348') // Mersch
|
||||||
|
// client.nearby({
|
||||||
|
// type: 'location',
|
||||||
|
// latitude: 49.7523,
|
||||||
|
// longitude: 6.1103
|
||||||
|
// }, {distance: 500})
|
||||||
|
// client.radar({
|
||||||
|
// north: 49.9,
|
||||||
|
// west: 6.11,
|
||||||
|
// south: 49.7,
|
||||||
|
// east: 6.13
|
||||||
|
// }, {results: 10})
|
||||||
|
|
||||||
|
// .then(([journey]) => {
|
||||||
|
// const leg = journey.legs[0]
|
||||||
|
// return client.journeyLeg(leg.id, leg.line.name)
|
||||||
|
// })
|
||||||
|
|
||||||
|
.then(data => {
|
||||||
|
console.log(require('util').inspect(data, { depth: null }))
|
||||||
|
})
|
||||||
|
.catch(console.error)
|
32
p/cfl/index.js
Normal file
32
p/cfl/index.js
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const products = require('./products')
|
||||||
|
|
||||||
|
const transformReqBody = (body) => {
|
||||||
|
body.client = {
|
||||||
|
type: 'IPH',
|
||||||
|
id: 'HAFAS',
|
||||||
|
v: '4000000',
|
||||||
|
name: 'cflPROD-STORE',
|
||||||
|
os: 'iPhone OS 9.3.5'
|
||||||
|
}
|
||||||
|
body.ver = '1.16'
|
||||||
|
body.auth = {aid: 'ALT2vl7LAFDFu2dz'}
|
||||||
|
body.lang = 'de'
|
||||||
|
|
||||||
|
return body
|
||||||
|
}
|
||||||
|
|
||||||
|
const cflProfile = {
|
||||||
|
locale: 'de-LU',
|
||||||
|
timezone: 'Europe/Luxembourg',
|
||||||
|
endpoint: 'https://horaires.cfl.lu/bin/mgate.exe',
|
||||||
|
transformReqBody,
|
||||||
|
|
||||||
|
products: products,
|
||||||
|
|
||||||
|
journeyLeg: true,
|
||||||
|
radar: true
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = cflProfile;
|
45
p/cfl/products.js
Normal file
45
p/cfl/products.js
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
module.exports = [
|
||||||
|
// todo: other bits
|
||||||
|
{
|
||||||
|
id: 'express-train',
|
||||||
|
mode: 'train',
|
||||||
|
bitmasks: [1, 2],
|
||||||
|
name: 'TGV, ICE, EuroCity',
|
||||||
|
short: 'TGV/ICE/EC',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'local-train',
|
||||||
|
mode: 'train',
|
||||||
|
bitmasks: [8, 16],
|
||||||
|
name: 'local trains',
|
||||||
|
short: 'local',
|
||||||
|
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: 'gondola',
|
||||||
|
mode: 'gondola',
|
||||||
|
bitmasks: [512],
|
||||||
|
name: 'Fun', // taken from the horaires.cfl.lu website
|
||||||
|
short: 'Fun',
|
||||||
|
default: true
|
||||||
|
}
|
||||||
|
]
|
18
p/cfl/readme.md
Normal file
18
p/cfl/readme.md
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# CFL profile for `hafas-client`
|
||||||
|
|
||||||
|
The [*Société Nationale des Chemins de Fer Luxembourgeois (CFL)*](https://en.wikipedia.org/wiki/Société_Nationale_des_Chemins_de_Fer_Luxembourgeois) is the national railway company of [Luxembourg](https://en.wikipedia.org/wiki/Luxembourg). This profile adds *CFL*-specific customisations to `hafas-client`.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
const createClient = require('hafas-client')
|
||||||
|
const cflProfile = require('hafas-client/p/cfl')
|
||||||
|
|
||||||
|
// create a client with CFL profile
|
||||||
|
const client = createClient(cflProfile)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Customisations
|
||||||
|
|
||||||
|
- *CFL*-specific products (such as [*Standseilbahn_Pfaffenthal-Kirchberg*](https://de.wikipedia.org/wiki/Standseilbahn_Pfaffenthal-Kirchberg))
|
|
@ -3,10 +3,12 @@
|
||||||
const slugg = require('slugg')
|
const slugg = require('slugg')
|
||||||
|
|
||||||
const parseOperator = (profile, a) => {
|
const parseOperator = (profile, a) => {
|
||||||
|
const name = a.name && a.name.trim()
|
||||||
|
if (!name) return null
|
||||||
return {
|
return {
|
||||||
type: 'operator',
|
type: 'operator',
|
||||||
id: slugg(a.name), // todo: find a more reliable way
|
id: slugg(a.name), // todo: find a more reliable way
|
||||||
name: a.name
|
name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ HAFAS endpoint | wrapper library | docs | example code | source code
|
||||||
[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)
|
[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 München*](https://en.wikipedia.org/wiki/Munich_S-Bahn) | - | [docs](p/sbahn-muenchen/readme.md) | [example code](p/sbahn-muenchen/example.js) | [src](p/sbahn-muenchen/index.js)
|
[*S-Bahn München*](https://en.wikipedia.org/wiki/Munich_S-Bahn) | - | [docs](p/sbahn-muenchen/readme.md) | [example code](p/sbahn-muenchen/example.js) | [src](p/sbahn-muenchen/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)
|
*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)
|
||||||
|
|
||||||
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