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
|
* @constructor
|
||||||
* @extends {ol.source.TileImage}
|
* @extends {ol.source.TileImage}
|
||||||
* @param {olx.source.ZoomifyOptions} options Zoomify options.
|
* @param {olx.source.ZoomifyOptions=} opt_options Options.
|
||||||
* @todo stability experimental
|
* @todo stability experimental
|
||||||
*/
|
*/
|
||||||
ol.source.Zoomify = function(options) {
|
ol.source.Zoomify = function(opt_options) {
|
||||||
|
|
||||||
/**
|
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||||
* Prefix of URL template.
|
|
||||||
* @private
|
|
||||||
* @type {!string}
|
|
||||||
*/
|
|
||||||
this.url_ = options.url;
|
|
||||||
|
|
||||||
/**
|
var size = options.size;
|
||||||
* Size of the image.
|
|
||||||
* @private
|
|
||||||
* @type {ol.Size}
|
|
||||||
*/
|
|
||||||
this.size_ = options.size;
|
|
||||||
|
|
||||||
/**
|
var imageSize = size.slice();
|
||||||
* 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 tiles = [
|
var tiles = [
|
||||||
Math.ceil(this.size_[0] / ol.DEFAULT_TILE_SIZE),
|
Math.ceil(imageSize[0] / ol.DEFAULT_TILE_SIZE),
|
||||||
Math.ceil(this.size_[1] / ol.DEFAULT_TILE_SIZE)
|
Math.ceil(imageSize[1] / ol.DEFAULT_TILE_SIZE)
|
||||||
];
|
];
|
||||||
this.tierSizeInTiles_ = [tiles];
|
var tierSizeInTiles = [tiles];
|
||||||
this.tierImageSize_ = [imageSize];
|
var tierImageSize = [imageSize];
|
||||||
|
|
||||||
while (imageSize[0] > ol.DEFAULT_TILE_SIZE ||
|
while (imageSize[0] > ol.DEFAULT_TILE_SIZE ||
|
||||||
imageSize[1] > 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[0] / ol.DEFAULT_TILE_SIZE),
|
||||||
Math.ceil(imageSize[1] / ol.DEFAULT_TILE_SIZE)
|
Math.ceil(imageSize[1] / ol.DEFAULT_TILE_SIZE)
|
||||||
];
|
];
|
||||||
this.tierSizeInTiles_.push(tiles);
|
tierSizeInTiles.push(tiles);
|
||||||
this.tierImageSize_.push(imageSize);
|
tierImageSize.push(imageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.tierSizeInTiles_.reverse();
|
tierSizeInTiles.reverse();
|
||||||
this.tierImageSize_.reverse();
|
tierImageSize.reverse();
|
||||||
this.numberOfTiers_ = this.tierSizeInTiles_.length;
|
var numberOfTiers = tierSizeInTiles.length;
|
||||||
var resolutions = [1];
|
var resolutions = [1];
|
||||||
this.tileCountUpToTier_ = [0];
|
var tileCountUpToTier = [0];
|
||||||
for (var i = 1; i < this.numberOfTiers_; i++) {
|
var i;
|
||||||
|
for (i = 1; i < numberOfTiers; i++) {
|
||||||
resolutions.unshift(Math.pow(2, i));
|
resolutions.unshift(Math.pow(2, i));
|
||||||
this.tileCountUpToTier_.push(
|
tileCountUpToTier.push(
|
||||||
this.tierSizeInTiles_[i - 1][0] * this.tierSizeInTiles_[i - 1][1] +
|
tierSizeInTiles[i - 1][0] * tierSizeInTiles[i - 1][1] +
|
||||||
this.tileCountUpToTier_[i - 1]
|
tileCountUpToTier[i - 1]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var createFromUrl = function(url) {
|
var createFromUrl = function(url) {
|
||||||
var template = url + '{tileIndex}/{z}-{x}-{y}.jpg';
|
var template = url + '{tileIndex}/{z}-{x}-{y}.jpg';
|
||||||
return (
|
return (
|
||||||
@@ -111,8 +73,8 @@ ol.source.Zoomify = function(options) {
|
|||||||
return undefined;
|
return undefined;
|
||||||
} else {
|
} else {
|
||||||
var tileIndex = tileCoord.x +
|
var tileIndex = tileCoord.x +
|
||||||
(tileCoord.y * this.tierSizeInTiles_[tileCoord.z][0]) +
|
(tileCoord.y * tierSizeInTiles[tileCoord.z][0]) +
|
||||||
this.tileCountUpToTier_[tileCoord.z];
|
tileCountUpToTier[tileCoord.z];
|
||||||
return template.replace('{tileIndex}', 'TileGroup' +
|
return template.replace('{tileIndex}', 'TileGroup' +
|
||||||
Math.floor((tileIndex) / ol.DEFAULT_TILE_SIZE))
|
Math.floor((tileIndex) / ol.DEFAULT_TILE_SIZE))
|
||||||
.replace('{z}', '' + tileCoord.z)
|
.replace('{z}', '' + tileCoord.z)
|
||||||
@@ -159,9 +121,8 @@ ol.source.Zoomify = function(options) {
|
|||||||
resolutions: resolutions
|
resolutions: resolutions
|
||||||
});
|
});
|
||||||
var tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
|
var tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
|
||||||
tileGrid.createTileCoordTransform({extent: [0, 0].concat(this.size_)}),
|
tileGrid.createTileCoordTransform({extent: [0, 0, size[0], size[1]]}),
|
||||||
createFromUrl(this.url_));
|
createFromUrl(options.url));
|
||||||
|
|
||||||
|
|
||||||
goog.base(this, {
|
goog.base(this, {
|
||||||
attributions: options.attributions,
|
attributions: options.attributions,
|
||||||
|
|||||||
Reference in New Issue
Block a user