Specify an actual extent when loading features in the Webgl points renderer

This means any specified loading strategy will be taken into account.

Also added some tests to make sure the interaction with the source is
correct.
This commit is contained in:
Olivier Guyot committed 2019-10-28 10:26:31 +01:00
1 parent 5d358a7367
commit cd3b222467
2 files changed
+47 -14

No files matched your search

@@ -104,7 +104,8 @@ describe('ol.renderer.webgl.PointsLayer', function() {
beforeEach(function() {
layer = new VectorLayer({
source: new VectorSource()
source: new VectorSource(),
renderBuffer: 10
});
renderer = new WebGLPointsLayerRenderer(layer, {
vertexShader: simpleVertexShader,
@@ -233,6 +234,35 @@ describe('ol.renderer.webgl.PointsLayer', function() {
renderer.prepareFrame(frameState);
expect(spy.callCount).to.be(2);
});
it('triggers source loading when the extent changes', function() {
const spy = sinon.spy(layer.getSource(), 'loadFeatures');
renderer.prepareFrame(frameState);
expect(spy.callCount).to.be(1);
renderer.prepareFrame(frameState);
expect(spy.callCount).to.be(1);
frameState.extent = [10, 20, 30, 40];
renderer.prepareFrame(frameState);
expect(spy.callCount).to.be(2);
expect(spy.getCall(1).args[0]).to.eql([0, 10, 40, 50]); // renderBuffer is 10
});
it('triggers source loading when the source revision changes', function() {
const spy = sinon.spy(layer.getSource(), 'loadFeatures');
renderer.prepareFrame(frameState);
expect(spy.callCount).to.be(1);
renderer.prepareFrame(frameState);
expect(spy.callCount).to.be(1);
layer.getSource().changed();
renderer.prepareFrame(frameState);
expect(spy.callCount).to.be(2);
});
});
describe('#forEachFeatureAtCoordinate', function() {