Why not ask your question on the new OpenStreetMap Community Forum?

Hi I'm selecting railway=station then searching 20m around them for any building that are not train_station. If there are none then I output the railway=station entity.

How do I check if the .build set to see if it has no members? Is there even a simpler way to achieve this?

In this example:

  • Tottenham Court Road shouldn't display as it has no adjacent building=train_station.
  • Russell Square should display as it does.
  • Goodge Street should as it's both building=train_station and railway=station.


foreach .TStats
 if (.build.count(ways) == 0) 
  (.TStats out geom;)

Edit: I spotted an error I my code, now rectified, but it doesn't help with the solution.

asked 26 Jun '18, 17:17

DaveF's gravatar image

accept rate: 16%

edited 26 Jun '18, 17:49

(.TStats out geom;) will output all members of the .TStats set, so the script will currently output the whole set for each one that matches the test.

(27 Jun '18, 02:29) maxerickson

I see. So is there a way to get the individual element of .TStats being processed by the foreach loop?

(27 Jun '18, 11:33) DaveF

Yep, take a look at https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#For-each_loop_.28foreach.29 it shows how to name the loop variable.

I experimented a bit, the current test doesn't work with the variable fixed.

(27 Jun '18, 12:20) maxerickson

Note I've updated the OP routine To test, I simplified the routine a bit: http://overpass-turbo.eu/s/zSZ I've made it more verbose than it needs to be, to hopefully make it clearer. if you look on the data tab Tottenham shouldn't be displaying as the way count is 0. It seems to me the if:count(ways) line isn't filtering, but I'm unsure why. I took it from : https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_API_by_Example#Isolated_Buildings. ----- Sorry, which variable shouldn't be fixed?

(27 Jun '18, 16:54) DaveF

By variable fixed I meant I experimented with the initial script after correcting the issue with the looping variable.

(27 Jun '18, 17:14) maxerickson
Be the first one to answer this question!
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: 26 Jun '18, 17:17

question was seen: 1,132 times

last updated: 27 Jun '18, 17:15

powered by OSQA