Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
test for #343 and first part of a fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nebulon42 committed Jul 10, 2017
1 parent 81c56a7 commit fba9bd9
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/carto/tree/definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ tree.Definition.prototype.collectSymbolizers = function(zooms, i) {
// resorting to the zoom range with the hole and stop processing further rules.
tree.Definition.prototype.toObject = 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,
objects = [],
Expand All @@ -241,7 +243,9 @@ tree.Definition.prototype.toObject = function(env, existing) {

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;
Expand Down
2 changes: 1 addition & 1 deletion lib/carto/tree/filterset.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ tree.Filterset.prototype.add = function(filter) {

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 === '!=') {
Expand Down
14 changes: 14 additions & 0 deletions test/rendering-mss/issue_343a.mss
Original file line number Diff line number Diff line change
@@ -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;
}
}
23 changes: 23 additions & 0 deletions test/rendering-mss/issue_343a.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Style name="style" filter-mode="first">
<Rule>
<MaxScaleDenominator>200000</MaxScaleDenominator>
<Filter>([tourism] = 'attraction') and ([tourism].match('anythingelse'))</Filter>
<MarkersSymbolizer marker-type="ellipse" fill="#ff0000" width="20" />
</Rule>
<Rule>
<MaxScaleDenominator>400000</MaxScaleDenominator>
<MinScaleDenominator>200000</MinScaleDenominator>
<Filter>([tourism] = 'attraction') and ([tourism].match('anythingelse'))</Filter>
<MarkersSymbolizer marker-type="ellipse" fill="#0000ff" width="6" />
</Rule>
<Rule>
<MaxScaleDenominator>200000</MaxScaleDenominator>
<Filter>([tourism] = 'attraction')</Filter>
<MarkersSymbolizer marker-type="ellipse" fill="#ff0000" width="20" />
</Rule>
<Rule>
<MaxScaleDenominator>400000</MaxScaleDenominator>
<Filter>([tourism].match('anythingelse'))</Filter>
<MarkersSymbolizer marker-type="ellipse" fill="#0000ff" width="6" />
</Rule>
</Style>
14 changes: 14 additions & 0 deletions test/rendering-mss/issue_343b.mss
Original file line number Diff line number Diff line change
@@ -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;
}
}
23 changes: 23 additions & 0 deletions test/rendering-mss/issue_343b.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Style name="style" filter-mode="first">
<Rule>
<MaxScaleDenominator>200000</MaxScaleDenominator>
<Filter>([tourism] = 'attraction') and ([tourism].match('anythingelse'))</Filter>
<MarkersSymbolizer marker-type="ellipse" fill="#ff0000" width="20" />
</Rule>
<Rule>
<MaxScaleDenominator>400000</MaxScaleDenominator>
<MinScaleDenominator>200000</MinScaleDenominator>
<Filter>([tourism] = 'attraction') and ([tourism].match('anythingelse'))</Filter>
<MarkersSymbolizer marker-type="ellipse" fill="#0000ff" width="6" />
</Rule>
<Rule>
<MaxScaleDenominator>200000</MaxScaleDenominator>
<Filter>([tourism] = 'attraction')</Filter>
<MarkersSymbolizer marker-type="ellipse" fill="#ff0000" width="20" />
</Rule>
<Rule>
<MaxScaleDenominator>400000</MaxScaleDenominator>
<Filter>([tourism].match('anythingelse'))</Filter>
<MarkersSymbolizer marker-type="ellipse" fill="#0000ff" width="6" />
</Rule>
</Style>

0 comments on commit fba9bd9

Please sign in to comment.