Snap to Road /snaptoroad
Snap to Road accepts a list of points obtained from satellite navigation systems (GNSS) in the form of latitude and longitude, collected along the route, and returns a list of points forming a route snapped to roads on the map. You can also use interpolation along the given points. In this case, the response will be a line corresponding to the road geometry.
This request can be an important part of developing tracking systems, particularly when visualizing collected satellite data.
Request Schema
https://api.visicom.ua/data-api/5.0/core/snaptoroad.json?[points][&interpolate][&mode][&key][&callback]
Request Parameters
| Parameter | Description |
|---|---|
points|p | Array of point coordinates. Each point is specified as lng,lat. The | symbol separates points in the list. Maximum number of points is 250. |
interpolate|l | Whether interpolation is needed to create a line following the full road geometry, including intersections and tunnels. If true, the response will contain a LineString object. Default is false. |
mode|m | Snap mode. Can be driving (default, snaps to driving roads) or walking (all roads). |
separate|s | If set, each point is processed separately, ignoring previous points (interpolate is ignored). Useful when snapping multiple devices in one request. Default is false. |
key | Authorization key. |
callback | JSONP callback function name. |
Example Request
https://api.visicom.ua/data-api/5.0/core/snaptoroad.json?points=30.36277,50.51605|30.49667,50.49508|30.59761,50.45226|30.51383,50.44789&interpolate=true&key=YOUR_API_KEY
Response
The structure of the snaptoroad response depends on the interpolate parameter and the number of points.
Single point, any interpolate value:
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
30.42615,
50.45119
]
}
}
Returns a GeoJSON object of type Feature. The geometry field contains a Point with road-snapped coordinates.
interpolate = false (default) with multiple points:
{
"type": "FeatureCollection",
"bbox": [
30.42615,
50.44802,
30.44679,
50.45716
],
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
30.42615,
50.45119
]
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
30.43615,
50.46119
]
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
30.44615,
50.47119
]
}
}
]
}
Returns a GeoJSON object of type FeatureCollection. The features array contains Feature objects with Point geometry for road-snapped coordinates.
interpolate = true with multiple points:
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[
30.42615,
50.45119
],
[
30.42749,
50.45097
],
[
30.42674,
50.44899
],
[
30.43016,
50.44846
],
[
30.43318,
50.44802
],
[
30.43347,
50.44879
],
[
30.4339,
50.44997
],
[
30.43456,
50.45171
],
[
30.43622,
50.45597
]
]
},
"bbox": [
30.42615,
50.44802,
30.44679,
50.45716
]
}
Returns a GeoJSON object of type Feature with LineString geometry corresponding to the snapped road route.
Demo
You can place points by clicking on the map: