Permalink
Browse files

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.
  • Loading branch information...
1 parent 5d917eb commit 9d1f737bcedd02608d439b7b85c68d33d047555f @ahocevar ahocevar committed Mar 3, 2013
Showing with 20 additions and 7 deletions.
  1. +3 −1 src/ol/filter/extentfilter.js
  2. +11 −4 src/ol/filter/filter.js
  3. +3 −1 src/ol/filter/geometryfilter.js
  4. +3 −1 src/ol/filter/logicalfilter.js
@@ -7,10 +7,11 @@ goog.require('ol.filter.Filter');
/**
* @constructor
- * @implements {ol.filter.Filter}
+ * @extends {ol.filter.Filter}
* @param {ol.Extent} extent The extent.
*/
ol.filter.Extent = function(extent) {
+ goog.base(this);
/**
* @type {ol.Extent}
@@ -19,6 +20,7 @@ ol.filter.Extent = function(extent) {
this.extent_ = extent;
};
+goog.inherits(ol.filter.Extent, ol.filter.Filter);
/**
View
@@ -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.
*/
-ol.filter.Filter.prototype.applies = function(feature) {};
+ol.filter.Filter.prototype.applies = goog.abstractMethod;
@@ -8,10 +8,11 @@ goog.require('ol.geom.GeometryType');
/**
* @constructor
- * @implements {ol.filter.Filter}
+ * @extends {ol.filter.Filter}
* @param {ol.geom.GeometryType} type The geometry type.
*/
ol.filter.Geometry = function(type) {
+ goog.base(this);
/**
* @type {ol.geom.GeometryType}
@@ -20,6 +21,7 @@ ol.filter.Geometry = function(type) {
this.type_ = type;
};
+goog.inherits(ol.filter.Geometry, ol.filter.Filter);
/**
@@ -7,11 +7,12 @@ goog.require('ol.filter.Filter');
/**
* @constructor
- * @implements {ol.filter.Filter}
+ * @extends {ol.filter.Filter}
* @param {Array.<ol.filter.Filter>} filters Filters to and-combine.
* @param {!ol.filter.LogicalOperator} operator Operator.
*/
ol.filter.Logical = function(filters, operator) {
+ goog.base(this);
/**
* @type {Array.<ol.filter.Filter>}
@@ -25,6 +26,7 @@ ol.filter.Logical = function(filters, operator) {
this.operator = operator;
};
+goog.inherits(ol.filter.Logical, ol.filter.Filter);
/**

0 comments on commit 9d1f737

Please sign in to comment.