drolbr / Overpass-API

A database engine to query the OpenStreetMap data.
http://overpass-api.de
GNU Affero General Public License v3.0
693 stars 90 forks source link

Union filter outputs only first group of matches, instead of all results #604

Closed MurzNN closed 3 years ago

MurzNN commented 3 years ago

Here is example of problematic query, that can be tested via https://overpass-turbo.eu/:

[out:json][timeout:180];
area["name"="Ямало-Ненецкий автономный округ"]["boundary"="administrative"]["admin_level"="4"];
(
  node[place="city"](area);
  node[place="town"](area);
  node[place="village"](area);
);
out qt;

It returns only two nodes in result, that matched first filter city, instead of more than 10.

If I comment-out first condition with city and repeat query:

[out:json][timeout:180];
area["name"="Ямало-Ненецкий автономный округ"]["boundary"="administrative"]["admin_level"="4"];
(
//  node[place="city"](area);
  node[place="town"](area);
  node[place="village"](area);
);
out qt;

it will return matches to second condition town, without village.

Can you please describe why this happens, and is this a bug, or I understand the Union syntax wrong? Thanks!

P.S. I

mmd-osm commented 3 years ago

Your query is buggy, you need to assign the results of the the first area statement to an explicit inputset.

area[...]->.myarea;
...
(
node[...](area.myarea);
node[...](area.myarea);
);

See https://help.openstreetmap.org/questions/20531/overpass-ql-nodes-and-ways-in-area for more explanation.

Kindly close this issue after reading this comment.

MurzNN commented 3 years ago

Thanks for quick reply, I wasn't know that specifying name for area is required, even when I need only one area! With named area all works well!