From ced15e27c1a3440195b7ec34e5dbf204a69c5442 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 29 Sep 2014 13:29:49 +0200 Subject: [PATCH] Remove rtree example Fixes #2732 --- examples/rtree.html | 51 ------------------- examples/rtree.js | 105 ---------------------------------------- src/ol/structs/rbush.js | 23 --------- 3 files changed, 179 deletions(-) delete mode 100644 examples/rtree.html delete mode 100644 examples/rtree.js diff --git a/examples/rtree.html b/examples/rtree.html deleted file mode 100644 index 937100ce3b..0000000000 --- a/examples/rtree.html +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - R-Tree example - - - - - -
- -
-
-
-
-
- -
- -
-

R-Tree example

-

R-Tree example. Please note that this example only works locally, it does not work when the examples are hosted. This is because it accesses internals the R-Tree data structure, which are not exported in the API.

-
-

See the rtree.js source to see how this is done.

-
-
vector, rtree
-
- -
- -
- - - - - - - diff --git a/examples/rtree.js b/examples/rtree.js deleted file mode 100644 index 3ef0055404..0000000000 --- a/examples/rtree.js +++ /dev/null @@ -1,105 +0,0 @@ -// NOCOMPILE -// FIXME this example dives into private members and will never compile :) -goog.require('ol.Feature'); -goog.require('ol.Map'); -goog.require('ol.View'); -goog.require('ol.extent'); -goog.require('ol.geom.Point'); -goog.require('ol.geom.Polygon'); -goog.require('ol.layer.Vector'); -goog.require('ol.source.Vector'); -goog.require('ol.style.Circle'); -goog.require('ol.style.Stroke'); -goog.require('ol.style.Style'); - - -var i, ii, j, jj; - -var count = 2000; -var features = new Array(count); -var e = 18000000; -for (i = 0; i < count; ++i) { - features[i] = new ol.Feature({ - 'geometry': new ol.geom.Point( - [2 * e * Math.random() - e, 2 * e * Math.random() - e]) - }); -} -var vectorSource = new ol.source.Vector({ - features: features -}); - -var styleArray = [new ol.style.Style({ - image: new ol.style.Circle({ - radius: 3, - fill: null, - stroke: new ol.style.Stroke({color: 'red', width: 1}) - }) -})]; - -var colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']; -var depthStyle = []; -for (i = 0, ii = colors.length; i < ii; ++i) { - depthStyle[i] = new ol.style.Style({ - fill: null, - image: null, - stroke: new ol.style.Stroke({ - color: colors[i], - width: (7 - i) / 2 - }), - zIndex: i - }); -} -var extentsByDepth = []; -vectorSource.rBush_.forEachNode(function(node) { - if (node.height > 0) { - if (goog.isDef(extentsByDepth[node.height])) { - extentsByDepth[node.height].push(node.extent); - } else { - extentsByDepth[node.height] = [node.extent]; - } - } -}); -var rtreeExtentFeatures = []; -for (i = 0, ii = extentsByDepth.length; i < ii; ++i) { - var extents = extentsByDepth[i]; - if (!goog.isDef(extents)) { - continue; - } - for (j = 0, jj = extents.length; j < jj; ++j) { - var extent = extents[j]; - var geometry = new ol.geom.Polygon([[ - ol.extent.getBottomLeft(extent), - ol.extent.getTopLeft(extent), - ol.extent.getTopRight(extent), - ol.extent.getBottomRight(extent) - ]]); - var feature = new ol.Feature({ - 'geometry': geometry, - 'styleArray': [depthStyle[i]] - }); - rtreeExtentFeatures.push(feature); - } -} - -var vector = new ol.layer.Vector({ - source: vectorSource, - style: styleArray -}); - -var rtree = new ol.layer.Vector({ - source: new ol.source.Vector({ - features: rtreeExtentFeatures - }), - style: function(feature, resolution) { - return feature.get('styleArray'); - } -}); - -var map = new ol.Map({ - layers: [vector, rtree], - target: 'map', - view: new ol.View({ - center: [0, 0], - zoom: 2 - }) -}); diff --git a/src/ol/structs/rbush.js b/src/ol/structs/rbush.js index d9e0f73d69..61ffd549bb 100644 --- a/src/ol/structs/rbush.js +++ b/src/ol/structs/rbush.js @@ -505,29 +505,6 @@ ol.structs.RBush.prototype.forEachInExtent_ = }; -/** - * @param {function(this: S, ol.structs.RBushNode.): *} callback Callback. - * @param {S=} opt_this The object to use as `this` in `callback`. - * @return {*} Callback return value. - * @template S - */ -ol.structs.RBush.prototype.forEachNode = function(callback, opt_this) { - /** @type {Array.>} */ - var toVisit = [this.root_]; - while (toVisit.length > 0) { - var node = toVisit.pop(); - var result = callback.call(opt_this, node); - if (result) { - return result; - } - if (!node.isLeaf()) { - toVisit.push.apply(toVisit, node.children); - } - } - return undefined; -}; - - /** * @return {Array.} All. */