SLD Rule Evaluation?
I’m curious about how others store/evaluate SLD rules/filters. At the moment, in OpenLayers SLD rendering, we have an ‘applies’, which is a string something like:
“feature[‘attributename’] == ‘foo’ || feature.fid == 1”
Which we eval. Yuck, I know.
But how else do you do it? What’s the internal storage look like?
I originally thought of something like a set of tuples:
(‘operation’, ‘value’, ‘type’, ‘extra’):
- (‘equals’, ‘foo’, ‘attribute’, ‘attributename’)
- (‘equals’, 1, ‘fid’)
But then Andreas pointed out that these are not just ‘and’ or ‘or’, but either of the two, and can also be nested… it seems like it quickly goes complex enough that we would need to implement a full boolean logic thingy of some kind, and it seems like the wrong way to go… but then again, so does eval.
Would love to have advice from someone else as to how they implement SLD filters and their application.
October 1st, 2007 at 1:19 pm
Why not DOM to store and compile into javascript for evaluation?
October 1st, 2007 at 1:40 pm
1. eval is slow
2. I hate calling eval on random stuff given to me by users.
3. Expressions don’t feel like the right way to implement filtering. But maybe I’m wrong.
October 1st, 2007 at 1:56 pm
I just wanted to make sure you ruled out the brain-dead solution before you wrote a rules engine.