bmwcarit / barefoot

Java map matching library for integrating the map into software and services with state-of-the-art online and offline map matching that can be used stand-alone and in the cloud.
Apache License 2.0
665 stars 186 forks source link

Matching U-turns #73

Closed ghost closed 6 years ago

ghost commented 6 years ago

When a U-turn is made not on a junction but on the middle of the road, the path reported by the matching algorithm is to the end of the road segment and back to current position. In this case the calculated distance is much greater (in some cases more than 1 km) than the actual traveled distance. Is it possible to split the road segment and make the switch in direction at some point near to actual U-turn. I'm providing a picture and test data. u-turn-1 points-1.txt

smattheis commented 6 years ago

That's not supported at the moment. This is kind of by design for the router because it would sometimes prefer u-turns instead of "natural" routes. To illustrate this, see the image below where the design prefers A over B.

barefoot

Note: intersection = blue bullet, position sample = numbered diamond, road segment = black line, route = orange line

However, I understand your case because it means that it also prefers C over D which is unnatural too. I could try out (so success is not guaranteed) a quick fix with a simple logic: For each determined transition (route) check its sequence of roads if it includes the opposite side segment of the start segment and if so, cut the route appropriately. That means it prefers then D over C but also still A over B. What do you think? Does it make sense to you?

ghost commented 6 years ago

Yes, this is exactly what we need. With one more condition - if the position is near (e.g. < MaxRadius) the junction then leave the logic as is and don't cut the road. Thank you in advance.

smattheis commented 6 years ago

This is addressed in PR #108. I'm closing this issue now.