How to search for multiple tags around one location?
Asked Answered
V

1

9

I'm trying to figure out what's the best solution to find all nodes of certain types around a given GPS-Location.

Let's say I want to get all cafes, pubs, restaurant and parks around a given point X.xx,Y.yy.

[out:json];(node[amenity][leisure](around:500,52.2740711,10.5222147););out;

This returns nothing because I think it searches for nodes that are both, amenity and leisure which is not possible.

[out:json];(node[amenity or leisure](around:500,52.2740711,10.5222147););out;
[out:json];(node[amenity,leisure](around:500,52.2740711,10.5222147););out;
[out:json];(node[amenity;leisure](around:500,52.2740711,10.5222147););out;
[out:json];(node[amenity|leisure](around:500,52.2740711,10.5222147););out;
[out:json];(node[amenity]|[leisure](around:500,52.2740711,10.5222147););out;
[out:json];(node[amenity],[leisure](around:500,52.2740711,10.5222147););out;
[out:json];(node[amenity];[leisure](around:500,52.2740711,10.5222147););out;

These solutions result in an error (400: Bad Request)

The only working solution I found is the following one which results in really long queries

[out:json];(node[amenity=cafe](around:500,52.2740711,10.5222147);node[leisure=park](around:500,52.2740711,10.5222147);node[amenity=pub](around:500,52.2740711,10.5222147);node[amenity=restaurant](around:500,52.2740711,10.5222147););out;

Isn't there an easier solution without multiple "around" statements?

EDIT: Found This on which is a little bit shorter. But still multiple "around" statements.

[out:json];(node["leisure"~"park"](around:400,52.2784715,10.5249662);node["ameni‌​ty"~"cafe|pub|restaurant"](around:400,52.2784715,10.5249662););out;
Vomit answered 24/7, 2014 at 10:46 Comment(1)
OK I found this one which is a little bit shorter. But still it has multiple "around" statements. [out:json];(node["leisure"~"park"](around:400,52.2784715,10.5249662);node["amenity"~"cafe|pub|restaurant"](around:400,52.2784715,10.5249662););out;Vomit
C
17

What you're probably looking for is regular expression support for keys (not only values).

Here's an example based on your query above:

[out:json];
node[~"^(amenity|leisure)$"~"."](around:500,52.2740711,10.5222147);
out;

NB: Since version 0.7.54 (released in Q1/2017) Overpass API also supports filter criteria with 'or' conditions. See this example on how to use this new (if: ) filter.

Cowherd answered 25/7, 2014 at 15:42 Comment(2)
Thank you! Just wanted to make sure I didn't miss something!!Vomit
This feature is available now, please check wiki.openstreetmap.org/wiki/Overpass_API/… for details.Cowherd

© 2022 - 2024 — McMap. All rights reserved.