Permalink
Browse files

update reference.json, will need update on mapnik/reference.json side

  • Loading branch information...
2 parents 306500b + fef914c commit bea9b437875206a030dcb6df3cf9478a2149dbba @tmcw tmcw committed Jun 18, 2012
@@ -130,6 +130,24 @@ tree.functions = {
}
};
+var image_filter_functors = [
+ 'emboss', 'blur', 'gray', 'sobel', 'edge-detect',
+ 'x-gradient', 'y-gradient', 'sharpen'];
+
+for (var i = 0; i < image_filter_functors.length; i++) {
+ var f = image_filter_functors[i];
+ tree.functions[f] = (function(f) {
+ return function() {
+ return new tree.ImageFilter(f);
+ };
+ })(f);
+}
+
+tree.functions['agg-stack-blur'] = function(x, y) {
+ return new tree.ImageFilter('agg-stack-blur', [x, y]);
+}
+
+
function hsla(hsla) {
return tree.functions.hsla(hsla.h, hsla.s, hsla.l, hsla.a);
}
View
@@ -52,7 +52,7 @@ var carto = {
[ 'anonymous', 'call', 'color', 'comment', 'definition', 'dimension',
'directive', 'element', 'expression', 'filterset', 'filter',
- 'keyword', 'layer', 'operation', 'quoted',
+ 'keyword', 'layer', 'operation', 'quoted', 'imagefilter',
'reference', 'rule', 'ruleset', 'selector', 'style', 'url', 'value',
'variable', 'zoom', 'invalid', 'fontset'
].forEach(function(n) {
View
@@ -479,14 +479,19 @@ carto.Parser = function Parser(env) {
name = name[1].toLowerCase();
- if (name === 'url') { return null }
- else { i += name.length + 1 }
+ if (name === 'url') {
+ return null;
+ } else {
+ i += name.length + 1;
+ }
args = $(this.entities.arguments);
- if (! $(')')) return;
+ if (!$(')')) return;
- if (name) { return new tree.Call(name, args, i) }
+ if (name) {
+ return new tree.Call(name, args, i);
+ }
},
arguments: function() {
var args = [], arg;
@@ -6,6 +6,7 @@
tree.Call = function Call(name, args, index) {
this.name = name;
this.args = args;
+ this.is = 'call';
this.index = index;
};
tree.Call.prototype = {
@@ -53,10 +54,6 @@ tree.Call.prototype = {
return new tree.Anonymous(this.name +
'(' + args.map(function(a) { return a.toString(); }).join(', ') + ')');
}
- },
-
- toString: function(env) {
- return this.eval(env).toString();
}
};
@@ -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()];
@@ -0,0 +1,23 @@
+(function(tree) {
+//
+// RGB Colors - #ff0014, #eee
+//
+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) {
+ return this.filter + ':' + this.args.join(',');
+ } else {
+ return this.filter;
+ }
+ }
+};
+
+
+})(require('../tree'));
@@ -91,9 +91,10 @@ 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;
if (value[0]) {
return tree.Reference.selector(selector).type == value[0].is;
} else {
@@ -113,10 +114,19 @@ tree.Reference.validValue = function(env, selector, value) {
}
}
return true;
+ } else if (tree.Reference.selector(selector).type == 'imagefilters') {
+ for (i in value.value) {
+ for (j in value.value[i].value) {
+ if (value.value[i].value[j].is !== 'imagefilter') {
+ return false;
+ }
+ }
+ }
+ return true;
} 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
@@ -131,6 +141,6 @@ tree.Reference.validValue = function(env, selector, value) {
}
}
}
-}
+};
})(require('../tree'));
Oops, something went wrong.

0 comments on commit bea9b43

Please sign in to comment.