### Install MkDocs and Serve Documentation Source: https://docs.opentripplanner.org/en/latest/Developers-Guide Installs the necessary Python packages for MkDocs and starts a local server to preview documentation changes. ```bash $ pip install -r doc/user/requirements.txt $ mkdocs serve ``` -------------------------------- ### Perform Local Release Build Test Source: https://docs.opentripplanner.org/en/latest/ReleaseChecklist Build and install the release locally to verify all tests pass and artifacts are generated. Requires GPG signing certificate setup for 'install'. ```bash mvn clean install -Prelease ``` -------------------------------- ### Start OTP Server with Loaded Graph Source: https://docs.opentripplanner.org/en/latest/Basic-Tutorial Starts the OpenTripPlanner server using a pre-built graph. The `--load` parameter is used to specify the graph directory. ```bash java -Xmx2G -jar otp-shaded-2.8.1.jar --load . ``` -------------------------------- ### Start OTP Server with Graph Building and Serving Source: https://docs.opentripplanner.org/en/latest/Basic-Tutorial Builds a transportation network graph and starts an OTP server in a single step. Specify the directory containing input files and configuration. ```bash $ java -Xmx2G -jar otp-shaded-2.8.1.jar --build --serve /home/username/otp ``` -------------------------------- ### Load and Serve OTP Graph from File Source: https://docs.opentripplanner.org/en/latest/Basic-Tutorial Starts an OTP server by loading a pre-built graph from the 'graph.obj' file. This is faster than rebuilding the graph. ```bash $ java -Xmx2G -jar otp-shaded-2.8.1.jar --load . ``` -------------------------------- ### Stop-Time Updater Configuration Example Source: https://docs.opentripplanner.org/en/latest/GTFS-RT-Config Example configuration for a stop-time updater, specifying frequency, delay propagation, URL, feed ID, and custom headers. ```json { "updaters" : [ { "type" : "stop-time-updater", "frequency" : "1m", "backwardsDelayPropagationType" : "REQUIRED_NO_DATA", "url" : "http://developer.trimet.org/ws/V1/TripUpdate/appID/0123456789ABCDEF", "feedId" : "TriMet", "headers" : { "Authorization" : "A-Token" } } ] } ``` -------------------------------- ### Example Debug UI Configuration Source: https://docs.opentripplanner.org/en/latest/DebugUiConfiguration This example shows how to configure additional background raster map layers for the Debug UI. It includes settings for the layer name, tile template URL, and attribution. ```json // debug-ui-config.json { "additionalBackgroundLayers" : [ { "name" : "TriMet aerial photos", "templateUrl" : "https://maps.trimet.org/wms/reflect?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.0&request=GetMap&srs=EPSG:3857&width=256&height=256&layers=aerials", "attribution" : "© TriMet" } ] } ``` -------------------------------- ### Vehicle Parking Updater with Bikeep Source: https://docs.opentripplanner.org/en/latest/sandbox/VehicleParking Example configuration for the vehicle parking updater using the Bikeep source. This snippet demonstrates a basic setup without custom headers. ```json { "updaters" : [ { "type" : "vehicle-parking", "feedId" : "bikeep", "sourceType" : "bikeep", "url" : "https://services.bikeep.com/location/v1/public-areas/no-baia-mobility/locations" } ] } ``` -------------------------------- ### Custom Base Path Example Source: https://docs.opentripplanner.org/en/latest/sandbox/MapboxVectorTilesApi Configure a custom base path for vector tile source URLs in tilejson.json. This is helpful for proxy setups that rewrite the path to OTP. ```properties vectorTiles.basePath=/otp_test/tiles ``` -------------------------------- ### SIRI-SX Lite Updater Example Configuration Source: https://docs.opentripplanner.org/en/latest/SIRI-Config Example configuration for a SIRI-SX Lite updater, including feed ID and URL. ```json // router-config.json { "updaters" : [ { "type" : "siri-sx-lite", "feedId" : "sta", "url" : "https://example.com/siri-lite/situation-exchange/xml" } ] } ``` -------------------------------- ### Vehicle Parking Updater Configuration Example Source: https://docs.opentripplanner.org/en/latest/sandbox/VehicleParking Example configuration for the vehicle-parking updater in router-config.json. This snippet shows how to set up the feedId, sourceType, and url for fetching parking data. ```json { "updaters" : [ { "type" : "vehicle-parking", "feedId" : "parking", "sourceType" : "siri-fm", "url" : "https://transmodel.api.opendatahub.com/siri-lite/fm/parking" } ] } ``` -------------------------------- ### SIRI-ET MQTT Updater Configuration Example Source: https://docs.opentripplanner.org/en/latest/sandbox/siri/SiriMqttUpdater Example configuration for the SIRI-ET MQTT updater in router-config.json. This snippet shows how to set up the updater with connection details, feed information, and priming parameters. ```json { "updaters" : [ { "type" : "siri-et-mqtt", "user" : "user", "password" : "pwd", "host" : "localhost", "port" : 1883, "feedId" : "1", "topic" : "trip/updates/#", "qos" : 1, "fuzzyTripMatching" : true, "numberOfPrimingWorkers" : 4, "maxPrimingIdleTime" : "1s" } ] } ``` -------------------------------- ### Load OTP Graph Source: https://docs.opentripplanner.org/en/latest/Netex-Tutorial Start an OTP2 server and load the previously built graph. Requires heap memory for loading and operation. ```bash java -Xmx6G -jar otp.jar --load . ``` -------------------------------- ### Use Custom Logback Configuration Source: https://docs.opentripplanner.org/en/latest/Logging To use a custom logback configuration file, specify its path using the 'logback.configurationFile' Java property when starting OTP. ```bash java -Dlogback.configurationFile=/path/to/logback.xml -jar otp.jar --load --serve data ``` -------------------------------- ### SIRI Azure SX Updater Configuration Example Source: https://docs.opentripplanner.org/en/latest/sandbox/siri/SiriAzureUpdater This is an example configuration for the SIRI Azure SX Updater. It shows how to set up the updater with a specific topic, service bus URL, feed ID, and historical data fetching parameters. ```json { "updaters" : [ { "type" : "siri-azure-sx-updater", "topic" : "some_topic", "servicebus-url" : "service_bus_url", "feedId" : "feed_id", "customMidnight" : 4, "history" : { "url" : "endpoint_url", "fromDateTime" : "-P1D", "toDateTime" : "P1D", "timeout" : 300000 } } ] } ``` -------------------------------- ### Creating a New Layer Builder (Java) Source: https://docs.opentripplanner.org/en/latest/sandbox/MapboxVectorTilesApi Example of creating a new layer by extending LayerBuilder. Requires implementing getGeometries and getExpansionFactor methods. ```java public class NewLayerBuilder extends LayerBuilder { @Override public List getGeometries(Envelope query) { // Implementation to return geometries with T as userData return new ArrayList<>(); } @Override public double getExpansionFactor() { // Implementation to return expansion factor return 0.25; } } // Add the new layer to VectorTilesResource.layers: // VectorTilesResource.layers.put(LayerType.NEW_LAYER_TYPE, NewLayerBuilder::new); ``` -------------------------------- ### Emission Module Configuration in Build Config Source: https://docs.opentripplanner.org/en/latest/sandbox/Emission Example configuration for `build-config.json` to set up the emission module. It includes average car emissions, occupancy, and feed details. ```json // build-config.json { "emission" : { "carAvgCo2PerKm" : 170, "carAvgOccupancy" : 1.3, "feeds" : [ { "feedId" : "MY", "source" : "https://my.org/emissions/latest" } ] } } ``` -------------------------------- ### Liipi Updater Configuration Source: https://docs.opentripplanner.org/en/latest/sandbox/VehicleParking Example configuration for the Liipi vehicle parking updater. Ensure 'type' is 'vehicle-parking' and 'sourceType' is 'liipi'. ```json { "updaters" : [ { "type" : "vehicle-parking", "sourceType" : "liipi", "feedId" : "liipi", "timeZone" : "Europe/Helsinki", "facilitiesFrequencySec" : 3600, "facilitiesUrl" : "https://parking.fintraffic.fi/api/v1/facilities.json?limit=-1", "utilizationsFrequencySec" : 600, "utilizationsUrl" : "https://parking.fintraffic.fi/api/v1/utilizations.json?limit=-1", "hubsUrl" : "https://parking.fintraffic.fi/api/v1/hubs.json?limit=-1" } ] } ``` -------------------------------- ### Vehicle Parking Updater with Park-API Source: https://docs.opentripplanner.org/en/latest/sandbox/VehicleParking Example configuration for the vehicle parking updater using the Park-API source. Includes optional tags for categorization. ```json { "updaters" : [ { "type" : "vehicle-parking", "sourceType" : "park-api", "feedId" : "parkapi", "timeZone" : "Europe/Berlin", "frequency" : "10m", "url" : "https://foo.bar", "headers" : { "Cache-Control" : "max-age=604800" }, "tags" : [ "source:parkapi" ] } ] } ``` -------------------------------- ### SIRI-ET Lite Updater Example Configuration Source: https://docs.opentripplanner.org/en/latest/SIRI-Config Configuration for a SIRI-ET Lite updater, specifying feed ID, URL, and enabling fuzzy trip matching. ```json // router-config.json { "updaters" : [ { "type" : "siri-et-lite", "feedId" : "sta", "url" : "https://example.com/siri-lite/estimated-timetable/xml", "fuzzyTripMatching" : true } ] } ``` -------------------------------- ### Create Data Directory and Download OSM/GTFS Source: https://docs.opentripplanner.org/en/latest/Container-Image Prepare the environment by creating a directory for input data and downloading the necessary OpenStreetMap (OSM) and General Transit Feed Specification (GTFS) files. ```bash # create directory for data and config mkdir berlin # download OSM curl -L https://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf -o berlin/osm.pbf # download GTFS curl -L https://vbb.de/vbbgtfs -o berlin/vbb-gtfs.zip ``` -------------------------------- ### Set Up Next Development Iteration Source: https://docs.opentripplanner.org/en/latest/ReleaseChecklist Prepare for the next development cycle by updating the changelog and bumping the POM version to a SNAPSHOT. ```bash mvn versions:set -DnewVersion=x.y.z-SNAPSHOT git add pom.xml doc/user/Changelog.md git commit -m "Prepare next development iteration x.y+1.0-SNAPSHOT" git push ``` -------------------------------- ### Empirical Delay Calendar Data Example Source: https://docs.opentripplanner.org/en/latest/sandbox/EmpiricalDelay This CSV file defines service calendars for delay data, similar to GTFS calendar.txt. It specifies unique service calendar identifiers and whether they apply on specific days of the week, along with start and end dates. ```csv empirical_delay_service_id,monday,tuesday,wednesday,thursday,friday,saturday,sunday,start_date,end_date Weekday,1,1,1,1,1,0,0,2025-01-01,2030-12-31 Weekend,0,0,0,0,0,1,1,2025-01-01,2030-12-31 Friday,0,0,0,0,1,0,0,2025-01-01,2030-12-31 ``` -------------------------------- ### SIRI-SX Updater Headers Example Source: https://docs.opentripplanner.org/en/latest/SIRI-Config Example configuration for adding custom HTTP headers to a SIRI-SX updater request. ```json // router-config.json { "updaters" : [ { "type" : "siri-sx-updater", "url" : "https://example.com/some/path", "feedId" : "feed_id", "timeout" : "30s", "headers" : { "Key" : "Value" } } ] } ``` -------------------------------- ### OpenTripPlanner Build Configuration Example Source: https://docs.opentripplanner.org/en/latest/BuildConfiguration This JSON file defines various configuration parameters for building an OpenTripPlanner graph. It includes settings for transit data, OSM data, DEM data, Netex and GTFS feeds, and transfer requests. ```json // build-config.json { "transitServiceStart" : "-P3M", "transitServiceEnd" : "P1Y", "osmCacheDataInMem" : true, "localFileNamePatterns" : { "osm" : "(i?)\.osm\.pbf$", "dem" : "(i?)\.dem\.tiff?$", "gtfs" : "(?i)gtfs", "netex" : "(?i)netex" }, "osmDefaults" : { "timeZone" : "Europe/Rome", "osmTagMapping" : "default" }, "osm" : [ { "source" : "gs://my-bucket/otp-work-dir/norway.osm.pbf", "timeZone" : "Europe/Oslo", "osmTagMapping" : "norway" } ], "demDefaults" : { "elevationUnitMultiplier" : 1.0 }, "dem" : [ { "source" : "gs://my-bucket/otp-work-dir/norway.dem.tiff", "elevationUnitMultiplier" : 2.5 } ], "netexDefaults" : { "feedId" : "EN", "sharedFilePattern" : "_stops.xml", "sharedGroupFilePattern" : "_(\w{3})_shared_data.xml", "groupFilePattern" : "(\w{3})_.*\.xml", "ignoreFilePattern" : "(temp|tmp)", "ferryIdsNotAllowedForBicycle" : [ "RUT:B107", "RUT:B209" ] }, "gtfsDefaults" : { "stationTransferPreference" : "recommended", "discardMinTransferTimes" : false, "blockBasedInterlining" : true, "maxInterlineDistance" : 200 }, "islandPruning" : { "islandWithStopsMaxSize" : 2, "islandWithoutStopsMaxSize" : 10, "adaptivePruningFactor" : 50.0, "adaptivePruningDistance" : 250 }, "transitFeeds" : [ { "type" : "gtfs", "feedId" : "SE", "source" : "https://skanetrafiken.se/download/sweden.gtfs.zip" }, { "type" : "netex", "feedId" : "NO", "source" : "gs://BUCKET/OTP_GCS_WORK_DIR/norway-netex.obj", "sharedFilePattern" : "_stops.xml", "sharedGroupFilePattern" : "_(\w{3})_shared_data.xml", "groupFilePattern" : "(\w{3})_.*\.xml", "ignoreFilePattern" : "(temp|tmp)" } ], "transferRequests" : [ { "modes" : "WALK" }, { "modes" : "WALK", "wheelchairAccessibility" : { "enabled" : true } }, { "modes" : "BICYCLE" }, { "modes" : "CAR" } ], "stopConsolidationFile" : "consolidated-stops.csv", "transferParametersForMode" : { "CAR" : { "disableDefaultTransfers" : true, "carsAllowedStopMaxTransferDuration" : "3h" }, "BIKE" : { "disableDefaultTransfers" : true, "maxTransferDuration" : "30m", "carsAllowedStopMaxTransferDuration" : "3h", "bikesAllowedStopMaxTransferDuration" : "1h" } } } ``` -------------------------------- ### Fetch Stops Example Source: https://docs.opentripplanner.org/en/latest/apis/GTFS-GraphQL-API This example demonstrates how to fetch a list of all stops using the GTFS GraphQL API via a curl command. ```APIDOC ## Fetch Stops ### Description Fetches a list of all available stops from the GTFS data. ### Method POST ### Endpoint http://localhost:8080/otp/gtfs/v1 ### Request Body - **query** (string) - Required - The GraphQL query string to fetch stops. - **operationName** (string) - Optional - The name of the operation. ### Request Example ```json { "query": "query stops {\n stops {\n gtfsId\n name\n }\n}\n", "operationName": "stops" } ``` ### Response #### Success Response (200) - **data** (object) - Contains the result of the query. - **stops** (array) - A list of stops. - **gtfsId** (string) - The GTFS ID of the stop. - **name** (string) - The name of the stop. #### Response Example ```json { "data": { "stops": [ { "gtfsId": "1001", "name": "Stop A" }, { "gtfsId": "1002", "name": "Stop B" } ] } } ``` ``` -------------------------------- ### Package OpenTripPlanner Project Source: https://docs.opentripplanner.org/en/latest/Developers-Guide Run this Maven command to download dependencies, build the project, and execute tests. ```bash mvn package ``` -------------------------------- ### Build OTP Graph Source: https://docs.opentripplanner.org/en/latest/Netex-Tutorial Instruct OTP2 to build a graph using the specified configuration. Requires sufficient heap memory. ```bash java -Xmx16G -jar otp.jar --build --save . ``` -------------------------------- ### Prometheus Metrics Example Source: https://docs.opentripplanner.org/en/latest/sandbox/ActuatorAPI This example shows typical Prometheus metrics exported by the Actuator API, including GraphQL timing metrics. These metrics can be used for performance monitoring and tracing. ```text ... graphql_timer_resolver_seconds_count{example-header-or-query-parameter-name="value",operationName="__UNKNOWN__",parent="QueryType"} 9 graphql_timer_resolver_seconds_sum{example-header-or-query-parameter-name="value",operationName="__UNKNOWN__",parent="QueryType"} 10.621173848 graphql_timer_resolver_seconds_max{example-header-or-query-parameter-name="value",operationName="__UNKNOWN__",parent="QueryType"} 1.997706365 ... ``` -------------------------------- ### Setting JVM Options for OTP Container Source: https://docs.opentripplanner.org/en/latest/Container-Image Demonstrates how to set Java Virtual Machine (JVM) options, such as memory allocation, for the OpenTripPlanner container using the `JAVA_TOOL_OPTIONS` environment variable. ```bash # If you want to set JVM options you can use the environment variable `JAVA_TOOL_OPTIONS`, so a full example to add to your docker command is `-e JAVA_TOOL_OPTIONS='-Xmx4g'`. ``` -------------------------------- ### Build OpenTripPlanner with Maven Source: https://docs.opentripplanner.org/en/latest/Getting-OTP Build the OpenTripPlanner project using Maven after cloning the source code. This command cleans the project and packages it into a JAR file. ```bash cd OpenTripPlanner mvn clean package ``` -------------------------------- ### Emission Route Format Example Source: https://docs.opentripplanner.org/en/latest/sandbox/Emission Example data file for the Emission Route format, specifying route ID, average CO2 per vehicle per kilometer, and average passenger count. ```csv route_id,avg_co2_per_vehicle_per_km,avg_passenger_count 1234,123,20 2345,0,0 3456,12.3,20.0 ``` -------------------------------- ### Example build-config.json for GCS Integration Source: https://docs.opentripplanner.org/en/latest/sandbox/GoogleCloudStorage This configuration demonstrates how to set up OTP to use Google Cloud Storage for storing and retrieving graph data, OSM data, DEM files, and transit feeds. It includes optional parameters for specifying a custom GCS host and a credentials file path. ```json // build-config.json { "gsConfig" : { "cloudServiceHost" : "http://fake-gcp:4443", "credentialFile" : "/path/to/file" }, "graph" : "gs://otp-test-bucket/a/b/graph.obj", "buildReportDir" : "gs://otp-test-bucket/a/b/np-report", "osm" : [ { "source" : "gs://otp-test-bucket/a/b/northpole.pbf" } ], "dem" : [ { "source" : "gs://otp-test-bucket/a/b/northpole.dem.tif" } ], "transitFeeds" : [ { "type" : "gtfs", "source" : "gs://otp-test-bucket/a/b/gtfs.zip" } ] } ``` -------------------------------- ### Emission Trip Hop Format Example Source: https://docs.opentripplanner.org/en/latest/sandbox/Emission Example data file for the Emission Trip Hop format, detailing trip ID, stop ID, stop sequence, and CO2 emissions per hop. ```csv trip_id,from_stop_id,from_stop_sequence,co2 Trip:3,Stop:A,1,90.456 Trip:3,Stop:A,2,130.483 Trip:3,Stop:A,3,172.646 ``` -------------------------------- ### Creating a New Property Mapper (Java) Source: https://docs.opentripplanner.org/en/latest/sandbox/MapboxVectorTilesApi Example of creating a new mapper by extending PropertyMapper. Requires implementing the map method to return key-value pairs for vector tile attributes. ```java public class NewPropertyMapper extends PropertyMapper { @Override public Collection> map(T input) { // Implementation to map OTP entity to key-value attributes Collection> attributes = new ArrayList<>(); // Example: attributes.add(new KeyValue<>("key", "value")); return attributes; } } // Add the new mapper to the layer's mappers map: // layer.mappers.put(MapperType.NEW_MAPPER_TYPE, graph -> new NewPropertyMapper<>()); ```