https://github.com/derhuerst/hafas-fetch-track-slice
Pass in a journey (leg) ID, get a slice between stations of its track.
https://github.com/derhuerst/hafas-fetch-track-slice
hafas public-transport shape track transit
Last synced: 4 months ago
JSON representation
Pass in a journey (leg) ID, get a slice between stations of its track.
- Host: GitHub
- URL: https://github.com/derhuerst/hafas-fetch-track-slice
- Owner: derhuerst
- License: isc
- Created: 2018-05-16T23:14:09.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-03-11T23:31:04.000Z (over 4 years ago)
- Last Synced: 2025-02-07T20:15:30.048Z (4 months ago)
- Topics: hafas, public-transport, shape, track, transit
- Language: JavaScript
- Homepage: https://github.com/derhuerst/hafas-fetch-track-slice#hafas-fetch-track-slice
- Size: 17.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# hafas-fetch-track-slice
**Pass in a [trip ID](https://github.com/public-transport/hafas-client/blob/ecc26ef313b75f9bedcf4ee1b2b95aebb3478379/docs/trip.md), get a slice between stations of its track.**
[](https://www.npmjs.com/package/hafas-fetch-track-slice)
[](https://travis-ci.org/derhuerst/hafas-fetch-track-slice)

[](https://github.com/sponsors/derhuerst)
[](https://twitter.com/derhuerst)## Installing
```shell
npm install hafas-fetch-track-slice
```## Usage
```js
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
})
``````js
{
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](https://github.com/derhuerst/hafas-fetch-track-slice/issues).