ol.Filter is now a (base) class, not an interface any more

ol.Filter can now also be used to provide a simple filter that
just evaluates a user provided filter function against a
feature.
This commit is contained in:
ahocevar
2013-03-03 14:25:11 +01:00
parent 5d917ebed6
commit 9d1f737bce
4 changed files with 20 additions and 7 deletions
+3 -1
View File
@@ -7,10 +7,11 @@ goog.require('ol.filter.Filter');
/** /**
* @constructor * @constructor
* @implements {ol.filter.Filter} * @extends {ol.filter.Filter}
* @param {ol.Extent} extent The extent. * @param {ol.Extent} extent The extent.
*/ */
ol.filter.Extent = function(extent) { ol.filter.Extent = function(extent) {
goog.base(this);
/** /**
* @type {ol.Extent} * @type {ol.Extent}
@@ -19,6 +20,7 @@ ol.filter.Extent = function(extent) {
this.extent_ = extent; this.extent_ = extent;
}; };
goog.inherits(ol.filter.Extent, ol.filter.Filter);
/** /**
+11 -4
View File
@@ -5,13 +5,20 @@ goog.require('ol.Feature');
/** /**
* @interface * @constructor
* @param {function(this:ol.filter.Filter, ol.Feature)=} opt_filterFunction
* Filter function. Should return true if the passed feature passes the
* filter, false otherwise.
*/ */
ol.filter.Filter = function() {}; ol.filter.Filter = function(opt_filterFunction) {
if (goog.isDef(opt_filterFunction)) {
this.applies = opt_filterFunction;
}
};
/** /**
* @param {ol.Feature} feature Feature to evaluate. * @param {ol.Feature} feature Feature to evaluate the filter against.
* @return {boolean} The provided feature passes this filter. * @return {boolean} The provided feature passes this filter.
*/ */
ol.filter.Filter.prototype.applies = function(feature) {}; ol.filter.Filter.prototype.applies = goog.abstractMethod;
+3 -1
View File
@@ -8,10 +8,11 @@ goog.require('ol.geom.GeometryType');
/** /**
* @constructor * @constructor
* @implements {ol.filter.Filter} * @extends {ol.filter.Filter}
* @param {ol.geom.GeometryType} type The geometry type. * @param {ol.geom.GeometryType} type The geometry type.
*/ */
ol.filter.Geometry = function(type) { ol.filter.Geometry = function(type) {
goog.base(this);
/** /**
* @type {ol.geom.GeometryType} * @type {ol.geom.GeometryType}
@@ -20,6 +21,7 @@ ol.filter.Geometry = function(type) {
this.type_ = type; this.type_ = type;
}; };
goog.inherits(ol.filter.Geometry, ol.filter.Filter);
/** /**
+3 -1
View File
@@ -7,11 +7,12 @@ goog.require('ol.filter.Filter');
/** /**
* @constructor * @constructor
* @implements {ol.filter.Filter} * @extends {ol.filter.Filter}
* @param {Array.<ol.filter.Filter>} filters Filters to and-combine. * @param {Array.<ol.filter.Filter>} filters Filters to and-combine.
* @param {!ol.filter.LogicalOperator} operator Operator. * @param {!ol.filter.LogicalOperator} operator Operator.
*/ */
ol.filter.Logical = function(filters, operator) { ol.filter.Logical = function(filters, operator) {
goog.base(this);
/** /**
* @type {Array.<ol.filter.Filter>} * @type {Array.<ol.filter.Filter>}
@@ -25,6 +26,7 @@ ol.filter.Logical = function(filters, operator) {
this.operator = operator; this.operator = operator;
}; };
goog.inherits(ol.filter.Logical, ol.filter.Filter);
/** /**