Skip to content

Commit

Permalink
OSRM API for routes (#99)
Browse files Browse the repository at this point in the history
* [doc] add osrm spec

* [doc] add valhalla spec

* WIP: adding OSRM native API.

* WIP: OSRM native API: routing coordinates validation.

* WIP: Request parameters implemented when they match routeRequest's parameters, and ignored when not. OSRM controller's writeRouteResponse is being implemnted, but it will need modifications of RouteResponse class.

* WIP: implementing response writing for an OSRM native routing request. Slight edition of routeResponse and osrmSource classes to do so.

* WIP: OSRM controller implemented, but unpolished and untested.
TODO :
* complete logging and varible check
* test the code

* OSRM routing request seems to work. TODO:
* check result to see if every property is valid and exact.
* adapt getcapabilities to OSRM API capabilities.

* Fixed OSRM native response's waypoints, and intersections geometry format.

* fix and tests

* some littles changes and tests

* [doc] update version to 2.2.5

---------

Co-authored-by: Loic <[email protected]>
Co-authored-by: Xav Dmz <[email protected]>
  • Loading branch information
3 people authored Apr 4, 2024
1 parent 1e9172b commit a0c9483
Show file tree
Hide file tree
Showing 17 changed files with 1,485 additions and 8 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## 2.2.5

FEAT:
- The native OSRM API v1 was added but some parameters and error responses are still missing

## 2.2.4
FIXED:
- The pg module can emit error event and they were not catched and so it caused some crashs of Road2
Expand Down
4 changes: 4 additions & 0 deletions docker/config/service.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
{
"name" : "simple",
"version" : "1.0.0"
},
{
"name" : "osrm",
"version" : "1.0.0"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion docker/distributions/debian/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ RUN apt-get update && \
libsqlite3-mod-spatialite libzmq3-dev libczmq-dev

### Installation prime-server
COPY --from=build /usr/local/lib/libprime_server.so.0.7.0 /usr/lib/libprime_server.so.0.0.0
COPY --from=build /usr/local/lib/libprime_server.so.0.7.1 /usr/lib/libprime_server.so.0.0.0
COPY --from=build /usr/local/lib/libprime_server.so.0 /usr/lib/libprime_server.so.0
COPY --from=build /usr/local/lib/libprime_server.so /usr/lib/libprime_server.so

Expand Down
262 changes: 262 additions & 0 deletions documentation/apis/osrm/1.0.0/api.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
{
"openapi": "3.0.0",
"info": {
"description": "Description of the OSRM API available via Road2. Only route operation in its v1 is available.",
"version": "1.0.0",
"title": "OSRM API inside Road2",
"contact": {
"email": "[email protected]"
}
},
"servers": [
{
"url": "http://localhost:8080/osrm/1.0.0/",
"description": "Local server"
}
],
"tags": [
{
"name": "Discover",
"description": "Discover the resources available on this instance."
},
{
"name": "Route",
"description": "Ask for one or multiple routes."
}
],
"paths": {
"/resources": {
"get": {
"tags": [
"Discover"
],
"summary": "Request used to discover the resources available on this instance.",
"description": "",
"operationId": "resources",
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/resources"
}
}
}
},
"404": {
"description": "Not found"
}
}
}
},
"/{resourceId}/{profileId}/{optimizationId}/route/v1/_/{coordinates}": {
"get": {
"tags": [
"Route"
],
"summary": "Compute a route",
"description": "This API route is the same of [the OSRM v1 route](http://project-osrm.org/docs/v5.5.1/api/#route-service). But the profile parameter is separated in three parameters : resourceId, profileId and optimizationId. It allows us to have the concepts of Road2 and a better compatibility with the native OSRM API.",
"operationId": "route",
"parameters": [
{
"name": "resourceId",
"in": "path",
"description": "The resource used for the compute. The list of resources is available on /resources. A resource is a concept of Road2, it is an agregation of multiple graphs. For instance, an unique topology with multiple costs.",
"required": true,
"schema": {
"type": "string"
},
"example": "bdtopo-osrm"
},
{
"name": "coordinates",
"in": "path",
"description": "String of format {longitude},{latitude};{longitude},{latitude}[;{longitude},{latitude} ...] or polyline({polyline}).",
"required": true,
"schema": {
"type": "string"
},
"example": "2.337306,48.849319"
},
{
"name": "profileId",
"in": "path",
"description": "The profile used for the compute. The list of profiles per resource is available on /resources.",
"required": true,
"schema": {
"type": "string"
},
"example": "car"
},
{
"name": "optimizationId",
"in": "path",
"description": "The optimization used for the compute. The list of optimizations per resource is available on /resources.",
"required": true,
"schema": {
"type": "string"
},
"example": "fastest"
},
{
"name": "alternatives",
"in": "query",
"description": "Search for alternative routes and return as well. Please note that even if an alternative route is requested, a result cannot be guaranteed.",
"required": false,
"schema": {
"type": "string"
},
"example": "false"
},
{
"name": "steps",
"in": "query",
"description": "Return route steps for each route leg.",
"required": false,
"schema": {
"type": "string"
},
"example": "false"
},
{
"name": "annotations",
"in": "query",
"description": "Returns additional metadata for each coordinate along the route geometry.",
"required": false,
"schema": {
"type": "string"
},
"example": "false"
},
{
"name": "geometries",
"in": "query",
"description": "Returned route geometry format (influences overview and per step). Values can be : polyline (default), polyline6 , geojson.",
"required": false,
"schema": {
"type": "string"
},
"example": "polyline"
},
{
"name": "overview",
"in": "query",
"description": "Add overview geometry either full, simplified according to highest zoom level it could be display on, or not at all. Values can be : simplified (default), full , false.",
"required": false,
"schema": {
"type": "string"
},
"example": "simplified"
},
{
"name": "continue_straight",
"in": "query",
"description": "Forces the route to keep going straight at waypoints constraining uturns there even if it would be faster. Default value depends on the profile. Values can be : default (default), true , false. ",
"required": false,
"schema": {
"type": "string"
},
"example": "default"
}
],
"responses": {
"200": {
"description": "Successful operation. For all the details, see [the OSRM documentation](http://project-osrm.org/docs/v5.5.1/api/#route-service).",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/osrmValidResponse"
}
}
}
},
"400": {
"description": "Error. For all the details, see [the OSRM documentation](http://project-osrm.org/docs/v5.5.1/api/#route-service).",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/osrmErrorResponse"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"osrmErrorResponse": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
}
}
},
"osrmValidResponse": {
"type": "object",
"properties": {
"code": {
"type": "string",
"description" : "if the request was successful Ok otherwise see the service dependent and general status codes on the [the OSRM documentation](http://project-osrm.org/docs/v5.5.1/api/#route-service)."
},
"routes": {
"type": "array",
"items": {
"type": "object",
"description": "For all the details, see the OSRM documentation of a [route object](http://project-osrm.org/docs/v5.5.1/api/#route-object)."
}
},
"waypoints": {
"type": "array",
"items": {
"type": "object",
"description": "For all the details, see the OSRM documentation of a [waypoint object](http://project-osrm.org/docs/v5.5.1/api/#waypoint-object)."
}
}
}
},
"resources": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"description": {
"type": "string"
},
"profiles": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"optimizations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
}
}
}
Loading

0 comments on commit a0c9483

Please sign in to comment.