Clear features properly when there is no spatial index

Previously clear() only kept the features collection in sync whern there
was also a features RTree.
This commit is contained in:
Andreas Hocevar
2015-07-15 15:15:41 +02:00
parent afce912f11
commit 8f7cbc5ed6
2 changed files with 54 additions and 6 deletions

View File

@@ -372,16 +372,14 @@ ol.source.Vector.prototype.bindFeaturesCollection_ = function(collection) {
*/
ol.source.Vector.prototype.clear = function(opt_fast) {
if (opt_fast) {
for (var featureId in this.featureChangeKeys_) {
var keys = this.featureChangeKeys_[featureId];
goog.array.forEach(keys, goog.events.unlistenByKey);
}
if (goog.isNull(this.featuresCollection_)) {
for (var featureId in this.featureChangeKeys_) {
var keys = this.featureChangeKeys_[featureId];
goog.array.forEach(keys, goog.events.unlistenByKey);
}
this.featureChangeKeys_ = {};
this.idIndex_ = {};
this.undefIdIndex_ = {};
} else {
this.featuresCollection_.clear();
}
} else {
var rmFeatureInternal = this.removeFeatureInternal;
@@ -390,6 +388,9 @@ ol.source.Vector.prototype.clear = function(opt_fast) {
goog.object.forEach(this.nullGeometryFeatures_, rmFeatureInternal, this);
}
}
if (!goog.isNull(this.featuresCollection_)) {
this.featuresCollection_.clear();
}
goog.asserts.assert(goog.object.isEmpty(this.featureChangeKeys_),
'featureChangeKeys is an empty object now');
goog.asserts.assert(goog.object.isEmpty(this.idIndex_),