LocalRoute.js calculates public transport routes on web browsers and mobile devices, online and offline. Map, route and timetable information from open data sources is preprocessed and compressed into a custom format. These comparatively tiny files are delivered to the client and decompressed before use.
LocalRoute.js guarantees routing availability and zero unexpected costs also abroad, and maintains the user's privacy.
Simply append all necessary source files:
cd build
./compile-debug-shim.sh lrOR
Compile with plovr. Download plovr.jar into bin and run:
cd build
java -jar ../bin/plovr.jar build plovr.json > ../dist/lr.jsOR
Compile with Google Closure Compiler. Download compiler.jar into bin and run:
cd build
./compile-shim.sh lrAfterwards, copy lr.js from the directory dist to where you want it.
node lr.js --date 2013-12-02 --in-gtfs helsinki/gtfs.zip \
--out-tempt helsinki/readable.txt --out-gtfs-geom helsinki/geom.txtThe interval of dates is 30 days starting from and including the given date parameter.
This preprocesses GTFS data in helsinki/gtfs.zip, stores (somewhat) human-readable transit schedules in helsinki/readable.txt and (if the last, optional argument is passed) compresses original route polyline coordinates into helsinki/geom.txt.
node lr.js --in-tempt helsinki/readable.txt --out-trans helsinki/trans.txtnode lr.js --in-tempt helsinki/readable.txt --in-pbf helsinki/osm.pbf \
--out-map helsinki/map-big.txtThis reads the previously stored transit data to get the coordinates of transit stops used to guess the area relevant to routing. Then it extracts the map data in PBF format, applies basic compression and stores it in helsinki-map.txt.
node lr.js --in-map helsinki/map-big.txt --out-map helsinki/map.txt \
--map-round 5 --compress-mapNote that the parameter --compress-map needs to be last.
node lr.js -M helsinki/map.txt -T helsinki/trans.txt \
-f 60.1688,24.9412 -t 60.3093,24.5141 \
-D 2013-12-03 -d 08:00API uses two global objects, gis and reach. gis has some general-purpose
functions, while reach is related to public transit. The main class to access data
is reach.trans.TransSet. It has members stopSet, lineSet and tripSet for all
public transit stops, lines and departures.
In localroute.js terminology a trip represents a single time that a vehicle goes from the first to the last stop of its route in one direction. Therefore a trip contains a single arrival for all stops along the route. All information the public uses to identify the route is connected to every trip.
A line is the list of stops passed along a vehicle's route, and in the future also its geometry. It has no other information.
- List of strings (names and codes), LZ77 compressed.
- Stop IDs, names (references to list of strings) and coordinates, delta encoded.
- Lines, encoded so that stops previously seen following the same predecessor are stored as indices into the predecessor's follower list.
- Keys: line names, codes and headsigns stored as references to list of strings.
- trips, grouped by valid day mask, delta encoded, LZ77 compressed.