Merge branch 'master' of github.com:mapbox/carto
This commit is contained in:
commit
339c330a6a
@ -4,6 +4,8 @@
|
||||
|
||||
* Add "name/" prefix for creating multiple instances of a symbolizer in the same
|
||||
attachment
|
||||
* Only output <Layer> tag when there's at least one style
|
||||
* Sort styles by location of first rule's index
|
||||
|
||||
### 0.2.3
|
||||
|
||||
|
@ -48,7 +48,9 @@ carto.Renderer.prototype.render = function render(m, callback) {
|
||||
var matching = rulesets.filter(function(definition) {
|
||||
return definition.appliesTo(l.name, classes);
|
||||
});
|
||||
_(inheritRules(matching, env)).each(function(rule) {
|
||||
var rules = inheritRules(matching, env);
|
||||
sorted = sortStyles(rules, env);
|
||||
_(sorted).each(function(rule) {
|
||||
var style = new tree.Style(l.name, rule.attachment, rule);
|
||||
if (style) {
|
||||
l.styles.push(style.name);
|
||||
@ -57,7 +59,9 @@ carto.Renderer.prototype.render = function render(m, callback) {
|
||||
output.push(style.toXML(env));
|
||||
}
|
||||
});
|
||||
output.push((new carto.tree.Layer(l)).toXML());
|
||||
if (l.styles.length) {
|
||||
output.push((new carto.tree.Layer(l)).toXML());
|
||||
}
|
||||
});
|
||||
|
||||
output.unshift(env.effects.map(function(e) {
|
||||
@ -165,6 +169,25 @@ function inheritRules(definitions, env) {
|
||||
return result;
|
||||
}
|
||||
|
||||
function sortStyles(styles, env) {
|
||||
styles.forEach(function(style) {
|
||||
style.index = Infinity;
|
||||
style.forEach(function(block) {
|
||||
block.rules.forEach(function(rule) {
|
||||
if (rule.index < style.index) {
|
||||
style.index = rule.index;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
var result = styles.slice();
|
||||
result.sort(function(a, b) {
|
||||
return b.index - a.index;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
// Find a rule like Map { background-color: #fff; },
|
||||
// if any, and return a list of properties to be inserted
|
||||
// into the <Map element of the resulting XML. Translates
|
||||
|
Loading…
Reference in New Issue
Block a user