add support for direct-image-filters
This commit is contained in:
parent
f88711db72
commit
60396cbeef
@ -5,13 +5,16 @@ var _ = require('underscore');
|
||||
// return a stringified style for Mapnik
|
||||
tree.StyleXML = function(name, attachment, definitions, env) {
|
||||
var existing = {};
|
||||
var image_filters = [], comp_op = [], opacity = [];
|
||||
var image_filters = [], direct_image_filters = [], comp_op = [], opacity = [];
|
||||
|
||||
for (var i = 0; i < definitions.length; i++) {
|
||||
for (var j = 0; j < definitions[i].rules.length; j++) {
|
||||
if (definitions[i].rules[j].name === 'image-filters') {
|
||||
image_filters.push(definitions[i].rules[j]);
|
||||
}
|
||||
if (definitions[i].rules[j].name === 'direct-image-filters') {
|
||||
direct_image_filters.push(definitions[i].rules[j]);
|
||||
}
|
||||
if (definitions[i].rules[j].name === 'comp-op') {
|
||||
comp_op.push(definitions[i].rules[j]);
|
||||
}
|
||||
@ -35,6 +38,14 @@ tree.StyleXML = function(name, attachment, definitions, env) {
|
||||
}).value().join(',') + '"';
|
||||
}
|
||||
|
||||
if (direct_image_filters.length) {
|
||||
attrs_xml += ' direct-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, ',', 'direct-image-filter');
|
||||
}).value().join(',') + '"';
|
||||
}
|
||||
|
||||
if (comp_op.length) {
|
||||
attrs_xml += ' comp-op="' + comp_op[0].value.ev(env).toString() + '"';
|
||||
}
|
||||
|
5
test/rendering-mss/scale-hsla-filter.mss
Normal file
5
test/rendering-mss/scale-hsla-filter.mss
Normal file
@ -0,0 +1,5 @@
|
||||
#layer {
|
||||
polygon-fill:red;
|
||||
image-filters:scale-hsla(.5,.5,.5,.5,.5,.5,.5,.5);
|
||||
direct-image-filters:scale-hsla(.5,.5,.5,.5,.5,.5,.5,.5);
|
||||
}
|
5
test/rendering-mss/scale-hsla-filter.xml
Normal file
5
test/rendering-mss/scale-hsla-filter.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<Style name="style" filter-mode="first" image-filters="scale-hsla(0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5)" direct-image-filters="scale-hsla(0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5)">
|
||||
<Rule>
|
||||
<PolygonSymbolizer fill="#ff0000" />
|
||||
</Rule>
|
||||
</Style>
|
Loading…
Reference in New Issue
Block a user