Skip to content
fpurcell edited this page Nov 30, 2011 · 67 revisions

Five Minute Deep-Dive into OTP

If you haven't already, please see the 2 minute introduction to running OTP (with Portland & TriMet data).

The intent of this 5 minute lesson is for you to build your own Graph.obj, first using the TriMet data...then using a transit agency GTFS file of your choosing. Going past our 5 minutes, we'll dive into adding elevation data to your graph (which is needed for the nifty street slope chart seen with biking directions), and performance tuning via contraction hierarchies (see below).


PORTLAND GRAPH

  1. (A bit of a repeat from the 2 minute introduction) Download http://maps5.trimet.org/otp-dev/otp.zip (~90 megs ... so do a mouse right-click, then 'Save link as...'). BTW, otp.zip is packaged nightly from the latest OTP source code.

  2. Unzip the contents to the / directory (or C:\ for Windows users).

    NOTE: it's very important to have the pre-built web app run from /otp (or C:\otp). If you want to run from another location, you'll need to edit the file WEB-INF/classes/data-sources.xml within /otp/webapps/opentripplanner-api-webapp.war.

  3. Download OSM street data for Portland http://maps5.trimet.org/otp-dev/or-wa.osm (~300 megs ... IMPORTANT: do a mouse right-click, then 'Save link as...', otherwise this text file is so big, you'll crash your browser trying to load it in a browser window)

  4. Move or-wa.osm to the /otp/cache/osm/ directory

  5. open a command prompt (cmd.exe on Windows)

  6. cd to /otp

  7. bin/build-graph.sh (or bin\build-graph.bat for Windows users)

    NOTE: this takes awhile...but you should end up with a new Graph.obj file.

  8. run bin/graph-vis.sh (or bin\graph-viz.bat for Windows users) to view your new Graph.obj

  9. bin/startup.sh (or bin\startup.bat for Windows users), then open http://localhost:8080/opentripplanner-webapp in a web browser to see OTP route around your new graph...

  10. See and GraphBuilder for more information on content and configuration of Graph.obj


CUSTOM GRAPH

  1. First, find a URL to a GTFS feed that you're interested in (see http://www.gtfs-data-exchange.com/ for ideas).

  2. cd /otp

  3. open graph-builder.xml in a text editor -- we're going to make two edits

  4. edit !#1 - change the GTFS url on/about line 17, from http://developer1.trimet.org/schedule/gtfs.zip to your desired gtfs.zip url path.

  5. edit !#2 - specify the OSM data for your region (not the or-wa.osm data). You have two options for acquiring OSM data for your region:

    a) if you have an existing .osm file for your region, edit the path from or-wa.osm to that file on line 66 of graph-builder.xml. (BTW, here's the url I use to retrieve the OSM data for or-wa.osm -- http://open.mapquestapi.com/xapi/api/0.6/map?bbox=-123.4,44.8,-121.5,45.8).

    b) let OTP download the .osm data for your region (based on the stop locations within your gtfs.zip file) -- to make that change, you need to un-comment the RegionBasedOpenStreetMapProviderImpl provider on line 45 of graph-builder.xml, and then comment out the StreamedFileBasedOpenStreetMapProviderImpl provider on line 65 of graph-builder.xml.

  6. cd to /otp

  7. bin/build-graph.sh (or bin\build-graph.bat for Windows users)

    NOTE: this takes awhile...but you should end up with a new Graph.obj file.

  8. run bin/graph-vis.sh (or bin\graph-viz.bat for Windows users) to view your new Graph.obj

  9. bin/startup.sh (or bin\startup.bat for Windows users), then open http://localhost:8080/opentripplanner-webapp in a web browser to see OTP route around your new graph...

  10. See and GraphBuilder for more information on content and configuration of Graph.obj


CONTRACTION

  1. We can speed up routing by optimizing the graph. The trade-off is slower graph building.

  2. We'll again edit graph-builder.xml, and rebuild our graph.

  3. open graph-builder.xml in a text editor

  4. uncomment the 'contraction hierarchies' section on line 93.

  5. cd to /otp

  6. bin/build-graph.sh

    NOTE: contraction hierarchies really help to speed up long-distance walk and bike routing (sometimes by many orders of magnitude).

  7. etc... see instructions above for running your new graph though otp ...


ELEVATION DATA

  1. If you want to add elevation data (for the U.S. only -- see http://ned.usgs.gov for more) to your graph, we'll again edit graph-builder.xml

  2. open graph-builder.xml in a text editor

  3. uncomment the 'nedBuilder' ref on line 118.

  4. cd to /otp

  5. bin/build-graph.sh

    NOTE: NED downloads take a real long time, and the graph building is really slow...

    NOTE: Those outside the US can also potentially use another elevation data set...see GraphBuilder#Elevationdata for (not much) more information.

  6. etc... see instructions above for running your new graph though otp ...

Good luck...

Clone this wiki locally