Use a switch to select tier size calculation

This commit is contained in:
Tom Payne
2014-02-20 19:30:47 +01:00
parent 00eff70ae6
commit a773ab256c

View File

@@ -1,6 +1,7 @@
goog.provide('ol.source.Zoomify'); goog.provide('ol.source.Zoomify');
goog.require('goog.array'); goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.dom'); goog.require('goog.dom');
goog.require('goog.dom.TagName'); goog.require('goog.dom.TagName');
goog.require('ol.ImageTile'); goog.require('ol.ImageTile');
@@ -42,10 +43,19 @@ ol.source.Zoomify = function(opt_options) {
var tierSizeInTiles = []; var tierSizeInTiles = [];
var tileSize = ol.DEFAULT_TILE_SIZE; var tileSize = ol.DEFAULT_TILE_SIZE;
if (tierSizeCalculation === 'truncated') { switch (tierSizeCalculation) {
case ol.source.ZoomifyTierSizeCalculation.DEFAULT:
while (imageWidth > tileSize || imageHeight > tileSize) {
tierSizeInTiles.push([
Math.ceil(imageWidth / tileSize),
Math.ceil(imageHeight / tileSize)
]);
tileSize += tileSize;
}
break;
case ol.source.ZoomifyTierSizeCalculation.TRUNCATED:
var width = imageWidth; var width = imageWidth;
var height = imageHeight; var height = imageHeight;
while (width > tileSize || height > tileSize) { while (width > tileSize || height > tileSize) {
tierSizeInTiles.push([ tierSizeInTiles.push([
Math.ceil(width / tileSize), Math.ceil(width / tileSize),
@@ -54,14 +64,10 @@ ol.source.Zoomify = function(opt_options) {
width >>= 1; width >>= 1;
height >>= 1; height >>= 1;
} }
} else { break;
while (imageWidth > tileSize || imageHeight > tileSize) { default:
tierSizeInTiles.push([ goog.asserts.fail();
Math.ceil(imageWidth / tileSize), break;
Math.ceil(imageHeight / tileSize)
]);
tileSize += tileSize;
}
} }
tierSizeInTiles.push([1, 1]); tierSizeInTiles.push([1, 1]);