Merge pull request #2219 from fredj/rbush-update
Allow the value to be changed while iterating over the rtree
This commit is contained in:
@@ -710,13 +710,13 @@ ol.structs.RBush.prototype.splitRoot_ = function(node1, node2) {
|
|||||||
* @param {T} value Value.
|
* @param {T} value Value.
|
||||||
*/
|
*/
|
||||||
ol.structs.RBush.prototype.update = function(extent, value) {
|
ol.structs.RBush.prototype.update = function(extent, value) {
|
||||||
if (goog.DEBUG && this.readers_) {
|
|
||||||
throw new Error('cannot update value while reading');
|
|
||||||
}
|
|
||||||
var key = this.getKey_(value);
|
var key = this.getKey_(value);
|
||||||
var currentExtent = this.valueExtent_[key];
|
var currentExtent = this.valueExtent_[key];
|
||||||
goog.asserts.assert(goog.isDef(currentExtent));
|
goog.asserts.assert(goog.isDef(currentExtent));
|
||||||
if (!ol.extent.equals(currentExtent, extent)) {
|
if (!ol.extent.equals(currentExtent, extent)) {
|
||||||
|
if (goog.DEBUG && this.readers_) {
|
||||||
|
throw new Error('cannot update extent while reading');
|
||||||
|
}
|
||||||
var removed = this.remove_(currentExtent, value);
|
var removed = this.remove_(currentExtent, value);
|
||||||
goog.asserts.assert(removed);
|
goog.asserts.assert(removed);
|
||||||
this.insert_(extent, value, this.root_.height - 1);
|
this.insert_(extent, value, this.root_.height - 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user