-
Notifications
You must be signed in to change notification settings - Fork 0
Calltaker and Field Trip Module Setup
This page contains instructions for setting up the Calltaker and Field Trip Planner extensions to OpenTripPlanner.
Once logged into the machine where you want to install the modules, grab the latest copy of OTP:
$ git clone git://github.com/openplans/OpenTripPlanner.git
For now, work on these modules is taking place in the branch "leaflet-ui". Switch to this branch:
$ git checkout leaflet-ui
A freestanding web application is used for storing and managing the Calltaker and Field Trip data, contained in the OTP module opentripplanner-datastore. It is built using the Play! web application framework.
Download version 1.2.5 of Play! from http://downloads.typesafe.com/releases/play-1.2.5.zip and install per the instructions at http://www.playframework.com/documentation/1.2.5/install.
Switch to the OpenTripPlanner/opentripplanner-datastore
directory, which contains the OTP Play! app.
Note: Within this directory, there is a file conf/application.conf
. By default, Play! backs the webapp with a file-based H2 database (per line 85 of this file). This is fine for testing and development purposes, but for production you may want to replace this with a more heavy-duty DB; see commented-out examples of other configurations in the application.conf
file.
Before you run the Play! app for the first time, run the following command from the OpenTripPlanner/opentripplanner-datastore
directory to set up the dependencies:
$ play dependencies
Then, to start the Play! app:
$ play run
(If you are logged in to a remote server, you may want to run this in the background using an instance of screen)
A special reverse geocoder (the 'municoder') is included to support an optional feature of the modules that allows for resolution of city names based on lat/lon locations. It is included as an OTP module called opentripplanner-municoder.
First, you must point it to a polygon shapefile on the local machine that will be used for the reverse-geocoding. This is done in the file opentripplanner-municoder/src/main/resources/org/opentripplanner/municoder/application-context.xml
. Open this file and look for the following lines:
<property name="shapefile" value="/var/otp/shp/pdx_boundaries.shp" />
<property name="nameField" value="CITYNAME" />
Replace these example values with ones for your setup. The shapefile
property is the location of the .shp file on the local machine and nameField
is the name of the field in the shapefile's attribute table that corresponds to the municipality names (i.e. the field whose values will be displayed in the UI).
Once the file is updated, build the WAR for the module (from the OpenTripPlanner
directory):
$ mvn package -DskipTests -pl opentripplanner-municoder
Then deploy the WAR file generated in opentripplanner-municoder/target/
to the servlet container.
The front-end is contained in the opentripplanner-leaflet-webapp module of OTP.
First, you need to set the locations of the various services you just set up. Open the configuration file at opentripplanner-leaflet-webapp/src/main/webapp/js/otp/config.js
and look for these lines:
hostname : "http://localhost:8080",
municoderHostname : "http://localhost:8080",
datastoreUrl : "http://localhost:9000",
These need to be updated to reflect the locations of the web services the webapp will be accessing:
- The
hostname
property is the location of the server running the OTP API (i.e. "/opentripplanner-api-webapp/ws/..." will be appended to it by the webapp when making OTP calls). - Ditto for
municoderHostname
-- if the municipal boundary reverse geocoder is running on the same Tomcat instance as OTP, this will be the same ashostname
. (If the municoder was not set up, comment out this line) -
datastoreUrl
is the web-facing location of the Play! instance set up above
Note: while "localhost" addresses can be used for local testing on the deployment machine itself, for deployments that will be accessed by external users you must specify addresses that can be understood by external clients (e.g. "http://yourserver.yourdomain.com:8080")
Once the configuration is updated, there are two options for making the UI public:
-
If you have an ordinary web server running on the machine and port 80 is publicly accessible, you may simply copy the contents of
OpenTripPlanner/opentripplanner-leaflet-webapp/src/main/webapp
to a web-visible location on the server (or create a sym-link from the web server directory to thewebapp
directory.) -
If a servlet container such as Tomcat is running (and presumably one is if you are also running OTP and/or the municoder), the UI may be deployed as a WAR file. To build the file (from the
OpenTripPlanner
directory):
$ mvn package -DskipTests -pl opentripplanner-api-webapp
Then deploy the WAR generated at opentripplanner-leaflet-webapp/target/opentripplanner-leaflet-webapp.war
. Note that any changes to config.js
will require rebuilding and redeploying the WAR.