Skip to content

Latest commit

 

History

History
25 lines (19 loc) · 719 Bytes

location-index.md

File metadata and controls

25 lines (19 loc) · 719 Bytes

Location Index

You get the location index from the GraphHopper instance, after you imported or loaded the data:

GraphHopper hopper = new GraphHopper();
hopper.set...
hopper.importOrLoad();

LocationIndex index = hopper.getLocationIndex();

//  now you can fetch the closest edge via:
QueryResult qr = index.findClosest(lat, lon, EdgeFilter.ALL_EDGES );
EdgeIteratorState edge = qr.getClosestEdge();

If you don't use the GraphHopper class you have to use the low level API:

LocationIndexTree index = new LocationIndexTree(graph.getBaseGraph(), dir);
index.setResolution(preciseIndexResolution);
index.setMaxRegionSearch(maxRegionSearch);
if (!index.loadExisting())
    index.prepareIndex();