Prevent image filter duplication. Fixes #270
This commit is contained in:
parent
0f65b869fd
commit
b113bfea99
@ -28,9 +28,11 @@ tree.StyleXML = function(name, attachment, definitions, env) {
|
|||||||
var attrs_xml = '';
|
var attrs_xml = '';
|
||||||
|
|
||||||
if (image_filters.length) {
|
if (image_filters.length) {
|
||||||
attrs_xml += ' image-filters="' + image_filters.map(function(f) {
|
attrs_xml += ' image-filters="' + _.chain(image_filters)
|
||||||
|
// prevent identical filters from being duplicated in the style
|
||||||
|
.uniq(function(i) { return i.id; }).map(function(f) {
|
||||||
return f.ev(env).toXML(env, true, ',', 'image-filter');
|
return f.ev(env).toXML(env, true, ',', 'image-filter');
|
||||||
}).join(',') + '"';
|
}).value().join(',') + '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (comp_op.length) {
|
if (comp_op.length) {
|
||||||
|
15
test/rendering/imagefilter-duplication.mml
Normal file
15
test/rendering/imagefilter-duplication.mml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over",
|
||||||
|
"Stylesheet": [
|
||||||
|
"imagefilter-duplication.mss"
|
||||||
|
],
|
||||||
|
"Layer": [{
|
||||||
|
"name": "world",
|
||||||
|
"srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over",
|
||||||
|
"Datasource": {
|
||||||
|
"file": "http://tilemill-data.s3.amazonaws.com/test_data/shape_demo.zip",
|
||||||
|
"type": "shape"
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
5
test/rendering/imagefilter-duplication.mss
Normal file
5
test/rendering/imagefilter-duplication.mss
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#world {
|
||||||
|
image-filters:agg-stack-blur(3,3);
|
||||||
|
[zoom=2] { line-width: 3; }
|
||||||
|
[zoom=3] { line-width: 5; }
|
||||||
|
}
|
27
test/rendering/imagefilter-duplication.result
Normal file
27
test/rendering/imagefilter-duplication.result
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE Map[]>
|
||||||
|
<Map srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over" maximum-extent="-20037508.34,-20037508.34,20037508.34,20037508.34">
|
||||||
|
|
||||||
|
|
||||||
|
<Style name="world" filter-mode="first" image-filters="agg-stack-blur(3,3)">
|
||||||
|
<Rule>
|
||||||
|
<MaxScaleDenominator>100000000</MaxScaleDenominator>
|
||||||
|
<MinScaleDenominator>50000000</MinScaleDenominator>
|
||||||
|
<LineSymbolizer stroke-width="5" />
|
||||||
|
</Rule>
|
||||||
|
<Rule>
|
||||||
|
<MaxScaleDenominator>200000000</MaxScaleDenominator>
|
||||||
|
<MinScaleDenominator>100000000</MinScaleDenominator>
|
||||||
|
<LineSymbolizer stroke-width="3" />
|
||||||
|
</Rule>
|
||||||
|
</Style>
|
||||||
|
<Layer name="world"
|
||||||
|
srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
|
||||||
|
<StyleName>world</StyleName>
|
||||||
|
<Datasource>
|
||||||
|
<Parameter name="file"><![CDATA[[absolute path]]]></Parameter>
|
||||||
|
<Parameter name="type"><![CDATA[shape]]></Parameter>
|
||||||
|
</Datasource>
|
||||||
|
</Layer>
|
||||||
|
|
||||||
|
</Map>
|
Loading…
Reference in New Issue
Block a user