End point on blocked edges

Hi,

My problem is as follow:

I have created a custom weight class to decide if I can use an edge or not. That is working amazingly well and I am very happy about that.

However, if one of my points is on a restricted edges, the GraphHopper class is still trying to map it to one edge with the following piece of code:

 for (int placeIndex = 0; placeIndex < points.size(); placeIndex++)
        {
            GHPoint point = points.get(placeIndex);
            QueryResult res = locationIndex.findClosest(point.lat, point.lon, edgeFilter);
            if (!res.isValid())
                rsp.addError(new IllegalArgumentException("Cannot find point " + placeIndex + ": " + point));
            qResults.add(res);
        }

the locationIndex.findClosest(point.lat, point.lon, edgeFilter); line will map it to the restricted edge that is not accessible.


Therefore my question:

How can I ensure that findClosest will map my point to an accessible node?

Currently I am thinking about changing the DefaultEdgeFilter for a factory that will return a EdgeFilter based on the encoder.

But that might not be the optimal solution.

Any thought about it? I don’t think I am the first one to encounter that issue but I couldn’t find anything related to that on the internet.

Please feel free to ask me to explain specific part of my question if that doesn’t make sense.

Thank for the time and the help

Yes, it should be somehow possible to plug in a custom edgefilter … maybe we need to use the Weighting as the factory as access restrictions should always lead to adaptations of this edgefilter