Overpass-API icon indicating copy to clipboard operation
Overpass-API copied to clipboard

Query language: Support "has no key like"

Open westnordost opened this issue 5 years ago • 12 comments

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:

  • Check if a recycling container is not tagged with any recycleable it accepts: [!~'^recycling:.*$'].
  • Check if the road has no cycleway tagged: !~'^cycleway(:left|:right|:both)?$'
  • There are other such schemes as the recycling scheme, at least I think for services provided at car shops, boat shops, motorcycle shops

westnordost avatar Aug 07 '20 18:08 westnordost

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...

mmd-osm avatar Aug 07 '20 18:08 mmd-osm

Ok, I understand

westnordost avatar Aug 07 '20 18:08 westnordost

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

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

westnordost avatar Aug 07 '20 18:08 westnordost

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

mmd-osm avatar Aug 07 '20 19:08 mmd-osm

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

westnordost avatar Aug 07 '20 20:08 westnordost

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 👍

westnordost avatar Aug 07 '20 20:08 westnordost

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

mmd-osm avatar Aug 07 '20 21:08 mmd-osm

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

(nwr[recycling]->.a; - nwr.a[~"^recycling:."~"."];);
out meta center;

mmd-osm avatar Aug 07 '20 21:08 mmd-osm

Yes, this is how I currently do it

westnordost avatar Aug 07 '20 21:08 westnordost

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

mmd-osm avatar Aug 07 '20 21:08 mmd-osm

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.

drolbr avatar Aug 13 '20 10:08 drolbr

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

mmd-osm avatar Jul 24 '22 08:07 mmd-osm