Merge pull request #10094 from ahocevar/immediate-hitdetection

New Layer#getFeatures method with fast hit detection
This commit is contained in:
Andreas Hocevar
2019-10-14 22:21:08 +02:00
committed by GitHub
20 changed files with 726 additions and 51 deletions
+10 -3
View File
@@ -675,14 +675,21 @@ class VectorSource extends Source {
* all features intersecting the given extent in random order (so it may include
* features whose geometries do not intersect the extent).
*
* This method is not available when the source is configured with
* `useSpatialIndex` set to `false`.
* When `useSpatialIndex` is set to false, this method will return all
* features.
*
* @param {import("../extent.js").Extent} extent Extent.
* @return {Array<import("../Feature.js").default<Geometry>>} Features.
* @api
*/
getFeaturesInExtent(extent) {
return this.featuresRtree_.getInExtent(extent);
if (this.featuresRtree_) {
return this.featuresRtree_.getInExtent(extent);
} else if (this.featuresCollection_) {
return this.featuresCollection_.getArray();
} else {
return [];
}
}