I am trying to write a query that will return all pubs and bars around a certain point. I'm having issues with the results that are ways. At the moment I am getting all the nodes for the way and then using some post processing to match up the first node of the way to the node lat/long data. Obviously, this is largely inefficient. This is the query I'm currently using. Many thanks.

[out:json]; (node[amenity=pub](around:5000,51.5152117,-0.144044); foreach(out;) way[amenity=pub](around:5000,51.5152117,-0.144044); foreach( out; node(w); out; ); node[amenity=bar](around:5000,51.5152117,-0.144044); foreach(out;) way[amenity=bar](around:5000,51.5152117,-0.144044); foreach( out; node(w); out;);); (._;%3E;)

asked 29 Sep '18, 23:26

adam__'s gravatar image

accept rate: 0%

Each way lists it's member nodes, so in your post processing you can build a mapping of node ids to nodes and use that to retrieve a way node, you don't need to order the output. So a query like http://overpass-turbo.eu/s/Cne should work.


You might also be interested in out center; which converts ways to a node at the center of the bounding box of the way (or relation).

permanent link

answered 30 Sep '18, 04:30

maxerickson's gravatar image

accept rate: 31%

out center is exactly what I'm after. My final query is http://overpass-turbo.eu/s/Cns since I don't need individual lat/lon of the ways nodes

(30 Sep '18, 12:10) adam__
Your answer
toggle preview

Follow this question

By Email:

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



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:


question asked: 29 Sep '18, 23:26

question was seen: 835 times

last updated: 30 Sep '18, 12:10

powered by OSQA