Skip to content
Erno Mäkinen edited this page Aug 7, 2013 · 17 revisions

This chapter outlines Tampere specific requirements, challenges and instructions for the City Navigator.

Tampere specific requirements and challenges

Real-time data

Tampere public transport real time data is available soon at least in SIRI format. It is still somewhat unclear how this data can be utilized in the City Navigator.

POI data

While City of Helsinki has REST API for City of Helsinki Service Map (http://www.hel.fi/palvelukarttaws/rest/index_en.html) and it is utilized in City Navigator there is no currently similar API for Tampere. Part of the data can be added to OpenStreetMap but not all, for example, opening times for museums and shops.

Regional transportation data

Currently only public transport data from City of Tampere is available but it would be important to have access to data for neighbour municipalities. This will change at least for many of the municipalities in July 2014 when zones are taken into use in Tampere region. For more info of the change see the news article "Vyöhykerajat käyttöön seudun bussiliikenteessä 1.7.2014".

Installation instructions

Introduction

Linux Ubuntu is the recommended development platform although in principle it should be possible to do development on Windows. Assumptions are that you have knowledge on sudo, apt-get, etc. commands. If you are using virtual server on ITS Factory Data Platform, you probably have to use sudo with most of the following commands.

Preparing server

There is data disk /dev/vdc that needs to be mounted and used for storing most of the city-navigator specific data since if virtual server is changed only data on the /dev/vdc/ will be kept.

If /dev/vdc has not been partitioned it can be done with sudo fdisk /dev/vdc/. Use the whole disk for the primary partition (defaults).

After partitioning run sudo mkfs.ext4 /dev/vdc1 and sudo mount /dev/vdc1 /mnt/data. To mount the partition automatically after reboot run sudo emacs /etc/fstab and add line /dev/vdc1 /mnt/data auto defaults 0 0 to the end of the file.

City Navigator installation

If you want to get started quickly see https://github.com/codeforeurope/navigator-proto#getting-started. You may also consider Building Node from sources. If you build Node from sources, still follow the getting started instructions after the very first paragraph.

OpenTripPlanner (OTP) Installation steps

  1. Get or create Tampere specific OpenStreetMap (OSM) data

    Currently there is a package available for Tampere region at http://dev.hsl.fi/tmp/tampere/tampere.osm.bz2. However, the data should be updated occasionally. Instructions for this are here: OpenStreetMap data

    On terminal change to directory where you want different parts (OpenStreetMap data, OpenTripPlanner, GTFS data, etc.) to be stored, then run: mkdir OpenStreetMap, cd OpenStreetMap, wget http://dev.hsl.fi/tmp/tampere/tampere.osm.bz2, and cd ..

  2. Get the Tampere specific GTFS Data

    The GTFS data resides in http://files.itsfactory.fi/google_transit.zip. GTFS data should be loaded dynamically in future, but currently you should just download the zip and store it for example to GTFS directory.

  3. Get OpenTripPlanner (OTP) from GitHub

    Run: git clone git://github.com/openplans/OpenTripPlanner.git

  4. Edit the graph-builder.xml file

    You should modify OpenTripPlanner/opentripplanner-integration/src/defaults/resources/graph-builder.xml to include Tampere specific OSM and GTFS data.

    Currently you can replace the default graph-builder.xml file with the one from http://dev.hsl.fi/tmp/tampere/graph-builder.xml and edit the two locations where tampere is mentioned to correspond those in your server.

  5. Edit OpenTripPlanner/opentripplanner-integration/pom.xml -file

    If Tomcat has been updated since the OpenTripPlanner.git was updated then you may need to change <tomcat.version> in pom.xml. See http://www.apache.org/dist/tomcat/tomcat-6/ for the available version.

    Also, look for -Xmx string in the pom.xml. You may need to increase memory to for example -Xmx2000m. Change this in all places where -Xmx string can be found in the pom.xml.

  6. Get maven and JDK

    Run: sudo apt-get install maven openjdk-6-jdk

    You may have to run sudo apt-get update before the above installations are successful.

  7. Build OTP, calculate routing graph and start WWW service

    You may do the above by running mvn install integration-test -DskipTests -P interactive. You can try to remove -DskipTests parameter but there was an error when this was tried in ITS Factory Data Platform on 13th of May, 2013. More info of using maven with OTP can be found from https://github.com/openplans/OpenTripPlanner/wiki/GettingStartedMaven/.

    If there is an error while running the mvn install or you want the routing graph to be calculated again, you may remove the file OpenTripPlanner/opentripplanner-integration/target/graph-bundle/Graph.obj.

  8. Trying out the OTP installation

    If the previous step goes smoothly something similar to following info is printed to terminal:

    [INFO] --- cargo-maven2-plugin:1.2.0:start (tomcat-execution) @ 
    opentripplanner-integration ---
    [INFO]
    [INFO] --- cargo-maven2-plugin:1.2.0:run (tomcat-execution) @ 
    opentripplanner-integration ---
    [INFO] Press Ctrl-C to stop the container...
    

    Open the page http://x.y.z:8080/opentripplanner-webapp with you web browser where x.y.z is the name or IP address of your server. You should see:

    alt text.

  9. Configuring City Navigator to use the OTP installation

    Finally, you should modify the config.coffee in navigator-proto/src directory. Change the otp_base_url for tampere to match http://x.y.z:8080/opentripplanner-api-webapp/ws/. Also, at the end of the config.coffee file change area from manchester to tampere.

    Now, you can run the city navigator locally with grunt server and test that installation works by going to http://localhost:9001. Remote testing requires setting up separate web server. For example ningx.

"Production" installation

Introduction

While OTP can be run with Tomcat via maven and city-navigator via grunt server, these are meant for development. Therefore, it is best to install tomcat as a service and include city-navigator under a web server, for example nginx. It is assumed that [Installation instructions](Tampere deployment#installation-instructions) have always been finished before the "Production Installation".

Note: ITS Factory virtual server keeps the tomcat and nginx installations only until shutdown because only data on /dev/vdc (mounted to /mnt/data) is kept at shutdown.

Installation steps

  1. Install nginx

    Follow instructions at http://wiki.nginx.org/Install#Ubuntu_PPA

  2. Install Tomcat and OTP under Tomcat

    Run following commands:

    sudo apt-get install tomcat7
    sudo cp /mnt/data/OpenTripPlanner/opentripplanner-integration/target/tomcat6x/container/webapps/opentripplanner-*.war /var/lib/tomcat7/webapps/
    sudo mkdir /var/lib/tomcat7/opentripplanner-integration
    sudo mkdir /var/lib/tomcat7/opentripplanner-integration/target
    sudo mkdir /var/lib/tomcat7/opentripplanner-integration/target/graph-bundle
    sudo cp /mnt/data/OpenTripPlanner/opentripplanner-integration/target/graph-bundle/Graph.obj /var/lib/tomcat7/opentripplanner-integration/target/graph-bundle/
    
  3. Edit nginx configuration

    Run: sudo emacs /etc/nginx/sites-available/default and add following lines in the file under server:

    location ~ ^/(opentripplanner-webapp|opentripplanner-api-webapp) {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;
        proxy_pass http://127.0.0.1:8042;
        add_header Access-Control-Allow-Origin *;
     }
    
  4. Edit Tomcat configuration

    Run sudo emacs /var/lib/tomcat7/conf/server.xml and change Connector port to 8042 (Port should be equal to the one defined in the nginx location setting in the previous step). More instructions can be found at: http://www.mkyong.com/tomcat/how-to-change-tomcat-default-port/

  5. Test Tomcat and OTP installation

    At command line run sudo /etc/init.d/tomcat7 restart and sudo /usr/sbin/nginx.

    Go to address http://178.217.134.18 with web browser to see that nginx is working. Go to address http://178.217.134.18/opentripplanner-webapp/ and look for a route to see that the OTP is working. If there is a problem you can take a look at the the end of the tomcat log file /var/lib/tomcat7/logs/catalina.out. Possible reason for the problems are related to memory (e.g. OutOfMemoryError). In this case run emacs /usr/share/tomcat7/bin/catalina.sh, add line CATALINA_OPTS="$CATALINA_OPTS -Xmx2000m" to near top of the configuration file, and restart the Tomcat.

  6. Make navigator-proto visible via nginx

    Run sudo emacs /etc/nginx/sites-available/default and change server root to root /mnt/data/navigator-proto;

  7. Configure city-navigator

    Run sudo emacs /mnt/data/navigator-proto/src/config.coffee and change tampere otp_base_url to otp_base_url: "http://178.217.134.18/opentripplanner-api-webapp/ws/"

  8. Finishing

    Restart the nginx sudo /usr/sbin/nginx -s reload, go to address http://178.217.134.18 with a web browser and look for a route to see that city-navigator is working properly.

Upkeeping the Installations

Updating City Navigator to the latest version

  1. Merge changes in the upstream

    Run: cd /mnt/data/navigator-proto, git fetch upstream, and git merge upstream/master. If there are any conflicts, fix them as usual.

  2. Finishing

    Run grunt and go to address http://178.217.134.18 with a web browser to see that city-navigator is working properly.

Updating the GTFS data

When schedules of the public transports change, for example, due to seasonal changes the GTFS data may need to be updated.

  1. Get the updated GTFS data

    Run: cd /mnt/data/gtfs/static/. You may want to make a backup of the old GTFS data file before running wget http://www.tampere.fi/ekstrat/ptdata/tamperefeed.zip and mv tamperefeed.zip google_transit.zip.

  2. Build OTP with the new route graph

    Run: cd /mnt/data/OpenTripPlanner/, rm /mnt/data/OpenTripPlanner/opentripplanner-integration/target/graph-bundle/Graph.obj, and mvn install integration-test -DskipTests -P interactive.

  3. Update the Tomcat OTP installation

    Run: cp /mnt/data/OpenTripPlanner/opentripplanner-integration/target/tomcat6x/container/webapps/opentripplanner-*.war /var/lib/tomcat7/webapps/ and cp /mnt/data/OpenTripPlanner/opentripplanner-integration/target/graph-bundle/Graph.obj /var/lib/tomcat7/opentripplanner-integration/target/graph-bundle/.

  4. Finishing

    Restart the Tomcat with /etc/init.d/tomcat7 restart and go to the address http://178.217.134.18 with web browser and look for a route to see that city-navigator is working.