-
Notifications
You must be signed in to change notification settings - Fork 6
Guide for building and viewing Digitransit OTP graphs locally
This guide gives you quick step-by-step instructions how to build and get HSLDevCom/OpenTripPlanner running on your local machine for testing purposes.
You can for example easily test the effect of potential OSM changes to routing network and travel times in a smaller predefined area.
Guide loosely follows the official OpenTripPlanner documentation.
These instructions will get you a copy of the HSLDevCom/OpenTripPlanner up and running on your local machine for development and testing purposes.
- Git, a version control system
- Java Development Kit, preferably version 8 (AKA version 1.8)
- Maven, a build and dependency management system
Follow OpenTripPlanner official instructions for building from source.
In short:
On Debian and Ubuntu:
sudo apt-get install openjdk-8-jdk maven git
Follow instructions for installing Git, Java Development Kit 8 and Maven on Windows.
Once you have these packages installed, create and/or switch to the directory where you will keep your Git repositories and make a local copy of the HSLdevcom/OpenTripPlanner source code:
mkdir git
cd git
git clone [email protected]/HSLdevcom/OpenTripPlanner.git
Then change to the newly cloned OpenTripPlanner repository directory and start a build:
cd OpenTripPlanner
mvn clean package
The Maven build also includes many time-consuming integration tests. When working with a stable release of OTP, you may want to turn them off by adding the switch:
mvn clean package -DskipTests
If all goes well you get a message like following:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 42.164s
[INFO] Finished at: Tue Feb 18 19:35:48 CET 2014
[INFO] Final Memory: 88M/695M
[INFO] ------------------------------------------------------------------------
Now you should have a jar-file at:
target\otp-x.x.x.-SNAPSHOT-shaded.jar
For more detailed but not Digitransit specific instructions, check official OpenTripPlanner documentation.
You will need some routing data:
- Digitransit GTFS data to build a transit network.
- OpenStreetMap data to build a road network for walking, cycling, and driving. (XML- or PBF-format, PBF is faster)
Get daily Digitransit GTFS-files(zip files), OSM PBF-file, pre-built routing graphs and OTP config files.
For Finland: https://api.digitransit.fi/routing-data/v2/finland
For HSL-area: https://api.digitransit.fi/routing-data/v2/hsl
Note! Digitransit uses real-time data that is not accessible via public API. Open
router-config.json
and delete everything under theupdater
-object to avoid errors.
You can use the pre-built daily graphs found in the previous links but also build the routing graph yourself from scratch.
As a Java program OTP is run under JVM. It´s worth creating graphs
-directory for the routing graphs and all the data files under your repo. For example graphs\example_dir
would need to contain the GTFS-files and the OSM data in PBF/XML-format of your target area. Typical command for starting OTP with 8 GB memory:
This will build a routing graph in the directory example_dir
java -jar -Xmx8G target\otp-x.x.x-SNAPSHOT-shaded.jar --build .\graphs\example_dir
Running the newly built graph in OTP:
java -jar target\otp-x.x.x-SNAPSHOT-shaded.jar --server --port 8082 --securePort 8083 --basePath ./ --graphs ./graphs --router example_dir
For analysis and debuggin purposes it is useful sometimes to build the graph only for a smaller selected area.
Download OSM PBF data of the smaller are you want to build graph for. Make sure that the GTFS-data you have covers your area.
There are several tools to extract OSM data. For example JOSM provides a useful interface for selecting the area you wish to download, and instant visualization of all the data you have downloaded. You can also save the data to .osm file (JOSM file format) for further processing. But because it employs the main OSM API, it is not intended for downloading large quantities of data.
After extracting your OSM data for a the smaller area place it in your working directory.
With smaller area you can run the OTP in memory. Following command builds the graph in memory in example_dir
and starts OTP at port 8082.
java -jar -Xmx8G target\otp-x.x.x-SNAPSHOT-shaded.jar --build .\graphs\example_dir --inMemory --port 8082
You can now access the running OTP instance with your web browser at http://localhost:8082
Zoom to your cropped area. You can use the interface to test routing between destinations. To see and debug the routing graph network of your local instance, activate the debug layers in your browser with http://localhost:8082/?debug_layers=true
. You can now access "Traversal permissions", "Wheelchair access" and "Bike safety" layers on the top right map layers menu.
OpenTripPlanner integrated debug visualization tool can be run with --visualize
flag, eg.
java -jar -Xmx8G target\otp-x.x.x-SNAPSHOT-shaded.jar --visualize --build .\graphs\example_dir --inMemory