Move search and searchReturningObject into methods
This commit is contained in:
+39
-33
@@ -62,39 +62,15 @@ ol.structs.RTree = function(opt_maxWidth) {
|
|||||||
*/
|
*/
|
||||||
this.minWidth_ = Math.floor(this.maxWidth_ / 2);
|
this.minWidth_ = Math.floor(this.maxWidth_ / 2);
|
||||||
|
|
||||||
var that = this; // FIXME remove
|
/**
|
||||||
|
* Start with an empty root-tree.
|
||||||
// Start with an empty root-tree
|
* @private
|
||||||
var rootTree = /** @type {ol.structs.RTreeNode} */
|
* @type {ol.structs.RTreeNode}
|
||||||
|
*/
|
||||||
|
this.rootTree_ = /** @type {ol.structs.RTreeNode} */
|
||||||
({extent: [0, 0, 0, 0], nodes: []});
|
({extent: [0, 0, 0, 0], nodes: []});
|
||||||
|
|
||||||
/**
|
var that = this; // FIXME remove
|
||||||
* Non-recursive search function
|
|
||||||
*
|
|
||||||
* @param {ol.Extent} extent Extent.
|
|
||||||
* @param {string=} opt_type Optional type of the objects we want to find.
|
|
||||||
* @return {Array} Result.
|
|
||||||
* @this {ol.structs.RTree}
|
|
||||||
*/
|
|
||||||
this.search = function(extent, opt_type) {
|
|
||||||
var rect = /** @type {ol.structs.RTreeNode} */ ({extent: extent});
|
|
||||||
return /** @type {Array} */ (that.searchSubtree_.apply(this,
|
|
||||||
[rect, false, [], rootTree, opt_type]));
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Non-recursive search function
|
|
||||||
*
|
|
||||||
* @param {ol.Extent} extent Extent.
|
|
||||||
* @param {string=} opt_type Optional type of the objects we want to find.
|
|
||||||
* @return {Object} Result. Keys are UIDs of the values.
|
|
||||||
* @this {ol.structs.RTree}
|
|
||||||
*/
|
|
||||||
this.searchReturningObject = function(extent, opt_type) {
|
|
||||||
var rect = /** @type {ol.structs.RTreeNode} */ ({extent: extent});
|
|
||||||
return /** @type {Object} */ (that.searchSubtree_.apply(this,
|
|
||||||
[rect, false, [], rootTree, opt_type, true]));
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Non-recursive function that deletes a specific region.
|
* Non-recursive function that deletes a specific region.
|
||||||
@@ -110,7 +86,7 @@ ol.structs.RTree = function(opt_maxWidth) {
|
|||||||
case 1:
|
case 1:
|
||||||
arguments[1] = false; // opt_obj == false for conditionals
|
arguments[1] = false; // opt_obj == false for conditionals
|
||||||
case 2:
|
case 2:
|
||||||
arguments[2] = rootTree; // Add root node to end of argument list
|
arguments[2] = that.rootTree_; // Add root node to end of argument list
|
||||||
default:
|
default:
|
||||||
arguments.length = 3;
|
arguments.length = 3;
|
||||||
}
|
}
|
||||||
@@ -140,7 +116,7 @@ ol.structs.RTree = function(opt_maxWidth) {
|
|||||||
if (goog.isDef(opt_type)) {
|
if (goog.isDef(opt_type)) {
|
||||||
node.type = opt_type;
|
node.type = opt_type;
|
||||||
}
|
}
|
||||||
that.insertSubtree_(node, rootTree);
|
that.insertSubtree_(node, that.rootTree_);
|
||||||
};
|
};
|
||||||
|
|
||||||
//End of RTree
|
//End of RTree
|
||||||
@@ -577,6 +553,36 @@ ol.structs.RTree.prototype.linearSplit_ = function(nodes) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Non-recursive search function
|
||||||
|
*
|
||||||
|
* @param {ol.Extent} extent Extent.
|
||||||
|
* @param {string=} opt_type Optional type of the objects we want to find.
|
||||||
|
* @return {Array} Result.
|
||||||
|
* @this {ol.structs.RTree}
|
||||||
|
*/
|
||||||
|
ol.structs.RTree.prototype.search = function(extent, opt_type) {
|
||||||
|
var rect = /** @type {ol.structs.RTreeNode} */ ({extent: extent});
|
||||||
|
return /** @type {Array} */ (
|
||||||
|
this.searchSubtree_(rect, false, [], this.rootTree_, opt_type));
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Non-recursive search function
|
||||||
|
*
|
||||||
|
* @param {ol.Extent} extent Extent.
|
||||||
|
* @param {string=} opt_type Optional type of the objects we want to find.
|
||||||
|
* @return {Object} Result. Keys are UIDs of the values.
|
||||||
|
* @this {ol.structs.RTree}
|
||||||
|
*/
|
||||||
|
ol.structs.RTree.prototype.searchReturningObject = function(extent, opt_type) {
|
||||||
|
var rect = /** @type {ol.structs.RTreeNode} */ ({extent: extent});
|
||||||
|
return /** @type {Object} */ (
|
||||||
|
this.searchSubtree_(rect, false, [], this.rootTree_, opt_type, true));
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Non-recursive internal search function
|
* Non-recursive internal search function
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user