Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify handling of tag filter parameters #653

Merged
merged 5 commits into from
Mar 5, 2022

Conversation

lonvia
Copy link
Collaborator

@lonvia lonvia commented Mar 5, 2022

Instead of grouping tag filter parameters (from the osm_tag query parameter) by the type of filter, the new code simply collects all parameters into a list of simple TagFilter objects. They are still sorted by include/exclude filter when building the query but otherwise just strung together in a big or filter. This results in a massive simplification of the code.

The outcome is the same except for the rather curious syntax of osm_tag=key:!value. Stringing two of these together with the same key (as in osm_tag=highway:!motorway&osm_tag=highway:!trunk) would give you all objects with the given keys except the ones with any of the given values (i.e all highways except motorways and trunks). Now the two queries are or'ed together independently, so you end up getting all objects with the given key (i.e. highways that are not motorways or highways that are not trunks). Given that the key:!value syntax was never documented or tested, I don't really see an issue with the change in semantics. The alternative would be to drop that interpretation completely and stick with the documented ones.

The PR also includes some simplifications around the tests for the PhotonRequestFactory, now making heavy use of parametrized tests (thank you, JUnit5) and fixes a few smaller issue around parameter parsing found while completing the tests.

lonvia added 5 commits March 5, 2022 00:06
Tag filters are now handled as a list of simple filters instead of
being grouped by filter kind. That greatly simplifies the code when
parsing the incoming request and when building the query.

The ES query for excluded tags has changed to from
(not t1 and not t2 and not t3...) to not (t1 or t2 or t3).
This is equivalent and more simple to handle.
Also adds some additional test cases for filter combinations.
Also fixes some minor parsing issues found with the new tests.
@lonvia lonvia merged commit 0a600b5 into komoot:master Mar 5, 2022
@lonvia lonvia deleted the simplify-tag-filters branch March 5, 2022 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant