NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

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%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×134
×2
×1

question asked: 05 Dec '18, 08:48

question was seen: 1,467 times

last updated: 05 Dec '18, 08:48

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum