mirror of
				https://github.com/public-transport/db-vendo-client.git
				synced 2025-11-04 10:06:32 +02:00 
			
		
		
		
	add RSAG profile
This commit is contained in:
		
							parent
							
								
									0ea2c01abe
								
							
						
					
					
						commit
						84637b2e96
					
				
					 5 changed files with 179 additions and 0 deletions
				
			
		
							
								
								
									
										43
									
								
								p/rsag/example.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								p/rsag/example.js
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,43 @@
 | 
			
		|||
'use strict'
 | 
			
		||||
 | 
			
		||||
const createClient = require('../..')
 | 
			
		||||
const rsagProfile = require('.')
 | 
			
		||||
 | 
			
		||||
const client = createClient(rsagProfile, 'hafas-client-example')
 | 
			
		||||
 | 
			
		||||
const rostockHbf = '8010304'
 | 
			
		||||
const güstrow = '8010153'
 | 
			
		||||
const albertEinsteinStr = {
 | 
			
		||||
	type: 'location',
 | 
			
		||||
	id: '990004201',
 | 
			
		||||
	address: 'Rostock - Südstadt, Albert-Einstein-Straße 23',
 | 
			
		||||
	latitude: 54.077208, longitude: 12.108299
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
client.journeys(rostockHbf, güstrow, {results: 1})
 | 
			
		||||
// client.departures(rostockHbf, {duration: 1})
 | 
			
		||||
// client.arrivals(rostockHbf, {duration: 10, linesOfStops: true})
 | 
			
		||||
// client.locations('güstrow', {results: 2})
 | 
			
		||||
// client.stop(rostockHbf, {linesOfStops: true}) // Dammtor
 | 
			
		||||
// client.nearby(albertEinsteinStr)
 | 
			
		||||
// client.radar({
 | 
			
		||||
// 	north: 54.177,
 | 
			
		||||
// 	west: 11.959,
 | 
			
		||||
// 	south: 54.074,
 | 
			
		||||
// 	east: 12.258
 | 
			
		||||
// }, {results: 10})
 | 
			
		||||
// client.reachableFrom(albertEinsteinStr, {
 | 
			
		||||
// 	when: new Date('2020-03-03T10:00:00+01:00'),
 | 
			
		||||
// 	maxDuration: 10
 | 
			
		||||
// })
 | 
			
		||||
 | 
			
		||||
// .then(({journeys}) => {
 | 
			
		||||
// 	const [journey] = journeys
 | 
			
		||||
// 	const leg = journey.legs[0]
 | 
			
		||||
// 	return client.trip(leg.tripId, leg.line.name, {polyline: true})
 | 
			
		||||
// })
 | 
			
		||||
 | 
			
		||||
.then((data) => {
 | 
			
		||||
	console.log(require('util').inspect(data, {depth: null, colors: true}))
 | 
			
		||||
})
 | 
			
		||||
.catch(console.error)
 | 
			
		||||
							
								
								
									
										33
									
								
								p/rsag/index.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								p/rsag/index.js
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,33 @@
 | 
			
		|||
'use strict'
 | 
			
		||||
 | 
			
		||||
const products = require('./products')
 | 
			
		||||
 | 
			
		||||
const transformReqBody = (ctx, body) => {
 | 
			
		||||
	body.client = {type: 'WEB', id: 'RSAG', name: 'webapp'}
 | 
			
		||||
	body.ext = 'VBN.2'
 | 
			
		||||
	body.ver = '1.24'
 | 
			
		||||
	body.auth = {type: 'AID', aid: 'tF5JTs25rzUhGrrl'}
 | 
			
		||||
 | 
			
		||||
	return body
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const hvvProfile = {
 | 
			
		||||
	locale: 'de-DE',
 | 
			
		||||
	timezone: 'Europe/Berlin',
 | 
			
		||||
	endpoint: 'https://fahrplan.rsag-online.de/bin/mgate.exe',
 | 
			
		||||
 | 
			
		||||
	transformReqBody,
 | 
			
		||||
 | 
			
		||||
	products,
 | 
			
		||||
 | 
			
		||||
	trip: true,
 | 
			
		||||
	radar: true,
 | 
			
		||||
	reachableFrom: true,
 | 
			
		||||
 | 
			
		||||
	// todo: these fail ver >=1.21, see #164
 | 
			
		||||
	refreshJourney: false,
 | 
			
		||||
	departuresGetPasslist: false,
 | 
			
		||||
	departuresStbFltrEquiv: false,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports = hvvProfile
 | 
			
		||||
							
								
								
									
										84
									
								
								p/rsag/products.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										84
									
								
								p/rsag/products.js
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,84 @@
 | 
			
		|||
'use strict'
 | 
			
		||||
 | 
			
		||||
module.exports = [
 | 
			
		||||
	{
 | 
			
		||||
		id: 'ice',
 | 
			
		||||
		mode: 'train',
 | 
			
		||||
		bitmasks: [1],
 | 
			
		||||
		name: 'InterCityExpress',
 | 
			
		||||
		short: 'ICE',
 | 
			
		||||
		default: true
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		id: 'ic-ec',
 | 
			
		||||
		mode: 'train',
 | 
			
		||||
		bitmasks: [2],
 | 
			
		||||
		name: 'InterCity & EuroCity',
 | 
			
		||||
		short: 'IC/EC',
 | 
			
		||||
		default: true
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		id: 'long-distance-train',
 | 
			
		||||
		mode: 'train',
 | 
			
		||||
		bitmasks: [4],
 | 
			
		||||
		name: 'InterRegio/high-speed train',
 | 
			
		||||
		short: 'IR/other',
 | 
			
		||||
		default: true
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		id: 'regional-train', // todo: rename
 | 
			
		||||
		mode: 'train',
 | 
			
		||||
		bitmasks: [8],
 | 
			
		||||
		name: 'regional train',
 | 
			
		||||
		short: 'RE/RB',
 | 
			
		||||
		default: true
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		id: 's-bahn',
 | 
			
		||||
		mode: 'train',
 | 
			
		||||
		bitmasks: [16],
 | 
			
		||||
		name: 'S-Bahn',
 | 
			
		||||
		short: 'S',
 | 
			
		||||
		default: true
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		id: 'bus',
 | 
			
		||||
		mode: 'bus',
 | 
			
		||||
		bitmasks: [32],
 | 
			
		||||
		name: 'Bus',
 | 
			
		||||
		short: 'B',
 | 
			
		||||
		default: true
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		id: 'ferry',
 | 
			
		||||
		mode: 'watercraft',
 | 
			
		||||
		bitmasks: [64],
 | 
			
		||||
		name: 'Schiff',
 | 
			
		||||
		short: 'F',
 | 
			
		||||
		default: true
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		id: 'u-bahn',
 | 
			
		||||
		mode: 'train',
 | 
			
		||||
		bitmasks: [128],
 | 
			
		||||
		name: 'U-Bahn',
 | 
			
		||||
		short: 'U',
 | 
			
		||||
		default: true
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		id: 'tram',
 | 
			
		||||
		mode: 'train',
 | 
			
		||||
		bitmasks: [256],
 | 
			
		||||
		name: 'Tram',
 | 
			
		||||
		short: 'T',
 | 
			
		||||
		default: true
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		id: 'on-call',
 | 
			
		||||
		mode: 'taxi', // todo: or `bus`?
 | 
			
		||||
		bitmasks: [512],
 | 
			
		||||
		name: 'Taxi/on-call vehicle',
 | 
			
		||||
		short: 'AST',
 | 
			
		||||
		default: true
 | 
			
		||||
	}
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										18
									
								
								p/rsag/readme.md
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								p/rsag/readme.md
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,18 @@
 | 
			
		|||
# RSAG profile for `hafas-client`
 | 
			
		||||
 | 
			
		||||
[*Rostocker Straßenbahn AG (RSAG)*](https://de.wikipedia.org/wiki/Rostocker_Straßenbahn_AG) is the local transport provider in [Rostock](https://en.wikipedia.org/wiki/Rostock). This profile adds *RSAG*-specific customizations to `hafas-client`.
 | 
			
		||||
 | 
			
		||||
## Usage
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
const createClient = require('hafas-client')
 | 
			
		||||
const rsagProfile = require('hafas-client/p/rsag')
 | 
			
		||||
 | 
			
		||||
// create a client with RSAG profile
 | 
			
		||||
const client = createClient(rsagProfile, 'my-awesome-program')
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## Customisations
 | 
			
		||||
 | 
			
		||||
- parses *RSAG*-specific products
 | 
			
		||||
| 
						 | 
				
			
			@ -223,6 +223,7 @@ HAFAS endpoint | wrapper library | docs | example code | source code
 | 
			
		|||
[Verkehrsverbund Süd-Niedersachsen (VSN)](https://de.wikipedia.org/wiki/Verkehrsverbund_S%C3%BCd-Niedersachsen) | - | [docs](p/vsn/readme.md) | [example code](p/vsn/example.js) | [src](p/vsn/index.js)
 | 
			
		||||
[Ingolstädter Verkehrsgesellschaft (INVG)](https://de.wikipedia.org/wiki/Ingolstädter_Verkehrsgesellschaft) | - | [docs](p/invg/readme.md) | [example code](p/invg/example.js) | [src](p/invg/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)
 | 
			
		||||
 | 
			
		||||
There are also libraries that use `hafas-client` and pass their own profile in:
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue