Describe the bug
When using the array form of a match expression, the order of elements in the array is sometimes ignored.
Consider a schema defining a color attribute taking different OSM tags in descending order of priority. An over-simplification of the expression could be:
- key: color
value:
- if:
natural: tree
value: green
- if:
historic: memorial
value: black
- if:
tourism: viewpoint
value: green
An OSM element, that has both a historic=memorial and a tourism=viewpoint tag, is assigned a color=green attribute rather than color=black.
Node 2156431602 has both a historic=memorial and a tourism=viewpoint tags. Examine its tile and see that it was assigned color: green rather than color: black
Expected behavior
I expect the "if" conditions to be evaluated in the order they appear in the array.
I believe this is natural expectation after reading the documentation for the match expression
For the first format:
the expression evaluate to the value associated with the first matching boolean expression at runtime:
For the second format:
you can use an array of objects with if andvalue keys and a last object with an else key
Regardless of my interpretation of the documentation, I believe this evaluation order would provide a valuable expressibility enhancements for priority-based value expressions.
Screenshots
Environment:
Hardware: Any
OS: Docker
Java version and distribution: Planetiler latest docker image
Maven version: Planetiler latest docker image
Additional context
It seems like the implementation is unifying all conditions with the same resulting value and thus converting the above into
- key: color
value:
- if:
natural: tree
tourism: viewpoint
value: green
- if:
historic: memorial
value: black
As far as I could see, the order is preserved between different value expressions, i.e. green has higher priority that black.
Describe the bug When using the array form of a match expression, the order of elements in the array is sometimes ignored.
Consider a schema defining a
color
attribute taking different OSM tags in descending order of priority. An over-simplification of the expression could be:An OSM element, that has both a
historic=memorial
and atourism=viewpoint
tag, is assigned acolor=green
attribute rather thancolor=black
.To Reproduce
Use the following
my_pois.yml
definitionmy_pois.pmtiles
historic=memorial
and atourism=viewpoint
tags. Examine its tile and see that it was assignedcolor: green
rather thancolor: black
Expected behavior I expect the "if" conditions to be evaluated in the order they appear in the array.
I believe this is natural expectation after reading the documentation for the match expression
Regardless of my interpretation of the documentation, I believe this evaluation order would provide a valuable expressibility enhancements for priority-based value expressions.
Screenshots
Environment:
Additional context It seems like the implementation is unifying all conditions with the same resulting value and thus converting the above into
As far as I could see, the order is preserved between different
value
expressions, i.e.green
has higher priority thatblack
.