If there is a U-turn on the last map-matched edge, that is not represented in the sequence of edges or the PostGIS geometry.
The root problem here is that the U-turn is only "forced" when the trace continues onto a subsequent edge. (The transition probabilities are inherently edge based.)
The best way to resolve this would be to add a section to fillRouteGaps() that checks whether there should be a U-turn on the final edge.
If there is a U-turn on the last map-matched edge, that is not represented in the sequence of edges or the PostGIS geometry.
The root problem here is that the U-turn is only "forced" when the trace continues onto a subsequent edge. (The transition probabilities are inherently edge based.)
The best way to resolve this would be to add a section to
fillRouteGaps()
that checks whether there should be a U-turn on the final edge.