OsmSharp / ui

The UI components.
http://osmsharp.com/
GNU General Public License v2.0
138 stars 90 forks source link

Route recalculation? #157

Closed JoeCooper closed 10 years ago

JoeCooper commented 10 years ago

I'm trying to find a way to detect when it is appropriate to recalculate a route. Is there anything built in for this or should I craft my own heuristic? Or would you recommend periodic recalculation? (I did try Googling it but nothing came up.)

xivk commented 10 years ago

There is no ready-made implementation but you could use the RouteTracker class:

https://github.com/OsmSharp/OsmSharp/blob/master/OsmSharp.Routing/Navigation/RouteTracker.cs

Use this property to get the point that is on the route and closest to the current position:

https://github.com/OsmSharp/OsmSharp/blob/master/OsmSharp.Routing/Navigation/RouteTracker.cs#L85

You should be able to calculate the distance and then implement your own heuristic. This is also something that is different between applications. For bicycles for example something like this would behave very different compared to cars or pedestrians even.

JoeCooper commented 10 years ago

Thanks!