{"id":271,"date":"2007-10-01T07:14:25","date_gmt":"2007-10-01T12:14:25","guid":{"rendered":"http:\/\/crschmidt.net\/blog\/?p=271"},"modified":"2007-10-01T07:14:25","modified_gmt":"2007-10-01T12:14:25","slug":"sld-rule-evaluation","status":"publish","type":"post","link":"https:\/\/crschmidt.net\/blog\/archives\/271\/sld-rule-evaluation\/","title":{"rendered":"SLD Rule Evaluation?"},"content":{"rendered":"<p>I&#8217;m curious about how others store\/evaluate SLD rules\/filters. At the moment, in OpenLayers SLD rendering, we have an &#8216;applies&#8217;, which is a string something like:<\/p>\n<p>&#8220;feature[&#8216;attributename&#8217;] == &#8216;foo&#8217; || feature.fid == 1&#8221;<\/p>\n<p>Which we eval. Yuck, I know.<\/p>\n<p>But how else do you do it? What&#8217;s the internal storage look like?<\/p>\n<p>I originally thought of something like a set of tuples:<\/p>\n<p>(&#8216;operation&#8217;, &#8216;value&#8217;, &#8216;type&#8217;, &#8216;extra&#8217;):<\/p>\n<ul>\n<li>(&#8216;equals&#8217;, &#8216;foo&#8217;, &#8216;attribute&#8217;, &#8216;attributename&#8217;)<\/li>\n<li>(&#8216;equals&#8217;, 1, &#8216;fid&#8217;)<\/li>\n<\/ul>\n<p>But then Andreas pointed out that these are not just &#8216;and&#8217; or &#8216;or&#8217;, but either of the two, and can also be nested&#8230; 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&#8230; but then again, so does eval.<\/p>\n<p>Would love to have advice from someone else as to how they implement SLD filters and their application.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m curious about how others store\/evaluate SLD rules\/filters. At the moment, in OpenLayers SLD rendering, we have an &#8216;applies&#8217;, which is a string something like: &#8220;feature[&#8216;attributename&#8217;] == &#8216;foo&#8217; || feature.fid == 1&#8221; Which we eval. Yuck, I know. But how else do you do it? What&#8217;s the internal storage look like? I originally thought of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[44,54],"tags":[],"class_list":["post-271","post","type-post","status-publish","format-standard","hentry","category-locality-and-space","category-openlayers"],"_links":{"self":[{"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/posts\/271","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/comments?post=271"}],"version-history":[{"count":0,"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/posts\/271\/revisions"}],"wp:attachment":[{"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/media?parent=271"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/categories?post=271"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/tags?post=271"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}