No need to use private variables in ol.source.Zoomify
This commit is contained in:
@@ -13,60 +13,22 @@ goog.require('ol.tilegrid.Zoomify');
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.source.TileImage}
|
||||
* @param {olx.source.ZoomifyOptions} options Zoomify options.
|
||||
* @param {olx.source.ZoomifyOptions=} opt_options Options.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.source.Zoomify = function(options) {
|
||||
ol.source.Zoomify = function(opt_options) {
|
||||
|
||||
/**
|
||||
* Prefix of URL template.
|
||||
* @private
|
||||
* @type {!string}
|
||||
*/
|
||||
this.url_ = options.url;
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
|
||||
/**
|
||||
* Size of the image.
|
||||
* @private
|
||||
* @type {ol.Size}
|
||||
*/
|
||||
this.size_ = options.size;
|
||||
var size = options.size;
|
||||
|
||||
/**
|
||||
* Depth of the Zoomify pyramid, number of tiers (zoom levels).
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.numberOfTiers_ = 0;
|
||||
|
||||
/**
|
||||
* Number of tiles up to the given tier of pyramid.
|
||||
* @private
|
||||
* @type {Array.<number>}
|
||||
*/
|
||||
this.tileCountUpToTier_ = null;
|
||||
|
||||
/**
|
||||
* Size (in tiles) for each tier of pyramid.
|
||||
* @private
|
||||
* @type {Array.<ol.Size>}
|
||||
*/
|
||||
this.tierSizeInTiles_ = null;
|
||||
|
||||
/**
|
||||
* Image size in pixels for each pyramid tier.
|
||||
* @private
|
||||
* @type {Array.<ol.Size>}
|
||||
*/
|
||||
this.tierImageSize_ = null;
|
||||
|
||||
var imageSize = [].concat(this.size_);
|
||||
var imageSize = size.slice();
|
||||
var tiles = [
|
||||
Math.ceil(this.size_[0] / ol.DEFAULT_TILE_SIZE),
|
||||
Math.ceil(this.size_[1] / ol.DEFAULT_TILE_SIZE)
|
||||
Math.ceil(imageSize[0] / ol.DEFAULT_TILE_SIZE),
|
||||
Math.ceil(imageSize[1] / ol.DEFAULT_TILE_SIZE)
|
||||
];
|
||||
this.tierSizeInTiles_ = [tiles];
|
||||
this.tierImageSize_ = [imageSize];
|
||||
var tierSizeInTiles = [tiles];
|
||||
var tierImageSize = [imageSize];
|
||||
|
||||
while (imageSize[0] > ol.DEFAULT_TILE_SIZE ||
|
||||
imageSize[1] > ol.DEFAULT_TILE_SIZE) {
|
||||
@@ -79,24 +41,24 @@ ol.source.Zoomify = function(options) {
|
||||
Math.ceil(imageSize[0] / ol.DEFAULT_TILE_SIZE),
|
||||
Math.ceil(imageSize[1] / ol.DEFAULT_TILE_SIZE)
|
||||
];
|
||||
this.tierSizeInTiles_.push(tiles);
|
||||
this.tierImageSize_.push(imageSize);
|
||||
tierSizeInTiles.push(tiles);
|
||||
tierImageSize.push(imageSize);
|
||||
}
|
||||
|
||||
this.tierSizeInTiles_.reverse();
|
||||
this.tierImageSize_.reverse();
|
||||
this.numberOfTiers_ = this.tierSizeInTiles_.length;
|
||||
tierSizeInTiles.reverse();
|
||||
tierImageSize.reverse();
|
||||
var numberOfTiers = tierSizeInTiles.length;
|
||||
var resolutions = [1];
|
||||
this.tileCountUpToTier_ = [0];
|
||||
for (var i = 1; i < this.numberOfTiers_; i++) {
|
||||
var tileCountUpToTier = [0];
|
||||
var i;
|
||||
for (i = 1; i < numberOfTiers; i++) {
|
||||
resolutions.unshift(Math.pow(2, i));
|
||||
this.tileCountUpToTier_.push(
|
||||
this.tierSizeInTiles_[i - 1][0] * this.tierSizeInTiles_[i - 1][1] +
|
||||
this.tileCountUpToTier_[i - 1]
|
||||
tileCountUpToTier.push(
|
||||
tierSizeInTiles[i - 1][0] * tierSizeInTiles[i - 1][1] +
|
||||
tileCountUpToTier[i - 1]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
var createFromUrl = function(url) {
|
||||
var template = url + '{tileIndex}/{z}-{x}-{y}.jpg';
|
||||
return (
|
||||
@@ -111,8 +73,8 @@ ol.source.Zoomify = function(options) {
|
||||
return undefined;
|
||||
} else {
|
||||
var tileIndex = tileCoord.x +
|
||||
(tileCoord.y * this.tierSizeInTiles_[tileCoord.z][0]) +
|
||||
this.tileCountUpToTier_[tileCoord.z];
|
||||
(tileCoord.y * tierSizeInTiles[tileCoord.z][0]) +
|
||||
tileCountUpToTier[tileCoord.z];
|
||||
return template.replace('{tileIndex}', 'TileGroup' +
|
||||
Math.floor((tileIndex) / ol.DEFAULT_TILE_SIZE))
|
||||
.replace('{z}', '' + tileCoord.z)
|
||||
@@ -159,9 +121,8 @@ ol.source.Zoomify = function(options) {
|
||||
resolutions: resolutions
|
||||
});
|
||||
var tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
|
||||
tileGrid.createTileCoordTransform({extent: [0, 0].concat(this.size_)}),
|
||||
createFromUrl(this.url_));
|
||||
|
||||
tileGrid.createTileCoordTransform({extent: [0, 0, size[0], size[1]]}),
|
||||
createFromUrl(options.url));
|
||||
|
||||
goog.base(this, {
|
||||
attributions: options.attributions,
|
||||
|
||||
Reference in New Issue
Block a user