mirror of
				https://github.com/public-transport/db-vendo-client.git
				synced 2025-10-31 16:16:32 +02:00 
			
		
		
		
	Saarfahrplan profile
This commit is contained in:
		
							parent
							
								
									5d0096c596
								
							
						
					
					
						commit
						1b941dea16
					
				
					 5 changed files with 192 additions and 0 deletions
				
			
		
							
								
								
									
										43
									
								
								p/saarfahrplan/example.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								p/saarfahrplan/example.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,43 @@ | |||
| 'use strict' | ||||
| 
 | ||||
| const createClient = require('../..') | ||||
| const saarfahrplanProfile = require('.') | ||||
| 
 | ||||
| const client = createClient(saarfahrplanProfile, 'hafas-client-example') | ||||
| 
 | ||||
| client.journeys('15541', '10609', {results: 1}) | ||||
| // .then(([journey]) => {
 | ||||
| // 	const leg = journey.legs[0]
 | ||||
| // 	return client.trip(leg.id, leg.line.name, {polyline: true})
 | ||||
| // })
 | ||||
| // .then(([journey]) => {
 | ||||
| // 	return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true})
 | ||||
| // })
 | ||||
| 
 | ||||
| // client.departures('15541', {duration: 1})
 | ||||
| // client.arrivals('15541', {duration: 10, stationLines: true})
 | ||||
| // client.locations('uhlandstr', {results: 2})
 | ||||
| // client.station('10609') // Uhlandstr., Saarbrücken
 | ||||
| // client.nearby({
 | ||||
| // 	type: 'location',
 | ||||
| // 	latitude: 49.229498,
 | ||||
| // 	longitude: 7.008609
 | ||||
| // }, {distance: 400})
 | ||||
| // client.radar({
 | ||||
| // 	north: 49.244044,
 | ||||
| // 	west: 6.987644,
 | ||||
| // 	south: 49.235332,
 | ||||
| // 	east: 7.006480
 | ||||
| // }, {results: 10})
 | ||||
| // client.reachableFrom({
 | ||||
| // 	type: 'location',
 | ||||
| // 	id: '009000763',
 | ||||
| // 	latitude: 49.235223,
 | ||||
| // 	longitude: 6.996493,
 | ||||
| // 	name: 'Saarbrücken, Rathaus'
 | ||||
| // }, {maxDuration: 20})
 | ||||
| 
 | ||||
| .then((data) => { | ||||
| 	console.log(require('util').inspect(data, {depth: null, colors: true})) | ||||
| }) | ||||
| .catch(console.error) | ||||
							
								
								
									
										37
									
								
								p/saarfahrplan/index.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								p/saarfahrplan/index.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,37 @@ | |||
| 'use strict' | ||||
| 
 | ||||
| const products = require('./products') | ||||
| 
 | ||||
| const transformReqBody = (body) => { | ||||
| 	body.client = { | ||||
| 		type: 'AND', | ||||
| 		id: 'ZPS-SAAR', | ||||
| 		v: 1000070, | ||||
| 		name: 'Saarfahrplan', | ||||
| 		os: 'Android 9' | ||||
| 	} | ||||
| 	body.ver = '1.21' | ||||
| 	body.auth = {type: 'AID', aid: '51XfsVqgbdA6oXzHrx75jhlocRg6Xe'} | ||||
| 	body.lang = 'de' | ||||
| 
 | ||||
| 	return body | ||||
| } | ||||
| 
 | ||||
| const saarfahrplanProfile = { | ||||
| 	locale: 'de-DE', | ||||
| 	timezone: 'Europe/Berlin', | ||||
| 	endpoint: 'https://saarfahrplan.de/bin/mgate.exe', | ||||
| 	transformReqBody, | ||||
| 
 | ||||
| 	// decrypted form of https://gist.github.com/derhuerst/f5a8c07f9b3226ecad6c8f64d83df6a2#file-haf_config_base-properties-L70
 | ||||
| 	salt: Buffer.from('HJtlubisvxiJxss', 'utf8'), | ||||
| 	addMicMac: true, | ||||
| 
 | ||||
| 	products: products, | ||||
| 
 | ||||
| 	trip: true, | ||||
| 	radar: true, | ||||
| 	reachableFrom: true | ||||
| } | ||||
| 
 | ||||
| module.exports = saarfahrplanProfile | ||||
							
								
								
									
										93
									
								
								p/saarfahrplan/products.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								p/saarfahrplan/products.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,93 @@ | |||
| 'use strict' | ||||
| 
 | ||||
| module.exports = [ | ||||
| 	{ | ||||
| 		id: 'nationalExpress', | ||||
| 		mode: 'train', | ||||
| 		bitmasks: [8192], | ||||
| 		name: 'Hochgeschwindigkeitszug', | ||||
| 		short: 'ICE', | ||||
| 		default: true | ||||
| 	}, | ||||
| 	{ | ||||
| 		id: 'national', | ||||
| 		mode: 'train', | ||||
| 		bitmasks: [4096], | ||||
| 		name: 'InterCity & EuroCity', | ||||
| 		short: 'IC/EC', | ||||
| 		default: true | ||||
| 	}, | ||||
| 	{ | ||||
| 		id: 'interregional', | ||||
| 		mode: 'train', | ||||
| 		bitmasks: [2048], | ||||
| 		name: 'InterRegio', | ||||
| 		short: 'IR', | ||||
| 		default: true | ||||
| 	}, | ||||
| 	{ | ||||
| 		id: 'regional', | ||||
| 		mode: 'train', | ||||
| 		bitmasks: [1024], | ||||
| 		name: 'Regionalzug', | ||||
| 		short: 'RB ?', // todo
 | ||||
| 		default: true | ||||
| 	}, | ||||
| 	{ | ||||
| 		id: 'suburban', | ||||
| 		mode: 'train', | ||||
| 		bitmasks: [512], | ||||
| 		name: 'S-Bahn', | ||||
| 		short: 'S-Bahn', | ||||
| 		default: true | ||||
| 	}, | ||||
| 	{ | ||||
| 		id: 'subway', | ||||
| 		mode: 'train', | ||||
| 		bitmasks: [256], | ||||
| 		name: 'U-Bahn', | ||||
| 		short: 'U', | ||||
| 		default: true | ||||
| 	}, | ||||
| 	{ | ||||
| 		id: 'saarbahn', | ||||
| 		mode: 'train', | ||||
| 		bitmasks: [128], | ||||
| 		name: 'Saarbahn', | ||||
| 		short: 'S', | ||||
| 		default: true | ||||
| 	}, | ||||
| 	{ | ||||
| 		id: 'bus', | ||||
| 		mode: 'bus', | ||||
| 		bitmasks: [64], | ||||
| 		name: 'Bus', | ||||
| 		short: 'Bus', | ||||
| 		default: true | ||||
| 	}, | ||||
| 	{ | ||||
| 		id: 'watercraft', | ||||
| 		mode: 'watercraft', | ||||
| 		bitmasks: [32], // todo: correct?
 | ||||
| 		name: 'Schiff', | ||||
| 		short: 'Schiff', | ||||
| 		default: true | ||||
| 	}, | ||||
| 	{ | ||||
| 		id: 'onCall', | ||||
| 		mode: null, // todo
 | ||||
| 		bitmasks: [16], | ||||
| 		name: 'Anruf-Sammel-Taxi', | ||||
| 		short: 'AST', | ||||
| 		default: true | ||||
| 	}, | ||||
| 	{ | ||||
| 		id: 'school-bus', | ||||
| 		mode: 'bus', | ||||
| 		bitmasks: [8], | ||||
| 		name: 'Schulbus', | ||||
| 		short: 'Schulbus', | ||||
| 		default: true | ||||
| 	} | ||||
| 	// todo: `1`, `2`, `4` bitmasks?
 | ||||
| ] | ||||
							
								
								
									
										18
									
								
								p/saarfahrplan/readme.md
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								p/saarfahrplan/readme.md
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,18 @@ | |||
| # Saarfahrplan profile for `hafas-client` | ||||
| 
 | ||||
| *Saarfahrplan* is the public transport information system in [Saarland](https://en.wikipedia.org/wiki/Saarland). This profile adds *Saarfahrplan*-specific customizations to `hafas-client`. | ||||
| 
 | ||||
| ## Usage | ||||
| 
 | ||||
| ```js | ||||
| const createClient = require('hafas-client') | ||||
| const saarfahrplanProfile = require('hafas-client/p/saarfahrplan') | ||||
| 
 | ||||
| // create a client with Saarfahrplan profile | ||||
| const client = createClient(saarfahrplanProfile, 'my-awesome-program') | ||||
| ``` | ||||
| 
 | ||||
| 
 | ||||
| ## Customisations | ||||
| 
 | ||||
| - parses *Saarfahrplan*-specific products (such as *Saarbahn*) | ||||
|  | @ -12,6 +12,7 @@ HAFAS endpoint | wrapper library | docs | example code | source code | |||
| [Nahverkehrsverbund Schleswig-Holstein (NAH.SH)](https://de.wikipedia.org/wiki/Nahverkehrsverbund_Schleswig-Holstein) | [`nahsh-hafas`](https://github.com/juliuste/nahsh-hafas) | [docs](p/nahsh/readme.md) | [example code](p/nahsh/example.js) | [src](p/nahsh/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) | ||||
| *Saarfahrplan* ([Saarland](https://en.wikipedia.org/wiki/Saarland)) | - | [docs](p/saarfahrplan/readme.md) | [example code](p/saarfahrplan/example.js) | [src](p/saarfahrplan/index.js) | ||||
| 
 | ||||
| [](https://www.npmjs.com/package/hafas-client) | ||||
| [](https://travis-ci.org/public-transport/hafas-client) | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue