Zoom range formalizing.
This commit is contained in:
parent
3550af0838
commit
af9194dbfb
@ -1,10 +1,24 @@
|
||||
(function(tree) {
|
||||
|
||||
tree.Filter = function(key, op, val, index) {
|
||||
var max_zoom = 22; // maximum number of zoom levels
|
||||
this.key = key;
|
||||
this.op = op;
|
||||
this.val = val;
|
||||
this.index = index;
|
||||
|
||||
if (this.key === 'zoom') {
|
||||
var val = parseInt(this.val, 10);
|
||||
if (this.op.value === '>' || this.op.value === '>=') {
|
||||
if (this.op.value === '>') val++;
|
||||
this.zoom_range = [val, max_zoom]
|
||||
// TODO: non-correct ops will fail here
|
||||
} else {
|
||||
if (this.op.value === '<') val--;
|
||||
this.zoom_range = [0, val]
|
||||
}
|
||||
}
|
||||
|
||||
this.zooms = {
|
||||
'1': [200000000, 500000000],
|
||||
'2': [100000000, 200000000],
|
||||
@ -31,6 +45,15 @@ tree.Filter = function(key, op, val, index) {
|
||||
};
|
||||
};
|
||||
|
||||
tree.Filter.prototype.union = function(filter) {
|
||||
if (filter.zoom_range) {
|
||||
return [
|
||||
Math.max(this.zoom_range[0], filter.zoom_range[0]),
|
||||
Math.min(this.zoom_range[1], filter.zoom_range[1])
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
tree.Filter.prototype.toCSS = function(env) {
|
||||
if (this.key === 'zoom') {
|
||||
if (parseInt(this.val) > 22 || parseInt(this.val) < 0) {
|
||||
@ -55,8 +78,7 @@ tree.Filter.prototype.toCSS = function(env) {
|
||||
return '<MinScaleDenominator>' + this.zooms[this.val][0] +
|
||||
'</MinScaleDenominator>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (this.val.is) {
|
||||
this.val = this.val.toCSS((this.val.is == 'string'));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user