Merge pull request #1731 from felixgirault/ol.source.zoomify
Add an alternative algorithm for zoomify tier size calculation
This commit is contained in:
@@ -24,18 +24,39 @@ ol.source.Zoomify = function(opt_options) {
|
|||||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||||
|
|
||||||
var size = options.size;
|
var size = options.size;
|
||||||
|
var tierSizeCalculation = 'default';
|
||||||
|
|
||||||
|
if (goog.isDef(options.tierSizeCalculation)) {
|
||||||
|
tierSizeCalculation = options.tierSizeCalculation;
|
||||||
|
}
|
||||||
|
|
||||||
var imageWidth = size[0];
|
var imageWidth = size[0];
|
||||||
var imageHeight = size[1];
|
var imageHeight = size[1];
|
||||||
|
|
||||||
var tierSizeInTiles = [];
|
var tierSizeInTiles = [];
|
||||||
var tileSize = ol.DEFAULT_TILE_SIZE;
|
var tileSize = ol.DEFAULT_TILE_SIZE;
|
||||||
while (imageWidth > tileSize || imageHeight > tileSize) {
|
|
||||||
tierSizeInTiles.push([
|
if (tierSizeCalculation === 'truncated') {
|
||||||
Math.ceil(imageWidth / tileSize),
|
var width = imageWidth;
|
||||||
Math.ceil(imageHeight / tileSize)
|
var height = imageHeight;
|
||||||
]);
|
|
||||||
tileSize += tileSize;
|
while (width > tileSize || height > tileSize) {
|
||||||
|
tierSizeInTiles.push([
|
||||||
|
Math.ceil(width / tileSize),
|
||||||
|
Math.ceil(height / tileSize)
|
||||||
|
]);
|
||||||
|
width >>= 1;
|
||||||
|
height >>= 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
while (imageWidth > tileSize || imageHeight > tileSize) {
|
||||||
|
tierSizeInTiles.push([
|
||||||
|
Math.ceil(imageWidth / tileSize),
|
||||||
|
Math.ceil(imageHeight / tileSize)
|
||||||
|
]);
|
||||||
|
tileSize += tileSize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tierSizeInTiles.push([1, 1]);
|
tierSizeInTiles.push([1, 1]);
|
||||||
tierSizeInTiles.reverse();
|
tierSizeInTiles.reverse();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user