When do I need to re-route

I just started using the Graphhopper Core Java library. I am developing an Android map app and I need to know when I need to recalculate the route that I was calculated previously e.g. when you deviate “too far” from the origianl route.

Thanks in advance…

Hey! @anelfdz Have you implemented reroute?

  1. Could be when the high traffic in the optimal route.
  2. May be the diversion in the route due to some reason.

I would calculate the heading of the vehicle and the distance to the resulting point list on the client side and decide if it is too hard to get back to the original route, somehow.

Well, I’m here, having the same problem…I have a route, instructions and entries from gpx. when I have a current instrction with more than two point, I calculate the current instruction heading and compare it with the heading of the segment between my location and last point for the current instruction. In some circumstances it works, but for highways or long ways with curves it fails because I use a difference of 30-45 degrees as start deviation point, and measure 50-100 meters of continue heading deviation. It signifies that the user deviates from instruction more than 30-45 degrees over a distance more than 50-100 meters. It’s my first approach. I think that if I could get the way where am I and “compares” with the way of the current instruction, maybe would be more accurate and simple.
Or maybe I need to implement some logic to work with trackpoints, but I don’t believe that it’s an effective method.
What do you think about?

I think I solved this situation… the main idea of what I did is:

  • Check if I am on the route, if not, then I need to calculate the route again (reroute). To do that, I calculate the distance from my location to the segment formed by the 1st and 2nd point of the route, and if it exceeds 5-10 meters, I may asume that I am not on the route.

  • Now that I know that I am on the route, I calculate the distance from my location to the 1st point of the route path and if it is greater than the distance traveled, then I take the 2nd and 3rd point as the current segment and so on.

What do you think about?

This sounds good. Now that you are speaking about this a similar method InstructionList.find comes to my mind. Maybe we can enhance this to suite your needs? Also we should add an example for this in the docs I guess…

I suppose that you think of use calcNormalizedEdgeDistance() function? You think previously check if your current location is between two points or search if necessary between what points are, it’s ok? I think too that if you are in a multi lane highway you must consider use more than 10 meters offset. It’s interesting, maybe we can create a good approach together. What dou you think?

I’m also pretty sure that you’ll need to track the previous state to know the future state especially for higher density of roads where a 10 meter error means that you would be on the other side of the road. And for this tracking&snapping you’ll need map matching

I have read about map matching and I have no idea of how to use it to solve this problem. Can you give me some tips?

Tell me if I am wrong. I track the location updates, then I use map matching to get the edges of the route in the map and then compare them (the result of using map matching with the path calculated previously). Is that ok?