hafas-osm-line-colours
Match legs
or departures
/arrivals
found with hafas-client
with OpenStreetMap transit line colours from datasets generated using osm-transit-lines
.
Installation
npm install hafas-osm-line-colours
Usage
// the actual methods are wrapped in this creator method because we only want the search tree to be created once, not every time we actually search for a line// takes a couple of seconds to create the client, depending on the size of your line dataset, but can then handle up to 250.000 queries per second// note that the data will be stored in-memory, so double-check your hardware before loading a dataset that covers the entire planetconst createTransitLineColourClient = const hafas = 'user-agent'const osmTransitLines = const main = async { const berlinBbox = south: 523418234221 north: 526697240587 west: 130882097323 east: 137606105539 const berlinTransitLines = await // see `osm-transit-lines` docs const legLineColour departureOrArrivalLineColour = // methods exposed by this module // departures/arrivals const virchowKlinikumBerlin = '000730855' const departure = await hafas // next train is a tram 50 const departureLineColour = // { backgroundColour: '#36ab94', textColour: null } (colour of tram 50), null if no matching background colour was found const arrival = await hafas // next train is a tram M13 const arrivalLineColour = // { backgroundColour: '#00cc00', textColour: null } (colour of tram M13), null if no matching background colour was found const zehlendorf = '008089098' const mexikoplatz = '008089023' const journey = await hafas // only leg is an S1 train const lineColour = // { backgroundColour: '#d474ae', textColour: null } (colour of S1), null if no matching background colour was found}
Since the lines list returned by osm-transit-lines
tends to be quite large, the module also exposes two helper methods that allow you to transform the lines list into a more memory-efficient array (that can also be stored) from which you can create a line colour client as well:
const linesToPoints createLineColourClientFromPoints = const main = async { const berlinBbox = south: 523418234221 north: 526697240587 west: 130882097323 east: 137606105539 const berlinTransitLines = await // see `osm-transit-lines` docs const berlinTransitLinePoints = const legLineColour departureOrArrivalLineColour = }
Contributing
If you found a bug or want to propose a feature, feel free to visit the issues page.