hafas-fetch-track-slice

2.0.0 • Public • Published

hafas-fetch-track-slice

Pass in a trip ID, get a slice between stations of its track.

npm version build status ISC-licensed support me via GitHub Sponsors chat with me on Twitter

Installing

npm install hafas-fetch-track-slice

Usage

const createHafas = require('vbb-hafas')
const fetchTrackSlice = require('hafas-fetch-track-slice')

const prevStation = {
	type: 'station',
	id: '900000016202'
	name: 'U Südstern',
	location: {
		type: 'location',
		latitude: 52.491252,
		longitude: 13.395382
	}
}
const nextStation = {
	type: 'station',
	id: '900000016153'
	name: 'U Gneisenaustr',
	location: {
		type: 'location',
		latitude: 52.490386,
		longitude: 13.400214
	}
}

const hafas = createHafas('my-awesome-program')
// get these from e.g. hafas.journeys(), hafas.departures() or hafas.radar()
const someTripId = '1|31817|10|86|16052018'

fetchTrackSlice(hafas, prevStation, nextStation, someTripId, 'U7')
.then(console.log)
.catch((err) => {
	console.error(err)
	process.exitCode = 1
})
{
	type: 'LineString',
	coordinates: [
		[
			13.407732293830614,
			52.4892844953395
		],
		[
			13.407732293830614,
			52.4892844953395
		]
	]
}

Contributing

If you have a question or have difficulties using hafas-fetch-track-slice, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to the issues page.

Package Sidebar

Install

npm i hafas-fetch-track-slice

Weekly Downloads

1

Version

2.0.0

License

ISC

Unpacked Size

5.93 kB

Total Files

4

Last publish

Collaborators

  • derhuerst