From 880f098f0fc84ad11023b1a8abec40124097e2d9 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Mon, 25 Nov 2013 19:27:58 +0100 Subject: [PATCH] Add ol.structs.RBush#update --- src/ol/structs/rbush.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/ol/structs/rbush.js b/src/ol/structs/rbush.js index 59e43722de..e52bf5ec50 100644 --- a/src/ol/structs/rbush.js +++ b/src/ol/structs/rbush.js @@ -618,3 +618,19 @@ ol.structs.RBush.prototype.splitRoot_ = function(node1, node2) { var children = [node1, node2]; this.root_ = new ol.structs.RBushNode(extent, height, children, null); }; + + +/** + * @param {ol.Extent} extent Extent. + * @param {T} value Value. + */ +ol.structs.RBush.prototype.update = function(extent, value) { + var key = this.getKey_(value); + var currentExtent = this.valueExtent_[key]; + goog.asserts.assert(goog.isDef(currentExtent)); + if (!ol.extent.equals(currentExtent, extent)) { + this.remove_(currentExtent, value); + this.insert_(extent, value, this.root_.height - 1); + this.valueExtent_[key] = extent; + } +};