Add min/maxResolution properties to rule options

This commit is contained in:
Tim Schaub
2013-09-27 11:45:43 +02:00
parent 2878309a41
commit 78c54addb3
3 changed files with 45 additions and 0 deletions
+6
View File
@@ -700,6 +700,12 @@
/**
* @typedef {Object} ol.style.RuleOptions
* @property {ol.expr.Expression|string|undefined} filter Filter.
* @property {number|undefined} maxResolution Optional maximum resolution. If
* a value is provided, the rule will apply at resolutions less than
* this value.
* @property {number|undefined} minResolution Optional minimum resolution. If
* a value is provided, the rule will apply at resolutions greater than or
* equal to this value.
* @property {Array.<ol.style.Symbolizer>|undefined} symbolizers Symbolizers.
*/
+14
View File
@@ -39,6 +39,20 @@ ol.style.Rule = function(options) {
this.symbolizers_ = goog.isDef(options.symbolizers) ?
options.symbolizers : [];
/**
* @type {number}
* @private
*/
this.minResolution_ = goog.isDef(options.minResolution) ?
options.minResolution : 0;
/**
* @type {number}
* @private
*/
this.maxResolution_ = goog.isDef(options.maxResolution) ?
options.maxResolution : Infinity;
};
+25
View File
@@ -2,6 +2,31 @@ goog.provide('ol.test.style.Rule');
describe('ol.style.Rule', function() {
describe('constructor', function() {
it('accepts a filter option', function() {
var rule = new ol.style.Rule({
filter: 'foo == "bar"'
});
expect(rule).to.be.a(ol.style.Rule);
});
it('accepts a minResolution option', function() {
var rule = new ol.style.Rule({
minResolution: 10
});
expect(rule).to.be.a(ol.style.Rule);
});
it('accepts a maxResolution option', function() {
var rule = new ol.style.Rule({
maxResolution: 100
});
expect(rule).to.be.a(ol.style.Rule);
});
});
describe('#applies()', function() {
var feature = new ol.Feature(),
rule;