This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Nearest point on a planet_osm_roads

0

I have a query that give me the nearest roads to a point

SELECT osm_id, ref, name, way, ST_AsText(ST_Transform(way, 4326)), *
FROM planet_osm_roads
where 
ST_DWithin(ST_Transform(ST_SetSrid(ST_Point(-1.28779, 51.78976), 4326), 3857), way, 20)
ORDER BY way <-> ST_Transform(ST_SetSrid(ST_Point(-1.28779, 51.78976), 4326), 3857) LIMIT 5;

Now I want in the same query to get for each road the nearest point(node) for my original point (-1.28779, 51.78976) I know how to do it in separate queries, but for less DB access I want it in the same query.

Tn;x for any help

asked 05 Dec '18, 08:48

altopalo's gravatar image

altopalo
5381013
accept rate: 0%

Source code available on GitHub .