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 Jan 20, 2017
1 parent fc18caa commit 1acaa1c
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 3 deletions.
9 changes: 7 additions & 2 deletions lib/carto/tree/definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
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 @@ -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 === '!=') {
Expand Down
10 changes: 10 additions & 0 deletions test/rendering/issue_343.mml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"Stylesheet": [
"issue_343.mss"
],
"Layer": [
{
"id": "world"
}
]
}
16 changes: 16 additions & 0 deletions test/rendering/issue_343.mss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#world {
[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;
}
}
}
31 changes: 31 additions & 0 deletions test/rendering/issue_343.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map[]>
<Map>
<Style name="world" filter-mode="first" >
<Rule>
<MaxScaleDenominator>200000</MaxScaleDenominator>
<Filter>([tourism].match('anythingelse')) and ([tourism] = 'attraction')</Filter>
<MarkersSymbolizer marker-type="ellipse" fill="#ff0000" width="20" />
</Rule>
<Rule>
<MaxScaleDenominator>400000</MaxScaleDenominator>
<MinScaleDenominator>200000</MinScaleDenominator>
<Filter>([tourism].match('anythingelse')) and ([tourism] = 'attraction')</Filter>
<MarkersSymbolizer marker-type="ellipse" fill="#0000ff" width="6" />
</Rule>
<Rule>
<MaxScaleDenominator>400000</MaxScaleDenominator>
<Filter>([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>
</Style>
<Layer name="world">
<StyleName>world</StyleName>
</Layer>

</Map>

0 comments on commit 1acaa1c

Please sign in to comment.