-
Notifications
You must be signed in to change notification settings - Fork 130
Comparing fields fails #121
Comments
I think this is basically a sub-issue of #92. Mapnik supports comparison operators between attributes: >>> from mapnik import Expression, Feature
>>> f = Feature(1)
>>> f['dem'] = 1
>>> f['rep'] = 0
>>> expr = Expression("[dem]>[rep]")
>>> expr.evaluate(f)
True But Carto appears to simply not let an expression like this pass through. I'm not familiar with the Carto internals about why this is so. It may trace back to less.js's understanding of valid selectors. @tmcw and @kkaefer ideally could comment on the how/why of this. |
This is just a minor quirk of filter validation. Should be fixable in an hour or two - I'll try to get to it today or this weekend. |
Upon further inspection, this is going to get bad. We can do some silly guessing, but it's going to suck. Like, You can do
You can also do
To use a field in PostGIS or whatever with spaces. And if you do
Then it compares MY FIELD with the string "MY FIELD" Ideally this should be completely symmetric and flexible, so you can compare fields, numbers, strings, and so on. I don't think there's a good way to implement this until we support
And require that field references everywhere need brackets. |
progress in master...refilter looks good. I confirmed that However, something like this should also work:
or even (though less useful).
This also breaks something like:
|
more on what mapnik supports: http://mapnik.org/news/2009/12/08/future_mapnik2/ |
@tmcw - is it a good time to revisit this? |
Yep, I'll take a look at it today. |
This needs to wait on a rewrite of the filter logic. Right now this is absurdly complex and should probably be fixed at the mapnik level more, or something. |
@tmcw - where is this one at now from your perspective? |
Getting closer - the last push I did of the filter logic should make this doable, but there's still a strong assumption in filterset that needs to be sorted out. |
I just test the code below and everything works fine. I think this issue can be closed! #style1[[billing] > [estimate]] {
marker-fill: green;
}
#style2[[billing] < [estimate]] {
marker-fill: red;
} <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Map srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over" maximum-extent="-20037508.34,-20037508.34,20037508.34,20037508.34">
<Style name="style1" filter-mode="first">
<Rule>
<Filter>([billing] > [estimate])</Filter>
<MarkersSymbolizer fill="#008000"/>
</Rule>
</Style>
<Style name="style2" filter-mode="first">
<Rule>
<Filter>([billing] < [estimate])</Filter>
<MarkersSymbolizer fill="#ff0000"/>
</Rule>
</Style>
</Map> Att. |
@tmcw Could you point me towards what you mean here? |
The examples mentioned in #121 (comment), #121 (comment) (except the last one) and #121 (comment) are (now) working. I'm waiting with closing until I know if there is something left to do. |
No further input, so I'm closing. |
Comparing two fields in a rule returns the error 'Cannot use operator ">" with value NaN'.
For example, I used this rule:
Where
dem
andrep
are integer values.The full Mapnik xml is here: https://gist.github.com/58423739bc4418764062
The text was updated successfully, but these errors were encountered: