in the Overpass API is there a way to use logical operators on tag existence?

2.5k views Asked by At

The Overpass API language guide does allow for logical operators when matching a tag value... for example:["name"~"holtorf|Gielgen"] will return whatever object has either name=holtorf or name=Gielgen.

You can also combine conditions and they will become an AND... so for example:

["name"]["name"="holtorf"]. Means to search for things that have the tag "name" and that the tag name is equal to "holtorf".

But what I want is an OR operator... something like:

["name"="holtorf"]|["name:eng"holtorf"]

In my specific application, I just want to know if there is ANY tag that start with "name"... so what I would like to do is put this into the API: ["^name"] (cause in this API "^" means "starts with"). But of course it searches for literal "^name" and returns nothing.

Is there some workaround?

2

There are 2 answers

5
dkiselev On BEST ANSWER

There is no OR operation, but you can use UNION

(
  way["name"="holtorf"];
  way["name:eng"=holtorf"]
);

There is also a DIFFERENCE and negotiation http://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Difference

And in your particular case, you could use key-value regexpressions matching. http://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Key.2Fvalue_matches_regular_expression_.28.7E.22key_regex.22.7E.22value_regex.22.29

[~"^name.*$"~"^holtorf$"];

//or only for key
[~"^name.*$"="Holtorf"];
0
SomeGenericDev On

You could try something like this

node["place"~"village|city|town|metropolis"]["name"~"^A"](area:3602145268);