mirror of
				https://github.com/public-transport/db-vendo-client.git
				synced 2025-10-31 16:16:32 +02:00 
			
		
		
		
	
							parent
							
								
									f20466c21c
								
							
						
					
					
						commit
						0ae13b09af
					
				
					 9 changed files with 243 additions and 0 deletions
				
			
		|  | @ -39,6 +39,7 @@ HAFAS endpoint | wrapper library | docs | example code | profile name | ||||||
| [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) | ||||||
| [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) | ||||||
|  | [Steirischer Verkehrsverbund (STV)](https://de.wikipedia.org/wiki/Steirischer_Verkehrsverbund) | - | [docs](stv/readme.md) | [example](stv/example.js) | [`stv`](stv) | ||||||
| [Salzburg public transport (SVV)](https://de.wikipedia.org/wiki/Salzburger_Verkehrsverbund) | - | [docs](svv/readme.md) | [example](svv/example.js) | [`svv`](svv) | [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) | [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) | [*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) | ||||||
|  |  | ||||||
							
								
								
									
										15
									
								
								p/stv/base.json
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								p/stv/base.json
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,15 @@ | ||||||
|  | { | ||||||
|  | 	"auth": { | ||||||
|  | 		"type": "AID", | ||||||
|  | 		"aid": "wf7mcf9bv3nv8g5f" | ||||||
|  | 	}, | ||||||
|  | 	"client": { | ||||||
|  | 		"type": "WEB", | ||||||
|  | 		"id": "VAO", | ||||||
|  | 		"name": "webapp" | ||||||
|  | 	}, | ||||||
|  | 	"endpoint": "https://verkehrsauskunft.verbundlinie.at/bin/mgate.exe", | ||||||
|  | 	"ext": "VAO.13", | ||||||
|  | 	"ver": "1.32", | ||||||
|  | 	"defaultLanguage": "de" | ||||||
|  | } | ||||||
							
								
								
									
										49
									
								
								p/stv/example.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								p/stv/example.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,49 @@ | ||||||
|  | 'use strict' | ||||||
|  | 
 | ||||||
|  | const createClient = require('../..') | ||||||
|  | const stvProfile = require('.') | ||||||
|  | 
 | ||||||
|  | const client = createClient(stvProfile, 'hafas-client example') | ||||||
|  | 
 | ||||||
|  | const grazSonnenhang = '460413500' | ||||||
|  | const grazHödlweg = '460415400' | ||||||
|  | 
 | ||||||
|  | // client.journeys(grazSonnenhang, grazHödlweg, {
 | ||||||
|  | // 	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(grazSonnenhang, {duration: 1})
 | ||||||
|  | // client.arrivals(grazSonnenhang, {duration: 10, linesOfStops: true})
 | ||||||
|  | 
 | ||||||
|  | client.locations('sonnenhang', {results: 3}) | ||||||
|  | // client.stop(grazSonnenhang, {linesOfStops: true})
 | ||||||
|  | // client.nearby({
 | ||||||
|  | // 	type: 'location',
 | ||||||
|  | // 	id: '980027564',
 | ||||||
|  | // 	address: 'Eisengasse 10, 8020 Graz',
 | ||||||
|  | // 	latitude: 47.076553,
 | ||||||
|  | // 	longitude: 15.406064,
 | ||||||
|  | // }, {distance: 1000})
 | ||||||
|  | // client.reachableFrom({
 | ||||||
|  | // 	type: 'location',
 | ||||||
|  | // 	id: '980027564',
 | ||||||
|  | // 	address: 'Eisengasse 10, 8020 Graz',
 | ||||||
|  | // 	latitude: 47.076553,
 | ||||||
|  | // 	longitude: 15.406064,
 | ||||||
|  | // }, {
 | ||||||
|  | // 	maxDuration: 30,
 | ||||||
|  | // })
 | ||||||
|  | 
 | ||||||
|  | .then((data) => { | ||||||
|  | 	console.log(require('util').inspect(data, {depth: null, colors: true})) | ||||||
|  | }) | ||||||
|  | .catch(console.error) | ||||||
							
								
								
									
										91
									
								
								p/stv/index.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										91
									
								
								p/stv/index.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,91 @@ | ||||||
|  | 'use strict' | ||||||
|  | 
 | ||||||
|  | const baseProfile = require('./base.json') | ||||||
|  | 
 | ||||||
|  | const products = [{ | ||||||
|  | 	id: 'train-and-s-bahn', | ||||||
|  | 	mode: 'train', | ||||||
|  | 	bitmasks: [1, 2], | ||||||
|  | 	name: 'Bahn & S-Bahn', | ||||||
|  | 	short: 'Bahn & S-Bahn', | ||||||
|  | 	default: true, | ||||||
|  | }, { | ||||||
|  | 	id: 'u-bahn', | ||||||
|  | 	mode: 'train', | ||||||
|  | 	bitmasks: [4], | ||||||
|  | 	name: 'U-Bahn', | ||||||
|  | 	short: 'U-Bahn', | ||||||
|  | 	default: true, | ||||||
|  | }, { | ||||||
|  | 	id: 'tram', | ||||||
|  | 	mode: 'train', | ||||||
|  | 	bitmasks: [16], | ||||||
|  | 	name: 'Straßenbahn', | ||||||
|  | 	short: 'Straßenbahn', | ||||||
|  | 	default: true, | ||||||
|  | }, { | ||||||
|  | 	id: 'city-bus', | ||||||
|  | 	mode: 'bus', | ||||||
|  | 	bitmasks: [128], | ||||||
|  | 	name: 'Stadtbus', | ||||||
|  | 	short: 'Stadtbus', | ||||||
|  | 	default: true, | ||||||
|  | }, { | ||||||
|  | 	id: 'regional-bus', | ||||||
|  | 	mode: 'bus', | ||||||
|  | 	bitmasks: [64], | ||||||
|  | 	name: 'Regionalbus', | ||||||
|  | 	short: 'Regionalbus', | ||||||
|  | 	default: true, | ||||||
|  | }, { | ||||||
|  | 	id: 'long-distance-bus', | ||||||
|  | 	mode: 'bus', | ||||||
|  | 	bitmasks: [32], | ||||||
|  | 	name: 'Fernbus', | ||||||
|  | 	short: 'Fernbus', | ||||||
|  | 	default: true, | ||||||
|  | }, { | ||||||
|  | 	id: 'other-bus', | ||||||
|  | 	mode: 'bus', | ||||||
|  | 	bitmasks: [2048], | ||||||
|  | 	name: 'sonstige Busse', | ||||||
|  | 	short: 'sonstige Busse', | ||||||
|  | 	default: true, | ||||||
|  | }, { | ||||||
|  | 	id: 'aerial-lift', | ||||||
|  | 	mode: 'gondola', | ||||||
|  | 	bitmasks: [256], | ||||||
|  | 	name: 'Seil-/Zahnradbahn', | ||||||
|  | 	short: 'Seil-/Zahnradbahn', | ||||||
|  | 	default: true, | ||||||
|  | }, { | ||||||
|  | 	id: 'ferry', | ||||||
|  | 	mode: 'watercraft', | ||||||
|  | 	bitmasks: [512], | ||||||
|  | 	name: 'Schiff', | ||||||
|  | 	short: 'Schiff', | ||||||
|  | 	default: true, | ||||||
|  | }, { | ||||||
|  | 	id: 'on-call', | ||||||
|  | 	mode: 'taxi', | ||||||
|  | 	bitmasks: [1024], | ||||||
|  | 	name: 'Anrufsammeltaxi', | ||||||
|  | 	short: 'AST', | ||||||
|  | 	default: true, | ||||||
|  | }] | ||||||
|  | 
 | ||||||
|  | const stvProfile = { | ||||||
|  | 	...baseProfile, | ||||||
|  | 	locale: 'at-DE', | ||||||
|  | 	timezone: 'Europe/Vienna', | ||||||
|  | 
 | ||||||
|  | 	products, | ||||||
|  | 
 | ||||||
|  | 	departuresGetPasslist: false, | ||||||
|  | 	departuresStbFltrEquiv: false, | ||||||
|  | 	refreshJourneyUseOutReconL: true, | ||||||
|  | 	trip: true, | ||||||
|  | 	reachableFrom: true, | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | module.exports = stvProfile | ||||||
							
								
								
									
										15
									
								
								p/stv/readme.md
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								p/stv/readme.md
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,15 @@ | ||||||
|  | # STV profile for `hafas-client` | ||||||
|  | 
 | ||||||
|  | [*Steirischer Verkehrsverbund (STV)*](https://de.wikipedia.org/wiki/Steirischer_Verkehrsverbund) is the local transport provider of [Styria](https://en.wikipedia.org/wiki/Styria) that runs its apps under the [*VerbundLinie*](https://www.verbundlinie.at) brand. This profile adds *STV*/*VerbundLinie* support to `hafas-client`. | ||||||
|  | 
 | ||||||
|  | ## Usage | ||||||
|  | 
 | ||||||
|  | ```js | ||||||
|  | const createClient = require('hafas-client') | ||||||
|  | const stvProfile = require('hafas-client/p/stv') | ||||||
|  | 
 | ||||||
|  | // create a client with STV profile | ||||||
|  | const client = createClient(stvProfile, 'my-awesome-program') | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | Check out the [code examples](example.js). | ||||||
							
								
								
									
										1
									
								
								test/e2e/fixtures/9f33037cf954e62ae7ee72fbc9fbb8c4
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								test/e2e/fixtures/9f33037cf954e62ae7ee72fbc9fbb8c4
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1 @@ | ||||||
|  | {"ver":"1.32","ext":"VAO.13","lang":"deu","id":"urk4mgmgm6agg2wx","err":"OK","cInfo":{"code":"OK","url":"","msg":""},"graph":{"id":"standard","index":0},"subGraph":{"id":"global","index":0},"view":{"id":"standard","index":0,"type":"WGS84"},"svcResL":[{"meth":"LocMatch","err":"OK","res":{"common":{"txtInstL":[{"id":"street","type":"NONE","mode":"ADD"},{"id":"city","type":"NONE","mode":"ADD"}],"icoL":[{"res":"prod_regbus","txtS":"421","fg":{"r":255,"g":255,"b":255},"bg":{"r":0,"g":121,"b":58},"zIdx":1000},{"res":"prod_bus","txtS":"53","fg":{"r":255,"g":255,"b":255},"bg":{"r":0,"g":121,"b":58},"zIdx":1000},{"res":"prod_regbus","txtS":"862","fg":{"r":255,"g":255,"b":255},"bg":{"r":0,"g":121,"b":58},"zIdx":1000},{"res":"prod_regbus","txtS":"265","fg":{"r":255,"g":255,"b":255},"bg":{"r":0,"g":121,"b":58},"zIdx":1000},{"res":"ADR"}]},"match":{"field":"S","state":"L","locL":[{"lid":"A=1@O=Graz Sonnenhang@X=15481555@Y=47067034@U=81@L=460413500@B=1@p=1628121247@","type":"S","name":"Graz Sonnenhang","nameFormatted":{"text":"Graz Sonnenhang"},"icoX":0,"extId":"460413500","state":"F","crd":{"x":15481555,"y":47067034,"floor":0},"meta":true,"pCls":192,"wt":191,"isMainMast":true,"gidL":["at:46:4135"]},{"lid":"A=1@O=Stattegg Sonnenhang@X=15418613@Y=47141626@U=81@L=460362700@B=1@p=1628121247@","type":"S","name":"Stattegg Sonnenhang","nameFormatted":{"text":"Stattegg Sonnenhang"},"icoX":1,"extId":"460362700","state":"F","crd":{"x":15418613,"y":47141626,"floor":0},"meta":true,"pCls":128,"wt":188,"isMainMast":true,"gidL":["at:46:3627"]},{"lid":"A=1@O=Mehrnbach Sonnenhang@X=13443674@Y=48207189@U=81@L=444079800@B=1@p=1628121247@","type":"S","name":"Mehrnbach Sonnenhang","nameFormatted":{"text":"Mehrnbach Sonnenhang"},"icoX":2,"extId":"444079800","state":"F","crd":{"x":13443674,"y":48207189,"floor":0},"meta":true,"pCls":64,"wt":10,"isMainMast":true,"gidL":["at:44:40798"]},{"lid":"A=1@O=Waxenberg Sonnenhang@X=14191927@Y=48481945@U=81@L=444569400@B=1@p=1628121247@","type":"S","name":"Waxenberg Sonnenhang","nameFormatted":{"text":"Waxenberg Sonnenhang"},"icoX":3,"extId":"444569400","state":"F","crd":{"x":14191927,"y":48481945,"floor":0},"meta":true,"pCls":64,"wt":2,"isMainMast":true,"gidL":["at:44:45694"]},{"lid":"A=2@O=Sonnenhang, 3262 Wang@X=15020723@Y=48049231@U=103@b=980111207@B=1@p=1626331592@","type":"A","name":"Sonnenhang, 3262 Wang","nameFormatted":{"text":"Sonnenhang, 3262 Wang","textInstructionIntervalL":[{"startIndex":0,"endIndex":10,"textInstructionX":0},{"startIndex":10,"endIndex":21,"textInstructionX":1}]},"icoX":4,"state":"F","crd":{"x":15020723,"y":48049231}}]}}}]} | ||||||
							
								
								
									
										35
									
								
								test/e2e/fixtures/9f33037cf954e62ae7ee72fbc9fbb8c4.headers
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								test/e2e/fixtures/9f33037cf954e62ae7ee72fbc9fbb8c4.headers
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,35 @@ | ||||||
|  | { | ||||||
|  |   "statusCode": 200, | ||||||
|  |   "headers": { | ||||||
|  |     "date": "Thu, 05 Aug 2021 18:10:17 GMT", | ||||||
|  |     "server": "Apache", | ||||||
|  |     "content-length": "841", | ||||||
|  |     "content-type": "application/json; charset=utf-8", | ||||||
|  |     "connection": "close" | ||||||
|  |   }, | ||||||
|  |   "url": "https://verkehrsauskunft.verbundlinie.at/bin/mgate.exe", | ||||||
|  |   "time": 266, | ||||||
|  |   "request": { | ||||||
|  |     "method": "POST", | ||||||
|  |     "headers": { | ||||||
|  |       "Content-Type": [ | ||||||
|  |         "application/json" | ||||||
|  |       ], | ||||||
|  |       "Accept-Encoding": [ | ||||||
|  |         "gzip, br, deflate" | ||||||
|  |       ], | ||||||
|  |       "Accept": [ | ||||||
|  |         "application/json" | ||||||
|  |       ], | ||||||
|  |       "user-agent": [ | ||||||
|  |         "public-transc9279a930e0bport/hafas-client:test" | ||||||
|  |       ], | ||||||
|  |       "Content-Length": [ | ||||||
|  |         "278" | ||||||
|  |       ], | ||||||
|  |       "Connection": [ | ||||||
|  |         "close" | ||||||
|  |       ] | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | } | ||||||
							
								
								
									
										35
									
								
								test/e2e/stv.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								test/e2e/stv.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,35 @@ | ||||||
|  | 'use strict' | ||||||
|  | 
 | ||||||
|  | const tap = require('tap') | ||||||
|  | 
 | ||||||
|  | const {createWhen} = require('./lib/util') | ||||||
|  | const createClient = require('../..') | ||||||
|  | const stvProfile = require('../../p/stv') | ||||||
|  | const createValidate = require('./lib/validate-fptf-with') | ||||||
|  | 
 | ||||||
|  | const when = createWhen(stvProfile.timezone, stvProfile.locale) | ||||||
|  | const cfg = { | ||||||
|  | 	when, | ||||||
|  | 	stationCoordsOptional: false, | ||||||
|  | 	products: stvProfile.products, | ||||||
|  | 	maxLatitude: 47.9504, | ||||||
|  | 	maxLongitude: 18.347, | ||||||
|  | 	minLatitude: 46.127, | ||||||
|  | 	minLongitude: 7.8635, | ||||||
|  | } | ||||||
|  | const validate = createValidate(cfg) | ||||||
|  | 
 | ||||||
|  | const client = createClient(stvProfile, 'public-transport/hafas-client:test') | ||||||
|  | 
 | ||||||
|  | const grazSonnenhang = '460413500' | ||||||
|  | 
 | ||||||
|  | tap.test('locations named "sonnenhang"', async (t) => { | ||||||
|  | 	const locations = await client.locations('sonnenhang') | ||||||
|  | 
 | ||||||
|  | 	validate(t, locations, 'locations', 'locations') | ||||||
|  | 	t.ok(locations.some((l) => { | ||||||
|  | 		return l.station && l.station.id === grazSonnenhang || l.id === grazSonnenhang | ||||||
|  | 	}), 'Graz Sonnenhang not found') | ||||||
|  | 
 | ||||||
|  | 	t.end() | ||||||
|  | }) | ||||||
|  | @ -61,6 +61,7 @@ node -p "$query" "$src/de/vos-hafas-mgate.json" >../p/vos/base.json | ||||||
| node -p "$query" "$src/de/vrn-hafas-mgate.json" >../p/vrn/base.json | 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/de/vsn-hafas-mgate.json" >../p/vsn/base.json | ||||||
| node -p "$query" "$src/at/ivb-hafas-mgate.json" >../p/ivb/base.json | node -p "$query" "$src/at/ivb-hafas-mgate.json" >../p/ivb/base.json | ||||||
|  | node -p "$query" "$src/at/stv-hafas-mgate.json" >../p/stv/base.json | ||||||
| node -p "$query" "$src/at/vvt-hafas-mgate.json" >../p/vvt/base.json | node -p "$query" "$src/at/vvt-hafas-mgate.json" >../p/vvt/base.json | ||||||
| node -p "$query" "$src/at/vvv-hafas-mgate.json" >../p/vvv/base.json | node -p "$query" "$src/at/vvv-hafas-mgate.json" >../p/vvv/base.json | ||||||
| node -p "$query" "$src/ch/bls-hafas-mgate.json" >../p/bls/base.json | node -p "$query" "$src/ch/bls-hafas-mgate.json" >../p/bls/base.json | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue