### Ubuntu Server Installation Source: https://context7.com/hsldevcom/digitransit/llms.txt Manual setup steps for installing dependencies, building OTP, and configuring a running instance on Ubuntu. ```bash # Install dependencies sudo apt-get update sudo apt-get install openjdk-8-jdk-headless nodejs git build-essential # Add Maven 3 repository and install sudo add-apt-repository ppa:andrei-pozolotin/maven3 sudo apt-get update sudo apt-get install maven3 # Create digitransit user sudo adduser digitransit su digitransit cd # Clone and build OpenTripPlanner git clone https://github.com/hsldevcom/opentripplanner cd opentripplanner mvn package # Create data directory mkdir ~/data/ # Copy OSM PBF and GTFS files to ~/data/ # Build graph java -Xmx7500M -jar opentripplanner/target/otp-*-SNAPSHOT-shaded.jar --build ./data/ # Setup running instance mkdir otp_running_instance cp opentripplanner/target/otp-*-SNAPSHOT-shaded.jar otp_running_instance/ mkdir otp_running_instance/data cp data/Graph.obj otp_running_instance/data/ ``` -------------------------------- ### Run Server Source: https://github.com/hsldevcom/digitransit/blob/master/Manual-steps-for-Ubuntu-14.04.md Starts the OpenTripPlanner server on the specified port. ```bash java -Xmx2048M -Duser.timezone=Europe/Rome -jar otp-0.20.0-SNAPSHOT-shaded.jar --server --port 1234 --basePath . --graphs data --autoScan --verbose ``` -------------------------------- ### Build and Run OpenTripPlanner Source: https://context7.com/hsldevcom/digitransit/llms.txt Compile the OTP project, build a routing graph from data files, and start the server. ```bash # Clone and build HSLdevcom/OpenTripPlanner git clone https://github.com/HSLdevcom/OpenTripPlanner.git cd OpenTripPlanner mvn clean package -DskipTests # Create data directory with GTFS and OSM files mkdir -p graphs/finland # Place GTFS zip files and OSM PBF file in graphs/finland/ # Build routing graph (requires ~8GB memory for larger regions) java -jar -Xmx8G target/otp-*-SNAPSHOT-shaded.jar --build ./graphs/finland # Start OTP server on port 8082 java -jar target/otp-*-SNAPSHOT-shaded.jar \ --server \ --port 8082 \ --securePort 8083 \ --basePath ./ \ --graphs ./graphs \ --router finland # Build and run in-memory for small areas (useful for testing) java -jar -Xmx8G target/otp-*-SNAPSHOT-shaded.jar \ --build ./graphs/test_area \ --inMemory \ --port 8082 # Access OTP web interface # http://localhost:8082 # Enable debug layers for network visualization # http://localhost:8082/?debug_layers=true ``` -------------------------------- ### Install Prerequisites on Linux Source: https://github.com/hsldevcom/digitransit/wiki/Guide-for-building-and-viewing-Digitransit-OTP-graphs-locally Commands to install Java 8, Maven, and Git on Debian or Ubuntu systems. ```bash sudo apt-get install openjdk-8-jdk maven git ``` ```bash sudo update-alternatives --config java ``` -------------------------------- ### Install Maven 3 Source: https://github.com/hsldevcom/digitransit/blob/master/Manual-steps-for-Ubuntu-14.04.md Adds the Maven 3 PPA and installs the package. ```bash add-apt-repository ppa:andrei-pozolotin/maven3 apt-get update apt-get install maven3 ``` -------------------------------- ### Install Dependencies Source: https://github.com/hsldevcom/digitransit/blob/master/Manual-steps-for-Ubuntu-14.04.md Installs necessary packages including OpenJDK, Node.js, and build tools. ```bash apt-get install openjdk-8-jdk-headless apt-get install nodejs apt-get install git apt-get install build-essential ``` -------------------------------- ### Build and Run OTP Server Source: https://github.com/hsldevcom/digitransit/wiki/Guide-for-building-and-viewing-Digitransit-OTP-graphs-locally Commands to build a routing graph from data files and start the OTP server instance. ```bash java -jar -Xmx8G target/otp-x.x.x-SNAPSHOT-shaded.jar --build ./graphs/example_dir ``` ```bash java -jar target/otp-x.x.x-SNAPSHOT-shaded.jar --server --port 8082 --securePort 8083 --basePath ./ --graphs ./graphs --router example_dir ``` -------------------------------- ### Build Output and Artifact Location Source: https://github.com/hsldevcom/digitransit/wiki/Guide-for-building-and-viewing-Digitransit-OTP-graphs-locally Example of a successful build output and the resulting JAR file path. ```text [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 42.164s [INFO] Finished at: Tue Feb 18 19:35:48 CET 2014 [INFO] Final Memory: 88M/695M [INFO] ------------------------------------------------------------------------ ``` ```text target/otp-x.x.x.-SNAPSHOT-shaded.jar ``` -------------------------------- ### Build Local Routing Graph in Memory Source: https://github.com/hsldevcom/digitransit/wiki/Guide-for-building-and-viewing-Digitransit-OTP-graphs-locally Use this command to build an OTP routing graph in memory for a specified directory. Ensure sufficient memory is allocated with -Xmx. The graph is built in the specified directory and OTP starts listening on the given port. ```bash java -jar -Xmx8G target/otp-x.x.x-SNAPSHOT-shaded.jar --build ./graphs/example_dir --inMemory --port 8082 ``` -------------------------------- ### Prepare Running Instance Source: https://github.com/hsldevcom/digitransit/blob/master/Manual-steps-for-Ubuntu-14.04.md Sets up the directory structure and copies the necessary files for execution. ```bash mkdir otp_running_instance cp opentripplanner/target/otp-0.20.0-SNAPSHOT-shaded.jar otp_running_instances/. mkdir otp_running_instance/data cp data/Graph.obj otp_running_instance/data/. ``` -------------------------------- ### Create Apache Configuration Source: https://github.com/hsldevcom/digitransit/blob/master/Manual-steps-for-Ubuntu-14.04.md Initializes the configuration file for the reverse proxy. ```bash cd /etc/apache2/sites-available/ touch digitransit.conf ``` -------------------------------- ### Clone and Build OpenTripPlanner Source: https://github.com/hsldevcom/digitransit/wiki/Guide-for-building-and-viewing-Digitransit-OTP-graphs-locally Commands to clone the repository and compile the project using Maven. ```bash mkdir git cd git git clone https://github.com/HSLdevcom/OpenTripPlanner.git ``` ```bash cd OpenTripPlanner mvn clean package ``` ```bash mvn clean package -DskipTests ``` -------------------------------- ### Add Custom APT Repositories Source: https://github.com/hsldevcom/digitransit/blob/master/Manual-steps-for-Ubuntu-14.04.md Adds OpenJDK and Node.js repositories to the system sources list. ```bash echo "deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu trusty main" >> /etc/apt/sources.list echo "deb https://deb.nodesource.com/node_4.x precise main" >> /etc/apt/sources.list apt-get update ``` -------------------------------- ### Build Project Source: https://github.com/hsldevcom/digitransit/blob/master/Manual-steps-for-Ubuntu-14.04.md Compiles the project using Maven. ```bash cd opentripplanner mvn package ``` -------------------------------- ### OTP Debug and Visualization Source: https://context7.com/hsldevcom/digitransit/llms.txt Launches OpenTripPlanner with visualization tools enabled for graph debugging. ```bash # Run OTP with visualization tool for graph debugging java -jar -Xmx8G target/otp-*-SNAPSHOT-shaded.jar \ --visualize \ --build ./graphs/test_area \ --inMemory # Access debug layers via web interface # http://localhost:8082/?debug_layers=true # Available debug layers: # - Traversal permissions (walk/bike/car access) # - Wheelchair accessibility # - Bike safety ratings # - Stop clusters # - Transit vertex types ``` -------------------------------- ### Clone Repository Source: https://github.com/hsldevcom/digitransit/blob/master/Manual-steps-for-Ubuntu-14.04.md Downloads the OpenTripPlanner source code. ```bash git clone https://github.com/hsldevcom/opentripplanner ``` -------------------------------- ### Run OTP Debug Visualization Tool Source: https://github.com/hsldevcom/digitransit/wiki/Guide-for-building-and-viewing-Digitransit-OTP-graphs-locally This command launches the OpenTripPlanner debug visualization tool. It builds the graph in the specified directory and runs OTP in memory, enabling visualization features. ```bash java -jar -Xmx8G target/otp-x.x.x-SNAPSHOT-shaded.jar --visualize --build ./graphs/example_dir --inMemory ``` -------------------------------- ### Activate Apache Site Source: https://github.com/hsldevcom/digitransit/blob/master/Manual-steps-for-Ubuntu-14.04.md Enables the site configuration and restarts the Apache service. ```bash cd ../site-enabled/. ln -s ../sites-available/digitransit service apache2 restart ``` -------------------------------- ### Create User Source: https://github.com/hsldevcom/digitransit/blob/master/Manual-steps-for-Ubuntu-14.04.md Creates a dedicated user for running the application. ```bash adduser digitransit ``` -------------------------------- ### Build Graph Source: https://github.com/hsldevcom/digitransit/blob/master/Manual-steps-for-Ubuntu-14.04.md Generates the graph file from data. Ensure sufficient memory is allocated via -Xmx. ```bash cd java -Xmx7500M -jar opentripplanner/target/otp-0.20.0-SNAPSHOT-shaded.jar --build ./data/ ``` -------------------------------- ### Run OTP Server Source: https://context7.com/hsldevcom/digitransit/llms.txt Executes the OTP server with specific memory allocation, timezone, and graph data directory settings. ```bash java -Xmx2048M -Duser.timezone=Europe/Helsinki \ -jar otp-*-SNAPSHOT-shaded.jar \ --server --port 1234 --basePath . --graphs data --autoScan --verbose ``` -------------------------------- ### Create Data Directory Source: https://github.com/hsldevcom/digitransit/blob/master/Manual-steps-for-Ubuntu-14.04.md Creates the directory for storing graph and GTFS data. ```bash mkdir ~/data/ ``` -------------------------------- ### Retrieve Routing Data via API Source: https://context7.com/hsldevcom/digitransit/llms.txt Download GTFS, OSM, and configuration files or list available files from the routing data endpoint. ```bash # Get Finland routing data (GTFS files, OSM data, pre-built graphs) curl -O https://api.digitransit.fi/routing-data/v2/finland/router-config.json curl -O https://api.digitransit.fi/routing-data/v2/finland/finland.osm.pbf curl -O https://api.digitransit.fi/routing-data/v2/finland/HSL.zip # Get Helsinki (HSL) area routing data curl -O https://api.digitransit.fi/routing-data/v2/hsl/router-config.json curl -O https://api.digitransit.fi/routing-data/v2/hsl/hsl.osm.pbf curl -O https://api.digitransit.fi/routing-data/v2/hsl/HSL.zip # List available files in routing data endpoint curl https://api.digitransit.fi/routing-data/v2/finland/ curl https://api.digitransit.fi/routing-data/v2/hsl/ ``` -------------------------------- ### Map Tile Service Interaction Source: https://context7.com/hsldevcom/digitransit/llms.txt Commands for loading OSM data into PostGIS and querying vector/raster tile endpoints. ```bash # Load OSM data into PostGIS osm2pgsql -d osm -U postgres -H localhost \ --slim --drop \ --style openstreetmap-carto.style \ finland.osm.pbf # Vector tiles endpoint (TileJSON) curl http://map.digitransit.fi/v1/tilejson.json # Get vector tile at z/x/y curl http://map.digitransit.fi/v1/{z}/{x}/{y}.pbf # Raster tiles endpoint curl http://map.digitransit.fi/raster/v1/{z}/{x}/{y}.png # Example: Get tile for Helsinki center at zoom 14 curl -o tile.pbf "http://map.digitransit.fi/v1/14/9326/4740.pbf" curl -o tile.png "http://map.digitransit.fi/raster/v1/14/9326/4740.png" ``` -------------------------------- ### Docker Compose Lifecycle Management Source: https://context7.com/hsldevcom/digitransit/llms.txt Commands for managing the lifecycle of the Docker-based services. ```bash # Start all services docker-compose up -d # View logs docker-compose logs -f otp # Scale OTP instances docker-compose up -d --scale otp=3 ``` -------------------------------- ### Configure Apache Reverse Proxy Source: https://context7.com/hsldevcom/digitransit/llms.txt Sets up an Apache virtual host to proxy requests to the local OTP server and enables necessary proxy modules. ```bash sudo tee /etc/apache2/sites-available/digitransit.conf << 'EOF' ServerName digitransit.example.com ProxyPreserveHost On ProxyRequests off ProxyPass / http://localhost:1234/ ProxyPassReverse / http://localhost:1234/ ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined EOF sudo a2ensite digitransit.conf sudo a2enmod proxy proxy_http sudo service apache2 restart ``` -------------------------------- ### Switch User Source: https://github.com/hsldevcom/digitransit/blob/master/Manual-steps-for-Ubuntu-14.04.md Changes the current session to the digitransit user. ```bash su digitransit cd ``` -------------------------------- ### Query OTP Routing API Source: https://context7.com/hsldevcom/digitransit/llms.txt Request journey plans or retrieve router metadata from the OTP service. ```bash # Plan a route from origin to destination curl "http://localhost:8082/otp/routers/default/plan?\ fromPlace=60.1699,24.9384\ &toPlace=60.2934,24.9481\ &date=2024-01-15\ &time=08:00:00\ &mode=TRANSIT,WALK\ &maxWalkDistance=1000\ &arriveBy=false" # Response includes itineraries with legs, transit details, walk segments # { # "plan": { # "itineraries": [ # { # "duration": 1800, # "legs": [ # { "mode": "WALK", "from": {...}, "to": {...} }, # { "mode": "BUS", "route": "550", "from": {...}, "to": {...} }, # { "mode": "WALK", "from": {...}, "to": {...} } # ] # } # ] # } # } # Get available routers curl http://localhost:8082/otp/routers # Get router metadata curl http://localhost:8082/otp/routers/default ``` -------------------------------- ### Use Geocoder API Source: https://context7.com/hsldevcom/digitransit/llms.txt Perform address searches, autocomplete suggestions, or reverse geocoding. ```bash # Search for an address or place curl "http://digitransit.fi/geocoder/search?text=Kamppi,Helsinki" # Response returns matching locations with coordinates # { # "features": [ # { # "type": "Feature", # "geometry": { # "type": "Point", # "coordinates": [24.9320, 60.1689] # }, # "properties": { # "name": "Kamppi", # "locality": "Helsinki", # "country": "Finland" # } # } # ] # } # Autocomplete search for suggestions while typing curl "http://digitransit.fi/geocoder/autocomplete?text=Ota" # Reverse geocoding - coordinates to address curl "http://digitransit.fi/geocoder/reverse?point.lat=60.1699&point.lon=24.9384" ``` -------------------------------- ### MQTT Realtime Data Integration Source: https://context7.com/hsldevcom/digitransit/llms.txt Connects to the Digitransit MQTT broker to stream vehicle position updates. ```javascript // Connect to MQTT broker for realtime vehicle data const mqtt = require('mqtt'); const client = mqtt.connect('mqtt://realtime.digitransit.fi'); // Subscribe to Helsinki region vehicle positions client.on('connect', () => { client.subscribe('/hfp/v2/journey/ongoing/vp/bus/#'); }); // Handle incoming vehicle position messages client.on('message', (topic, message) => { const data = JSON.parse(message.toString()); console.log(`Vehicle ${data.veh} at ${data.lat}, ${data.long}`); // { // "VP": { // "desi": "550", // "dir": "1", // "oper": 22, // "veh": 1234, // "lat": 60.1699, // "long": 24.9384, // "spd": 12.5, // "hdg": 180 // } // } }); ``` -------------------------------- ### Docker Compose Service Configuration Source: https://context7.com/hsldevcom/digitransit/llms.txt Defines the multi-container architecture for the Digitransit stack, including OTP, geocoder, map server, and HAProxy. ```yaml version: '3' services: otp: image: hsldevcom/opentripplanner ports: - "8080:8080" volumes: - ./graphs:/var/otp/graphs environment: - JAVA_OPTS=-Xmx4G geocoder: image: hsldevcom/digitransit-geocoder ports: - "3100:3100" depends_on: - elasticsearch elasticsearch: image: elasticsearch:7.x ports: - "9200:9200" map-server: image: hsldevcom/digitransit-map ports: - "8090:8090" depends_on: - postgis postgis: image: postgis/postgis environment: - POSTGRES_DB=osm ui: image: hsldevcom/digitransit-ui ports: - "80:8080" environment: - OTP_URL=http://otp:8080 - GEOCODER_URL=http://geocoder:3100 - MAP_URL=http://map-server:8090 haproxy: image: haproxy ports: - "443:443" volumes: - ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg ``` -------------------------------- ### Apache VirtualHost Configuration Source: https://github.com/hsldevcom/digitransit/blob/master/Manual-steps-for-Ubuntu-14.04.md Configuration block for the Apache reverse proxy. ```apache ServerName digitransit.localhost ServerAlias digitransit.localhost ServerAdmin webmaster@localhost ProxyPreserveHost On ProxyRequests off ProxyPass / http://localhost:1234/ ProxyPassReverse / http://localhost:1234/ ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined ``` -------------------------------- ### GTFS Data Conversion and Transformation Source: https://context7.com/hsldevcom/digitransit/llms.txt Tools for converting transit data formats and aligning GTFS shapes with OSM road networks. ```bash # Convert Kalkati XML format to GTFS git clone https://github.com/HSLdevcom/kalkati2gtfs.git cd kalkati2gtfs python kalkati2gtfs.py input.xml output.zip # Fit GTFS shapes to OSM road network for better map alignment git clone https://github.com/hannesj/gtfs_shape_mapfit.git cd gtfs_shape_mapfit python mapfit.py gtfs.zip osm.pbf output.zip # Apply GTFS transformations using OneBusAway transformer java -jar onebusaway-gtfs-transformer-cli.jar \ --transform="{'op':'remove','match':{'class':'Route','shortName':'999'}}" \ input.zip output.zip ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.