### OSRM Service Request Examples Source: https://project-osrm.org/docs/v5.24.0/api Examples of using curl to perform routing queries with coordinates, exclusions, and polyline encoding. ```bash curl 'http://router.project-osrm.org/route/v1/driving/13.388860,52.517037;13.397634,52.529407;13.428555,52.523219?overview=false' ``` ```bash curl 'http://router.project-osrm.org/route/v1/driving/13.388860,52.517037;13.397634,52.529407?exclude=motorway' ``` ```bash curl 'http://router.project-osrm.org/route/v1/driving/polyline(ofp_Ik_vpAilAyu@te@g`E)?overview=false' ``` -------------------------------- ### Trip Service Example Requests Source: https://project-osrm.org/docs/v5.24.0/api Examples of using curl to request a trip route in Berlin with different waypoint counts and constraints. ```bash # Round trip in Berlin with three stops: curl 'http://router.project-osrm.org/trip/v1/driving/13.388860,52.517037;13.397634,52.529407;13.428555,52.523219' ``` ```bash # Round trip in Berlin with four stops, starting at the first stop, ending at the last: curl 'http://router.project-osrm.org/trip/v1/driving/13.388860,52.517037;13.397634,52.529407;13.428555,52.523219;13.418555,52.523215?source=first&destination=last' ``` -------------------------------- ### RouteLeg object JSON example Source: https://project-osrm.org/docs/v5.24.0/api Example of a RouteLeg object response with steps disabled and annotations enabled. ```json { "distance": 30.0, "duration": 100.0, "weight": 100.0, "steps": [], "annotation": { "distance": [5,5,10,5,5], "duration": [15,15,40,15,15], "datasources": [1,0,0,0,1], "metadata": { "datasource_names": ["traffic","lua profile","lua profile","lua profile","traffic"] }, "nodes": [49772551,49772552,49786799,49786800,49786801,49786802], "speed": [0.3, 0.3, 0.3, 0.3, 0.3] } } ``` -------------------------------- ### Route object JSON example Source: https://project-osrm.org/docs/v5.24.0/api Example of a Route object response with three waypoints, geojson geometry, and steps disabled. ```json { "distance": 90.0, "duration": 300.0, "weight": 300.0, "weight_name": "duration", "geometry": {"type": "LineString", "coordinates": [[120.0, 10.0], [120.1, 10.0], [120.2, 10.0], [120.3, 10.0]]}, "legs": [ { "distance": 30.0, "duration": 100.0, "steps": [] }, { "distance": 60.0, "duration": 200.0, "steps": [] } ] } ``` -------------------------------- ### Annotation object JSON example Source: https://project-osrm.org/docs/v5.24.0/api Example of an Annotation object providing fine-grained information for a route leg. ```json { "distance": [5,5,10,5,5], "duration": [15,15,40,15,15], "datasources": [1,0,0,0,1], "metadata": { "datasource_names": ["traffic","lua profile","lua profile","lua profile","traffic"] }, "nodes": [49772551,49772552,49786799,49786800,49786801,49786802], "weight": [15,15,40,15,15] } ``` -------------------------------- ### GET /trip/v1/{profile}/{coordinates} Source: https://project-osrm.org/docs/v5.24.0/api Calculates a trip through the provided coordinates, solving the Traveling Salesman Problem. ```APIDOC ## GET /trip/v1/{profile}/{coordinates} ### Description The trip plugin solves the Traveling Salesman Problem using a greedy heuristic for 10 or more waypoints and brute force for less than 10. It returns an approximate path through the provided coordinates. ### Method GET ### Endpoint /trip/v1/{profile}/{coordinates} ### Parameters #### Path Parameters - **profile** (string) - Required - The mode of transport (e.g., driving). - **coordinates** (string) - Required - Semicolon-separated list of longitude,latitude coordinates. #### Query Parameters - **roundtrip** (boolean) - Optional - Whether the route returns to the first location (default: true). - **source** (string) - Optional - Start coordinate constraint: 'any' or 'first' (default: 'any'). - **destination** (string) - Optional - End coordinate constraint: 'any' or 'last' (default: 'any'). - **steps** (boolean) - Optional - Whether to return route instructions (default: false). - **annotations** (string) - Optional - Metadata to return for each coordinate (e.g., nodes, distance, duration). - **geometries** (string) - Optional - Geometry format: 'polyline', 'polyline6', or 'geojson' (default: 'polyline'). - **overview** (string) - Optional - Overview geometry detail: 'simplified', 'full', or 'false' (default: 'simplified'). ### Response #### Success Response (200) - **code** (string) - Status code of the request. - **waypoints** (array) - Array of Waypoint objects. - **trips** (array) - Array of Route objects. ``` -------------------------------- ### GET /route/v1/{profile}/{coordinates} Source: https://project-osrm.org/docs/v5.24.0/api Finds the fastest route between coordinates in the supplied order. ```APIDOC ## GET /route/v1/{profile}/{coordinates} ### Description Finds the fastest route between coordinates in the supplied order. ### Method GET ### Endpoint /route/v1/{profile}/{coordinates} ### Parameters #### Path Parameters - **profile** (string) - Required - The routing profile. - **coordinates** (string) - Required - Semicolon-separated list of {longitude},{latitude} pairs. #### Query Parameters - **alternatives** (boolean/number) - Optional - Search for alternative routes. - **steps** (boolean) - Optional - Returned route steps for each route leg. - **geometries** (string) - Optional - Returned route geometry format (polyline, polyline6, geojson). - **overview** (string) - Optional - Add overview geometry (simplified, full, false). - **annotations** (string) - Optional - Returns additional metadata for each coordinate. ### Response #### Success Response (200) - **code** (string) - Status code (e.g., "Ok"). - **waypoints** (array) - Array of Waypoint objects. - **routes** (array) - Array of Route objects. ``` -------------------------------- ### Fetch a Vector Tile Source: https://project-osrm.org/docs/v5.24.0/api Example request to retrieve a Z=13 tile for a specific coordinate using curl. ```bash # This fetches a Z=13 tile for downtown San Francisco: curl 'http://router.project-osrm.org/tile/v1/car/tile(1310,3166,13).mvt' ``` -------------------------------- ### Execute Table Service Requests Source: https://project-osrm.org/docs/v5.24.0/api Examples of cURL requests for generating duration and distance matrices using different parameters and coordinate formats. ```bash # Returns a 3x3 duration matrix: curl 'http://router.project-osrm.org/table/v1/driving/13.388860,52.517037;13.397634,52.529407;13.428555,52.523219' # Returns a 1x3 duration matrix curl 'http://router.project-osrm.org/table/v1/driving/13.388860,52.517037;13.397634,52.529407;13.428555,52.523219?sources=0' # Returns a asymmetric 3x2 duration matrix with from the polyline encoded locations `qikdcB}~dpXkkHz`: curl 'http://router.project-osrm.org/table/v1/driving/polyline(egs_Iq_aqAppHzbHulFzeMe`EuvKpnCglA)?sources=0;1;3&destinations=2;4' # Returns a 3x3 duration matrix: curl 'http://router.project-osrm.org/table/v1/driving/13.388860,52.517037;13.397634,52.529407;13.428555,52.523219?annotations=duration' # Returns a 3x3 distance matrix for CH: curl 'http://router.project-osrm.org/table/v1/driving/13.388860,52.517037;13.397634,52.529407;13.428555,52.523219?annotations=distance' # Returns a 3x3 duration matrix and a 3x3 distance matrix for CH: curl 'http://router.project-osrm.org/table/v1/driving/13.388860,52.517037;13.397634,52.529407;13.428555,52.523219?annotations=distance,duration' ``` -------------------------------- ### GET /nearest/v1/{profile}/{coordinates} Source: https://project-osrm.org/docs/v5.24.0/api Snaps a coordinate to the street network and returns the nearest n matches. ```APIDOC ## GET /nearest/v1/{profile}/{coordinates} ### Description Snaps a coordinate to the street network and returns the nearest n matches. ### Method GET ### Endpoint http://{server}/nearest/v1/{profile}/{coordinates}.json?number={number} ### Parameters #### Path Parameters - **profile** (string) - Required - The routing profile (e.g., driving). - **coordinates** (string) - Required - The coordinate as {longitude},{latitude}. #### Query Parameters - **number** (integer) - Optional - Number of nearest segments that should be returned (default 1). ### Response #### Success Response (200) - **code** (string) - Status code (e.g., "Ok"). - **waypoints** (array) - Array of Waypoint objects sorted by distance. #### Response Example { "waypoints" : [ { "nodes": [2264199819, 0], "hint" : "KSoKADRYroqUBAEAEAAAABkAAAAGAAAAAAAAABhnCQCLtwAA_0vMAKlYIQM8TMwArVghAwEAAQH1a66g", "distance" : 4.152629, "name" : "Friedrichstraße", "location" : [13.388799, 52.517033] } ], "code" : "Ok" } ``` -------------------------------- ### GET /table/v1/{profile}/{coordinates} Source: https://project-osrm.org/docs/v5.24.0/api Computes the duration and/or distance of the fastest route between all pairs of supplied coordinates. ```APIDOC ## GET /table/v1/{profile}/{coordinates} ### Description Computes the duration of the fastest route between all pairs of supplied coordinates. Returns the durations or distances or both between the coordinate pairs. ### Method GET ### Endpoint /table/v1/{profile}/{coordinates} ### Parameters #### Path Parameters - **profile** (string) - Required - The routing profile (e.g., driving). - **coordinates** (string) - Required - The coordinates to use, either as semicolon-separated lon,lat pairs or a polyline. #### Query Parameters - **sources** (string) - Optional - Use location with given index as source (e.g., 0;5;7). - **destinations** (string) - Optional - Use location with given index as destination (e.g., 5;1;4). - **annotations** (string) - Optional - Return the requested table or tables (duration, distance, or duration,distance). - **fallback_speed** (double) - Optional - Speed used to estimate duration if no route is found. - **fallback_coordinate** (string) - Optional - Use input or snapped coordinate for fallback calculations. - **scale_factor** (double) - Optional - Scales the table duration values. ### Response #### Success Response (200) - **code** (string) - Status code (e.g., Ok). - **durations** (array) - Matrix of travel times in seconds. - **distances** (array) - Matrix of travel distances in meters. - **sources** (array) - Waypoint objects for sources. - **destinations** (array) - Waypoint objects for destinations. - **fallback_speed_cells** (array) - Optional matrix of i,j pairs for estimated values. ``` -------------------------------- ### Waypoint Object JSON Example Source: https://project-osrm.org/docs/v5.24.0/api Describes a snapped coordinate on a route, including street name, distance, and a hint for query optimization. ```json { "hint" : "KSoKADRYroqUBAEAEAAAABkAAAAGAAAAAAAAABhnCQCLtwAA_0vMAKlYIQM8TMwArVghAwEAAQH1a66g", "distance" : 4.152629, "name" : "Friedrichstraße", "location" : [ 13.388799, 52.517033 ] } ``` -------------------------------- ### GET /tile/v1/{profile}/tile({x},{y},{zoom}).mvt Source: https://project-osrm.org/docs/v5.24.0/api Retrieves a vector tile for a specific profile, coordinate, and zoom level. ```APIDOC ## GET /tile/v1/{profile}/tile({x},{y},{zoom}).mvt ### Description Generates Mapbox Vector Tiles containing road geometries and metadata for the routing graph. Tiles are only available for zoom level 12 and higher. ### Method GET ### Endpoint /tile/v1/{profile}/tile({x},{y},{zoom}).mvt ### Parameters #### Path Parameters - **profile** (string) - Required - The routing profile (e.g., car). - **x** (integer) - Required - The x coordinate of the tile. - **y** (integer) - Required - The y coordinate of the tile. - **zoom** (integer) - Required - The zoom level (must be >= 12). ### Response #### Success Response (200) - **Content-Type** (application/x-protobuf) - Binary encoded vector tile blob containing 'speeds' and 'turns' layers. ``` -------------------------------- ### Query Route Service Source: https://project-osrm.org/docs/v5.24.0/api Example of using curl to request a route between three coordinates in Berlin without returning overview geometry. ```bash # Query on Berlin with three coordinates and no overview geometry returned: curl 'http://router.project-osrm.org/route/v1/driving/13.388860,52.517037;13.397634,52.529407;13.428555,52.523219?overview=false' ``` -------------------------------- ### Query Nearest Locations Source: https://project-osrm.org/docs/v5.24.0/api Example of using curl to find the three nearest snapped locations for a specific coordinate with bearing constraints. ```bash # Querying nearest three snapped locations of `13.388860,52.517037` with a bearing between `20° - 340°`. curl 'http://router.project-osrm.org/nearest/v1/driving/13.388860,52.517037?number=3&bearings=0,20' ``` -------------------------------- ### Lane Object JSON Example Source: https://project-osrm.org/docs/v5.24.0/api Represents a turn lane at a specific location, including road indications and validity status. ```json { "indications": ["left", "straight"], "valid": "false" } ``` -------------------------------- ### GET /match/v1/{profile}/{coordinates} Source: https://project-osrm.org/docs/v5.24.0/api Matches a sequence of GPS coordinates to the road network. This endpoint processes input points and returns the most plausible route match, including support for steps, geometries, and metadata annotations. ```APIDOC ## GET /match/v1/{profile}/{coordinates} ### Description Matches given GPS points to the road network in the most plausible way. The service handles noisy data and can split traces based on large timestamp gaps. ### Method GET ### Endpoint /match/v1/{profile}/{coordinates} ### Parameters #### Path Parameters - **profile** (string) - Required - The mode of transport (e.g., driving, cycling). - **coordinates** (string) - Required - A list of semicolon-separated coordinates (longitude,latitude). #### Query Parameters - **steps** (boolean) - Optional - Returned route steps for each route. - **geometries** (string) - Optional - Returned route geometry format (polyline, polyline6, geojson). - **overview** (string) - Optional - Add overview geometry (simplified, full, false). - **annotations** (string) - Optional - Returns additional metadata for each coordinate. - **timestamps** (string) - Optional - Timestamps for the input locations in seconds since UNIX epoch. - **radiuses** (string) - Optional - Standard deviation of GPS precision for each point. - **gaps** (string) - Optional - Allows input track splitting (split, ignore). - **tidy** (boolean) - Optional - Allows input track modification for better quality. - **waypoints** (string) - Optional - Indices of input coordinates to treat as waypoints. ### Response #### Success Response (200) - **code** (string) - Status code (e.g., "Ok"). - **tracepoints** (array) - Array of Waypoint objects representing all points of the trace. - **matchings** (array) - Array of Route objects that assemble the trace. ``` -------------------------------- ### Intersection Object JSON Example Source: https://project-osrm.org/docs/v5.24.0/api Describes a cross-way, including location, available bearings, entry flags, and associated lane information. ```json { "location":[13.394718,52.543096], "in":0, "out":2, "bearings":[60,150,240,330], "entry":["false","true","true","true"], "classes": ["toll", "restricted"], "lanes":{ "indications": ["left", "straight"], "valid": "false" } } ``` -------------------------------- ### GET /{service}/{version}/{profile}/{coordinates} Source: https://project-osrm.org/docs/v5.24.0/api General structure for all OSRM service requests. This endpoint allows querying routing services by specifying the service type, protocol version, profile, and coordinates. ```APIDOC ## GET /{service}/{version}/{profile}/{coordinates}[.{format}] ### Description Performs a request to one of the OSRM services (route, nearest, table, match, trip, or tile) using the specified profile and coordinates. ### Method GET ### Endpoint /{service}/{version}/{profile}/{coordinates}[.{format}] ### Parameters #### Path Parameters - **service** (string) - Required - One of: route, nearest, table, match, trip, tile - **version** (string) - Required - Protocol version, e.g., v1 - **profile** (string) - Required - Mode of transportation (e.g., car, bike, foot) - **coordinates** (string) - Required - Coordinates in {longitude},{latitude} format or polyline/polyline6 #### Query Parameters - **format** (string) - Optional - json or flatbuffers - **bearings** (string) - Optional - Limits search to segments with given bearing - **radiuses** (string) - Optional - Limits search to given radius in meters - **generate_hints** (boolean) - Optional - Adds a Hint to the response - **hints** (string) - Optional - Hint from previous request - **approaches** (string) - Optional - Keep waypoints on curb side - **exclude** (string) - Optional - Additive list of classes to avoid - **snapping** (string) - Optional - default or any - **skip_waypoints** (boolean) - Optional - Removes waypoints from the response ### Response #### Success Response (200) - **code** (string) - Status code (Ok) - **message** (string) - Optional human-readable message - **data_version** (string) - Optional timestamp from the OSM file #### Error Response (400) - **code** (string) - Error code (e.g., InvalidUrl, InvalidService, NoSegment, TooBig) - **message** (string) - Optional human-readable error message ``` -------------------------------- ### Construct the OSRM Flatbuffers root object Source: https://project-osrm.org/docs/v5.24.0/api Use the generated Flatbuffers parser to initialize the root object from a raw input buffer. ```cpp auto osrm = osrm::engine::api::fbresult::GetFBResult(some_input_buffer); ``` -------------------------------- ### Configure Table Service Options Source: https://project-osrm.org/docs/v5.24.0/api Defines the sources and destinations indices for the table service request. ```text sources=0;5;7&destinations=5;1;4;2;3;6 ``` -------------------------------- ### Request Option Array Encoding Source: https://project-osrm.org/docs/v5.24.0/api Syntax for passing array-like parameters to OSRM services. ```text {option}={element};{element}[;{element} ... ] ``` ```text {option}={element};;{element} ``` -------------------------------- ### RouteStep JSON Representation Source: https://project-osrm.org/docs/v5.24.0/api A sample JSON object illustrating the structure of a RouteStep, including maneuver, intersection, and geometry data. ```json { "geometry" : "{lu_IypwpAVrAvAdI", "mode" : "driving", "duration" : 15.6, "weight" : 15.6, "intersections" : [ { "bearings" : [ 10, 92, 184, 270 ], "lanes" : [ { "indications" : [ "left", "straight" ], "valid" : "false" }, { "valid" : "true", "indications" : [ "right" ] } ], "out" : 2, "in" : 3, "entry" : [ "true", "true", "true", "false" ], "location" : [ 13.39677, 52.54366 ] }, { "out" : 1, "lanes" : [ { "indications" : [ "straight" ], "valid" : "true" }, { "indications" : [ "right" ], "valid" : "false" } ], "bearings" : [ 60, 240, 330 ], "in" : 0, "entry" : [ "false", "true", "true" ], "location" : [ 13.394718, 52.543096 ] } ], "name" : "Lortzingstraße", "distance" : 152.3, "maneuver" : { "modifier" : "right", "type" : "turn" } } ``` -------------------------------- ### Standard API Response Source: https://project-osrm.org/docs/v5.24.0/api The structure of a successful JSON response from an OSRM service. ```json { "code": "Ok", "message": "Everything worked", "data_version": "2017-11-17T21:43:02Z" } ``` -------------------------------- ### Nearest Service Response Source: https://project-osrm.org/docs/v5.24.0/api JSON response structure for a successful nearest service request. ```json { "waypoints" : [ { "nodes": [ 2264199819, 0 ], "hint" : "KSoKADRYroqUBAEAEAAAABkAAAAGAAAAAAAAABhnCQCLtwAA_0vMAKlYIQM8TMwArVghAwEAAQH1a66g", "distance" : 4.152629, "name" : "Friedrichstraße", "location" : [ 13.388799, 52.517033 ] }, { "nodes": [ 2045820592, 0 ], "hint" : "KSoKADRYroqUBAEABgAAAAAAAAAAAAAAKQAAABhnCQCLtwAA7kvMAAxZIQM8TMwArVghAwAAAQH1a66g", "distance" : 11.811961, "name" : "Friedrichstraße", "location" : [ 13.388782, 52.517132 ] }, { "nodes": [ 0, 21487242 ], "hint" : "KioKgDbbDgCUBAEAAAAAABoAAAAAAAAAPAAAABlnCQCLtwAA50vMADJZIQM8TMwArVghAwAAAQH1a66g", "distance" : 15.872438, "name" : "Friedrichstraße", "location" : [ 13.388775, 52.51717 ], } ], "code" : "Ok" } ``` -------------------------------- ### OSRM API JSON Response Structure Source: https://project-osrm.org/docs/v5.24.0/api Represents a successful API response containing location data, travel durations, and distances between points. ```json { "sources": [ { "location": [ 13.3888, 52.517033 ], "hint": "PAMAgEVJAoAUAAAAIAAAAAcAAAAAAAAArss0Qa7LNEHiVIRA4lSEQAoAAAAQAAAABAAAAAAAAADMAAAAAEzMAKlYIQM8TMwArVghAwEA3wps52D3", "name": "Friedrichstraße" }, { "location": [ 13.397631, 52.529432 ], "hint": "WIQBgL6mAoAEAAAABgAAAAAAAAA7AAAAhU6PQHvHj0IAAAAAQbyYQgQAAAAGAAAAAAAAADsAAADMAAAAf27MABiJIQOCbswA_4ghAwAAXwVs52D3", "name": "Torstraße" }, { "location": [ 13.428554, 52.523239 ], "hint": "7UcAgP___38fAAAAUQAAACYAAABTAAAAhSQKQrXq5kKRbiZCWJo_Qx8AAABRAAAAJgAAAFMAAADMAAAASufMAOdwIQNL58wA03AhAwMAvxBs52D3", "name": "Platz der Vereinten Nationen" } ], "durations": [ [ 0, 192.6, 382.8 ], [ 199, 0, 283.9 ], [ 344.7, 222.3, 0 ] ], "destinations": [ { "location": [ 13.3888, 52.517033 ], "hint": "PAMAgEVJAoAUAAAAIAAAAAcAAAAAAAAArss0Qa7LNEHiVIRA4lSEQAoAAAAQAAAABAAAAAAAAADMAAAAAEzMAKlYIQM8TMwArVghAwEA3wps52D3", "name": "Friedrichstraße" }, { "location": [ 13.397631, 52.529432 ], "hint": "WIQBgL6mAoAEAAAABgAAAAAAAAA7AAAAhU6PQHvHj0IAAAAAQbyYQgQAAAAGAAAAAAAAADsAAADMAAAAf27MABiJIQOCbswA_4ghAwAAXwVs52D3", "name": "Torstraße" }, { "location": [ 13.428554, 52.523239 ], "hint": "7UcAgP___38fAAAAUQAAACYAAABTAAAAhSQKQrXq5kKRbiZCWJo_Qx8AAABRAAAAJgAAAFMAAADMAAAASufMAOdwIQNL58wA03AhAwMAvxBs52D3", "name": "Platz der Vereinten Nationen" } ], "code": "Ok", "distances": [ [ 0, 1886.89, 3791.3 ], [ 1824, 0, 2838.09 ], [ 3275.36, 2361.73, 0 ] ], "fallback_speed_cells": [ [ 0, 1 ], [ 1, 0 ] ] } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.