rename ZoomFilter to Zoom to reflect that it's no longer treated as a Filter

This commit is contained in:
Konstantin Käfer 2011-01-26 11:36:07 -05:00
parent d772884d13
commit fca6f37a7f
3 changed files with 28 additions and 29 deletions

View File

@ -816,7 +816,7 @@ mess.Parser = function Parser(env) {
(op = $(this.entities.comparison)) &&
(val = $(/^\d+/)) &&
$(']')) {
return new tree.ZoomFilter(op, val, memo);
return new tree.Zoom(op, val, memo);
}
},

View File

@ -107,7 +107,7 @@ mess.Renderer = function Renderer(env) {
next(null);
}
else {
next('No .shp file found in zipfile.');
next("No .shp file found in zipfile.");
}
});
});
@ -169,12 +169,11 @@ mess.Renderer = function Renderer(env) {
function loadStyles() {
var group = this.group();
m.Stylesheet.forEach(function(s) {
var g = group();
if (s.id) {
g(null, [s.id, s.data]);
group()(null, [s.id, s.data]);
} else {
fs.readFile(s, 'utf-8', function(err, data) {
g(err, [s, data]);
group()(err, [s, data]);
});
}
});
@ -182,7 +181,7 @@ mess.Renderer = function Renderer(env) {
function compileStyles(e, results) {
var options = {},
group = this.group();
for (var i = 0; i < results.length; i++) {
for (var i = 0, l = results.length; i < l; i++) {
new mess.Parser(_.extend(_.extend({
filename: results[i][0]
}, that.env), this.env)).parse(results[i][1],
@ -220,7 +219,7 @@ mess.Renderer = function Renderer(env) {
for (var i = 0; i < definitions.length; i++) {
definitions[i].symbolizers().forEach(function(sym) {
var index = sym + '/' + definitions[i].selector.attachment;
if (!bySymbolizer[index]) {
if(!bySymbolizer[index]) {
bySymbolizer[index] = [];
}
bySymbolizer[index].push(
@ -274,7 +273,7 @@ mess.Renderer = function Renderer(env) {
resolveConditions: function(definitions) {
var rules = [];
var negatedFilters = [];
var negatedZoom = tree.ZoomFilter.newFromRange([0, Infinity]);
var negatedZoom = tree.Zoom.newFromRange([0, Infinity]);
for (var i = 0; i < definitions.length; i++) {
var selector = definitions[i].selector;
@ -321,7 +320,7 @@ mess.Renderer = function Renderer(env) {
// Add a separate rule for each zoom range.
for (var j = 0; j < zoomRanges.length; j++) {
var rule = definitions[i].clone();
rule.selector.zoom = tree.ZoomFilter.newFromRange(zoomRanges[j]);
rule.selector.zoom = tree.Zoom.newFromRange(zoomRanges[j]);
rules.push(rule);
}
}

View File

@ -1,29 +1,29 @@
(function(tree) {
tree.ZoomFilter = function ZoomFilter(op, value, index) {
tree.Zoom = function Zoom(op, value, index) {
value = parseInt(value);
if (value > tree.ZoomFilter.maxZoom || value < 0) {
if (value > tree.Zoom.maxZoom || value < 0) {
throw {
message: 'Only zoom levels between 0 and ' + tree.ZoomFilter.maxZoom + ' supported.',
message: 'Only zoom levels between 0 and ' + tree.Zoom.maxZoom + ' supported.',
index: index
};
}
this.range = tree.ZoomFilter.rangeFromCondition(op.value, value);
this.range = tree.Zoom.rangeFromCondition(op.value, value);
this.specificity = 1;
};
tree.ZoomFilter.newFromRange = function(range) {
var obj = Object.create(tree.ZoomFilter.prototype);
tree.Zoom.newFromRange = function(range) {
var obj = Object.create(tree.Zoom.prototype);
obj.range = [];
for (var i = 0; i < tree.ZoomFilter.maxZoom; i++) {
for (var i = 0; i < tree.Zoom.maxZoom; i++) {
obj.range[i] = i >= range[0] && i <= range[1];
}
return obj;
}
tree.ZoomFilter.maxZoom = 22;
tree.Zoom.maxZoom = 22;
tree.ZoomFilter.ranges = {
tree.Zoom.ranges = {
0: 1000000000,
1: 500000000,
2: 200000000,
@ -55,20 +55,20 @@ tree.ZoomFilter.ranges = {
* which denotes whether this filter should apply
* to each of the zoom levels from 0-22.
*/
tree.ZoomFilter.rangeFromCondition = function(op, value) {
tree.Zoom.rangeFromCondition = function(op, value) {
var range = [];
if (op === '=') {
for (var i = 0; i < tree.ZoomFilter.maxZoom; i++) {
for (var i = 0; i < tree.Zoom.maxZoom; i++) {
range[i] = (i == value);
}
} else if (op === '>' || op === '>=') {
if (op === '>') value++;
for (var i = 0; i < tree.ZoomFilter.maxZoom; i++) {
for (var i = 0; i < tree.Zoom.maxZoom; i++) {
range[i] = (i >= value);
}
} else {
if (op === '<') value--;
for (var i = 0; i < tree.ZoomFilter.maxZoom; i++) {
for (var i = 0; i < tree.Zoom.maxZoom; i++) {
range[i] = (i <= value);
}
}
@ -78,7 +78,7 @@ tree.ZoomFilter.rangeFromCondition = function(op, value) {
/**
* Returns an array of ranges that are set.
*/
tree.ZoomFilter.prototype.getRanges = function() {
tree.Zoom.prototype.getRanges = function() {
var ranges = [], start = null;
for (var i = 0; i < this.range.length; i++) {
if (start == null && this.range[i]) {
@ -95,7 +95,7 @@ tree.ZoomFilter.prototype.getRanges = function() {
/**
* Find the overlap of this and another set
*/
tree.ZoomFilter.prototype.intersection = function(filter) {
tree.Zoom.prototype.intersection = function(filter) {
if (filter.range) {
for (var i = 0; i < this.range.length; i++) {
this.range[i] = this.range[i] && filter.range[i];
@ -113,7 +113,7 @@ tree.ZoomFilter.prototype.intersection = function(filter) {
* Usage is for doing the equivalent of an ElseFilter
* for defaulting to non-zoom-filtered rules
*/
tree.ZoomFilter.prototype.negate = function() {
tree.Zoom.prototype.negate = function() {
var negated = this.clone();
negated.range = this.range.map(function(i) {
return !i;
@ -121,19 +121,19 @@ tree.ZoomFilter.prototype.negate = function() {
return negated;
};
tree.ZoomFilter.prototype.toXML = function(env) {
tree.Zoom.prototype.toXML = function(env) {
var ranges = this.getRanges();
return ranges.map(function(range) {
return ((range[0] > 0) ?
'<MaxScaleDenominator>' + tree.ZoomFilter.ranges[range[0]] + '</MaxScaleDenominator>'
'<MaxScaleDenominator>' + tree.Zoom.ranges[range[0]] + '</MaxScaleDenominator>'
: '') +
((range[1] < 22) ?
'<MinScaleDenominator>' + tree.ZoomFilter.ranges[range[1] + 1] + '</MinScaleDenominator>'
'<MinScaleDenominator>' + tree.Zoom.ranges[range[1] + 1] + '</MinScaleDenominator>'
: '');
});
};
tree.ZoomFilter.prototype.clone = function() {
tree.Zoom.prototype.clone = function() {
var obj = Object.create(Object.getPrototypeOf(this));
obj.range = this.range.slice();
obj.specificity = this.specificity;