Strange routes persist in 8 - possible reasons?

Hi, Using version 7, I was having strange routes, so I tried version 8. But I still have weird routes. For example: the route here with all the default settings…

using Google maps, the route looks like this

Looks like many others also have this problem (e.g., Strange routes at the border of dataset - #7 by Geoman, Strange routing - indirect route and more). What are the reasons that could be behind the weird routes? Sometimes, OSM tags show one-way which restrict direct route. What are the other possible reasons for these routes? How can we explain such routes? And how to solve/avoid these- any generic solution?

Your destination isn’t directly reachable according to OSM:

The road around the facility is tagged with access=no and has additional barrier=gate nodes.

GraphHopper picks the nearest routable street which happens to be the nearby motorway:

GH yields a sensible route with a slightly modified destination:

@karussell it would be nice if the snapping would be a bit smarter in that regard.

Instead of simply blocking trunk/motorway like we do it in the SnapPreventionEdgeFilter we could apply a factor to the normDist depending on the EdgeIteratorState.

e.g 2 * normedDist for trunk/motorway

Snap findClosest(double lat, double lon, EdgeFilter edgeFilter, EdgePriority edgePriority);
public interface EdgePriority {
    EdgePriority DEFAULT_PRIORITY = edgeState -> 1d;

    double priority(EdgeIteratorState edgeState);

Oh… thanks for the explanation.

Why GH blocks motorway in SnapPreventionEdgeFilter? What does it actually do?

Not by default. But you can tell it to:!in=query&path=snap_prevention&t=request

At the moment I don’t think a “smart” snapping would be an improvement. We have point_hints and snap_preventions for the /route endpoint, which should solve mostly all issues in this regard. For the public GraphHopper Maps I would keep it as it is (maybe in the future we add point_hints) but you can configure it and we e.g. already avoid ferries.