🎨 adding any, none, has, !has, >, < and <= style filters

This commit is contained in:
Michael Straßburger 2016-11-05 20:24:49 +01:00
parent f705cf4cd4
commit 401335049d

View File

@ -61,6 +61,18 @@ module.exports = class Styler
return false for appliesTo in filters when not appliesTo feature return false for appliesTo in filters when not appliesTo feature
true true
when "any"
filters = (@_compileFilter subFilter for subFilter in filter[1..])
(feature) ->
return true for appliesTo in filters when appliesTo feature
false
when "none"
filters = (@_compileFilter subFilter for subFilter in filter[1..])
(feature) ->
return false for appliesTo in filters when appliesTo feature
true
when "==" when "=="
(feature) -> feature.properties[filter[1]] is filter[2] (feature) -> feature.properties[filter[1]] is filter[2]
@ -77,9 +89,21 @@ module.exports = class Styler
return false for value in filter[2..] when feature.properties[filter[1]] is value return false for value in filter[2..] when feature.properties[filter[1]] is value
true true
when "has"
(feature) -> !!feature.properties[filter[1]]
when "!has"
(feature) -> !feature.properties[filter[1]]
when ">"
(feature) -> feature.properties[filter[1]] > filter[2]
when ">=" when ">="
(feature) -> feature.properties[filter[1]] >= filter[2] (feature) -> feature.properties[filter[1]] >= filter[2]
when "<"
(feature) -> feature.properties[filter[1]] < filter[2]
when "<=" when "<="
(feature) -> feature.properties[filter[1]] <= filter[2] (feature) -> feature.properties[filter[1]] <= filter[2]