У меня есть набор сырых данных с GPS-трекеров, но если прямо их выводить на карту, до зачастую бывает брак в виде срезанных углов и изгибов.
Хочу привязать трек к дорогам. Нашел продукт OSRM (
https://github.com/Project-OSRM/osrm-backend) с функция match map. Но что-то я не пойму что мне делать с его выводом.
Исходный GeoJSON:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[
40.96777081489563,
57.014261542961314
],
[
40.96928358078003,
57.01361317487102
],
[
40.96896171569824,
57.012404025803264
],
[
40.97000241279602,
57.01218205213829
],
[
40.97169756889343,
57.011434341624685
],
[
40.97221255302429,
57.009816197876354
],
[
40.97302794456482,
57.00985124866738
]
]
}
}
]
}
Запрос:
/match/v1/driving/40.96777081489563,57.014261542961314;40.96928358078003,57.01361317487102;40.96896171569824,57.012404025803264;40.97000241279602,57.01218205213829;40.97169756889343,57.011434341624685;40.97221255302429,57.009816197876354;40.97302794456482,57.00985124866738?steps=false&annotations=false&geometries=geojson&overview=false
Результат:
{
'code': 'Ok',
'matchings': [
{
'confidence': 0,
'legs': [
{
'steps': [
],
'distance': 132.1,
'duration': 32,
'summary': '',
'weight': 32
},
{
'steps': [
],
'distance': 138.4,
'duration': 21.6,
'summary': '',
'weight': 21.6
},
{
'steps': [
],
'distance': 98.1,
'duration': 25.9,
'summary': '',
'weight': 25.9
},
{
'steps': [
],
'distance': 174.7,
'duration': 43.8,
'summary': '',
'weight': 43.8
},
{
'steps': [
],
'distance': 402.3,
'duration': 44,
'summary': '',
'weight': 45.9
},
{
'steps': [
],
'distance': 50.9,
'duration': 16.2,
'summary': '',
'weight': 20.4
}
],
'distance': 996.5,
'duration': 183.5,
'weight_name': 'routability',
'weight': 189.6
}
],
'tracepoints': [
{
'alternatives_count': 0,
'waypoint_index': 0,
'matchings_index': 0,
'location': [
40.967772,
57.014263
],
'name': '',
'distance': 0.126847,
'hint': 'R3g4gEl4OAA8AAAAtgAAAAAAAAAAAAAAkJfKQXJTl0IAAAAAAAAAADwAAAC2AAAAAAAAAAAAAAD4AQAAXB5xAvf3ZQNbHnEC9vdlAwAADwfM-Vyn'
},
{
'alternatives_count': 0,
'waypoint_index': 1,
'matchings_index': 0,
'location': [
40.969276,
57.013603
],
'name': 'улица Шестернина',
'distance': 1.214997,
'hint': 'PHg4AE54OIAFAAAAEwAAAAAAAAAHAAAAxKZiQG9FVEEAAAAAMaWfQAUAAAATAAAAAAAAAAcAAAD4AQAAPCRxAmP1ZQNEJHECbfVlAwAAPxLM-Vyn'
},
{
'alternatives_count': 0,
'waypoint_index': 2,
'matchings_index': 0,
'location': [
40.968977,
57.012403
],
'name': 'улица Жиделева',
'distance': 0.917787,
'hint': 'Ong4gFp4OAB5AAAAGgAAAEkAAAAaAAAAtzGpQqdlikGxw0lCILmRQXkAAAAaAAAASQAAABoAAAD4AQAAESNxArPwZQMCI3ECtPBlAwEAfwvM-Vyn'
},
{
'alternatives_count': 0,
'waypoint_index': 3,
'matchings_index': 0,
'location': [
40.970006,
57.012166
],
'name': '',
'distance': 1.798277,
'hint': 'XHg4gF54OACWAAAAagAAAAAAAAAWAAAAtyB7QiaIMUIAAAAAekwUQZYAAABqAAAAAAAAABYAAAD4AQAAFidxAsbvZQMSJ3EC1u9lAwAAHwXM-Vyn'
},
{
'alternatives_count': 0,
'waypoint_index': 4,
'matchings_index': 0,
'location': [
40.971605,
57.011396
],
'name': '',
'distance': 7.05764,
'hint': 'XXg4gIp4OAAgAAAAAAAAAAMBAAAAAAAA_5FWQQAAAACADNhCAAAAACAAAAAAAAAAAwEAAAAAAAD4AQAAVS1xAsTsZQOyLXEC6uxlAwIA3wTM-Vyn'
},
{
'alternatives_count': 0,
'waypoint_index': 5,
'matchings_index': 0,
'location': [
40.972258,
57.009812
],
'name': 'проспект Ленина',
'distance': 2.769079,
'hint': 'AOUDgP___38jAAAAIwAAAAAAAAAAAAAAvBk9QgAAAAAAAAAAAAAAACMAAAAjAAAAAAAAAAAAAAD4AQAA4i9xApTmZQO1L3ECmOZlAwAADxbM-Vyn'
},
{
'alternatives_count': 1,
'waypoint_index': 6,
'matchings_index': 0,
'location': [
40.973035,
57.009828
],
'name': '',
'distance': 2.596368,
'hint': 'vXQ4AAR1OIAVAAAARgAAAAAAAAAOAAAA9_aRQGVnZ0EAAAAApcQ6QAsAAAAjAAAAAAAAAAcAAAD4AQAA6zJxAqTmZQPkMnECu-ZlAwAATxDM-Vyn'
}
]
}
Ну и как теперь получить красивый GeoJSON?