diff --git a/lib/carto/tree/definition.js b/lib/carto/tree/definition.js index 07f446e..a8ab4ea 100644 --- a/lib/carto/tree/definition.js +++ b/lib/carto/tree/definition.js @@ -90,6 +90,11 @@ tree.Definition.prototype.symbolizersToXML = function(env, symbolizers, zoom) { for (var i = 0; i < sym_order.length; i++) { var attributes = symbolizers[sym_order[i]]; var symbolizer = sym_order[i].split('/').pop(); + + // Skip the magical * symbolizer which is used for universal properties + // which are bubbled up to Style elements intead of Symbolizer elements. + if (symbolizer === '*') continue; + var fail = tree.Reference.requiredProperties(symbolizer, attributes); if (fail) { var rule = attributes[Object.keys(attributes).shift()]; diff --git a/lib/carto/tree/imagefilter.js b/lib/carto/tree/imagefilter.js index 80933a0..2ca0662 100644 --- a/lib/carto/tree/imagefilter.js +++ b/lib/carto/tree/imagefilter.js @@ -2,14 +2,20 @@ // // RGB Colors - #ff0014, #eee // -tree.ImageFilter = function ImageFilter(type, args) { +tree.ImageFilter = function ImageFilter(filter, args) { this.is = 'imagefilter'; + this.filter = filter; + this.args = args || null; }; tree.ImageFilter.prototype = { eval: function() { return this; }, toString: function() { - + if (this.args) { + // TODO + } else { + return this.filter; + } } }; diff --git a/lib/carto/tree/reference.js b/lib/carto/tree/reference.js index 3084dfc..9c9b2d7 100644 --- a/lib/carto/tree/reference.js +++ b/lib/carto/tree/reference.js @@ -91,7 +91,7 @@ tree.Reference._validateValue = { tree.Reference.isFont = function(selector) { return tree.Reference.selector(selector).validate == 'font'; -} +}; tree.Reference.validValue = function(env, selector, value) { var i, j; @@ -126,7 +126,7 @@ tree.Reference.validValue = function(env, selector, value) { } else { if (tree.Reference.selector(selector).validate) { var valid = false; - for (var i = 0; i < value.value.length; i++) { + for (i = 0; i < value.value.length; i++) { if (tree.Reference.selector(selector).type == value.value[i].is && tree.Reference ._validateValue @@ -141,6 +141,6 @@ tree.Reference.validValue = function(env, selector, value) { } } } -} +}; })(require('../tree')); diff --git a/lib/carto/tree/style.js b/lib/carto/tree/style.js index 854be9b..f89ea0b 100644 --- a/lib/carto/tree/style.js +++ b/lib/carto/tree/style.js @@ -1,4 +1,5 @@ (function(tree) { +var _ = require('underscore'); tree.Style = function Style(name, attachment, definitions) { this.attachment = attachment; @@ -9,11 +10,25 @@ tree.Style = function Style(name, attachment, definitions) { tree.Style.prototype.toXML = function(env) { var existing = {}; // TODO :add filters and comp op + var image_filters = _.flatten(this.definitions.map(function(definition) { + return definition.rules.filter(function(rule) { + return (rule.name === 'image-filters'); + }); + })); + var rules = this.definitions.map(function(definition) { return definition.toXML(env, existing); }); - return ''; + var image_filters_xml = ''; + + if (image_filters.length) { + image_filters_xml = 'image-filters="' + image_filters.map(function(f) { + return f.value.eval(env).toString(env, null, ';'); + }).join(',') + '"'; + } + + return ''; }; })(require('../tree')); diff --git a/lib/carto/tree/value.js b/lib/carto/tree/value.js index 2dc8fca..531a5c9 100644 --- a/lib/carto/tree/value.js +++ b/lib/carto/tree/value.js @@ -14,10 +14,10 @@ tree.Value.prototype = { })); } }, - toString: function(env, selector) { + toString: function(env, selector, sep) { return this.value.map(function(e) { return e.toString(env); - }).join(', '); + }).join(sep || ', '); }, clone: function() { var obj = Object.create(tree.Value.prototype); diff --git a/test/rendering/image_filters.mss b/test/rendering/image_filters.mss index 10c491d..5a57d74 100644 --- a/test/rendering/image_filters.mss +++ b/test/rendering/image_filters.mss @@ -2,5 +2,6 @@ polygon-fill: #FFF; line-color:#F00; line-width: 0.5; - image-filters: blur() sharpen(); + image-filters: blur(), sharpen(); + line-dasharray: 2, 3; }