New Layer#getFeatures method with fast hit detection for VectorLayer

This commit is contained in:
Andreas Hocevar
2019-09-26 19:55:14 +02:00
parent 057cc92716
commit 315695eeb8
13 changed files with 429 additions and 31 deletions

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 [];
}
}