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

Query language: Support "has no key like" #589

Open westnordost opened 3 years ago

westnordost commented 3 years ago

What already exists is [!key] and [~kexRegex]. What is missing is [!~keyRegex] or similar to check if an element has no key that matches with the regex tagged.

Example use cases:

mmd-osm commented 3 years ago

This wasn't implemented for performance reasons, as it would be prohibitively expensive. I would have to look up a reference to a previous discussion on this topic if needed.

I could find some discussion on this topic in https://github.com/drolbr/Overpass-API/issues/59#issuecomment-55022401, but I don't find the performance hint anymore...

westnordost commented 3 years ago

Ok, I understand

westnordost commented 3 years ago

Ah wait, but perhaps as an evaluator in an if condition?

if: hasTagLike("^recycling:.*$")

mmd-osm commented 3 years ago

Evaluators don't support any regular expressions at this time...

westnordost commented 3 years ago

Ok. But if they do in the future, that might be a thing to consider.

westnordost commented 3 years ago

I further worked on the "element filter syntax" used by StreetComplete by the way and found that for everything I need to conveniently support these extensions exists in OQL 👍

mmd-osm commented 3 years ago

Found this commit: the XML query language rejects regular expressions on keys w/ negation: https://github.com/drolbr/Overpass-API/commit/7209dd399b8abfadbc8f413cb914ac0c0be81d35

mmd-osm commented 3 years ago

Just wanted to mention that you would typically use a difference statement in this case:

(nwr[recycling]->.a; - nwr.a[~"^recycling:."~"."];);
out meta center;
westnordost commented 3 years ago

Yes, this is how I currently do it

mmd-osm commented 3 years ago

Yeah, I know :) this was meant as hint to people who found this issue via some web search.

drolbr commented 3 years ago

I do not see any inevitable performance problem here. When other conditionals restrict the result set or the expression is sufficiently broadly (think of way[!~"."~"."], finding all ways without any tag) then it is probably fine.

It is just not a high priority.

mmd-osm commented 1 year ago

Prototype implementation is here for testing: https://overpass-turbo.eu/s/1ko6