mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
parent
39950122a6
commit
ed86ad0b56
10 changed files with 218 additions and 1 deletions
15
p/kvb/base.json
Normal file
15
p/kvb/base.json
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"auth": {
|
||||||
|
"type": "AID",
|
||||||
|
"aid": "Rt6foY5zcTTRXMQs"
|
||||||
|
},
|
||||||
|
"client": {
|
||||||
|
"type": "WEB",
|
||||||
|
"id": "HAFAS",
|
||||||
|
"name": "webapp",
|
||||||
|
"l": "vs_webapp"
|
||||||
|
},
|
||||||
|
"endpoint": "https://auskunft.kvb.koeln/gate",
|
||||||
|
"defaultLanguage": "de",
|
||||||
|
"ver": "1.42"
|
||||||
|
}
|
47
p/kvb/example.js
Normal file
47
p/kvb/example.js
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const createClient = require('../..')
|
||||||
|
const kvbProfile = require('.')
|
||||||
|
|
||||||
|
const client = createClient(kvbProfile, 'hafas-client example')
|
||||||
|
|
||||||
|
const heumarkt = '900000001'
|
||||||
|
const poststr = '900000003'
|
||||||
|
|
||||||
|
// client.journeys(heumarkt, poststr, {
|
||||||
|
// 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(heumarkt, {duration: 1})
|
||||||
|
// client.arrivals(heumarkt, {duration: 10, linesOfStops: true})
|
||||||
|
|
||||||
|
client.locations('heumarkt', {results: 3})
|
||||||
|
// client.stop(heumarkt, {linesOfStops: true})
|
||||||
|
// client.nearby({
|
||||||
|
// type: 'location',
|
||||||
|
// id: '991023531',
|
||||||
|
// address: 'An den Dominikanern 27',
|
||||||
|
// latitude: 50.942454, longitude: 6.954064,
|
||||||
|
// }, {distance: 500})
|
||||||
|
// client.reachableFrom({
|
||||||
|
// type: 'location',
|
||||||
|
// id: '991023531',
|
||||||
|
// address: 'An den Dominikanern 27',
|
||||||
|
// latitude: 50.942454, longitude: 6.954064,
|
||||||
|
// }, {
|
||||||
|
// maxDuration: 15,
|
||||||
|
// })
|
||||||
|
|
||||||
|
.then((data) => {
|
||||||
|
console.log(require('util').inspect(data, {depth: null, colors: true}))
|
||||||
|
})
|
||||||
|
.catch(console.error)
|
63
p/kvb/index.js
Normal file
63
p/kvb/index.js
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const baseProfile = require('./base.json')
|
||||||
|
|
||||||
|
const products = [{
|
||||||
|
id: 'stadtbahn',
|
||||||
|
mode: 'train',
|
||||||
|
bitmasks: [2],
|
||||||
|
name: 'Stadtbahn',
|
||||||
|
short: 'Stadtbahn',
|
||||||
|
default: true,
|
||||||
|
}, {
|
||||||
|
id: 'bus',
|
||||||
|
mode: 'bus',
|
||||||
|
bitmasks: [8],
|
||||||
|
name: 'Bus',
|
||||||
|
short: 'Bus',
|
||||||
|
default: true,
|
||||||
|
}, {
|
||||||
|
id: 'taxibus',
|
||||||
|
mode: 'bus',
|
||||||
|
bitmasks: [256],
|
||||||
|
name: 'Taxibus',
|
||||||
|
short: 'Taxibus',
|
||||||
|
default: true,
|
||||||
|
}, {
|
||||||
|
id: 's-bahn',
|
||||||
|
mode: 'train',
|
||||||
|
bitmasks: [1],
|
||||||
|
name: 'S-Bahn',
|
||||||
|
short: 'S',
|
||||||
|
default: true,
|
||||||
|
}, {
|
||||||
|
id: 'regionalverkehr',
|
||||||
|
mode: 'train',
|
||||||
|
bitmasks: [46],
|
||||||
|
name: 'Regionalverkehr',
|
||||||
|
short: 'Regionalverkehr',
|
||||||
|
default: true,
|
||||||
|
}, {
|
||||||
|
id: 'fernverkehr',
|
||||||
|
mode: 'train',
|
||||||
|
bitmasks: [32],
|
||||||
|
name: 'Fernverkehr',
|
||||||
|
short: 'Fernverkehr',
|
||||||
|
default: true,
|
||||||
|
}]
|
||||||
|
|
||||||
|
const vosProfile = {
|
||||||
|
...baseProfile,
|
||||||
|
locale: 'de-DE',
|
||||||
|
timezone: 'Europe/Berlin',
|
||||||
|
|
||||||
|
products,
|
||||||
|
|
||||||
|
departuresGetPasslist: false,
|
||||||
|
departuresStbFltrEquiv: false,
|
||||||
|
refreshJourneyUseOutReconL: true,
|
||||||
|
trip: true,
|
||||||
|
reachableFrom: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = vosProfile
|
15
p/kvb/readme.md
Normal file
15
p/kvb/readme.md
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
# KVB profile for `hafas-client`
|
||||||
|
|
||||||
|
[*Kölner Verkehrs-Betriebe (KVB)*](https://de.wikipedia.org/wiki/Kölner_Verkehrs-Betriebe) is the local transport provider of [Cologne](https://en.wikipedia.org/wiki/Cologne). This profile adds *KVB* support to `hafas-client`.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
const createClient = require('hafas-client')
|
||||||
|
const kvbProfile = require('hafas-client/p/kvb')
|
||||||
|
|
||||||
|
// create a client with KVB profile
|
||||||
|
const client = createClient(kvbProfile, 'my-awesome-program')
|
||||||
|
```
|
||||||
|
|
||||||
|
Check out the [code examples](example.js).
|
|
@ -38,6 +38,7 @@ HAFAS endpoint | wrapper library | docs | example code | profile name
|
||||||
[Verkehrsverbund Mittelthüringen (VMT)](https://en.wikipedia.org/wiki/Verkehrsverbund_Mittelthüringen) | - | [docs](vmt/readme.md) | [example](vmt/example.js) | [`vmt`](vmt)
|
[Verkehrsverbund Mittelthüringen (VMT)](https://en.wikipedia.org/wiki/Verkehrsverbund_Mittelthüringen) | - | [docs](vmt/readme.md) | [example](vmt/example.js) | [`vmt`](vmt)
|
||||||
[Verkehrsgemeinschaft Osnabrück (VOS)](https://de.wikipedia.org/wiki/Verkehrsgemeinschaft_Osnabrück) | - | [docs](vos/readme.md) | [example](vos/example.js) | [`vos`](vos)
|
[Verkehrsgemeinschaft Osnabrück (VOS)](https://de.wikipedia.org/wiki/Verkehrsgemeinschaft_Osnabrück) | - | [docs](vos/readme.md) | [example](vos/example.js) | [`vos`](vos)
|
||||||
[Aachener Verkehrsverbund (AVV)](https://de.wikipedia.org/wiki/Verkehrsgemeinschaft_Osnabrück) | - | [docs](avv/readme.md) | [example](avv/example.js) | [`avv`](avv)
|
[Aachener Verkehrsverbund (AVV)](https://de.wikipedia.org/wiki/Verkehrsgemeinschaft_Osnabrück) | - | [docs](avv/readme.md) | [example](avv/example.js) | [`avv`](avv)
|
||||||
|
[Kölner Verkehrs-Betriebe (KVB)](https://de.wikipedia.org/wiki/Kölner_Verkehrs-Betriebe) | - | [docs](kvb/readme.md) | [example](kvb/example.js) | [`kvb`](kvb)
|
||||||
[Rejseplanen in Denmark](http://www.rejseplanen.dk) | - | [docs](rejseplanen/readme.md) | [example](rejseplanen/example.js) | [`rejseplanen`](rejseplanen)
|
[Rejseplanen in Denmark](http://www.rejseplanen.dk) | - | [docs](rejseplanen/readme.md) | [example](rejseplanen/example.js) | [`rejseplanen`](rejseplanen)
|
||||||
[Innsbrucker Verkehrsbetriebe (IVB)](https://de.wikipedia.org/wiki/Innsbrucker_Verkehrsbetriebe_und_Stubaitalbahn) | - | [docs](ivb/readme.md) | [example](ivb/example.js) | [`ivb`](ivb)
|
[Innsbrucker Verkehrsbetriebe (IVB)](https://de.wikipedia.org/wiki/Innsbrucker_Verkehrsbetriebe_und_Stubaitalbahn) | - | [docs](ivb/readme.md) | [example](ivb/example.js) | [`ivb`](ivb)
|
||||||
[Oberösterreichischer Verkehrsverbund (OÖVV)](https://de.wikipedia.org/wiki/Oberösterreichischer_Verkehrsverbund) | - | [docs](ooevv/readme.md) | [example](ooevv/example.js) | [`ooevv`](ooevv)
|
[Oberösterreichischer Verkehrsverbund (OÖVV)](https://de.wikipedia.org/wiki/Oberösterreichischer_Verkehrsverbund) | - | [docs](ooevv/readme.md) | [example](ooevv/example.js) | [`ooevv`](ooevv)
|
||||||
|
|
1
test/e2e/fixtures/1943a180fe03ac3865c9a8359c3e6668
vendored
Normal file
1
test/e2e/fixtures/1943a180fe03ac3865c9a8359c3e6668
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"graph":{"id":"standard","index":0},"subGraph":{"id":"global","index":0},"svcResL":[{"meth":"LocMatch","res":{"common":{"graphL":[{"id":"standard","index":0}],"icoL":[{"bg":{"b":255,"g":255,"r":255},"brd":{"b":0,"g":0,"r":0},"fg":{"b":0,"g":0,"r":0},"res":"prod_sub"},{"bg":{"b":255,"g":255,"r":255},"brd":{"b":0,"g":0,"r":0},"fg":{"b":0,"g":0,"r":0},"res":"prod_bus"},{"res":"loc_addr"}],"prodL":[{"prodCtx":{"lineId":"de:vrs:1"},"cls":2,"icoX":0,"name":"1","nameS":"1"},{"prodCtx":{"lineId":"de:vrs:5"},"cls":2,"icoX":0,"name":"5","nameS":"5"},{"prodCtx":{"lineId":"de:vrs:7"},"cls":2,"icoX":0,"name":"7","nameS":"7"},{"prodCtx":{"lineId":"de:vrs:9"},"cls":2,"icoX":0,"name":"9","nameS":"9"},{"prodCtx":{"lineId":"E"},"cls":2,"icoX":0,"name":"E","nameS":"E"},{"prodCtx":{"lineId":"de:vrs:106"},"cls":8,"icoX":1,"name":"106","nameS":"106"},{"prodCtx":{"lineId":"de:vrs:132"},"cls":8,"icoX":1,"name":"132","nameS":"132"},{"prodCtx":{"lineId":"de:vrs:133"},"cls":8,"icoX":1,"name":"133","nameS":"133"},{"prodCtx":{"lineId":"WUPSI__250"},"cls":8,"icoX":1,"name":"250","nameS":"250"},{"prodCtx":{"lineId":"RVK_WK_260"},"cls":8,"icoX":1,"name":"260","nameS":"260"},{"prodCtx":{"lineId":"REVG___978"},"cls":8,"icoX":1,"name":"978","nameS":"978"},{"prodCtx":{"lineId":"RVK_WK_N26"},"cls":8,"icoX":1,"name":"N26","nameS":"N26"},{"prodCtx":{"lineId":"de:vrs:151"},"cls":8,"icoX":1,"name":"151","nameS":"151"},{"prodCtx":{"lineId":"de:vrs:152"},"cls":8,"icoX":1,"name":"152","nameS":"152"},{"prodCtx":{"lineId":"de:vrs:165"},"cls":8,"icoX":1,"name":"165","nameS":"165"},{"prodCtx":{"lineId":"de:vrs:3"},"cls":2,"icoX":0,"name":"3","nameS":"3"},{"prodCtx":{"lineId":"de:vrs:4"},"cls":2,"icoX":0,"name":"4","nameS":"4"},{"prodCtx":{"lineId":"de:vrs:16"},"cls":2,"icoX":0,"name":"16","nameS":"16"},{"prodCtx":{"lineId":"de:vrs:18"},"cls":2,"icoX":0,"name":"18","nameS":"18"},{"prodCtx":{"lineId":"de:vrs:136"},"cls":8,"icoX":1,"name":"136","nameS":"136"},{"prodCtx":{"lineId":"de:vrs:146"},"cls":8,"icoX":1,"name":"146","nameS":"146"}],"subGraphL":[{"id":"Koel_619","index":1159,"name":"Köln Heumarkt"},{"id":"Koel_289","index":294,"name":"Köln Eil Heumarer Str."},{"id":"Koel_620","index":1160,"name":"Köln Neumarkt"}],"viewL":[{"id":"standard","index":0,"type":"WGS84"},{"id":"Koel_619","index":1,"type":"WGS84"},{"id":"Koel_289","index":1,"type":"WGS84"},{"id":"Koel_620","index":1,"type":"WGS84"}]},"match":{"locL":[{"crd":{"viewAlternatives":[{"subGraphNodes":[{"viewNodes":[{"viewX":0},{"viewX":1}],"subGraphX":0}],"graphX":0}],"floor":0,"x":6959269,"y":50935712},"gidL":["A×de:05315:11110"],"pRefL":[0,1,2,3,4,5,6,7,8,9,10,11],"TZOffset":0,"chgTime":"000000","extId":"900000001","icoX":0,"isMainMast":true,"lid":"A=1@O=Köln Heumarkt@X=6959269@Y=50935712@U=1@L=900000001@B=1@p=1637929092@","meta":true,"name":"Köln Heumarkt","pCls":10,"state":"F","type":"S","wt":22316},{"crd":{"x":6960150,"y":50934759},"icoX":2,"lid":"A=2@O=Heumarkt@X=6960150@Y=50934759@U=100@b=991023566@B=1@p=1606316333@","name":"Heumarkt","state":"M","type":"A"},{"crd":{"x":6960518,"y":50934651},"icoX":2,"lid":"A=2@O=Heumarkt, 50667@X=6960518@Y=50934651@U=100@b=991067738@B=1@p=1606316333@","name":"Heumarkt, 50667","state":"M","type":"A"},{"crd":{"viewAlternatives":[{"subGraphNodes":[{"viewNodes":[{"viewX":0},{"viewX":2}],"subGraphX":1}],"graphX":0}],"floor":0,"x":7077891,"y":50897211},"gidL":["A×de:05315:17265"],"pRefL":[12,13,14],"TZOffset":0,"chgTime":"000000","extId":"900000460","icoX":1,"isMainMast":true,"lid":"A=1@O=Köln Eil Heumarer Str.@X=7077891@Y=50897211@U=1@L=900000460@B=1@p=1637929092@","meta":true,"name":"Köln Eil Heumarer Str.","pCls":8,"state":"F","type":"S","wt":2019},{"crd":{"viewAlternatives":[{"subGraphNodes":[{"viewNodes":[{"viewX":0},{"viewX":3}],"subGraphX":2}],"graphX":0}],"floor":0,"x":6948329,"y":50935667},"gidL":["A×de:05315:11111"],"pRefL":[0,15,16,2,3,17,18,4,19,20],"TZOffset":0,"chgTime":"000000","extId":"900000002","icoX":0,"isMainMast":true,"lid":"A=1@O=Köln Neumarkt@X=6948329@Y=50935667@U=1@L=900000002@B=1@p=1637929092@","meta":true,"name":"Köln Neumarkt","pCls":10,"state":"F","type":"S","wt":22316}],"field":"S","state":"L"}},"err":"OK"}],"view":{"id":"standard","index":0,"type":"WGS84"},"err":"OK","id":"m5wejiqikcy3wiwg","lang":"deu","ver":"1.42"}
|
39
test/e2e/fixtures/1943a180fe03ac3865c9a8359c3e6668.headers
vendored
Normal file
39
test/e2e/fixtures/1943a180fe03ac3865c9a8359c3e6668.headers
vendored
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
{
|
||||||
|
"statusCode": 200,
|
||||||
|
"headers": {
|
||||||
|
"date": "Sat, 27 Nov 2021 22:46:26 GMT",
|
||||||
|
"server": "Apache/2.4.38 (Debian) OpenSSL/1.1.1d",
|
||||||
|
"content-type": "application/json",
|
||||||
|
"access-control-allow-headers": "*",
|
||||||
|
"access-control-allow-methods": "GET,POST,OPTIONS",
|
||||||
|
"access-control-allow-origin": "*",
|
||||||
|
"backend-group": "default",
|
||||||
|
"connection": "close",
|
||||||
|
"transfer-encoding": "chunked"
|
||||||
|
},
|
||||||
|
"url": "https://auskunft.kvb.koeln/gate",
|
||||||
|
"time": 195,
|
||||||
|
"request": {
|
||||||
|
"method": "POST",
|
||||||
|
"headers": {
|
||||||
|
"Content-Type": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"Accept-Encoding": [
|
||||||
|
"gzip, br, deflate"
|
||||||
|
],
|
||||||
|
"Accept": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"user-agent": [
|
||||||
|
"public-transpo912a53de656frt/hafas-client:test"
|
||||||
|
],
|
||||||
|
"Content-Length": [
|
||||||
|
"279"
|
||||||
|
],
|
||||||
|
"Connection": [
|
||||||
|
"close"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
35
test/e2e/kvb.js
Normal file
35
test/e2e/kvb.js
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const tap = require('tap')
|
||||||
|
|
||||||
|
const {createWhen} = require('./lib/util')
|
||||||
|
const createClient = require('../..')
|
||||||
|
const kvbProfile = require('../../p/kvb')
|
||||||
|
const createValidate = require('./lib/validate-fptf-with')
|
||||||
|
|
||||||
|
const when = createWhen(kvbProfile.timezone, kvbProfile.locale)
|
||||||
|
const cfg = {
|
||||||
|
when,
|
||||||
|
stationCoordsOptional: false,
|
||||||
|
products: kvbProfile.products,
|
||||||
|
maxLatitude: 51.6479,
|
||||||
|
maxLongitude: 7.8333,
|
||||||
|
minLatitude: 50.3253,
|
||||||
|
minLongitude: 6.2320,
|
||||||
|
}
|
||||||
|
const validate = createValidate(cfg)
|
||||||
|
|
||||||
|
const client = createClient(kvbProfile, 'public-transport/hafas-client:test')
|
||||||
|
|
||||||
|
const heumarkt = '900000001'
|
||||||
|
|
||||||
|
tap.test('locations named "heumarkt"', async (t) => {
|
||||||
|
const locations = await client.locations('heumarkt')
|
||||||
|
|
||||||
|
validate(t, locations, 'locations', 'locations')
|
||||||
|
t.ok(locations.some((l) => {
|
||||||
|
return l.station && l.station.id === heumarkt || l.id === heumarkt
|
||||||
|
}), 'Heumarkt not found')
|
||||||
|
|
||||||
|
t.end()
|
||||||
|
})
|
|
@ -71,3 +71,4 @@ 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/tpg-hafas-mgate.json" >../p/tpg/base.json
|
||||||
node -p "$query" "$src/ch/zvv-hafas-mgate.json" >../p/zvv/base.json
|
node -p "$query" "$src/ch/zvv-hafas-mgate.json" >../p/zvv/base.json
|
||||||
node -p "$query" "$src/us/dart-hafas-mgate.json" >../p/dart/base.json
|
node -p "$query" "$src/us/dart-hafas-mgate.json" >../p/dart/base.json
|
||||||
|
node -p "$query" "$src/de/kvb-hafas-mgate.json" >../p/kvb/base.json
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 023caad70f42e808189a6d3e1b6fcaef47ce870c
|
Subproject commit fcb5e2f94abc00e718b44e487de11ebe39f6b89f
|
Loading…
Add table
Reference in a new issue