Connection Scan Algorithm for JavaScript
State:
-
basic csa without footpaths is functional
-
merger that combines different streams of connections is functional
The Connection Scan Algorithm (CSA) for Javascript takes a stream of "connections" and transforms it into a stream of solutions to get from a certain stop to a certain stop. The algorithm will find the earliest arrival times first, and will return alternatives as long as the stream runs.
Use it
You can install the library using npm:
npm install csa
And include it in your nodejs application
var csa = ;var planner = departureStop: "..." arrivalStop: "..."departureTime:;connectionsReadStream;planner;planner;
Multiple connection streams
Instead of using one stream of connections, you can combine multiple streams as input by using MergeStream
var connectionsStreams = 'stream1' connectionsReadStream1 'stream2' connectionsReadStream2 ...; var connectionsReadStream = connectionsStreams querydepartureTime;
You can add streams by setting an eventlistener on the MergeStream instance. To remove a stream, just end the stream itself.
connectionsReadStream;
Protip: you can use browserify on this repo to use CSA in the browser