mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
add SVV profile
This commit is contained in:
parent
1b0133190f
commit
fa3146d706
5 changed files with 162 additions and 0 deletions
46
p/svv/example.js
Normal file
46
p/svv/example.js
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const createClient = require('../..')
|
||||||
|
const svvProfile = require('.')
|
||||||
|
|
||||||
|
const client = createClient(svvProfile, 'hafas-client-example')
|
||||||
|
|
||||||
|
const sam = '455086100'
|
||||||
|
const volksgarten = '455082100'
|
||||||
|
const zillnerstr2 = {
|
||||||
|
type: 'location',
|
||||||
|
id: '980133005',
|
||||||
|
address: 'Zillnerstraße 2, 5020 Salzburg',
|
||||||
|
latitude: 47.801434, longitude: 13.031006,
|
||||||
|
}
|
||||||
|
|
||||||
|
client.journeys(sam, volksgarten, {results: 1, polylines: true})
|
||||||
|
// .then(({journeys}) => {
|
||||||
|
// const [journey] = journeys
|
||||||
|
// const leg = journey.legs[0]
|
||||||
|
// return client.trip(leg.tripId, leg.line.name, {polyline: true})
|
||||||
|
// })
|
||||||
|
// .then(({journeys}) => {
|
||||||
|
// const [journey] = journeys
|
||||||
|
// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true})
|
||||||
|
// })
|
||||||
|
|
||||||
|
// client.departures(sam, {duration: 1})
|
||||||
|
// client.arrivals(sam, {duration: 10, linesOfStops: true})
|
||||||
|
// client.locations('salzburg sam', {results: 2})
|
||||||
|
// client.stop(sam, {linesOfStops: true}) // Dammtor
|
||||||
|
// client.nearby(zillnerstr2)
|
||||||
|
// client.radar({
|
||||||
|
// north: 47.815,
|
||||||
|
// west: 13.007,
|
||||||
|
// south: 47.792,
|
||||||
|
// east: 13.059
|
||||||
|
// }, {results: 10})
|
||||||
|
// client.reachableFrom(zillnerstr2, {
|
||||||
|
// when: new Date('2020-06-01T10:00:00+0200'),
|
||||||
|
// })
|
||||||
|
|
||||||
|
.then((data) => {
|
||||||
|
console.log(require('util').inspect(data, {depth: null, colors: true}))
|
||||||
|
})
|
||||||
|
.catch(console.error)
|
29
p/svv/index.js
Normal file
29
p/svv/index.js
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const products = require('./products')
|
||||||
|
|
||||||
|
const transformReqBody = (ctx, body) => {
|
||||||
|
body.client = {type: 'WEB', id: 'VAO', name: 'webapp'}
|
||||||
|
body.ext = 'VAO.11'
|
||||||
|
body.ver = '1.20'
|
||||||
|
body.auth = {type: 'AID', aid: 'wf7mcf9bv3nv8g5f'}
|
||||||
|
return body
|
||||||
|
}
|
||||||
|
|
||||||
|
const svvProfile = {
|
||||||
|
locale: 'at-DE',
|
||||||
|
timezone: 'Europe/Vienna',
|
||||||
|
endpoint: 'https://fahrplan.salzburg-verkehr.at/bin/mgate.exe',
|
||||||
|
|
||||||
|
transformReqBody,
|
||||||
|
|
||||||
|
products,
|
||||||
|
|
||||||
|
trip: true,
|
||||||
|
refreshJourney: true,
|
||||||
|
reachableFrom: true,
|
||||||
|
departuresGetPasslist: false,
|
||||||
|
departuresStbFltrEquiv: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = svvProfile
|
68
p/svv/products.js
Normal file
68
p/svv/products.js
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
module.exports = [
|
||||||
|
{
|
||||||
|
id: 'bahn-s-bahn',
|
||||||
|
mode: 'train',
|
||||||
|
bitmasks: [1, 2],
|
||||||
|
name: 'Bahn & S-Bahn',
|
||||||
|
short: 'S/Zug',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'u-bahn',
|
||||||
|
mode: 'train',
|
||||||
|
bitmasks: [4],
|
||||||
|
name: 'U-Bahn',
|
||||||
|
short: 'U',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'strassenbahn',
|
||||||
|
mode: 'train',
|
||||||
|
bitmasks: [16],
|
||||||
|
name: 'Strassenbahn',
|
||||||
|
short: 'Str',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'fernbus',
|
||||||
|
mode: 'bus',
|
||||||
|
bitmasks: [32],
|
||||||
|
name: 'Fernbus',
|
||||||
|
short: 'Bus',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'regionalbus',
|
||||||
|
mode: 'bus',
|
||||||
|
bitmasks: [64],
|
||||||
|
name: 'Regionalbus',
|
||||||
|
short: 'Bus',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'stadtbus',
|
||||||
|
mode: 'bus',
|
||||||
|
bitmasks: [128],
|
||||||
|
name: 'Stadtbus',
|
||||||
|
short: 'Bus',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'seilbahn-zahnradbahn',
|
||||||
|
mode: 'gondola',
|
||||||
|
bitmasks: [256],
|
||||||
|
name: 'Seil-/Zahnradbahn',
|
||||||
|
short: 'Seil-/Zahnradbahn',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'schiff',
|
||||||
|
mode: 'watercraft',
|
||||||
|
bitmasks: [512],
|
||||||
|
name: 'Schiff',
|
||||||
|
short: 'F',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
]
|
18
p/svv/readme.md
Normal file
18
p/svv/readme.md
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# SVV profile for `hafas-client`
|
||||||
|
|
||||||
|
[*Salzburger Verkehrsverbund (SVV)*](https://de.wikipedia.org/wiki/Salzburger_Verkehrsverbund) is the local transit authority of [Salzburg](https://en.wikipedia.org/wiki/Salzburg). This profile adds *SVV*-specific customizations to `hafas-client`.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
const createClient = require('hafas-client')
|
||||||
|
const svvProfile = require('hafas-client/p/svv')
|
||||||
|
|
||||||
|
// create a client with SVV profile
|
||||||
|
const client = createClient(svvProfile, 'my-awesome-program')
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Customisations
|
||||||
|
|
||||||
|
- parses *SVV*-specific products
|
|
@ -226,6 +226,7 @@ HAFAS endpoint | wrapper library | docs | example code | source code
|
||||||
[Verkehrsverbund Bremen/Niedersachsen (VBN)](https://de.wikipedia.org/wiki/Verkehrsverbund_Bremen/Niedersachsen) | - | [docs](p/vbn/readme.md) | [example code](p/vbn/example.js) | [src](p/vbn/index.js)
|
[Verkehrsverbund Bremen/Niedersachsen (VBN)](https://de.wikipedia.org/wiki/Verkehrsverbund_Bremen/Niedersachsen) | - | [docs](p/vbn/readme.md) | [example code](p/vbn/example.js) | [src](p/vbn/index.js)
|
||||||
[Rostocker Straßenbahn AG (RSAG)](https://de.wikipedia.org/wiki/Rostocker_Straßenbahn_AG) | - | [docs](p/rsag/readme.md) | [example code](p/rsag/example.js) | [src](p/rsag/index.js)
|
[Rostocker Straßenbahn AG (RSAG)](https://de.wikipedia.org/wiki/Rostocker_Straßenbahn_AG) | - | [docs](p/rsag/readme.md) | [example code](p/rsag/example.js) | [src](p/rsag/index.js)
|
||||||
[Verkehrsverbund Mittelthüringen (VMT)](https://en.wikipedia.org/wiki/Verkehrsverbund_Mittelthüringen) | - | [docs](p/vmt/readme.md) | [example code](p/vmt/example.js) | [src](p/vmt/index.js)
|
[Verkehrsverbund Mittelthüringen (VMT)](https://en.wikipedia.org/wiki/Verkehrsverbund_Mittelthüringen) | - | [docs](p/vmt/readme.md) | [example code](p/vmt/example.js) | [src](p/vmt/index.js)
|
||||||
|
[Salzburg public transport (SVV)](https://de.wikipedia.org/wiki/Salzburger_Verkehrsverbund) | - | [docs](p/svv/readme.md) | [example code](p/svv/example.js) | [src](p/svv/index.js)
|
||||||
|
|
||||||
There are also libraries that use `hafas-client` and pass their own profile in:
|
There are also libraries that use `hafas-client` and pass their own profile in:
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue