HTTP Interface for routing‐api - HY-OHTUPROJ-OSRM/osrm-project GitHub Wiki
Preface
This documentation provides details about the available HTTP endpoints in routing-api. These routes facilitate zone additions/deletions, road processing status updates and more.
Beware of the difference between effectValue
and effect_value
, and even better, fix it if possible.
Routes
/zones
Method: GET
Description: Returns all zones which that currently modify road speeds as a GeoJSON FeatureCollection
.
Example response data:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[25.108741, 60.208046],
[25.108097, 60.207555],
[25.114301, 60.206052],
[25.114794, 60.206745],
[25.108741, 60.208046]
]
]
},
"properties": {
"id": 64,
"type": "constant",
"effect_value": 5,
"name": "Työmaa"
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[24.89436, 60.162182],
[24.894875, 60.161435],
[24.901199, 60.161455],
[24.89861, 60.163015],
[24.89436, 60.162182]
]
]
},
"properties": {
"id": 68,
"type": "roadblock",
"effect_value": null,
"name": "Onnettomuus"
}
},
...
]
}
/zones/diff
Method: POST
Description: Takes the payload as a JSON object, which contains an array of zones to add as GeoJSON features called added
and an array of zone ids to delete called deleted
. Modifying a zone is done by deleting the old zone and adding the modified zone as a new zone. Sending a request to this route causes the roads inside the zones to be blocked in routing, which may take from seconds to minutes depending on dataset size and machine speed.
Example request data:
{
"added": [
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[24.89436, 60.162182],
[24.894875, 60.161435],
[24.901199, 60.161455],
[24.89861, 60.163015],
[24.89436, 60.162182]
]
]
},
"properties": {
"id": 1,
"type": "roadblock",
"name": "Blocked area",
"effectValue": 10
}
},
...
],
"deleted": [
"1",
"2",
...
]
}
/status
Method: GET
Description: Establishes a server-sent events connection, which receives status updates of the road speed update process (i.e. the process started by a request to /zones/diff
).
Event schema:
{
"status": "none" | "processing" | "completed",
"progress": {
"percentage": Number (0-100)
"estimate": ISO 8601 timestring | undefined
}
}
Example event stream:
data: {"status":"none","progress":{"percentage":0}}
data: {"status":"processing","progress":{"percentage":0,"estimate":"2024-06-28T20:01:09.575Z"}}
data: {"status":"processing","progress":{"percentage":10,"estimate":"2024-06-28T20:01:09.575Z"}}
data: {"status":"processing","progress":{"percentage":20,"estimate":"2024-06-28T20:01:09.575Z"}}
...
data: {"status":"processing","progress":{"percentage":90,"estimate":"2024-06-28T20:01:09.575Z"}}
data: {"status":"completed","progress":{"percentage":100,"estimate":"2024-06-28T20:01:09.575Z"}}
/route
Method: GET
Description: A proxy for the corresponding endpoint in osrm-backend. See their documentation for reference.
This fetches a route between two points. This route will be affected by the zones created by requests to /zones/diff
.
/tile
Method: GET
Description: A proxy for the corresponding endpoint in osrm-backend. See their documentation for reference.
Returns vector tiles of the road network which osrm-backend uses for routing. The speed values of the road segments are affected by requests to /zones/diff
.
/segments
Method: GET
Description: Return all currently blocked segments in a detailed format.
Example response data:
[
{
"start": {
"id": "378265",
"lat": 60.2086783,
"lon": 24.9417179
},
"end": {
"id": "378266",
"lat": 60.2091056,
"lon": 24.9414745
},
"originalSpeed": 30,
"currentSpeed": 0
},
{
"start": {
"id": "378424",
"lat": 60.2067288,
"lon": 24.9678996
},
"end": {
"id": "378425",
"lat": 60.2073081,
"lon": 24.9681886
},
"originalSpeed": 30,
"currentSpeed": 0
},
...
]