Merge pull request #1733 from twpayne/zoomify-clean-ups
Zoomify clean-ups
This commit is contained in:
@@ -930,6 +930,7 @@
|
|||||||
* requests.
|
* requests.
|
||||||
* @property {string|undefined} logo Logo.
|
* @property {string|undefined} logo Logo.
|
||||||
* @property {!string} url Prefix of URL template.
|
* @property {!string} url Prefix of URL template.
|
||||||
|
* @property {string|undefined} tierSizeCalculation Tier size calculation method: `default` or `truncated`.
|
||||||
* @property {ol.Size} size Size of the image.
|
* @property {ol.Size} size Size of the image.
|
||||||
* @todo stability experimental
|
* @todo stability experimental
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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');
|
||||||
@@ -12,6 +13,15 @@ goog.require('ol.source.TileImage');
|
|||||||
goog.require('ol.tilegrid.Zoomify');
|
goog.require('ol.tilegrid.Zoomify');
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
ol.source.ZoomifyTierSizeCalculation = {
|
||||||
|
DEFAULT: 'default',
|
||||||
|
TRUNCATED: 'truncated'
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
@@ -24,37 +34,40 @@ 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';
|
var tierSizeCalculation = goog.isDef(options.tierSizeCalculation) ?
|
||||||
|
options.tierSizeCalculation :
|
||||||
if (goog.isDef(options.tierSizeCalculation)) {
|
ol.source.ZoomifyTierSizeCalculation.DEFAULT;
|
||||||
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;
|
||||||
|
|
||||||
if (tierSizeCalculation === 'truncated') {
|
switch (tierSizeCalculation) {
|
||||||
var width = imageWidth;
|
case ol.source.ZoomifyTierSizeCalculation.DEFAULT:
|
||||||
var height = imageHeight;
|
while (imageWidth > tileSize || imageHeight > tileSize) {
|
||||||
|
tierSizeInTiles.push([
|
||||||
while (width > tileSize || height > tileSize) {
|
Math.ceil(imageWidth / tileSize),
|
||||||
tierSizeInTiles.push([
|
Math.ceil(imageHeight / tileSize)
|
||||||
Math.ceil(width / tileSize),
|
]);
|
||||||
Math.ceil(height / tileSize)
|
tileSize += tileSize;
|
||||||
]);
|
}
|
||||||
width >>= 1;
|
break;
|
||||||
height >>= 1;
|
case ol.source.ZoomifyTierSizeCalculation.TRUNCATED:
|
||||||
}
|
var width = imageWidth;
|
||||||
} else {
|
var height = imageHeight;
|
||||||
while (imageWidth > tileSize || imageHeight > tileSize) {
|
while (width > tileSize || height > tileSize) {
|
||||||
tierSizeInTiles.push([
|
tierSizeInTiles.push([
|
||||||
Math.ceil(imageWidth / tileSize),
|
Math.ceil(width / tileSize),
|
||||||
Math.ceil(imageHeight / tileSize)
|
Math.ceil(height / tileSize)
|
||||||
]);
|
]);
|
||||||
tileSize += tileSize;
|
width >>= 1;
|
||||||
}
|
height >>= 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
goog.asserts.fail();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
tierSizeInTiles.push([1, 1]);
|
tierSizeInTiles.push([1, 1]);
|
||||||
|
|||||||
Reference in New Issue
Block a user