How can I find the closest road / way to a point?


For example if I have some navigation start point on the map, the navigation starts automatically on the closest road. Or the closest way. Im interested in finding that closest way to a point. Especially I am interested in the part of the way from crossing to crossing.
Can someone help me how to get that with graphhopper?

I am working with the java jar version. So I have a graphhopper object.

So input: some lat, long
output: lat long of the crossing the one way, lat long of the crossing the other way. Both crossings on the closest road.

Hiya, are you talking about essentially snapping the point to roadside?

I have faced that quite a bit with our national address database. It is most prevalent when the central land package location was closest to the highway, instead of the residential road (our database stores GEOM’s at the center of the land package)

The solution was to use Oracle SQL (SDO.GEOM) to essentially snap the point to roadside. This involved using the GEOM data to access the associated road segment (not the closest) and move the point 10m from the center line.
I’m unsure if you have that level of data, but when I was working on this I was unsure of the functionality within graphhopper. I think you would still need the association between the point on the map and the actual road to use.

PostGIS contains a function called ST_Translate

From :

/* Move a point 1 degree longitude */
/* PostGIS */
SELECT ST_AsText(ST_Translate(ST_GeomFromText('POINT(-71.01 42.37)',4326),1,0)) As wgs_transgeomtxt;

You would still need to know which direction to move in.
Hope that is some help?

Sorry for my simple drawing.
For the green start point I would like to get Point A and B. That are end points from the closet way near to the green Marker.

What I am doing is a bit more complicated. I am woking on the Orienteering problem. With 30.000 Locations in Berlin. I try a special kind of clustering for the distance matrix. It should become smaller so I can save the precomputed distance matrix on mobile devices. So the question is, how can I find points that are on the same part of the road, or going north, that belong to the same crossing.

Sorry, I don’t have an exact answer to solve your problem.
Open street map has the details of the crossing as bridge, and footpath.

Can you find from graphhopper the closest bridge which is a footpath to your point?

A bridge is only in this case relevant, isn’t it?
But I need a general method.
Currently I am trying out an idea.

I am calculation two routes. One to lat + eps, long + 2 eps and one to lat - eps, lat - 2 eps. The both points I am looking for are in the instruction lists in the second instruction the first point.
I hope at least in most cases that works.

But for example if the street is only open to one side, both routes travel to this side. So i don’t get the two end points from the nearest road part. But I think I can dealt with that.

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