Merge pull request #9361 from lutzhelm/9343-zdirection
Add a zDirection option for Zoomify - implements #9343
BIN
rendering/cases/zoomify-no-zdirection/expected.png
Normal file
|
After Width: | Height: | Size: 778 B |
25
rendering/cases/zoomify-no-zdirection/main.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import Map from '../../../src/ol/Map.js';
|
||||||
|
import View from '../../../src/ol/View.js';
|
||||||
|
import TileLayer from '../../../src/ol/layer/Tile.js';
|
||||||
|
import Zoomify from '../../../src/ol/source/Zoomify.js';
|
||||||
|
|
||||||
|
const layer = new TileLayer({
|
||||||
|
source: new Zoomify({
|
||||||
|
url: '/data/tiles/zoomify/',
|
||||||
|
size: [200, 200],
|
||||||
|
tileSize: 100
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
new Map({
|
||||||
|
layers: [layer],
|
||||||
|
target: 'map',
|
||||||
|
view: new View({
|
||||||
|
resolutions: [2, 1],
|
||||||
|
extent: [0, -200, 200, 0],
|
||||||
|
center: [100, -100],
|
||||||
|
zoom: 0.4
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
render();
|
||||||
BIN
rendering/cases/zoomify-zdirection/expected.png
Normal file
|
After Width: | Height: | Size: 801 B |
26
rendering/cases/zoomify-zdirection/main.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import Map from '../../../src/ol/Map.js';
|
||||||
|
import View from '../../../src/ol/View.js';
|
||||||
|
import TileLayer from '../../../src/ol/layer/Tile.js';
|
||||||
|
import Zoomify from '../../../src/ol/source/Zoomify.js';
|
||||||
|
|
||||||
|
const layer = new TileLayer({
|
||||||
|
source: new Zoomify({
|
||||||
|
url: '/data/tiles/zoomify/',
|
||||||
|
size: [200, 200],
|
||||||
|
tileSize: 100,
|
||||||
|
zDirection: -1
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
new Map({
|
||||||
|
layers: [layer],
|
||||||
|
target: 'map',
|
||||||
|
view: new View({
|
||||||
|
resolutions: [2, 1],
|
||||||
|
extent: [0, -200, 200, 0],
|
||||||
|
center: [100, -100],
|
||||||
|
zoom: 0.4
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
render();
|
||||||
BIN
rendering/data/tiles/zoomify/TileGroup0/0-0-0.jpg
Normal file
|
After Width: | Height: | Size: 733 B |
BIN
rendering/data/tiles/zoomify/TileGroup0/1-0-0.jpg
Normal file
|
After Width: | Height: | Size: 670 B |
BIN
rendering/data/tiles/zoomify/TileGroup0/1-0-1.jpg
Normal file
|
After Width: | Height: | Size: 734 B |
BIN
rendering/data/tiles/zoomify/TileGroup0/1-1-0.jpg
Normal file
|
After Width: | Height: | Size: 670 B |
BIN
rendering/data/tiles/zoomify/TileGroup0/1-1-1.jpg
Normal file
|
After Width: | Height: | Size: 669 B |
@@ -143,7 +143,8 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
|
|||||||
const tileSource = tileLayer.getSource();
|
const tileSource = tileLayer.getSource();
|
||||||
const sourceRevision = tileSource.getRevision();
|
const sourceRevision = tileSource.getRevision();
|
||||||
const tileGrid = tileSource.getTileGridForProjection(projection);
|
const tileGrid = tileSource.getTileGridForProjection(projection);
|
||||||
const z = tileGrid.getZForResolution(viewResolution, this.zDirection);
|
const zDirection = tileSource.zDirection === undefined ? this.zDirection : tileSource.zDirection;
|
||||||
|
const z = tileGrid.getZForResolution(viewResolution, zDirection);
|
||||||
const tileResolution = tileGrid.getResolution(z);
|
const tileResolution = tileGrid.getResolution(z);
|
||||||
let extent = frameState.extent;
|
let extent = frameState.extent;
|
||||||
|
|
||||||
|
|||||||
@@ -105,6 +105,14 @@ class TileSource extends Source {
|
|||||||
*/
|
*/
|
||||||
this.tileOptions = {transition: options.transition};
|
this.tileOptions = {transition: options.transition};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* zDirection hint, read by the renderer. Indicates which resolution should be used
|
||||||
|
* by a renderer if the views resolution does not match any resolution of the tile source.
|
||||||
|
* If 0, the nearest resolution will be used. If 1, the nearest lower resolution
|
||||||
|
* will be used. If -1, the nearest higher resolution will be used.
|
||||||
|
* @type {number=}
|
||||||
|
*/
|
||||||
|
this.zDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -111,6 +111,10 @@ export class CustomTile extends ImageTile {
|
|||||||
* @property {number} [transition] Duration of the opacity transition for rendering.
|
* @property {number} [transition] Duration of the opacity transition for rendering.
|
||||||
* To disable the opacity transition, pass `transition: 0`.
|
* To disable the opacity transition, pass `transition: 0`.
|
||||||
* @property {number} [tileSize=256] Tile size. Same tile size is used for all zoom levels.
|
* @property {number} [tileSize=256] Tile size. Same tile size is used for all zoom levels.
|
||||||
|
* @property {number} [zDirection] Indicate which resolution should be used
|
||||||
|
* by a renderer if the views resolution does not match any resolution of the tile source.
|
||||||
|
* If 0, the nearest resolution will be used. If 1, the nearest lower resolution
|
||||||
|
* will be used. If -1, the nearest higher resolution will be used.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -253,6 +257,11 @@ class Zoomify extends TileImage {
|
|||||||
transition: options.transition
|
transition: options.transition
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
this.zDirection = options.zDirection;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||