-
Notifications
You must be signed in to change notification settings - Fork 1k
SettingUpOTPServer
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. Currently, these instructions are for the 'stable' OTP branch, running as a Tomcat container, and with XML-based configuration - not the stand-alone mode of the latest master branch.
To start with the installation, connect to your server via SSH and...
sudo apt-get update
sudo apt-get install tomcat6 maven2 subversion default-jdk wget iptables tomcat6-examples tomcat6-admin
sudo apt-get install git
(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.
Update the Tomcat server settings for maximum memory, thread and request handling, and (if needed) security, as per RunningTheWebappInTomcat
3.1. Navigate to the directory where you want OTP project to be located.
3.2. Type in the console following command
git clone https://github.com/opentripplanner/OpenTripPlanner
The project will take some time to download to your server.
Now - since the rest of these instructions are relevant for the 'stable' branch of OTP using XML-based configuration and the traditional folder structure - switch across to the stable branch by typing the following:
cd OpenTripPlanner
git checkout stable
4.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.
4.2. Create Graph configuration file as described in GraphBuilder guide, and place it in the newly created folder.
4.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.
4.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
4.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)
See GraphBuilder page for main graph building instructions. If you want to make multiple graphs available from the same server (e.g. to support trip-planning for different regions, or if you are comparing the impact of between different networks in the same region), see MultipleGraphs.
Go to the directory where the graph builder jar file has been created.
cd opentripplanner-graph-builder/target
then run the following command that will build your OTP graph file from specified timetable and streetmap files (including, if you requested it, downloading the OSM map source files directly):
java -Xmx1024M -jar graph-builder.jar /PathToGraphConfigFileCreatedInStep3.2./graph-config.xml
This will take some time to compile the results into a Graph.obj file (especially if you requested downloading the OSM files from the server rather than using a locally-saved version). You can follow the progress in the console.
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....
As per: ConfiguringTheWebapp
If you do make any changes, then make sure you re-run the build command above, to ensure these changed files get included in your WAR package files.
sudo cp /PathToYourProjectHomeDirectory/opentripplanner-webapp/target/opentripplanner-webapp.war /var/lib/tomcat6/webapps/
sudo cp /PathToYourProjectHomeDirectory/opentripplanner-api-webapp/target/opentripplanner-api-webapp.war /var/lib/tomcat6/webapps/
sudo /etc/init.d/tomcat6 restart
Navigate to http://YOURSERVERNAME:8080/opentripplanner-webapp/ Your OTP project should now be ready and running.
unless you are intentionally working with legacy versions of OpenTripPlanner. Please consult the current documentation at readthedocs