Test extents passed to loader
This commit is contained in:
committed by
Andreas Hocevar
parent
3b760dc308
commit
67c37c2163
@@ -6,6 +6,7 @@ import Circle from '../../../../../src/ol/geom/Circle.js';
|
||||
import Point from '../../../../../src/ol/geom/Point.js';
|
||||
import {fromExtent} from '../../../../../src/ol/geom/Polygon.js';
|
||||
import VectorLayer from '../../../../../src/ol/layer/Vector.js';
|
||||
import {bbox as bboxStrategy} from '../../../../../src/ol/loadingstrategy.js';
|
||||
import {get as getProjection} from '../../../../../src/ol/proj.js';
|
||||
import {checkedFonts} from '../../../../../src/ol/render/canvas.js';
|
||||
import CanvasVectorLayerRenderer from '../../../../../src/ol/renderer/canvas/VectorLayer.js';
|
||||
@@ -220,17 +221,25 @@ describe('ol.renderer.canvas.VectorLayer', function() {
|
||||
});
|
||||
|
||||
describe('#prepareFrame and #compose', function() {
|
||||
let frameState, projExtent, renderer, worldWidth, buffer;
|
||||
let frameState, projExtent, renderer, worldWidth, buffer, loadExtent;
|
||||
const loader = function(extent) {
|
||||
loadExtent = extent;
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
const layer = new VectorLayer({
|
||||
source: new VectorSource({wrapX: true})
|
||||
source: new VectorSource({
|
||||
wrapX: true,
|
||||
loader: loader,
|
||||
strategy: bboxStrategy
|
||||
})
|
||||
});
|
||||
renderer = new CanvasVectorLayerRenderer(layer);
|
||||
const projection = getProjection('EPSG:3857');
|
||||
projExtent = projection.getExtent();
|
||||
worldWidth = getWidth(projExtent);
|
||||
buffer = layer.getRenderBuffer();
|
||||
loadExtent = undefined;
|
||||
frameState = {
|
||||
viewHints: [],
|
||||
viewState: {
|
||||
@@ -251,7 +260,7 @@ describe('ol.renderer.canvas.VectorLayer', function() {
|
||||
projExtent[0] - worldWidth + buffer,
|
||||
-10000, projExtent[2] + worldWidth - buffer, 10000
|
||||
], buffer));
|
||||
|
||||
expect(loadExtent).to.eql(renderer.replayGroup_.maxExtent_);
|
||||
});
|
||||
|
||||
it('sets correct extent for viewport less than 1 world wide', function() {
|
||||
@@ -263,6 +272,7 @@ describe('ol.renderer.canvas.VectorLayer', function() {
|
||||
projExtent[0] - worldWidth + buffer,
|
||||
-10000, projExtent[2] + worldWidth - buffer, 10000
|
||||
], buffer));
|
||||
expect(loadExtent).to.eql(renderer.replayGroup_.maxExtent_);
|
||||
});
|
||||
|
||||
it('sets correct extent for viewport more than 1 world wide', function() {
|
||||
@@ -274,6 +284,7 @@ describe('ol.renderer.canvas.VectorLayer', function() {
|
||||
projExtent[0] - worldWidth + buffer,
|
||||
-10000, projExtent[2] + worldWidth - buffer, 10000
|
||||
], buffer));
|
||||
expect(loadExtent).to.eql(renderer.replayGroup_.maxExtent_);
|
||||
});
|
||||
|
||||
it('sets correct extent for viewport more than 2 worlds wide', function() {
|
||||
@@ -287,6 +298,7 @@ describe('ol.renderer.canvas.VectorLayer', function() {
|
||||
projExtent[0] - 2 * worldWidth - 10000,
|
||||
-10000, projExtent[2] + 2 * worldWidth + 10000, 10000
|
||||
], buffer));
|
||||
expect(loadExtent).to.eql(renderer.replayGroup_.maxExtent_);
|
||||
});
|
||||
|
||||
it('sets replayGroupChanged correctly', function() {
|
||||
@@ -319,6 +331,90 @@ describe('ol.renderer.canvas.VectorLayer', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('#prepareFrame with a loadWrapX: false source', function() {
|
||||
let frameState, projExtent, renderer, worldWidth, buffer, loadExtent;
|
||||
const loader = function(extent) {
|
||||
loadExtent = extent;
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
const layer = new VectorLayer({
|
||||
source: new VectorSource({
|
||||
wrapX: true,
|
||||
loadWrapX: false,
|
||||
loader: loader,
|
||||
strategy: bboxStrategy
|
||||
})
|
||||
});
|
||||
renderer = new CanvasVectorLayerRenderer(layer);
|
||||
const projection = getProjection('EPSG:3857');
|
||||
projExtent = projection.getExtent();
|
||||
worldWidth = getWidth(projExtent);
|
||||
buffer = layer.getRenderBuffer();
|
||||
loadExtent = undefined;
|
||||
frameState = {
|
||||
viewHints: [],
|
||||
viewState: {
|
||||
center: [0, 0],
|
||||
projection: projection,
|
||||
resolution: 1,
|
||||
rotation: 0
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
it('loads correct extent for small viewport near dateline', function() {
|
||||
|
||||
frameState.extent =
|
||||
[projExtent[0] - 10000, -10000, projExtent[0] + 10000, 10000];
|
||||
renderer.prepareFrame(frameState);
|
||||
expect(renderer.replayGroup_.maxExtent_).to.eql(bufferExtent([
|
||||
projExtent[0] - worldWidth + buffer,
|
||||
-10000, projExtent[2] + worldWidth - buffer, 10000
|
||||
], buffer));
|
||||
expect(loadExtent).to.eql(bufferExtent(frameState.extent, buffer));
|
||||
});
|
||||
|
||||
it('loads correct extent for viewport less than 1 world wide', function() {
|
||||
|
||||
frameState.extent =
|
||||
[projExtent[0] - 10000, -10000, projExtent[1] - 10000, 10000];
|
||||
renderer.prepareFrame(frameState);
|
||||
expect(renderer.replayGroup_.maxExtent_).to.eql(bufferExtent([
|
||||
projExtent[0] - worldWidth + buffer,
|
||||
-10000, projExtent[2] + worldWidth - buffer, 10000
|
||||
], buffer));
|
||||
expect(loadExtent).to.eql(bufferExtent(frameState.extent, buffer));
|
||||
});
|
||||
|
||||
it('loads correct extent for viewport more than 1 world wide', function() {
|
||||
|
||||
frameState.extent =
|
||||
[2 * projExtent[0] - 10000, -10000, 2 * projExtent[1] + 10000, 10000];
|
||||
renderer.prepareFrame(frameState);
|
||||
expect(renderer.replayGroup_.maxExtent_).to.eql(bufferExtent([
|
||||
projExtent[0] - worldWidth + buffer,
|
||||
-10000, projExtent[2] + worldWidth - buffer, 10000
|
||||
], buffer));
|
||||
expect(loadExtent).to.eql(bufferExtent(frameState.extent, buffer));
|
||||
});
|
||||
|
||||
it('loads correct extent for viewport more than 2 worlds wide', function() {
|
||||
|
||||
frameState.extent = [
|
||||
projExtent[0] - 2 * worldWidth - 10000,
|
||||
-10000, projExtent[1] + 2 * worldWidth + 10000, 10000
|
||||
];
|
||||
renderer.prepareFrame(frameState);
|
||||
expect(renderer.replayGroup_.maxExtent_).to.eql(bufferExtent([
|
||||
projExtent[0] - 2 * worldWidth - 10000,
|
||||
-10000, projExtent[2] + 2 * worldWidth + 10000, 10000
|
||||
], buffer));
|
||||
expect(loadExtent).to.eql(bufferExtent(frameState.extent, buffer));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('hit detection', function() {
|
||||
|
||||
it('with no fill and transparent fill', function() {
|
||||
|
||||
Reference in New Issue
Block a user