The shortest route is faster than the fastest route ?!

I am using graphopper routing engine for bike routing and I got surprised with some results. I was evaluating the duration and the distance of the route with different weighting and I found that the “shortest” route is faster than the “fastest” route. I am using this code:

GraphHopper hopper = new GraphHopperOSM().forServer();
    // where to store graphhopper files?
    double latFrom=52.119414;
double lonFrom=11.627536;
double lonTo=11.653850;
double latTo=52.142014;

    `// simple configuration of the request object, see the GraphHopperServlet classs for more possibilities.
    GHRequest req = new GHRequest(latFrom, lonFrom, latTo, lonTo).
    GHResponse rsp = hopper.route(req);
    // first check for errors
    if(rsp.hasErrors()) {
       // handle them!
       // rsp.getErrors()

    // use the best path, see the GHResponse class for more possibilities.
    PathWrapper path = rsp.getBest();
    // points, distance in meters and time in millis of the full path
    PointList pointList = path.getPoints();
    double distance = path.getDistance();
    long timeInMs = path.getTime();` 

For these coordinates, using the fastest path, I got the following results: distance is: 3719.9744845032633 duration :794923
and using the shortest path, I got: distance is: 3406.465484503264 duration :770216
and using the short_fastest I get the best results for the duration: distance is: 3418.522484503264 duration :691584
Is there any explanation ?

Which GH version are you using?

I am using the last version 0.13. I installed it following this guide 11 days ago

It is indeed a bit misleading that for bike we call this fastest. In fact it is the default weighting which considers also safety aspects. See this line:

where we use the PriorityWeighting if supported. This can lead to detours still the shorter route is usually less practical.

To avoid any “priority” stuff you can overwrite the createWeighting method and always return FastestWeighting if you prefer this.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

Powered by Discourse