NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the 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.

http://overpass-turbo.eu/s/zRH

[bbox:{{bbox}}];
nwr[railway=station]->.TStats;
foreach .TStats
(
 way(around:20)[building];
 way._[building!=train_station]->.build;
 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

DaveF
3.3k8498133
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

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:

×483
×8
×3

question asked: 26 Jun '18, 17:17

question was seen: 1,363 times

last updated: 27 Jun '18, 17:15

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