diff --git a/lib/carto/tree/definition.js b/lib/carto/tree/definition.js
index 2283c18c5..9b0afa862 100644
--- a/lib/carto/tree/definition.js
+++ b/lib/carto/tree/definition.js
@@ -186,13 +186,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 933439298..ceadbac00 100644
--- a/lib/carto/tree/filterset.js
+++ b/lib/carto/tree/filterset.js
@@ -234,7 +234,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