Incorrect edge snapped to first point in map matching results

Hello forum,

We’re seeing a case in which the first point is snapped incorrectly to the second edge of an OSM way.

We are expecting that the first point (in gray) is snapped to OSM nodes 306707128 and 307680747.

Yet map matching returns the next edge between 307680747 and 307680743

(see image)

I’m not sure how to work around this issue. Please let me know if I should be filing this in JIRA.

I’ve attached the GPX file to repro the issue.

Trangc505133f2b225399f2ef371d53cce0b1.gpx (1.4 KB)

After tightening the error tolerance for map matching from 40 to 15, I am getting the correct result.
However, the question is is why with a 20-40 error sigma, why would map matching choose to eliminate the first edge?
Proximity to the first edge is 1.222006m whereas it is 16.3m to the second edge. Regardless of tolerance, it seems that the first edge should have been chosen due to fidelity of path.

Here btw are map matched results with a 15 error sigma: