Revert last, still in transforms branch

This commit is contained in:
Tom MacWright 2012-06-20 19:04:18 -04:00
parent 5ff9051104
commit 42784dcca2
13 changed files with 32 additions and 75 deletions

View File

@ -50,7 +50,7 @@ var carto = {
}
};
[ 'call', 'color', 'comment', 'definition', 'dimension',
[ 'anonymous', 'call', 'color', 'comment', 'definition', 'dimension',
'directive', 'element', 'expression', 'filterset', 'filter',
'keyword', 'layer', 'operation', 'quoted', 'imagefilter',
'reference', 'rule', 'ruleset', 'selector', 'style', 'url', 'value',

View File

@ -497,7 +497,7 @@ carto.Parser = function Parser(env) {
return new tree.Invalid(value, memo, 'Missing closing ) in URL.');
} else {
return new tree.URL((value.value || value instanceof tree.Variable) ?
value : new tree.Quoted('"', value), imports.paths);
value : new tree.Anonymous(value), imports.paths);
}
},

View File

@ -0,0 +1,13 @@
(function(tree) {
tree.Anonymous = function Anonymous(string) {
this.value = string.value || string;
};
tree.Anonymous.prototype = {
toString: function() {
return this.value;
},
eval: function() { return this; }
};
})(require('../tree'));

View File

@ -4,13 +4,11 @@
// A function call node.
//
tree.Call = function Call(name, args, index) {
this.is = 'call';
this.name = name;
this.args = args;
this.is = 'call';
this.index = index;
};
tree.Call.prototype = {
//
// When evaluating a function call,
@ -36,7 +34,7 @@ tree.Call.prototype = {
}
}
if (this.name in tree.functions) {
if (this.name in tree.functions) { // 1.
if (tree.functions[this.name].length === args.length) {
return tree.functions[this.name].apply(tree.functions, args);
} else {
@ -52,26 +50,16 @@ tree.Call.prototype = {
value: 'undefined'
};
}
} else {
return this;
// return new tree.Anonymous(this.name +
// '(' + args.map(function(a) { return a.toString(); }).join(', ') + ')');
} else { // 2.
return new tree.Anonymous(this.name +
'(' + args.map(function(a) { return a.toString(); }).join(', ') + ')');
}
},
toString: function(env, format) {
if (format === 'image-filter') {
if (this.args.length) {
return this.name + ':' + this.args.join(',');
} else {
return this.name;
}
toString: function(env) {
if (this.args.length) {
return this.name + ':' + this.args.join(',');
} else {
if (this.args.length) {
return this.name + '(' + this.args.join(',') + ')';
} else {
return this.name;
}
return this.name;
}
}
};

View File

@ -125,7 +125,6 @@ tree.Reference.validValue = function(env, selector, value) {
} else if (tree.Reference.selector(selector).type == 'functions') {
for (i in value.value) {
for (j in value.value[i].value) {
console.log(value.value[i]);
if (value.value[i].value[j].is !== 'call') {
return false;
}

View File

@ -35,7 +35,7 @@ tree.Rule.prototype.toString = function() {
// rule without the usual attribute="content" wrapping. Right
// now this is just for the TextSymbolizer, but applies to other
// properties in reference.json which specify serialization=content
tree.Rule.prototype.toXML = function(env, content, sep, format) {
tree.Rule.prototype.toXML = function(env, content) {
if (!tree.Reference.validSelector(this.name)) {
return env.error({
message: "Unrecognized rule: " + this.name,
@ -77,7 +77,7 @@ tree.Rule.prototype.toXML = function(env, content, sep, format) {
var f = tree._getFontSet(env, this.value.value);
return 'fontset-name="' + f.name + '"';
} else if (content) {
return this.value.toString(env, this.name, sep);
return this.value.toString(env, this.name);
} else {
return tree.Reference.selectorName(this.name) +
'="' +

View File

@ -36,10 +36,10 @@ tree.Style.prototype.toXML = function(env) {
if (image_filters.length) {
attrs_xml += ' image-filters="' + image_filters.map(function(f) {
return f.eval(env).toXML(env, true, ' ', 'image-filter');
}).join(' ') + '" ';
return f.toXML(env, true);
}).join(',') + '" ';
}
if (comp_op.length) {
attrs_xml += ' comp-op="' + comp_op[0].value.eval(env).toString() + '" ';
}

View File

@ -4,7 +4,6 @@ tree.Value = function Value(value) {
this.value = value;
this.is = 'value';
};
tree.Value.prototype = {
eval: function(env) {
if (this.value.length === 1) {
@ -15,13 +14,11 @@ tree.Value.prototype = {
}));
}
},
toString: function(env, selector, sep, format) {
toString: function(env, selector, sep) {
return this.value.map(function(e) {
return e.toString(env, format);
return e.toString(env);
}).join(sep || ', ');
},
clone: function() {
var obj = Object.create(tree.Value.prototype);
if (Array.isArray(obj)) obj.value = this.value.slice();

View File

@ -5,7 +5,6 @@ tree.Variable = function Variable(name, index, filename) {
this.index = index;
this.filename = filename;
};
tree.Variable.prototype = {
eval: function(env) {
var variable,
@ -18,7 +17,6 @@ tree.Variable.prototype = {
var thisframe = env.frames.filter(function(f) {
return f.name == that.name;
});
if (thisframe.length) {
return thisframe[0].value.eval(env);
} else {

View File

@ -2,7 +2,7 @@
polygon-fill: #FFF;
line-color:#F00;
line-width: 0.5;
image-filters: blur(), sharpen(), agg-stack-blur(2, 2);
image-filters: blur() sharpen() agg-stack-blur(2, 2);
composite-operation: src-in;
line-dasharray: 2, 3;
}

View File

@ -1,14 +0,0 @@
{
"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": [
"transforms.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"
}
}]
}

View File

@ -1,4 +0,0 @@
#world {
point-file: url(foo.png);
point-transform: translate(2, 2);
}

View File

@ -1,20 +0,0 @@
<?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" >
<Rule>
<PointSymbolizer file="foo.png" transform="translate(2,2)" />
</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>