Skip to content
DieBuche edited this page Sep 13, 2012 · 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).


PORTLAND GRAPH

  1. (A bit of a repeat from the 2 minute introduction) Download http://maps5.trimet.org/otp-dev/otp.zip (~100 megs file ... 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] (http://maps5.trimet.org/otp-dev/or-wa.osm) IMPORTANT: this file is ~370 megs ... 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 a while...but you should end up with a new Graph.obj file.

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

  9. bin/start-server.sh (or bin\start-server.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. Further, either edit 'TriMet' as the defaultAgencyId, or simply remove this element.

  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) [RECOMMENDED] obtain a .osm file for your region, then edit the path to that file on line 66 of graph-builder.xml. NOTE that your .osm file can have a much larger extent than your transit data ... preferable in fact. 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 << DANGER clicking this xapi link will result in a big file that will probably crash your browser...again, right-click to do a save-as of this file>>.

    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.

    Xapi courtesy of MapQuest

  6. cd to /otp

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

    NOTE: this takes a while...but you should end up with a new Graph.obj file. If you don't see any log messages for more than about ten minutes, try increasing the amount of memory used with -Xmx, or not using MapBuilder.

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

  9. bin/start-server.sh (or bin\start-sever.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


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