Add a zDirection option for Zoomify
Via zDirection, the renderer's selection of a tile source's resolution can be controlled if the view's resolution does not match any tile source resolution. Currently the zDirection option is only available for Zoomify. The comment https://github.com/openlayers/openlayers/issues/9343#issuecomment-474341033 describes why caution is advised when using zDirection for other sources. ol/source/Tile~TileSource#getZDirection has been added to avoid having the getZDirection method solely in the Zoomify source - just to document the possibility.
This commit is contained in:
@@ -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.getZDirection() === undefined ? this.zDirection : tileSource.getZDirection();
|
||||||
|
const z = tileGrid.getZForResolution(viewResolution, zDirection);
|
||||||
const tileResolution = tileGrid.getResolution(z);
|
const tileResolution = tileGrid.getResolution(z);
|
||||||
let extent = frameState.extent;
|
let extent = frameState.extent;
|
||||||
|
|
||||||
|
|||||||
@@ -326,6 +326,18 @@ class TileSource extends Source {
|
|||||||
*/
|
*/
|
||||||
useTile(z, x, y, projection) {}
|
useTile(z, x, y, projection) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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. If undefined,
|
||||||
|
* the decision is left to the renderer.
|
||||||
|
* @return {number|undefined} Prefered zDirection for source resolution selection.
|
||||||
|
*/
|
||||||
|
getZDirection() {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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,19 @@ class Zoomify extends TileImage {
|
|||||||
transition: options.transition
|
transition: options.transition
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @protected
|
||||||
|
* @type {number|undefined}
|
||||||
|
*/
|
||||||
|
this.zDirection = options.zDirection;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
getZDirection() {
|
||||||
|
return this.zDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user