RTree API improvements and more tests

This change reverts the RTree API back to the original one (i.e.
insert() instead of put(), search() instead of find()), and
creates a new searchReturningObject() method that returns an
object keyed by UIDs.

It also adds missing tests for type restricted search and
searchReturningObject().
This commit is contained in:
ahocevar
2013-05-22 18:25:40 -05:00
parent 2d765a6cf9
commit 10e3a16f40
3 changed files with 74 additions and 28 deletions

View File

@@ -69,7 +69,7 @@ ol.layer.FeatureCache.prototype.add = function(feature) {
if (!goog.isNull(geometry)) {
var geometryType = geometry.getType();
this.geometryTypeIndex_[geometryType][id] = feature;
this.rTree_.put(geometry.getBounds(),
this.rTree_.insert(geometry.getBounds(),
feature, geometryType);
}
};
@@ -87,7 +87,7 @@ ol.layer.FeatureCache.prototype.getFeaturesObject = function(opt_filter) {
if (opt_filter instanceof ol.filter.Geometry) {
features = this.geometryTypeIndex_[opt_filter.getType()];
} else if (opt_filter instanceof ol.filter.Extent) {
features = this.rTree_.find(opt_filter.getExtent());
features = this.rTree_.searchReturningObject(opt_filter.getExtent());
} else if (opt_filter instanceof ol.filter.Logical &&
opt_filter.operator === ol.filter.LogicalOperator.AND) {
var filters = opt_filter.getFilters();
@@ -104,7 +104,7 @@ ol.layer.FeatureCache.prototype.getFeaturesObject = function(opt_filter) {
if (extentFilter && geometryFilter) {
var type = geometryFilter.getType();
features = goog.object.isEmpty(this.geometryTypeIndex_[type]) ? {} :
this.rTree_.find(extentFilter.getExtent(), type);
this.rTree_.searchReturningObject(extentFilter.getExtent(), type);
}
}
}