Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search for multiple tags around one location?

Tags:

overpass-api

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;
like image 933
Willey Avatar asked Jul 24 '14 10:07

Willey


1 Answers

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.

like image 86
mmd Avatar answered Oct 19 '22 02:10

mmd