Skip to content
This repository has been archived by the owner on Jul 6, 2022. It is now read-only.

Latest commit

 

History

History
25 lines (19 loc) · 713 Bytes

location-index.md

File metadata and controls

25 lines (19 loc) · 713 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 = 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();