Add more IIIF tile source tests
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
// import {DEFAULT_TILE_SIZE} from '../../../../src/ol/tilegrid/common.js';
|
||||
import {DEFAULT_TILE_SIZE} from '../../../../src/ol/tilegrid/common.js';
|
||||
import IIIF from '../../../../src/ol/source/IIIF.js';
|
||||
import {Versions} from '../../../../src/ol/format/IIIFInfo.js';
|
||||
// import {CustomTile} from '../../../../src/ol/source/Zoomify.js';
|
||||
// import TileGrid from '../../../../src/ol/tilegrid/TileGrid.js';
|
||||
|
||||
|
||||
describe('ol.source.IIIF', function() {
|
||||
@@ -169,7 +167,7 @@ describe('ol.source.IIIF', function() {
|
||||
|
||||
});
|
||||
|
||||
it('constructs the same number of resolutions as sizes are given', function() {
|
||||
it('constructs the same number of resolutions as distinguishable sizes are given', function() {
|
||||
|
||||
let tileUrlFunction = getSource({
|
||||
sizes: [[2000, 1500], [1000, 750], [500, 375]]
|
||||
@@ -205,7 +203,7 @@ describe('ol.source.IIIF', function() {
|
||||
|
||||
});
|
||||
|
||||
it('given resolutions without tilesize or supported features do not result in tiling', function() {
|
||||
it('cannot provide scaled tiles sizes without provieded tilesize or supported features', function() {
|
||||
|
||||
const tileUrlFunction = getSource({
|
||||
resolutions: [16, 8, 4, 2, 1]
|
||||
@@ -219,7 +217,7 @@ describe('ol.source.IIIF', function() {
|
||||
|
||||
});
|
||||
|
||||
it('given tilesize results in tiling with minimal resolutions set and canonical URLs', function() {
|
||||
it('provides canonical tile URLs for all necessary resolutions if only a tileSize exists', function() {
|
||||
|
||||
let tileUrlFunction = getSource({
|
||||
tileSize: 512
|
||||
@@ -256,15 +254,133 @@ describe('ol.source.IIIF', function() {
|
||||
|
||||
});
|
||||
|
||||
it('', function() {
|
||||
//expect(tileUrlFunction([]));
|
||||
it('provides canonical tile URLs for all provided resolutions if a tileSize also exists', function() {
|
||||
|
||||
const tileUrlFunction = getSource({
|
||||
tileSize: 512,
|
||||
resolutions: [8, 4, 2, 1]
|
||||
}).getTileUrlFunction();
|
||||
|
||||
expect(tileUrlFunction([0, 0, 0])).to.be('http://iiif.test/image-id/full/250,/0/default.jpg');
|
||||
expect(tileUrlFunction([1, 0, 0])).to.be('http://iiif.test/image-id/full/500,/0/default.jpg');
|
||||
expect(tileUrlFunction([2, 0, 0])).to.be('http://iiif.test/image-id/0,0,1024,1024/512,/0/default.jpg');
|
||||
expect(tileUrlFunction([2, 1, 0])).to.be('http://iiif.test/image-id/1024,0,976,1024/488,/0/default.jpg');
|
||||
expect(tileUrlFunction([2, 0, 1])).to.be('http://iiif.test/image-id/0,1024,1024,476/512,/0/default.jpg');
|
||||
expect(tileUrlFunction([2, 1, 1])).to.be('http://iiif.test/image-id/1024,1024,976,476/488,/0/default.jpg');
|
||||
expect(tileUrlFunction([3, 0, 0])).to.be('http://iiif.test/image-id/0,0,512,512/512,/0/default.jpg');
|
||||
expect(tileUrlFunction([3, 3, 0])).to.be('http://iiif.test/image-id/1536,0,464,512/464,/0/default.jpg');
|
||||
expect(tileUrlFunction([3, 0, 2])).to.be('http://iiif.test/image-id/0,1024,512,476/512,/0/default.jpg');
|
||||
expect(tileUrlFunction([3, 3, 2])).to.be('http://iiif.test/image-id/1536,1024,464,476/464,/0/default.jpg');
|
||||
expect(tileUrlFunction([4, 0, 0])).to.be(undefined);
|
||||
|
||||
});
|
||||
|
||||
// canonical tiles
|
||||
// unsufficient features, no tilesize, but resolution given: static
|
||||
// sufficient features, no tilesize: default tilesize
|
||||
// sufficient features, tilesize: this one
|
||||
// sufficient features, all teh combinations
|
||||
it('supports non square tiles', function() {
|
||||
|
||||
let tileUrlFunction = getSource({
|
||||
tileSize: [1024, 512]
|
||||
}).getTileUrlFunction();
|
||||
|
||||
expect(tileUrlFunction([0, 0, 0])).to.be('http://iiif.test/image-id/full/500,/0/default.jpg');
|
||||
expect(tileUrlFunction([1, 0, 0])).to.be('http://iiif.test/image-id/0,0,2000,1024/1000,/0/default.jpg');
|
||||
expect(tileUrlFunction([1, 0, 1])).to.be('http://iiif.test/image-id/0,1024,2000,476/1000,/0/default.jpg');
|
||||
expect(tileUrlFunction([2, 0, 0])).to.be('http://iiif.test/image-id/0,0,1024,512/1024,/0/default.jpg');
|
||||
expect(tileUrlFunction([2, 1, 0])).to.be('http://iiif.test/image-id/1024,0,976,512/976,/0/default.jpg');
|
||||
expect(tileUrlFunction([2, 0, 2])).to.be('http://iiif.test/image-id/0,1024,1024,476/1024,/0/default.jpg');
|
||||
expect(tileUrlFunction([2, 1, 2])).to.be('http://iiif.test/image-id/1024,1024,976,476/976,/0/default.jpg');
|
||||
expect(tileUrlFunction([3, 0, 0])).to.be(undefined);
|
||||
|
||||
tileUrlFunction = getSource({
|
||||
tileSize: [1024, 512],
|
||||
version: Versions.VERSION3
|
||||
}).getTileUrlFunction();
|
||||
|
||||
expect(tileUrlFunction([0, 0, 0])).to.be('http://iiif.test/image-id/full/500,375/0/default.jpg');
|
||||
expect(tileUrlFunction([2, 0, 0])).to.be('http://iiif.test/image-id/0,0,1024,512/1024,512/0/default.jpg');
|
||||
|
||||
});
|
||||
|
||||
it('provides tile URLs with default tile size if sufficient supported features are provided', function() {
|
||||
|
||||
let tileUrlFunction = getSource({
|
||||
supports: ['regionByPx', 'sizeByW']
|
||||
}).getTileUrlFunction();
|
||||
|
||||
const maxZoom = Math.ceil(Math.log2(width / DEFAULT_TILE_SIZE));
|
||||
|
||||
expect(tileUrlFunction([maxZoom, 0, 0])).to.be('http://iiif.test/image-id/0,0,' + DEFAULT_TILE_SIZE + ',' + DEFAULT_TILE_SIZE + '/' + DEFAULT_TILE_SIZE + ',/0/default.jpg');
|
||||
expect(tileUrlFunction([maxZoom + 1, 0, 0])).to.be(undefined);
|
||||
|
||||
tileUrlFunction = getSource({
|
||||
supports: ['regionByPx', 'sizeByH']
|
||||
}).getTileUrlFunction();
|
||||
|
||||
expect(tileUrlFunction([maxZoom, 0, 0])).to.be('http://iiif.test/image-id/0,0,' + DEFAULT_TILE_SIZE + ',' + DEFAULT_TILE_SIZE + '/,' + DEFAULT_TILE_SIZE + '/0/default.jpg');
|
||||
expect(tileUrlFunction([maxZoom + 1, 0, 0])).to.be(undefined);
|
||||
|
||||
tileUrlFunction = getSource({
|
||||
supports: ['regionByPx', 'sizeByWh']
|
||||
}).getTileUrlFunction();
|
||||
|
||||
expect(tileUrlFunction([maxZoom, 0, 0])).to.be('http://iiif.test/image-id/0,0,' + DEFAULT_TILE_SIZE + ',' + DEFAULT_TILE_SIZE + '/' + DEFAULT_TILE_SIZE + ',' + DEFAULT_TILE_SIZE + '/0/default.jpg');
|
||||
expect(tileUrlFunction([maxZoom + 1, 0, 0])).to.be(undefined);
|
||||
|
||||
tileUrlFunction = getSource({
|
||||
supports: ['regionByPct', 'sizeByPct']
|
||||
}).getTileUrlFunction();
|
||||
|
||||
const tileWPct = (DEFAULT_TILE_SIZE / width * 100).toLocaleString('en', {maximumFractionDigits: 10}),
|
||||
tileHPct = (DEFAULT_TILE_SIZE / height * 100).toLocaleString('en', {maximumFractionDigits: 10});
|
||||
|
||||
expect(tileUrlFunction([maxZoom, 0, 0])).to.be('http://iiif.test/image-id/pct:0,0,' + tileWPct + ',' + tileHPct + '/pct:100/0/default.jpg');
|
||||
expect(tileUrlFunction([maxZoom + 1, 0, 0])).to.be(undefined);
|
||||
|
||||
});
|
||||
|
||||
it('prefers canonical tile URLs', function() {
|
||||
|
||||
let tileUrlFunction = getSource({
|
||||
tileSize: 512,
|
||||
supports: ['regionByPx', 'regionByPct', 'sizeByW', 'sizeByH', 'sizeByWh', 'sizeByPct']
|
||||
}).getTileUrlFunction();
|
||||
|
||||
expect(tileUrlFunction([2, 0, 0])).to.be('http://iiif.test/image-id/0,0,512,512/512,/0/default.jpg');
|
||||
|
||||
tileUrlFunction = getSource({
|
||||
tileSize: 512,
|
||||
version: Versions.VERSION3,
|
||||
supports: ['regionByPx', 'regionByPct', 'sizeByW', 'sizeByH', 'sizeByWh', 'sizeByPct']
|
||||
}).getTileUrlFunction();
|
||||
|
||||
expect(tileUrlFunction([2, 0, 0])).to.be('http://iiif.test/image-id/0,0,512,512/512,512/0/default.jpg');
|
||||
|
||||
});
|
||||
|
||||
|
||||
it('provides correct tile URLs for percentage URL parameter values', function() {
|
||||
|
||||
const tileUrlFunction = getSource({
|
||||
tileSize: 512,
|
||||
supports: ['regionByPct', 'sizeByPct']
|
||||
}).getTileUrlFunction();
|
||||
|
||||
expect(tileUrlFunction([0, 0, 0])).to.be('http://iiif.test/image-id/full/pct:25/0/default.jpg');
|
||||
expect(tileUrlFunction([-1, 0, 0])).to.be(undefined);
|
||||
expect(tileUrlFunction([0, 1, 0])).to.be(undefined);
|
||||
expect(tileUrlFunction([0, 0, 1])).to.be(undefined);
|
||||
|
||||
expect(tileUrlFunction([1, 0, 0])).to.be('http://iiif.test/image-id/pct:0,0,51.2,68.2666666667/pct:50/0/default.jpg');
|
||||
expect(tileUrlFunction([1, 1, 0])).to.be('http://iiif.test/image-id/pct:51.2,0,48.8,68.2666666667/pct:50/0/default.jpg');
|
||||
expect(tileUrlFunction([1, 0, 1])).to.be('http://iiif.test/image-id/pct:0,68.2666666667,51.2,31.7333333333/pct:50/0/default.jpg');
|
||||
expect(tileUrlFunction([1, 1, 1])).to.be('http://iiif.test/image-id/pct:51.2,68.2666666667,48.8,31.7333333333/pct:50/0/default.jpg');
|
||||
|
||||
expect(tileUrlFunction([2, 0, 0])).to.be('http://iiif.test/image-id/pct:0,0,25.6,34.1333333333/pct:100/0/default.jpg');
|
||||
expect(tileUrlFunction([2, 3, 0])).to.be('http://iiif.test/image-id/pct:76.8,0,23.2,34.1333333333/pct:100/0/default.jpg');
|
||||
expect(tileUrlFunction([2, 0, 2])).to.be('http://iiif.test/image-id/pct:0,68.2666666667,25.6,31.7333333333/pct:100/0/default.jpg');
|
||||
expect(tileUrlFunction([2, 3, 2])).to.be('http://iiif.test/image-id/pct:76.8,68.2666666667,23.2,31.7333333333/pct:100/0/default.jpg');
|
||||
expect(tileUrlFunction([3, 0, 0])).to.be(undefined);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user