Adding required attributes for shieldsymbolizer and textsymbolizer. Fixes #20.
This commit is contained in:
parent
e035a8986e
commit
370e3f917c
@ -192,11 +192,13 @@ tree.Reference = {
|
||||
"shield": {
|
||||
"name": {
|
||||
"css": "shield-name",
|
||||
"type": "none"
|
||||
"type": "none",
|
||||
"required": true
|
||||
},
|
||||
"face-name": {
|
||||
"css": "shield-name",
|
||||
"type": "string"
|
||||
"face_name": {
|
||||
"css": "shield-face-name",
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"size": {
|
||||
"css": "shield-size",
|
||||
@ -388,11 +390,13 @@ tree.Reference = {
|
||||
"text": {
|
||||
"name": {
|
||||
"css": "text-name",
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"face_name": {
|
||||
"css": "text-face-name",
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"size": {
|
||||
"css": "text-size",
|
||||
@ -664,6 +668,26 @@ tree.Reference.symbolizer = function(selector) {
|
||||
}
|
||||
};
|
||||
|
||||
tree.Reference.requiredPropertyList = function(symbolizer_name) {
|
||||
var properties = [];
|
||||
for (var j in tree.Reference.symbolizers[symbolizer_name]) {
|
||||
if (tree.Reference.symbolizers[symbolizer_name][j].required) {
|
||||
properties.push(tree.Reference.symbolizers[symbolizer_name][j].css);
|
||||
}
|
||||
}
|
||||
return properties;
|
||||
};
|
||||
|
||||
tree.Reference.requiredProperties = function(symbolizer_name, properties) {
|
||||
var req = tree.Reference.requiredPropertyList(symbolizer_name);
|
||||
for (i in req) {
|
||||
if (properties.indexOf(req[i]) === -1) {
|
||||
return 'Property ' + req[i] + ' required for defining '
|
||||
+ symbolizer_name + ' styles.';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
tree.Reference.validValue = function(selector, value) {
|
||||
if (value[0]) {
|
||||
return tree.Reference.selector(selector).type == value[0].is;
|
||||
|
@ -156,7 +156,6 @@ tree.Ruleset.prototype = {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rulesets = rulesets.join('');
|
||||
|
||||
// If this is the root node, we don't render
|
||||
@ -191,9 +190,17 @@ tree.Ruleset.prototype = {
|
||||
var symname = i.charAt(0).toUpperCase() + i.slice(1) + 'Symbolizer';
|
||||
// TODO: replace with _.values when underscore is included
|
||||
sym = [];
|
||||
prop_names = [];
|
||||
for (j in symbolizers[i]) {
|
||||
sym.push(symbolizers[i][j]);
|
||||
prop_names.push(j);
|
||||
}
|
||||
if (err = tree.Reference.requiredProperties(i, prop_names)) {
|
||||
throw {
|
||||
message: err
|
||||
};
|
||||
}
|
||||
|
||||
out.push(' <' +
|
||||
symname + ' ' +
|
||||
sym.join('\n ') +
|
||||
|
Loading…
Reference in New Issue
Block a user