-
Notifications
You must be signed in to change notification settings - Fork 129
Support modulo in selectors #377
Comments
Looks great. |
Was a PR ever done for the branch @springmeyer did? |
No, because the syntax is a bit incomplete. When you are only able to specify x % 2 without anything else it is unclear what you are filtering for. |
I've run into the need for this too. I think @nebulon42 is correct about the suggested patch - it makes something like this work:
whereas what we want is slightly different:
The latter is the example used in the mapnik documenation for filters. As far as I can figure out, the problem seems to be in carto's parsing of the filter. It expects to see something like
I can't figure out if one of the existing five tests for keys should be modified to allow the above, or a sixth test added. Any guidance on the right approach would be welcome - I'm a bit out of my depth here. |
I tried adding |
If we allow expressions in filters we might have to start writing fields explicitly with Line 548 in f37bd50
$(this.expression) the failing tests complain about keywords. So the parsers does not recognize height in height = 0 as field anymore. Writing [height] = 0 fixes that.
But I only had a quick look. Maybe there is a better alternative. |
One has the be careful in which order the expression is added for the parser. Seems to work now, only restriction is that field references have to be properly written within brackets e.g. |
backport of 31023fb
Mapnik supports the numeric modulo (%) operator in selectors: https://github.com/mapnik/mapnik/wiki/Filter#examples-in-xml
For example:
Carto support for this would be good.
The text was updated successfully, but these errors were encountered: