From 19d1cd83ff15fbb92cd4a029e43527d2cde1a8e6 Mon Sep 17 00:00:00 2001 From: MikeGodin Date: Thu, 30 Jul 2015 12:03:57 -0400 Subject: [PATCH] Added numeric value comparison filters Added numeric value comparison filters for ">", "<", ">=", and "<=". --- lib/cartoRenderer.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/cartoRenderer.js b/lib/cartoRenderer.js index d5ca345..960b50f 100644 --- a/lib/cartoRenderer.js +++ b/lib/cartoRenderer.js @@ -1073,10 +1073,32 @@ var cartoSelectorIsMatch = function(definition, feature, source, zoom) { for (var filterKey in definition.filters) { var filter = definition.filters[filterKey]; - if (filter.op === "=") { + switch (filter.op) { + case "=": if (feature.properties[filter.key] !== filter.val) { return false; } + break; + case "<": + if (feature.properties[filter.key] >= filter.val) { + return false; + } + break; + case ">": + if (feature.properties[filter.key] <= filter.val) { + return false; + } + break; + case "<=": + if (feature.properties[filter.key] > filter.val) { + return false; + } + break; + case ">=": + if (feature.properties[filter.key] < filter.val) { + return false; + } + break; } } }