add support for image-filters-inflate - refs mapnik/mapnik#2165

This commit is contained in:
Dane Springmeyer 2014-02-27 10:41:43 -08:00
parent 12a3d6cad2
commit a5e5c045c9
3 changed files with 12 additions and 4 deletions

View File

@ -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 = [], direct_image_filters = [], comp_op = [], opacity = [];
var image_filters = [], image_filters_inflate = [], 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 === 'image-filters-inflate') {
image_filters_inflate.push(definitions[i].rules[j]);
}
if (definitions[i].rules[j].name === 'direct-image-filters') {
direct_image_filters.push(definitions[i].rules[j]);
}
@ -38,6 +41,10 @@ tree.StyleXML = function(name, attachment, definitions, env) {
}).value().join(',') + '"';
}
if (image_filters_inflate.length) {
attrs_xml += ' image-filters-inflate="' + image_filters_inflate[0].value.ev(env).toString() + '"';
}
if (direct_image_filters.length) {
attrs_xml += ' direct-image-filters="' + _.chain(direct_image_filters)
// prevent identical filters from being duplicated in the style

View File

@ -1,4 +1,5 @@
#layer {
image-filters:invert();
direct-image-filters:invert();
image-filters:invert();
image-filters-inflate:true;
direct-image-filters:invert();
}

View File

@ -1,2 +1,2 @@
<Style name="style" filter-mode="first" image-filters="invert" direct-image-filters="invert">
<Style name="style" filter-mode="first" image-filters="invert" image-filters-inflate="true" direct-image-filters="invert">
</Style>