### Serve Command Configuration File Example Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/commands.md Example configuration file settings for the 'serve' command, specifying graph location, profiles, and server ports. ```yaml graphhopper: graph.location: ./graph-cache profiles: - name: tgv_all custom_model_files: [rail.json] server: applicationConnectors: - type: http port: 8989 adminConnectors: - type: http port: 8990 ``` -------------------------------- ### Serve Command Example with Specific Paths and Port Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/commands.md An example of the serve command with specific system properties for graph location and application port. ```bash java -Xmx2500m \ -Ddw.graphhopper.graph.location=/mnt/cache/graph-fr \ -Ddw.server.applicationConnector.port=8989 \ -jar railway_routing-0.0.1-SNAPSHOT.jar \ serve config.yml ``` -------------------------------- ### Start OpenRailRouting Server Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/architecture.md The main entry point for starting the OpenRailRouting HTTP server using Dropwizard. ```java public static void main(String[] args) throws Exception { new RailwayRoutingApplication().run("server", args); } ``` -------------------------------- ### Match Command Example Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/commands.md An example of the 'match' command with specified options for profile, GPX location, GPS accuracy, and maximum nodes. Includes system properties for graph location. ```bash java -Xmx2500m \ -Ddw.graphhopper.graph.location=./graph-cache \ -jar railway_routing-0.0.1-SNAPSHOT.jar \ match \ --profile tgv_all \ --gpx-location="/data/tracks/*.gpx" \ --gps-accuracy 20 \ --max-nodes 5000 \ config.yml ``` -------------------------------- ### OpenRailRouting Import Command Example Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/commands.md An example of running the import command with specific input and output paths defined via system properties. Ensure the configuration file is correctly specified. ```bash java -Xmx2500m \ -Ddw.graphhopper.datareader.file=/data/france-railway.pbf \ -Ddw.graphhopper.graph.location=/mnt/cache/graph-fr \ -jar railway_routing-0.0.1-SNAPSHOT.jar \ import config.yml ``` -------------------------------- ### Startup Logging Information Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/commands.md Example log messages observed during the startup process of the 'serve' command. These indicate graph loading and server initialization. ```log [main] INFO de.geofabrik.railway_routing.http.RailwayRoutingApplication - Loading graph from cache [main] INFO com.graphhopper.GraphHopper - Loaded X profiles from graph [main] INFO org.eclipse.jetty.server.Server - Started HTTP server on port 8989 ``` -------------------------------- ### Logging Output Example Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/commands.md Example log messages indicating the progress and results of matching a single GPX track. ```log [main] INFO - Matching GPX track /data/tracks/track1.gpx on the graph. [main] DEBUG - matches: 150 [main] DEBUG - gpx length: 12345, match length: 12340 [main] INFO - export results to:/data/tracks/track1.gpx.res.gpx ``` -------------------------------- ### Map Matching Endpoint Base URL Example Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/endpoints.md Example of the base URL for the map matching endpoint. No authentication is required. ```http http://localhost:8989/match ``` -------------------------------- ### Example: Create and Convert InputCSVEntry Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/api-reference.md Demonstrates the creation of an `InputCSVEntry` with specific coordinates and its conversion to an `Observation` object. ```java InputCSVEntry entry = new InputCSVEntry(48.8566, 2.3522); Observation obs = entry.toGPXEntry(); ``` -------------------------------- ### Startup Verification using /info Endpoint Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/commands.md Verify the server has started correctly by making a request to the /info endpoint. This checks if the server is running and provides basic information. ```bash curl http://localhost:8989/info ``` -------------------------------- ### Serve Command with System Properties Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/commands.md Configure the server using Java system properties. This example sets the OSM file location, graph cache directory, and application port. ```bash java -Xmx2500m \ -Ddw.graphhopper.datareader.file=/path/to/map.pbf \ -Ddw.graphhopper.graph.location=./graph-cache \ -Ddw.server.applicationConnector.port=8989 \ -jar railway_routing-0.0.1-SNAPSHOT.jar \ serve config.yml ``` -------------------------------- ### OpenRailRouting Import Command Log Output Example Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/commands.md Example log output during the OpenRailRouting import process, showing progress in parsing, encoding, preparation, and completion time. Useful for monitoring import status and diagnosing issues. ```log [main] INFO de.geofabrik.railway_routing.reader.OSMRailwayReader - Parsed X railway edges [main] INFO com.graphhopper.routing.util.EncodingManager - Encoded values: gauge, voltage, ... [main] INFO com.graphhopper.routing.ch.NodeBasedCHPreparation - Preparation for profile 'tgv_all' complete [main] INFO com.graphhopper.GraphHopper - Import complete. Time: X minutes ``` -------------------------------- ### Configuration Precedence Example Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/commands.md Demonstrates how system properties (-Ddw.key=value) and command-line arguments override the base configuration file. Command-line arguments have the highest priority. ```bash java -Xmx2500m \ -Ddw.graphhopper.graph.location=/system/cache \ -jar railway_routing-0.0.1-SNAPSHOT.jar \ import \ -o /command/cache \ config.yml ``` -------------------------------- ### Build Project with Maven Source: https://github.com/geofabrik/openrailrouting/blob/master/README.md Use Maven to clean the project and install all dependencies. This command compiles the code and prepares the application for execution. ```sh mvn clean install ``` -------------------------------- ### OSMFrequencyParser Example Tags Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/parsers.md Illustrates how different 'frequency' OSM tag values are processed and stored, including valid and ignored cases. ```text frequency=16.7 → stored as 16.7 (German railways) frequency=50 → stored as 50.0 (European standard) frequency=60 → stored as 60.0 (Americas) frequency=25 → ignored (not standard) frequency=100 → ignored (exceeds max 80) ``` -------------------------------- ### CSV Input Schema Example Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/endpoints.md Example of a CSV formatted request body for the map matching endpoint. Latitude and longitude are required columns. The separator defaults to ';'. ```csv latitude;longitude 48.8566;2.3522 48.8567;2.3523 ``` -------------------------------- ### OSMVoltageParser Example Tags Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/parsers.md Demonstrates the processing of 'voltage' tags, showing how valid values are stored, ignored values (below minimum), and the expected behavior for malformed tags. ```plaintext voltage=750 → stored as 750.0 voltage=15000 → stored as 15000.0 voltage=3.5 → ignored (below min) voltage=10000 → stored as 10000.0 voltage=750;1500 → raises IllegalArgumentException (should be split) ``` -------------------------------- ### GPX Input Schema Example Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/endpoints.md Example of a GPX 1.1 XML formatted request body for the map matching endpoint. Ensure trackpoints include latitude and longitude, with optional timestamps. ```xml ``` -------------------------------- ### Example Registration Flow Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/parsers.md Illustrates the flow from configuration requesting encoded values to the RailImportRegistry providing the correct parser and encoding data from OSM ways. ```text Config requests: graph.encoded_values = "gauge,voltage,electrified" ↓ RailImportRegistry.createImportUnit("gauge") → Returns OSMGaugeParser ↓ For each OSM way: → OSMGaugeParser.handleWayTags(way with gauge=1435) → Encodes 1435 into edge's gauge slot ``` -------------------------------- ### Gauge Tag Parsing Example Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/architecture.md Shows the flow of parsing an OSM 'gauge' tag and encoding it into an edge's value using OSMGaugeParser. ```java OSM way with gauge=1435 ↓ OSMGaugeParser.handleWayTags() ↓ Parse "1435" as integer ↓ gaugeEnc.setInt(edgeId, 1435) ↓ Edge stores gauge value ``` -------------------------------- ### Serve API with OpenRailRouting Source: https://github.com/geofabrik/openrailrouting/blob/master/README.md Use the 'serve' action to start an HTTP server for the API and web interface. Configure the port using dw.server.applicationConnector.port. If no data is imported, an import will occur first. Required settings can be Java system properties or in the YAML config file. ```sh java -jar target/railway_routing-0.0.1-SNAPSHOT.jar serve config.yml ``` -------------------------------- ### CSV Input Example for POST /match Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/api-reference.md Shows how to provide CSV formatted track data for the POST /match endpoint. Specify the 'profile' and 'type' query parameters, and set the 'Content-Type' to 'text/csv'. The 'csv_output.separator' can be adjusted if needed. ```http POST /match?profile=tramtrain&type=csv&csv_output.separator=, Content-Type: text/csv latitude;longitude 48.8566;2.3522 48.8567;2.3523 ``` -------------------------------- ### Match GPX Input, JSON Output Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/endpoints.md This example demonstrates how to use the /match endpoint to process a GPX file and receive the output in JSON format. It specifies the 'tgv_all' profile and requests JSON output. ```APIDOC ## POST /match ### Description Matches a GPS track to railway data and returns the result. ### Method POST ### Endpoint /match ### Parameters #### Query Parameters - **profile** (string) - Required - The routing profile to use (e.g., 'tgv_all'). - **type** (string) - Required - The output format (e.g., 'json'). #### Request Body - **file** (binary) - Required - The GPX file containing the track data. ### Request Example ```bash curl -X POST "http://localhost:8989/match?profile=tgv_all&type=json" \ -H "Content-Type: application/gpx+xml" \ -d @track.gpx ``` ### Response #### Success Response (200) - **body** (JSON) - The matched route information. #### Response Example ```json { "message": "input contains less than two points", "hints": [ { "details": "IllegalArgumentException: input contains less than two points", "message": "input contains less than two points" } ] } ``` ``` -------------------------------- ### GPX Input Example for POST /match Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/api-reference.md Demonstrates how to send GPX track data in the request body for the POST /match endpoint. Ensure the 'profile' and 'type' query parameters are set, and the 'Content-Type' header is 'application/gpx+xml'. ```http POST /match?profile=tgv_all&type=json&gps_accuracy=40 Content-Type: application/gpx+xml ``` -------------------------------- ### GET /info Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/INDEX.md Retrieves information about the OpenRailRouting server. ```APIDOC ## GET /info ### Description Retrieves information about the OpenRailRouting server. ### Method GET ### Endpoint /info ``` -------------------------------- ### Output GPX Format Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/commands.md Example structure of the output GPX file, including metadata, route information (rte), and track points (trkpt). ```xml 0: Continue on Rue de Rivoli ... ... ``` -------------------------------- ### Match with Path Details Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/endpoints.md This example shows how to request specific path details, such as 'railway_class', 'gauge', and 'voltage', when matching a GPX track using the /match endpoint. ```APIDOC ## POST /match ### Description Matches a GPS track to railway data and allows requesting specific path details. ### Method POST ### Endpoint /match ### Parameters #### Query Parameters - **profile** (string) - Required - The routing profile to use (e.g., 'tgv_all'). - **path_details** (string) - Optional - Specifies the type of path details to include (e.g., 'railway_class', 'gauge', 'voltage'). Can be specified multiple times. #### Request Body - **file** (binary) - Required - The GPX file containing the track data. ### Request Example ```bash curl -X POST "http://localhost:8989/match" \ -H "Content-Type: application/gpx+xml" \ -G \ --data-urlencode "profile=tgv_all" \ --data-urlencode "path_details=railway_class" \ --data-urlencode "path_details=gauge" \ --data-urlencode "path_details=voltage" \ -d @track.gpx ``` ### Response #### Success Response (200) - **body** (JSON) - The matched route information including the requested path details. #### Response Example (JSON formatted data with path details) ``` -------------------------------- ### Match with GPS Accuracy and Gap Filling Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/endpoints.md This example demonstrates how to use the /match endpoint with additional parameters for GPS accuracy and gap filling. It uses a GPX input and requests JSON output with the 'non_tgv' profile. ```APIDOC ## POST /match ### Description Matches a GPS track to railway data, allowing for GPS accuracy specification and gap filling. ### Method POST ### Endpoint /match ### Parameters #### Query Parameters - **profile** (string) - Required - The routing profile to use (e.g., 'non_tgv'). - **type** (string) - Required - The output format (e.g., 'json'). - **gps_accuracy** (integer) - Optional - The GPS accuracy in meters. - **fill_gaps** (boolean) - Optional - Whether to fill gaps in the track data. #### Request Body - **file** (binary) - Required - The GPX file containing the track data. ### Request Example ```bash curl -X POST "http://localhost:8989/match" \ -H "Content-Type: application/gpx+xml" \ -G \ --data-urlencode "profile=non_tgv" \ --data-urlencode "type=json" \ --data-urlencode "gps_accuracy=20" \ --data-urlencode "fill_gaps=true" \ -d @track.gpx ``` ### Response #### Success Response (200) - **body** (JSON) - The matched route information. #### Response Example (JSON formatted data) ``` -------------------------------- ### OSMElectrifiedParser Tag Mapping Examples Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/parsers.md Shows the mapping between 'electrified' OSM tag values and their corresponding Electrified enum values, including default and unrecognized cases. ```text electrified=contact_line → CONTACT_LINE electrified=rail → RAIL electrified=no → NO (missing) → UNSET electrified=something → OTHER ``` -------------------------------- ### Match CSV Input, CSV Output Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/endpoints.md This example shows how to use the /match endpoint with CSV input data and request CSV output. It utilizes the 'tramtrain' profile. ```APIDOC ## POST /match ### Description Matches a GPS track to railway data and returns the result. ### Method POST ### Endpoint /match ### Parameters #### Query Parameters - **profile** (string) - Required - The routing profile to use (e.g., 'tramtrain'). - **type** (string) - Required - The output format (e.g., 'csv'). #### Request Body - **file** (binary) - Required - The CSV file containing the track data. ### Request Example ```bash curl -X POST "http://localhost:8989/match?profile=tramtrain&type=csv" \ -H "Content-Type: text/csv" \ -d @track.csv ``` ### Response #### Success Response (200) - **body** (CSV) - The matched route information in CSV format. #### Response Example (CSV formatted data) ``` -------------------------------- ### cURL Request: With GPS Accuracy and Gap Filling Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/endpoints.md This example shows how to include GPS accuracy in meters and enable gap filling for route matching. The `--data-urlencode` flag is used for parameters. ```bash curl -X POST "http://localhost:8989/match" \ -H "Content-Type: application/gpx+xml" \ -G \ --data-urlencode "profile=non_tgv" \ --data-urlencode "type=json" \ --data-urlencode "gps_accuracy=20" \ --data-urlencode "fill_gaps=true" \ -d @track.gpx ``` -------------------------------- ### OSMGaugeParser Example Tags Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/parsers.md Illustrates how different 'gauge' tag values are processed and stored, including valid values, ignored non-numeric values, out-of-range values, and the expected behavior for malformed tags. ```plaintext gauge=1435 → stored as 1435 gauge=1000 → stored as 1000 gauge=abc → ignored (NumberFormatException) gauge=2500 → ignored (exceeds max 2047) gauge=1435;1000 → raises IllegalArgumentException (should be split by OSMReader) ``` -------------------------------- ### GPX Response Example Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/endpoints.md This XML structure conforms to the GPX standard, suitable for use with GPS devices and mapping software. It includes route points and track segments. The Content-Type header will be application/gpx+xml. ```xml 2024 https://www.openstreetmap.org/copyright 0: Continue on Rue de Rivoli ... ... ``` -------------------------------- ### JSON Response Example Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/endpoints.md This is a typical JSON response structure for a routing query. It includes path details, map matching information, and request metadata. Use this format for applications requiring structured data. ```json { "paths": [ { "distance": 1234.56, "time": 45000, "instructions": [ { "text": "Continue on Rue de Rivoli", "distance": 234.0, "time": 10000, "sign": 0 } ], "points": "yvxwFzuysV...", "points_encoded": true, "bbox": [2.3522, 48.8566, 2.3535, 48.8575], "snapped_waypoints": "encoded_polyline", "legs": [ { "distance": 1234.56, "time": 45000, "instructions": [...] } ] } ], "map_matching": { "distance": 1234.56, "time": 45000, "original_distance": 1250.00 }, "traversal_keys": [123, 456, 789], "info": { "copyrights": ["© OpenStreetMap contributors"], "took": 125 } } ``` -------------------------------- ### Basic Serve Command Syntax Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/commands.md This is the basic syntax for running the serve command. Ensure you have the correct JAR file and configuration. ```bash java -Xmx2500m [SYSTEM_PROPERTIES] \ -jar railway_routing-0.0.1-SNAPSHOT.jar \ serve config.yml ``` -------------------------------- ### Serve Command Overview Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/commands.md This section describes the 'serve' command, its syntax, and the system properties that can be used to configure the server's behavior, such as data file locations, cache directories, and ports. ```APIDOC ## serve Command Runs the HTTP server for routing, map-matching, and isochrones. ### Syntax ```bash java -Xmx2500m [SYSTEM_PROPERTIES] \ -jar railway_routing-0.0.1-SNAPSHOT.jar \ serve config.yml ``` ### System Properties | Property | Type | Default | Description | |----------|------|---------|-------------| | dw.graphhopper.datareader.file | String | "" | OSM file (used for initialization if cache not found) | | dw.graphhopper.graph.location | String | ./graph-cache | Graph cache directory | | dw.server.applicationConnector.port | Integer | 8989 | HTTP API port | | dw.server.adminConnector.port | Integer | 8990 | Admin/metrics port | ### Configuration File Settings ```yaml graphhopper: graph.location: ./graph-cache profiles: - name: tgv_all custom_model_files: [rail.json] server: applicationConnectors: - type: http port: 8989 adminConnectors: - type: http port: 8990 ``` ### Behavior 1. Reads graph from graph.location directory (or imports if not present) 2. Initializes all configured profiles 3. Starts Dropwizard HTTP server on configured port 4. Registers REST endpoints: /route, /match, /isochrone, /nearest, /info, etc. 5. Registers web frontend at /maps 6. Listens for incoming requests ``` -------------------------------- ### Get GraphHopper Configuration Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/api-reference.md Retrieves the GraphHopper configuration from the server settings. ```java public GraphHopperConfig getGraphHopperConfiguration() ``` -------------------------------- ### Startup Verification Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/commands.md Provides commands to verify the server startup by checking the '/info' and '/health' endpoints, along with expected responses. ```APIDOC ### Startup Verification ```bash curl http://localhost:8989/info ``` Expected response: ```json { "version": "1.1", "profiles": ["tgv_all", "tramtrain", ...], "profiles_ch": ["tgv_all", "tramtrain"], "encoded_values": ["gauge", "voltage", ...] } ``` ### Health Check ```bash curl http://localhost:8989/health ``` ``` -------------------------------- ### InputCSVEntry Accessors Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/api-reference.md Accessor methods for setting and getting latitude and longitude values in an InputCSVEntry. ```APIDOC ## setLatitude(double lat) ### Description Sets the latitude value for the CSV entry. ### Method ```java void setLatitude(double lat) ``` ``` ```APIDOC ## setLongitude(double lon) ### Description Sets the longitude value for the CSV entry. ### Method ```java void setLongitude(double lon) ``` ``` ```APIDOC ## getLatitude() ### Description Retrieves the latitude value from the CSV entry. ### Method ```java double getLatitude() ``` ### Return latitude value ``` ```APIDOC ## getLongitude() ### Description Retrieves the longitude value from the CSV entry. ### Method ```java double getLongitude() ``` ### Return longitude value ``` -------------------------------- ### Startup Verification Expected /info Response Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/commands.md The expected JSON response from the /info endpoint upon successful startup. It includes version, profiles, and encoded values. ```json { "version": "1.1", "profiles": ["tgv_all", "tramtrain", ...], "profiles_ch": ["tgv_all", "tramtrain"], "encoded_values": ["gauge", "voltage", ...] } ``` -------------------------------- ### InputCSVEntry Accessors Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/api-reference.md Defines methods for setting and getting latitude and longitude values for a CSV trackpoint entry. ```java void setLatitude(double lat) void setLongitude(double lon) double getLatitude() double getLongitude() ``` -------------------------------- ### Match Command Syntax Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/commands.md Basic syntax for executing the 'match' command. Requires Java, the routing JAR, and a configuration file. ```bash java -Xmx2500m [SYSTEM_PROPERTIES] \ -jar railway_routing-0.0.1-SNAPSHOT.jar \ match [OPTIONS] config.yml ``` -------------------------------- ### Minimal Configuration for Serving Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/configuration.md A basic configuration for serving the routing service. It specifies the input data file and the cache location for the graph. Includes two profiles with different custom model files. ```yaml graphhopper: datareader.file: /data/europe.pbf graph.location: ./graph-cache profiles: - name: tgv_all custom_model_files: [all_tracks.json] - name: tgv_gauge_1435 custom_model_files: [all_tracks.json, gauge_1435.json] server: applicationConnectors: - type: http port: 8989 ``` -------------------------------- ### Match Command with System Properties Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/configuration.md Configure the match command using system properties, such as the graph cache location. Ensure the `dw.graphhopper.graph.location` is correctly set. ```bash java -Xmx2500m \ -Ddw.graphhopper.graph.location=./graph-cache \ -jar railway_routing-0.0.1-SNAPSHOT.jar \ match \ --profile tgv_all \ --gpx-location="/path/to/tracks/*.gpx" \ config.yml ``` -------------------------------- ### GraphHopper Encoded Values Configuration Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/configuration.md Configure a comma-separated list of encoded values to store per edge. This example includes railway-specific and standard GraphHopper encoded values. ```yaml graphhopper: graph.encoded_values: gauge,voltage,electrified,frequency,railway_class,railway_service,preferred_direction,road_environment,max_speed,rail_access,rail_average_speed ``` -------------------------------- ### Import Command with System Properties Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/configuration.md Use system properties prefixed with `-D` to override configuration for the import command. Specify the OSM input file and graph cache location. ```bash java -Xmx2500m \ -Ddw.graphhopper.datareader.file=/path/to/map.pbf \ -Ddw.graphhopper.graph.location=./graph-cache \ -jar railway_routing-0.0.1-SNAPSHOT.jar \ import config.yml ``` -------------------------------- ### Custom Model Configuration for Encoded Values Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/types.md Examples of referencing encoded values within custom models for routing logic. Demonstrates conditional priority and area allowances based on encoded values. ```json { "priority": [ ["if", ["==", "railway_class", "rail"], 100], ["if", ["==", "electrified", "contact_line"], 90], ["else", 50] ], "areas": [ ["if", ["in", "gauge", [1435, 0]], "allow"] ] } ``` -------------------------------- ### Dropwizard Server Configuration (YAML) Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/configuration.md Configure application and admin ports, and request logging. Ensure the `server.applicationConnectors[0].port` is set to your desired API port. ```yaml server: applicationConnectors: - type: http port: 8989 adminConnectors: - type: http port: 8990 requestLog: appenders: - type: file currentLogFilename: logs/request.log ``` -------------------------------- ### Base Configuration File Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/commands.md Defines the base configuration for the application. Settings in this file can be overridden by system properties and command-line arguments. ```yaml # config.yml graphhopper: graph.location: /default/cache ``` -------------------------------- ### Initialize and Update Git Submodules Source: https://github.com/geofabrik/openrailrouting/blob/master/README.md Before building, initialize and update the Git submodules to ensure all necessary components are present. This is a prerequisite for the Maven build. ```sh git submodule init git submodule update ``` -------------------------------- ### Electrified Usage in Custom Models Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/types.md Example of how to use the electrified encoded value within a custom routing model to check for specific conditions, such as routing electric multiple units on overhead catenary lines. ```python if electrified == CONTACT_LINE && vehicle_types == electric_multiple_unit { # Allow routing on electrified tracks } ``` -------------------------------- ### Launch Railway Routing Application Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/api-reference.md Launches the Dropwizard web service for railway routing. Requires a configuration file and sufficient memory allocation. ```java public static void main(String[] args) throws Exception ``` ```bash java -Xmx2500m -jar railway_routing-0.0.1-SNAPSHOT.jar serve config.yml ``` -------------------------------- ### CSV Response Example Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/endpoints.md A simple CSV format providing longitude and latitude coordinates. This is useful for quick data export or integration with tools that primarily use comma-separated values. The Content-Type header will be text/csv. ```csv longitude;latitude 2.3522;48.8566 2.3523;48.8567 ``` -------------------------------- ### RailwayHopper Initialization and Loading Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/api-reference.md Methods for configuring, initializing, loading, and importing data into the `RailwayHopper` instance. ```java void setGraphHopperLocation(String location) GraphHopper init(GraphHopperConfig config) void load() void importAndClose() ``` -------------------------------- ### OpenRailRouting Import Command with System Properties Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/commands.md Specifies input OSM file and output graph directory using Java system properties for the import command. This is the preferred method for setting these paths. ```bash java -Xmx2500m \ -Ddw.graphhopper.datareader.file=/path/to/input.pbf \ -Ddw.graphhopper.graph.location=./graph-cache \ -jar railway_routing-0.0.1-SNAPSHOT.jar \ import config.yml ``` -------------------------------- ### Set JVM Heap Memory Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/commands.md Use -Xmx to set the maximum heap size and -Xms for the initial heap size. Recommended settings vary based on graph size. ```bash java -Xmx2500m -Xms50m -jar railway_routing-0.0.1-SNAPSHOT.jar ... ``` -------------------------------- ### Glob Pattern Shell Expansion - Correct Usage Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/commands.md Demonstrates the correct way to use glob patterns with the --gpx-location argument by enclosing the pattern in quotes to prevent shell expansion. ```bash java -jar railway_routing-0.0.1-SNAPSHOT.jar match --gpx-location="/data/*.gpx" config.yml ``` -------------------------------- ### Map-Matching GPX Files Command Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/api-reference.md Command-line interface for batch map-matching GPX files. Use this to process GPS tracks. ```bash java -jar railway_routing-0.0.1-SNAPSHOT.jar match \ --profile tgv_all \ --gpx-location="/path/to/tracks/*.gpx" \ --gps-accuracy 40 \ --max-nodes 10000 \ config.yml ``` -------------------------------- ### Use Custom Attribute in Routing Model Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/architecture.md Define routing priorities based on custom encoded values within a JSON custom model file. This example shows setting priority based on the 'my_attr' value. ```json { "priority": [ ["if", ["==", "my_attr", "VALUE1"], 100], ["else", 50] ] } ``` -------------------------------- ### RailwayRoutingApplication.main Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/api-reference.md Launches the Dropwizard web service for railway routing. ```APIDOC ## main ### Description Launches the web service. ### Method Signature ```java public static void main(String[] args) throws Exception ``` ### Usage ```bash java -Xmx2500m -jar railway_routing-0.0.1-SNAPSHOT.jar serve config.yml ``` ``` -------------------------------- ### Multi-Profile Configuration with Custom Models Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/configuration.md Configuration for multiple profiles, including 'non_tgv', 'light_rail_1000mm', and 'metro_all', each with specific turn costs and custom model files. It also defines CH and LM profiles and routing parameters. ```yaml graphhopper: datareader.file: /data/world.pbf graph.location: /mnt/cache/graph custom_models.directory: /etc/openrailrouting/models profiles: - name: non_tgv turn_costs: vehicle_types: [train] u_turn_costs: 900 custom_model_files: [rail.json, non_tgv.json, preferred_direction.json] - name: light_rail_1000mm turn_costs: vehicle_types: [light_rail] u_turn_costs: 180 custom_model_files: [light_rail.json, gauge_1000.json] - name: metro_all turn_costs: vehicle_types: [subway] u_turn_costs: 120 custom_model_files: [subway.json] profiles_ch: - profile: non_tgv - profile: light_rail_1000mm - profile: metro_all routing.max_visited_nodes: 50000 routing.non_ch.max_waypoint_distance: 10000000 ``` -------------------------------- ### Match GPX Files Command Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/architecture.md Defines the 'match' command for the command-line interface, used for batch processing GPX files for map-matching. ```java RailwayMatchCommand - Command: `match` - Batch GPX file matching - Argument parsing for --profile, --gpx-location - Glob pattern expansion for multiple files ``` -------------------------------- ### GraphHopper Preparation (Speed/Hybrid Mode) Configuration Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/configuration.md Specify profiles for Contraction Hierarchies (CH) and Landmarks (LM) preparation. CH is used for faster routing, while LM offers flexible speed-up. ```yaml graphhopper: profiles_ch: - profile: profile_name profiles_lm: [] ``` -------------------------------- ### Full Feature Configuration Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/configuration.md An extensive configuration enabling various features like encoded values, custom models directory, detailed profile settings including turn costs, and specific configurations for CH and LM profiles. Also includes server and logging settings. ```yaml graphhopper: datareader.file: /data/france.pbf graph.location: ./graph-cache graph.encoded_values: gauge,voltage,electrified,frequency,railway_class,railway_service,preferred_direction,road_environment,max_speed,rail_access,rail_average_speed custom_models.directory: ./custom_models profiles: - name: tgv_all turn_costs: vehicle_types: [train] u_turn_costs: 300 enable_uturn_times: true custom_model_files: [rail.json, tgv_all.json, preferred_direction.json] - name: tramtrain turn_costs: vehicle_types: [train, tram, light_rail] u_turn_costs: 180 enable_uturn_times: true custom_model_files: [tramtrain.json, gauge_1435.json] profiles_ch: - profile: tgv_all - profile: tramtrain profiles_lm: [] routing.max_visited_nodes: 10000 server: applicationConnectors: - type: http port: 8989 adminConnectors: - type: http port: 8990 logging: level: INFO appenders: - type: file currentLogFilename: logs/application.log archive: true archivedLogFilenamePattern: logs/application-%d.log ``` -------------------------------- ### General OpenRailRouting CLI Usage Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/commands.md This is the general structure for running any OpenRailRouting CLI command. Adjust memory allocation (-Xmx) and system properties as needed. The configuration file is always the last argument. ```bash java -Xmx2500m [SYSTEM_PROPERTIES] \ -jar railway_routing-0.0.1-SNAPSHOT.jar \ [COMMAND] [COMMAND_ARGS] [CONFIG_FILE] ``` -------------------------------- ### Import Graph with OpenRailRouting Source: https://github.com/geofabrik/openrailrouting/blob/master/README.md Use the 'import' action to load the graph data. Specify the input OSM file with --input and the output directory for the graph cache with --output. Alternatively, set graphhopper.datareader.file and graphhopper.graph.location as Java system properties or in the config file. ```sh java -jar target/railway_routing-0.0.1-SNAPSHOT.jar import --input PATH --output PATH ``` -------------------------------- ### Import OSM Data Command Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/api-reference.md Command-line interface for importing OpenStreetMap data into the graph cache. Use this to prepare routing data. ```bash java -jar railway_routing-0.0.1-SNAPSHOT.jar import \ -i input.osm.pbf \ -o ./graph-cache \ config.yml ``` -------------------------------- ### Configuration File Snippet Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/commands.md A snippet showing the configuration for the graph location within the YAML configuration file. ```yaml graphhopper: graph.location: ./graph-cache ``` -------------------------------- ### Perform Map Matching with OpenRailRouting Source: https://github.com/geofabrik/openrailrouting/blob/master/README.md Use the 'match' action for map matching. The --gpx-location argument is required and can be a single file or a wildcard pattern (enclosed in quotes). The -V or --vehicle argument specifies the routing profile. Optional arguments include GPS accuracy and max nodes. ```sh java -jar target/railway_routing-0.0.1-SNAPSHOT-jar-with-dependencies.jar match config.yml --gpx-location="path/to/files/*.gpx" -V VEHICLE ``` -------------------------------- ### OpenRailRouting Import Configuration File Settings Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/commands.md Alternative to system properties, these settings can be specified within the YAML configuration file for the import command. This allows for centralized configuration. ```yaml graphhopper: datareader.file: /data/map.pbf graph.location: ./graph-cache ``` -------------------------------- ### Constructor for OSMFrequencyParser Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/parsers.md Initializes the OSMFrequencyParser with a DecimalEncodedValue for frequency. ```java public OSMFrequencyParser(DecimalEncodedValue frequencyEnc) ``` -------------------------------- ### Initialize OSMRailwayServiceParser Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/parsers.md Constructor for OSMRailwayServiceParser. Requires an EnumEncodedValue for RailwayService. ```java public OSMRailwayServiceParser(EnumEncodedValue railwayServiceEnc) ``` -------------------------------- ### Run OpenRailRouting Engine Source: https://github.com/geofabrik/openrailrouting/blob/master/README.md Execute the main routing engine JAR file. Adjust -Xmx and -Xms for memory allocation. Specify the OSM data file using -Ddw.graphhopper.datareader.file. The ACTION and CONFIG_FILE are mandatory. ```sh java -Xmx2500m -Xms50m \ -Ddw.graphhopper.datareader.file=$OSMFILE \ -jar target/railway_routing-0.0.1-SNAPSHOT.jar ACTION [ARGUMENTS] CONFIG_FILE [OPTARG] ``` -------------------------------- ### YAML Configuration with Environment Variable Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/configuration.md Use shell expansion in YAML to reference environment variables. The graph.location is set using the previously exported GRAPH_LOCATION. ```yaml graphhopper: graph.location: ${GRAPH_LOCATION} ``` -------------------------------- ### Query Parameters Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/endpoints.md All parameters are optional except `profile`. This section details the available query parameters for routing requests. ```APIDOC ## Query Parameters All parameters are optional except `profile`. | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | profile | String | — | **Required.** Routing profile name (e.g., "tgv_all", "tramtrain") | | type | String | json | Output format: "json", "gpx", "csv" | | gps_accuracy | Double | 40 | GPS measurement error sigma in meters | | fill_gaps | Boolean | false | Fill unmatched gaps using routing | | max_visited_nodes | Integer | 3000 | Maximum graph nodes to visit during matching | | calcPoints | Boolean | true | Include path geometry in response | | instructions | Boolean | true | Include turn-by-turn instructions | | elevation | Boolean | false | Include elevation profile | | locale | String | en | Locale for instruction text (e.g., "de", "fr") | | path_details | List | — | Additional details per edge: "road_class", "max_speed", "railway_class", "gauge", "voltage", "frequency", "electrified", "railway_service" | | points_encoded | Boolean | true | Encode path polyline (vs. explicit lat/lon) | | points_encoded_multiplier | Double | 1e5 | Precision multiplier for polyline encoding | | way_point_max_distance | Double | 1 | Douglas-Peucker simplification threshold (meters) | | gpx.route | Boolean | true | Include route element in GPX output | | gpx.track | Boolean | true | Include track element in GPX output | | traversal_keys | Boolean | false | Include edge traversal keys in JSON | | csv_input.separator | Char | ; | CSV field separator | | csv_input.quoteChar | Char | " | CSV quote character | | csv_output.separator | Char | ; | CSV output field separator | ``` -------------------------------- ### Import GPX Stream Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/api-reference.md Parses a GPX XML formatted InputStream into a list of observations. Ensure the stream contains valid GPX data with trackpoints. ```java public static List importGpx(InputStream inputStream) ``` -------------------------------- ### Initialize OSMRailwayClassParser Source: https://github.com/geofabrik/openrailrouting/blob/master/_autodocs/parsers.md Constructor for OSMRailwayClassParser. Requires an EnumEncodedValue for RailwayClass. ```java public OSMRailwayClassParser(EnumEncodedValue railwayClassEnc) ```