How to find the closest point on a street?

Hi there!

How can I find the closest point (from another one) on a street? When you calculate a route using GraphHopper, it finds the closest point (from the start point of the route) such that it is on a street, so how can I do that?

Thanks in advance…

GraphHopper does that in the LocationIndex.

Yes, I know I can do this:

QueryResult rua = hopper.getLocationIndex().findClosest(latitude, longitude, EdgeFilter.ALL_EDGES);

but how can I use QueryResult to get the closest point? Thanks for the replay.

Have you looked into the QueryResult class? It contains many properties, like the closest edge, node, and also coordinates of the snapped position.

What exactly is that “closest edge”?
I tried:
EdgeIteratorState edge = qr.getClosestEdge();
PointList ghPoint3DS = edge.fetchWayGeometry(0);
for (int i = 0; i < ghPoint3DS.size(); i++) {
System.out.println("got point " + i + " along: " + ghPoint3DS.getLat(i) + ", " + ghPoint3DS.getLon(i));
But that does not give points along the closest road or way or similar. That gives points on a line a few Meters away on some way ca.50m away from the closest way.

And is there some Javadoc page?
I am missing the documentation of the classes and methods of Graphhopper.