#13690 VectorSource#getFeaturesInExtent add projection parameter

This commit is contained in:
Tomas Burleigh
2022-05-21 14:28:19 +12:00
parent 3857e2051c
commit 78274befb8
4 changed files with 148 additions and 3 deletions

View File

@@ -14,7 +14,7 @@ import VectorEventType from './VectorEventType.js';
import {TRUE, VOID} from '../functions.js';
import {all as allStrategy} from '../loadingstrategy.js';
import {assert} from '../asserts.js';
import {containsExtent, equals} from '../extent.js';
import {containsExtent, equals, wrapAndSliceX} from '../extent.js';
import {extend} from '../array.js';
import {getUid} from '../util.js';
import {getValues, isEmpty} from '../obj.js';
@@ -736,12 +736,23 @@ class VectorSource extends Source {
* features.
*
* @param {import("../extent.js").Extent} extent Extent.
* @param {import("../proj/Projection.js").default} [projection] Projection.
* @return {Array<import("../Feature.js").default<Geometry>>} Features.
* @api
*/
getFeaturesInExtent(extent) {
getFeaturesInExtent(extent, projection) {
if (this.featuresRtree_) {
return this.featuresRtree_.getInExtent(extent);
const multiWorld = projection && projection.canWrapX() && this.getWrapX();
if (!multiWorld) {
return this.featuresRtree_.getInExtent(extent);
}
const extents = wrapAndSliceX(extent, projection);
return [].concat(
...extents.map((anExtent) => this.featuresRtree_.getInExtent(anExtent))
);
} else if (this.featuresCollection_) {
return this.featuresCollection_.getArray().slice(0);
} else {