mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-04-20 23:23:56 +03:00
parent
24c2cc6ea4
commit
33dab455ce
7 changed files with 173 additions and 10 deletions
|
@ -41,6 +41,7 @@ HAFAS endpoint | wrapper library | docs | example code | profile name
|
|||
[Salzburg public transport (SVV)](https://de.wikipedia.org/wiki/Salzburger_Verkehrsverbund) | - | [docs](svv/readme.md) | [example](svv/example.js) | [`svv`](svv)
|
||||
[Verkehrsverbund Tirol (VVT)](https://de.wikipedia.org/wiki/Verkehrsverbund_Tirol) | - | [docs](vvt/readme.md) | [example](vvt/example.js) | [`vvt`](vvt)
|
||||
[*Kärntner Linien/Verkehrsverbund Kärnten (VKG/VVK)*](https://de.wikipedia.org/wiki/Verkehrsverbund_Kärnten) | - | [docs](vkg/readme.md) | [example](vkg/example.js) | [`vkg`](vkg)
|
||||
[*Transports publics genevois (TPG)*](https://en.wikipedia.org/wiki/Geneva_Public_Transport) (Geneva) | - | [docs](tpg/readme.md) | [example](tpg/example.js) | [`tpg`](tpg)
|
||||
[*BLS AG*](https://en.wikipedia.org/wiki/BLS_AG) (Bern) | - | [docs](bls/readme.md) | [example](bls/example.js) | [`bls`](bls)
|
||||
[Zürich public transport (ZVV)](https://en.wikipedia.org/wiki/Zürcher_Verkehrsverbund) | - | [docs](zvv/readme.md) | [example](zvv/example.js) | [`zvv`](zvv)
|
||||
|
||||
|
|
13
p/tpg/base.json
Normal file
13
p/tpg/base.json
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"auth": {
|
||||
"type": "AID",
|
||||
"aid": "9CZsdl5PqX8n5D6b"
|
||||
},
|
||||
"client": {
|
||||
"type": "WEB",
|
||||
"id": "HAFAS",
|
||||
"name": "webapp"
|
||||
},
|
||||
"endpoint": "https://tpg-webapp.hafas.de/bin/mgate.exe",
|
||||
"defaultLanguage": "fr"
|
||||
}
|
53
p/tpg/example.js
Normal file
53
p/tpg/example.js
Normal file
|
@ -0,0 +1,53 @@
|
|||
'use strict'
|
||||
|
||||
const createClient = require('../..')
|
||||
const tpgProfile = require('.')
|
||||
|
||||
const client = createClient(tpgProfile, 'hafas-client-example')
|
||||
|
||||
const miremont = '100449'
|
||||
const moillebeau = '100451'
|
||||
|
||||
client.journeys(miremont, moillebeau, {results: 1, stopovers: true})
|
||||
|
||||
// .then(({journeys}) => {
|
||||
// const [journey] = journeys
|
||||
// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true})
|
||||
// })
|
||||
|
||||
// .then(({journeys}) => {
|
||||
// const [journey] = journeys
|
||||
// const leg = journey.legs[0]
|
||||
// return client.trip(leg.tripId, leg.line.name, {polyline: true})
|
||||
// })
|
||||
|
||||
// client.departures(miremont, {duration: 1})
|
||||
// client.arrivals(miremont, {duration: 10, linesOfStops: true})
|
||||
// client.radar({
|
||||
// north: 46.1849,
|
||||
// east: 6.1919,
|
||||
// south: 46.2215,
|
||||
// west: 6.1192,
|
||||
// }, {results: 10})
|
||||
|
||||
// client.locations('miremont', {results: 3})
|
||||
// client.stop(miremont, {linesOfStops: true})
|
||||
// client.nearby({
|
||||
// type: 'location',
|
||||
// latitude: 46.197768,
|
||||
// longitude: 6.148046,
|
||||
// }, {distance: 500})
|
||||
// client.reachableFrom({
|
||||
// type: 'location',
|
||||
// id: '990001624',
|
||||
// address: 'Cours des Bastions 10, 1205 Genève',
|
||||
// latitude: 46.197768,
|
||||
// longitude: 6.148046,
|
||||
// }, {
|
||||
// maxDuration: 10,
|
||||
// })
|
||||
|
||||
.then((data) => {
|
||||
console.log(require('util').inspect(data, {depth: null, colors: true}))
|
||||
})
|
||||
.catch(console.error)
|
87
p/tpg/index.js
Normal file
87
p/tpg/index.js
Normal file
|
@ -0,0 +1,87 @@
|
|||
'use strict'
|
||||
|
||||
const baseProfile = require('./base.json')
|
||||
|
||||
const products = [{
|
||||
id: 'tgv',
|
||||
mode: 'train',
|
||||
bitmasks: [1],
|
||||
name: 'TGV',
|
||||
short: 'TGV',
|
||||
default: true,
|
||||
}, {
|
||||
id: 'intercites',
|
||||
mode: 'train',
|
||||
bitmasks: [2],
|
||||
name: 'Intercités',
|
||||
short: 'Intercités',
|
||||
default: true,
|
||||
}, {
|
||||
id: 'ir',
|
||||
mode: 'train',
|
||||
bitmasks: [4],
|
||||
name: 'IR',
|
||||
short: 'IR',
|
||||
default: true,
|
||||
}, {
|
||||
id: 'train-direct',
|
||||
mode: 'train',
|
||||
bitmasks: [8],
|
||||
name: 'Train direct',
|
||||
short: 'Train direct',
|
||||
default: true,
|
||||
}, {
|
||||
id: 'bateau',
|
||||
mode: 'watercraft',
|
||||
bitmasks: [16],
|
||||
name: 'Bateau',
|
||||
short: 'Bateau',
|
||||
default: true,
|
||||
}, {
|
||||
id: 'regio-express',
|
||||
mode: 'train',
|
||||
bitmasks: [32],
|
||||
name: 'Regio Express',
|
||||
short: 'Regio Express',
|
||||
default: true,
|
||||
}, {
|
||||
id: 'bus',
|
||||
mode: 'bus',
|
||||
bitmasks: [64],
|
||||
name: 'Bus',
|
||||
short: 'Bus',
|
||||
default: true,
|
||||
}, {
|
||||
id: 'transport-a-cables',
|
||||
mode: 'gondola',
|
||||
bitmasks: [128],
|
||||
name: 'Transport à câbles',
|
||||
short: 'Transport à câbles',
|
||||
default: true,
|
||||
}, {
|
||||
id: 'tram',
|
||||
mode: 'train',
|
||||
bitmasks: [512],
|
||||
name: 'Tram',
|
||||
short: 'Tram',
|
||||
default: true,
|
||||
}]
|
||||
|
||||
const tpgProfile = {
|
||||
...baseProfile,
|
||||
locale: 'de-DE',
|
||||
timezone: 'Europe/Berlin',
|
||||
ver: '1.40',
|
||||
|
||||
products,
|
||||
|
||||
trip: true,
|
||||
radar: true,
|
||||
refreshJourneyUseOutReconL: true,
|
||||
reachableFrom: true,
|
||||
|
||||
departuresGetPasslist: false,
|
||||
departuresStbFltrEquiv: false,
|
||||
}
|
||||
|
||||
module.exports = tpgProfile
|
15
p/tpg/readme.md
Normal file
15
p/tpg/readme.md
Normal file
|
@ -0,0 +1,15 @@
|
|||
# TPG profile for `hafas-client`
|
||||
|
||||
[*Transports publics genevois (TPG)*](https://en.wikipedia.org/wiki/Geneva_Public_Transport) is the local transport provider of the [Canton of Geneva](https://en.wikipedia.org/wiki/Canton_of_Geneva). This profile adds *TPG* support to `hafas-client`.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const createClient = require('hafas-client')
|
||||
const tpgProfile = require('hafas-client/p/TPG')
|
||||
|
||||
// create a client with TPG profile
|
||||
const client = createClient(tpgProfile, 'my-awesome-program')
|
||||
```
|
||||
|
||||
Check out the [code examples](example.js).
|
|
@ -1,14 +1,7 @@
|
|||
{
|
||||
"statusCode": 200,
|
||||
"headers": {
|
||||
"date": "Mon, 26 Jul 2021 15:45:01 GMT",
|
||||
"server": "Apache",
|
||||
"content-length": "3720",
|
||||
"connection": "close",
|
||||
"content-type": "application/json; charset=utf-8"
|
||||
},
|
||||
"timeout": true,
|
||||
"time": 0,
|
||||
"url": "https://bls.hafas.de/bin/mgate.exe",
|
||||
"time": 1023,
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
|
@ -22,7 +15,7 @@
|
|||
"application/json"
|
||||
],
|
||||
"user-agent": [
|
||||
"pu1a6b1bee0fa6blic-transport/hafas-client:test"
|
||||
"public-transport/hafas-client:tes84543f948adat"
|
||||
],
|
||||
"Content-Length": [
|
||||
"706"
|
||||
|
|
|
@ -62,4 +62,5 @@ node -p "$query" "$src/de/vrn-hafas-mgate.json" >../p/vrn/base.json
|
|||
node -p "$query" "$src/de/vsn-hafas-mgate.json" >../p/vsn/base.json
|
||||
node -p "$query" "$src/at/vvt-hafas-mgate.json" >../p/vvt/base.json
|
||||
node -p "$query" "$src/ch/bls-hafas-mgate.json" >../p/bls/base.json
|
||||
node -p "$query" "$src/ch/tpg-hafas-mgate.json" >../p/tpg/base.json
|
||||
node -p "$query" "$src/ch/zvv-hafas-mgate.json" >../p/zvv/base.json
|
||||
|
|
Loading…
Add table
Reference in a new issue