inconsistent `distance_along_edge` in map matching result
- Dominant language
- C++
- Stars
- 6.2k
- Forks
- 981
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 14
Description
Having this request
```
curl -X POST \
http://192.168.1.14:8002/trace_attributes \
-H 'Content-Type: application/json' \
-H 'Postman-Token: c4323b77-7016-4086-808e-551e912b064c' \
-H 'cache-control: no-cache' \
-d '{"shape":[{"lat": 1.407722, "lon": 103.80849, "time": 1537460873}, {"lat": 1.395893, "lon": 103.81542, "time": 1537460933}, {"lat": 1.393112, "lon": 103.82495, "time": 1537460973}, {"lat": 1.393462, "lon": 103.830005, "time": 1537460993}], "filters": {"attributes": ["edge.way_id", "edge.speed", "edge.length", "matched.point", "matched.type", "matched.edge_index", "edge.id", "matched.distance_along_edge", "matched.point", "edge.begin_shape_index", "edge.end_shape_index", "shape", "matched.distance_from_trace_point"], "action": "include"}, "costing": "auto", "shape_match": "map_snap"}'
```
I'm getting the response
```
{
"matched_points": [
{
"distance_along_edge": 0.782,
"lon": 103.808472,
"distance_from_trace_point": 1.784,
"lat": 1.407717,
"edge_index": 0,
"time": 1537460873,
"type": "matched"
},
{
"distance_along_edge": 0,
"lon": 103.815392,
"distance_from_trace_point": 5.298,
"lat": 1.395856,
"edge_index": 5,
"time": 1537460933,
"type": "matched"
},
{
"distance_along_edge": 0.225,
"lon": 103.824951,
"distance_from_trace_point": 1.107,
"lat": 1.393102,
"edge_index": 10,
"time": 1537460973,
"type": "matched"
},
{
"distance_along_edge": 0.155,
"lon": 103.830002,
"distance_from_trace_point": 0.936,
"lat": 1.393453,
"edge_index": 12,
"time": 1537460993,
"type": "matched"
}
],
"shape": "gm|tAm|}~dElVoIhS_J|_B}|@bj@wc@~b@c[ju@ce@dv@{`@~KsFdW{KjSmJjy@s[vp@oStaA{U~{@mTxg@qR`b@{VnZwWbNsQjZwb@rMiXzFqQ|EoSpEoSpE{VpFwWlNiv@jQsz@xLwm@bMco@jQsyA|Dcz@tF{t@jCsdARag@wEaeBsD_h@wIux@}A_S",
"edges": [
{
"length": 0.087,
"id": 520764801040,
"end_shape_index": 2,
"speed": 90,
"way_id": 480874192,
"begin_shape_index": 0
},
{
"length": 0.205,
"id": 520362147856,
"end_shape_index": 3,
"speed": 90,
"way_id": 630810313,
"begin_shape_index": 2
},
{
"length": 0.101,
"id": 521838542864,
"end_shape_index": 4,
"speed": 90,
"way_id": 480875785,
"begin_shape_index": 3
},
{
"length": 0.342,
"id": 521301671952,
"end_shape_index": 8,
"speed": 90,
"way_id": 480875787,
"begin_shape_index": 4
},
{
"length": 0.049,
"id": 1146219413520,
"end_shape_index": 9,
"speed": 90,
"way_id": 166702720,
"begin_shape_index": 8
},
{
"length": 0.759,
"id": 1146085195792,
"end_shape_index": 18,
"speed": 90,
"way_id": 166702718,
"begin_shape_index": 9
},
{
"length": 0.245,
"id": 521637216272,
"end_shape_index": 23,
"speed": 90,
"way_id": 166702718,
"begin_shape_index": 18
},
{
"length": 0.39,
"id": 891574829072,
"end_shape_index": 28,
"speed": 90,
"way_id": 37583929,
"begin_shape_index": 23
},
{
"length": 0.254,
"id": 891641937936,
"end_shape_index": 30,
"speed": 90,
"way_id": 37583930,
"begin_shape_index": 28
},
{
"length": 0.106,
"id": 520295038992,
"end_shape_index": 31,
"speed": 90,
"way_id": 635164746,
"begin_shape_index": 30
},
{
"length": 0.548,
"id": 892615016464,
"end_shape_index": 36,
"speed": 90,
"way_id": 265150829,
"begin_shape_index": 31
},
{
"length": 0.104,
"id": 2056316272656,
"end_shape_index": 37,
"speed": 90,
"way_id": 635161211,
"begin_shape_index": 36
},
{
"length": 0.036,
"id": 520966127632,
"end_shape_index": 38,
"speed": 90,
"way_id": 635161212,
"begin_shape_index": 37
}
],
"alternate_paths": []
}
```
so here I have 4 matched points, with distances between them `1524`, `1103` and `563`, correspondingly. But when I'm trying to calculate the distance between the points using edges' lengths (accounting the distance along edge), I'm getting the following distances `1474`, `1118.3` and `534`.
So looks like the edge `#5` is incorrectly snapped to second interval (according to the `distance_along_edge`) and it should belong to the first interval
Contributor guide
Assessment
This issue has not been assessed yet.