Merge pull request #13691 from burleight/vectorSource-getFeaturesInExtent-wrapX
#13690 VectorSource#getFeaturesInExtent add projection parameter
This commit is contained in:
@@ -7,6 +7,7 @@ import Point from '../../../../../src/ol/geom/Point.js';
|
||||
import VectorLayer from '../../../../../src/ol/layer/Vector.js';
|
||||
import VectorSource from '../../../../../src/ol/source/Vector.js';
|
||||
import View from '../../../../../src/ol/View.js';
|
||||
import sinon from 'sinon';
|
||||
import {bbox as bboxStrategy} from '../../../../../src/ol/loadingstrategy.js';
|
||||
import {
|
||||
fromLonLat,
|
||||
@@ -979,4 +980,45 @@ describe('ol.source.Vector', function () {
|
||||
expect(source.getFeatures().length).to.be(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getFeaturesInExtent()', function () {
|
||||
it('adjusts the extent if projection canWrapX', function () {
|
||||
const a = new Feature(new Point([0, 0]));
|
||||
const b = new Feature(new Point([179, 0]));
|
||||
const c = new Feature(new Point([-179, 0]));
|
||||
|
||||
const source = new VectorSource({
|
||||
features: [a, b, c],
|
||||
});
|
||||
|
||||
const projection = getProjection('EPSG:4326');
|
||||
|
||||
expect(
|
||||
source.getFeaturesInExtent([-180, -90, 180, 90], projection).length
|
||||
).to.be(3);
|
||||
const onlyB = source.getFeaturesInExtent([1, -90, 180, 90], projection);
|
||||
expect(onlyB.length).to.be(1);
|
||||
expect(onlyB).to.contain(b);
|
||||
const bAndC = source.getFeaturesInExtent([1, -90, 182, 90], projection);
|
||||
expect(bAndC.length).to.be(2);
|
||||
expect(bAndC).to.contain(b);
|
||||
expect(bAndC).to.contain(c);
|
||||
|
||||
const onlyC = source.getFeaturesInExtent([-180, -90, -1, 90], projection);
|
||||
expect(onlyC.length).to.be(1);
|
||||
expect(onlyC).to.contain(c);
|
||||
|
||||
const bAndCAgain = source.getFeaturesInExtent(
|
||||
[-182, -90, -1, 90],
|
||||
projection
|
||||
);
|
||||
expect(bAndCAgain.length).to.be(2);
|
||||
expect(bAndCAgain).to.contain(b);
|
||||
expect(bAndCAgain).to.contain(c);
|
||||
|
||||
const onlyA = source.getFeaturesInExtent([359, -90, 361, 90], projection);
|
||||
expect(onlyA.length).to.be(1);
|
||||
expect(onlyA).to.contain(a);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user