How to actually increase Location Index max distance search?

Hi everyone,

in this post and in this one as well, there’s an issue discussed where the Location index fails to find a closest node.

The solution is to increase the index.maxDistanceSearch. However, there are no setters for said variable. How does one actually increase that variable?

Thanks a lot!

Hi,

I had the same problem. This is how I fixed it:

   LocationIndex index1 = new LocationIndexTree(hopper.getGraphHopperStorage().getBaseGraph(), new RAMDirectory(graphFolder, true));
    index1.setResolution(res);
    ((LocationIndexTree) index1).setMaxRegionSearch(50);
    index1.setApproximation(false);
    
    if (!index1.loadExisting()) 
        index1.prepareIndex();

    GHRequest req = new GHRequest(latFrom, lonFrom, latTo, lonTo);
    req.setWeighting("fastest");
    req.setVehicle("car");
    req.setLocale(Locale.US);
    req.setAlgorithm(Parameters.Algorithms.ALT_ROUTE);
    req.getHints().put(Parameters.Algorithms.AltRoute.MAX_PATHS, "16");

GraphHopperStorage storage = hopper.getGraphHopperStorage();
int closestNode = qr.getClosestNode();
NodeAccess nodeAccess = storage.getNodeAccess();
double lat0 = nodeAccess.getLat(closestNode);
double lon0 = nodeAccess.getLon(closestNode);

I think what helped was setting the algorithm to Alt_root.

1 Like

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