Pushing new serialization tag in reference.json, new textsymbolizer

syntax, version 0.4.0
This commit is contained in:
Tom MacWright 2011-10-19 14:03:25 -04:00
parent f5258f1eb3
commit 72bd0b9ad2
5 changed files with 26 additions and 4 deletions

View File

@ -1,5 +1,9 @@
## Changelog
### 0.4.0
* Switches text-symbolizer syntax to new-style for Mapnik 2.0
### 0.3.0
* Add "name/" prefix for creating multiple instances of a symbolizer in the same

View File

@ -104,11 +104,22 @@ tree.Definition.prototype.symbolizersToXML = function(env, symbolizers, zoom) {
return str[1].toUpperCase();
}) + 'Symbolizer';
var selfclosing = true, tagcontent;
xml += ' <' + name + ' ';
for (var key in attributes) {
xml += attributes[key].eval(env).toXML(env) + ' ';
var x = tree.Reference.selector(attributes[key].name);
if (x.serialization && x.serialization === 'content') {
selfclosing = false;
tagcontent = attributes[key].eval(env).toXML(env, true);
} else {
xml += attributes[key].eval(env).toXML(env) + ' ';
}
}
if (selfclosing) {
xml += '/>\n';
} else {
xml += '>' + tagcontent + '</' + name + '>\n';
}
xml += '/>\n';
}
xml += ' </Rule>\n';
return xml;

View File

@ -631,6 +631,7 @@
"css": "text-name",
"type": "string",
"required": true,
"serialization": "content",
"doc": "Value to use for a text label. Data columns are specified using brackets like [column_name]"
},
"face-name": {

View File

@ -31,7 +31,11 @@ tree.Rule.prototype.toString = function() {
return '[' + tree.Zoom.toString(this.zoom) + '] ' + this.name + ': ' + this.value;
};
tree.Rule.prototype.toXML = function(env) {
// second argument, if true, outputs the value of this
// 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) {
if (!tree.Reference.validSelector(this.name)) {
return env.error({
message: "Unrecognized rule: " + this.name,
@ -62,6 +66,8 @@ tree.Rule.prototype.toXML = function(env) {
} else if (tree.Reference.isFont(this.name) && this.value.value.length > 1) {
var f = tree._getFontSet(env, this.value.value);
return 'fontset-name="' + f.name + '"';
} else if (content) {
return this.value.toString(env, this.name);
} else {
return tree.Reference.selectorName(this.name) +
'="' +

View File

@ -22,7 +22,7 @@
"Konstantin Käfer",
"Alexis Sellier <self@cloudhead.net>"
],
"version": "0.3.0",
"version": "0.4.0",
"licenses": [{
"type": "Apache"
}],