Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
do not rely on * symbolizer in the reference for image filters and co…
Browse files Browse the repository at this point in the history
…mpositing, ref mapnik/mapnik-reference#135
  • Loading branch information
nebulon42 committed Jul 5, 2017
1 parent 9ea8663 commit d240d6b
Showing 1 changed file with 41 additions and 18 deletions.
59 changes: 41 additions & 18 deletions lib/carto/tree/reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,57 @@ ref.selectorData = function(selector, i) {
};

ref.validSelector = function(selector) { return !!ref.selector_cache[selector]; };
ref.selectorName = function(selector) { return ref.selectorData(selector, 2); };
ref.selector = function(selector) { return ref.selectorData(selector, 0); };
ref.symbolizer = function(selector) { return ref.selectorData(selector, 1); };
ref.selectorName = function(selector) { return ref.selectorData(selector, 3); };
ref.selector = function(selector) { return ref.selectorData(selector, 1); };
ref.symbolizer = function(selector) { return ref.selectorData(selector, 2); };

function generateSelectorCache(data) {
var index = {};
for (var i in data.symbolizers) {
for (var j in data.symbolizers[i]) {
if (data.symbolizers[i][j].hasOwnProperty('css')) {
index[data.symbolizers[i][j].css] = [data.symbolizers[i][j], i, j];
}
_.forEach(data.style, function (rule, i) {
if (_.has(rule, 'css')) {
index[rule.css] = ['style', rule, '*', i];
}
}
});
_.forEach(data.layer, function (rule, i) {
if (_.has(rule, 'css')) {
index[rule.css] = ['layer', rule, '*', i];
}
});
_.forEach(data.symbolizers, function (symbolizer, i) {
_.forEach(symbolizer, function (rule, j) {
if (_.has(rule, 'css')) {
index[rule.css] = ['symbolizer', rule, i, j];
}
});
});
return index;
}

function generateMapnikFunctions(data) {
var functions = {};
for (var i in data.symbolizers) {
for (var j in data.symbolizers[i]) {
if (data.symbolizers[i][j].type === 'functions') {
for (var k = 0; k < data.symbolizers[i][j].functions.length; k++) {
var fn = data.symbolizers[i][j].functions[k];
functions[fn[0]] = fn[1];
}
}
_.forEach(data.style, function (rule) {
if (rule.type === 'functions') {
_.forEach(rule.functions, function (func) {
functions[func[0]] = func[1];
});
}
}
});
_.forEach(data.layer, function (rule) {
if (rule.type === 'functions') {
_.forEach(rule.functions, function (func) {
functions[func[0]] = func[1];
});
}
});
_.forEach(data.symbolizers, function (symbolizer) {
_.forEach(symbolizer, function (rule) {
if (rule.type === 'functions') {
_.forEach(rule.functions, function (func) {
functions[func[0]] = func[1];
});
}
});
});
return functions;
}

Expand Down

0 comments on commit d240d6b

Please sign in to comment.