Merge pull request #13648 from tschaub/data-tile-size

Explicit data tile size
This commit is contained in:
Tim Schaub
2022-05-07 10:16:40 -06:00
committed by GitHub
15 changed files with 273 additions and 91 deletions

View File

@@ -33,6 +33,28 @@ describe('ol/DataTile', function () {
});
});
describe('#getSize()', function () {
it('returns [256, 256] by default', function () {
const tileCoord = [0, 0, 0];
const tile = new DataTile({
tileCoord: tileCoord,
loader: loader,
});
expect(tile.getSize()).to.eql([256, 256]);
});
it('respects what is provided in the constructor', function () {
const size = [123, 456];
const tileCoord = [0, 0, 0];
const tile = new DataTile({
size: size,
tileCoord: tileCoord,
loader: loader,
});
expect(tile.getSize()).to.eql(size);
});
});
describe('#load()', function () {
it('handles loading states correctly', function (done) {
const tileCoord = [0, 0, 0];

View File

@@ -5,6 +5,7 @@ import View from '../../../../../src/ol/View.js';
import WebGLHelper from '../../../../../src/ol/webgl/Helper.js';
import WebGLTileLayer from '../../../../../src/ol/layer/WebGLTile.js';
import {createCanvasContext2D} from '../../../../../src/ol/dom.js';
import {createXYZ} from '../../../../../src/ol/tilegrid.js';
import {getForViewAndSize} from '../../../../../src/ol/extent.js';
import {getRenderPixel} from '../../../../../src/ol/render.js';
@@ -81,7 +82,8 @@ describe('ol/layer/WebGLTile', function () {
it('retrieves pixel data', (done) => {
const layer = new WebGLTileLayer({
source: new DataTileSource({
tilePixelRatio: 1 / 256,
tileSize: 1,
tileGrid: createXYZ(),
loader(z, x, y) {
return new Uint8Array([5, 4, 3, 2, 1]);
},
@@ -106,7 +108,8 @@ describe('ol/layer/WebGLTile', function () {
it('preserves the original data type', (done) => {
const layer = new WebGLTileLayer({
source: new DataTileSource({
tilePixelRatio: 1 / 256,
tileSize: 1,
tileGrid: createXYZ(),
loader(z, x, y) {
return new Float32Array([1.11, 2.22, 3.33, 4.44, 5.55]);
},

View File

@@ -40,6 +40,30 @@ describe('ol/source/DataTile', function () {
});
});
describe('#getTileSize()', function () {
it('returns [256, 256] by default', function () {
const source = new DataTileSource({});
expect(source.getTileSize(0)).to.eql([256, 256]);
});
it('respects a tileSize passed to the constructor', function () {
const size = [1234, 5678];
const source = new DataTileSource({tileSize: size});
expect(source.getTileSize(0)).to.eql(size);
});
it('picks from an array of sizes passed to setTileSizes()', function () {
const sizes = [
[123, 456],
[234, 567],
[345, 678],
];
const source = new DataTileSource({});
source.setTileSizes(sizes);
expect(source.getTileSize(1)).to.eql(sizes[1]);
});
});
describe('#getInterpolate()', function () {
it('is false by default', function () {
const source = new DataTileSource({loader: () => {}});