From dd662b576ca986e7e3ab6d698a93e3aeadfee148 Mon Sep 17 00:00:00 2001 From: nebulon42 Date: Fri, 20 Jan 2017 17:18:41 +0100 Subject: [PATCH] test for #343 and first part of a fix --- lib/carto/tree/definition.js | 9 +++++++-- lib/carto/tree/filterset.js | 2 +- test/rendering-mss/issue_343a.mss | 14 ++++++++++++++ test/rendering-mss/issue_343a.xml | 23 +++++++++++++++++++++++ test/rendering-mss/issue_343b.mss | 14 ++++++++++++++ test/rendering-mss/issue_343b.xml | 23 +++++++++++++++++++++++ 6 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 test/rendering-mss/issue_343a.mss create mode 100644 test/rendering-mss/issue_343a.xml create mode 100644 test/rendering-mss/issue_343b.mss create mode 100644 test/rendering-mss/issue_343b.xml diff --git a/lib/carto/tree/definition.js b/lib/carto/tree/definition.js index 3996c369d..9b84beddd 100644 --- a/lib/carto/tree/definition.js +++ b/lib/carto/tree/definition.js @@ -211,13 +211,18 @@ tree.Definition.prototype.collectSymbolizers = function(zooms, i) { // resorting to the zoom range with the hole and stop processing further rules. tree.Definition.prototype.toXML = function(env, existing) { var filter = this.filters.toString(); - if (!(filter in existing)) existing[filter] = tree.Zoom.all; + if (!(filter in existing)) { + existing[filter] = tree.Zoom.all; + } var available = tree.Zoom.all, xml = '', symbolizers, zooms = { available: tree.Zoom.all }; + for (var i = 0; i < this.rules.length && available; i++) { zooms.rule = this.rules[i].zoom; - if (!(existing[filter] & zooms.rule)) continue; + if (!(existing[filter] & zooms.rule)) { + continue; + } do { zooms.current = zooms.rule & available; diff --git a/lib/carto/tree/filterset.js b/lib/carto/tree/filterset.js index 0c3f4e593..daee15bb9 100644 --- a/lib/carto/tree/filterset.js +++ b/lib/carto/tree/filterset.js @@ -236,7 +236,7 @@ tree.Filterset.prototype.add = function(filter, env) { // eslint-disable-line if (op === '=') { for (var i in this.filters) { - if (this.filters[i].key == key) delete this.filters[i]; + if (this.filters[i].key == key && this.filters[i].op != '=~') delete this.filters[i]; } this.filters[key + '='] = filter; } else if (op === '!=') { diff --git a/test/rendering-mss/issue_343a.mss b/test/rendering-mss/issue_343a.mss new file mode 100644 index 000000000..2d483391f --- /dev/null +++ b/test/rendering-mss/issue_343a.mss @@ -0,0 +1,14 @@ +[zoom >= 12] { + [tourism = "attraction"] { + marker-type: ellipse; + marker-fill: red; + marker-width: 20; + } +} +[zoom >= 11] { + [tourism =~ "anythingelse"] { + marker-type: ellipse; + marker-fill: blue; + marker-width: 6; + } +} diff --git a/test/rendering-mss/issue_343a.xml b/test/rendering-mss/issue_343a.xml new file mode 100644 index 000000000..46de23c40 --- /dev/null +++ b/test/rendering-mss/issue_343a.xml @@ -0,0 +1,23 @@ + diff --git a/test/rendering-mss/issue_343b.mss b/test/rendering-mss/issue_343b.mss new file mode 100644 index 000000000..40eb26c9b --- /dev/null +++ b/test/rendering-mss/issue_343b.mss @@ -0,0 +1,14 @@ +[zoom >= 11] { + [tourism =~ "anythingelse"] { + marker-type: ellipse; + marker-fill: blue; + marker-width: 6; + } +} +[zoom >= 12] { + [tourism = "attraction"] { + marker-type: ellipse; + marker-fill: red; + marker-width: 20; + } +} diff --git a/test/rendering-mss/issue_343b.xml b/test/rendering-mss/issue_343b.xml new file mode 100644 index 000000000..313b77b6b --- /dev/null +++ b/test/rendering-mss/issue_343b.xml @@ -0,0 +1,23 @@ + \ No newline at end of file