Skip to content
Karel Novotny edited this page Jul 19, 2011 · 4 revisions

OTP Server setup instructions

Important: Following instructions apply to Ubuntu servers (tested on Ubuntu Lucid Lynx). You might try to follow them also if your server is built on other Linux distribution, but there is less chance that everything will go smoothly.

The validity of this tutorial is limited by changes brought by future OTP development. It is expected that particularly OTP setup configuration will be done significantly differently as OTP evolves.

To start with the installation, connect to your server via SSH and...

1. Install necessary packages needed to install and run OTP:

sudo apt-get install tomcat6 maven2 subversion default-jdk wget iptables tomcat6-examples tomcat6-admin

(you will need tomcat6-admin only if you are planning to administer your Tomcat server through web-interface, instead of command line)

If you are using other linux distribution (non debian-based), you will probably need to modify above command and install the packages in the way specific for your distribution.

2. Download the project

2.1. Navigate to the directory where you want OTP project to be located.

2.2. Type in the console following command

svn co https://svn.opentripplanner.org/trunk opentripplanner

The last part of the command ("openplanner") defines the name of the folder which will contain all OTP project files project home directory. Name it anything you wish.

The project will take some time to download to your server.

3. Configure main OTP settings

3.1. Create a folder outside of OTP home directory which will contain the graph object (a file which is based on osm map and which is used as basis for routing) and also graph configuration file. This can be anywhere you wish but a good idea is to create it alongside OTP home directory. Lets call this new folder XX.

3.2. Create Graph configuration file as described in GraphBuilder guide, and place it in the newly created folder.

3.3. Configure /PathToYourProjectHomeDirectory/opentripplanner-integration/src/defaults/resources/graph-builder.xml file as follows:

  • Configure path in...

...so that it will point to the directory where your Graph.obj file (map graph) will be located Folder XX

More details in GraphBuilder tutorial.

3.4. Configure /opentripplanner/opentripplanner-webapp/src/main/webapp/js/otp/config.js file as follows:

Default map zoom

If you wish your OTP pages to load specific region as default (region for which you will be providing routing), you must edit following command in the section

// The default extent to zoom the map to when the web app loads.

You want to edit the "defaultExtent" option. The default config file should have a comment explaining how to do this. You'll just want to replace the string "automatic" with the bounds of the extent you want, e.g:

new OpenLayers.Bounds(-180, -90, 180, 90)

(except obviously you'll want to replace the numbers with the actual coordinates you want)

Loading OSM map as background

If the basemap layer is not satisfactory for your region then you can set OSM default tiles (the same which show on http://openstreetmap.org) to be your default basemap. Do it by modifying the http link in the section starting {{{

baseLayer: new OpenLayers.Layer.OSM({

"http://a.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png",

Replace z,x, and y with coordinates identifying the tiles you want OTP to donload and display as basemap. Find coordinates of the tiles you need at http://a.tah.openstreetmap.org/Browse .

Metric system

If you are using meters and kilometres as opposed to miles and feet (OTP default), change parameters in the section // Metrics system: (starting line 95 of the config file):

  • uncomment

metricsSystem : 'international', // => meters, km

  • Instead, comment the line

metricsSystem : 'english', // => feet, miles

3.5. Configure /PathToYourProjectHomeDirectory/opentripplanner-integration/src/defaults/resources/data-sources.xml and /PathToYourProjectHomeDirectory/opentripplanner-api-webapp/src/defaults/resources/data-sources.xml files as follows:

Replace path to the graph-bundle folder by path to the new folder you created (folder XX)

4. Build the graph

4.1.

cd opentripplanner-graph-builder/target

4.2. Run the following command that will download OSM map source files and build OTP graph from it:

java -Xmx1024M -jar graph-builder.jar /PathToGraphConfigFileCreatedInStep3.2./graph-config.xml

This will take some time for the map files to download from OSM server and to be compiled into the Graph.obj file. You can follow the progress in the console.

5. Run MVN integration test to create the OTP project

cd PathToYourProjectHomeDirectory and run following command:

mvn -e integration-test -DskipTests

Alternatively, you can use the maven package goal if you just need the war files.

mvn -e package -DskipTests

For details on this step see GettingStartedMaven tutorial....

6. Copy WAR files created by the integration test into Apache Tomcat working directory:

cp /PathToYourProjectHomeDirectory/opentripplanner-webapp/target/opentripplanner-webapp.war /var/lib/tomcat6/webapps/

cp /PathToYourProjectHomeDirectory/opentripplanner-api-webapp/target/opentripplanner-api-webapp.war /var/lib/tomcat6/webapps/

7. Restart the server

/etc/init.d/tomcat6 restart

Navigate to http://YOURSERVERNAME:8080/opentripplanner-webapp/ Your OTP project should now be ready and running.

Clone this wiki locally