Remove unnecessary changes to Tile and ImageTile for changing Zoomify source tile size.
This commit is contained in:
@@ -19,7 +19,6 @@ goog.require('ol.events.EventType');
|
||||
* @param {olx.TileOptions=} opt_options Tile options.
|
||||
*/
|
||||
ol.ImageTile = function(tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options) {
|
||||
var options = opt_options || {};
|
||||
|
||||
ol.Tile.call(this, tileCoord, state, opt_options);
|
||||
|
||||
@@ -52,14 +51,6 @@ ol.ImageTile = function(tileCoord, state, src, crossOrigin, tileLoadFunction, op
|
||||
*/
|
||||
this.tileLoadFunction_ = tileLoadFunction;
|
||||
|
||||
var tileCoordZ = tileCoord[0];
|
||||
var tileGridTileSize = (options.tileGrid ? options.tileGrid.getTileSize(tileCoordZ) : undefined);
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {number}
|
||||
*/
|
||||
this.tileSize_ = tileGridTileSize || ol.DEFAULT_TILE_SIZE;
|
||||
};
|
||||
ol.inherits(ol.ImageTile, ol.Tile);
|
||||
|
||||
|
||||
@@ -75,10 +75,7 @@ ol.source.Tile = function(options) {
|
||||
* @protected
|
||||
* @type {olx.TileOptions}
|
||||
*/
|
||||
this.tileOptions = {
|
||||
transition: options.transition,
|
||||
tileGrid: this.tileGrid
|
||||
};
|
||||
this.tileOptions = {transition: options.transition};
|
||||
|
||||
};
|
||||
ol.inherits(ol.source.Tile, ol.source.Source);
|
||||
|
||||
@@ -11,6 +11,62 @@ goog.require('ol.source.TileImage');
|
||||
goog.require('ol.tilegrid.TileGrid');
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.ImageTile}
|
||||
* @param {ol.tilegrid.TileGrid} tileGrid TileGrid that the tile belongs to.
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
* @param {ol.TileState} state State.
|
||||
* @param {string} src Image source URI.
|
||||
* @param {?string} crossOrigin Cross origin.
|
||||
* @param {ol.TileLoadFunctionType} tileLoadFunction Tile load function.
|
||||
* @param {olx.TileOptions=} opt_options Tile options.
|
||||
* @private
|
||||
*/
|
||||
var ZoomifyTileClass = function(
|
||||
tileGrid, tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options) {
|
||||
|
||||
ol.ImageTile.call(this, tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement}
|
||||
*/
|
||||
this.zoomifyImage_ = null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.Size|number}
|
||||
*/
|
||||
this.tileSize_ = tileGrid.getTileSize(tileCoord[0]);
|
||||
};
|
||||
ol.inherits(ZoomifyTileClass, ol.ImageTile);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ZoomifyTileClass.prototype.getImage = function() {
|
||||
if (this.zoomifyImage_) {
|
||||
return this.zoomifyImage_;
|
||||
}
|
||||
var tileSize = (Array.isArray(this.tileSize_) ? this.tileSize_[0] : this.tileSize_);
|
||||
var image = ol.ImageTile.prototype.getImage.call(this);
|
||||
if (this.state == ol.TileState.LOADED) {
|
||||
if (image.width == tileSize && image.height == tileSize) {
|
||||
this.zoomifyImage_ = image;
|
||||
return image;
|
||||
} else {
|
||||
var context = ol.dom.createCanvasContext2D(tileSize, tileSize);
|
||||
context.drawImage(image, 0, 0);
|
||||
this.zoomifyImage_ = context.canvas;
|
||||
return context.canvas;
|
||||
}
|
||||
} else {
|
||||
return image;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Layer source for tile data in Zoomify format (both Zoomify and Internet
|
||||
@@ -133,6 +189,8 @@ ol.source.Zoomify = function(opt_options) {
|
||||
|
||||
var tileUrlFunction = ol.TileUrlFunction.createFromTileUrlFunctions(urls.map(createFromTemplate));
|
||||
|
||||
ol.source.Zoomify.Tile_ = ZoomifyTileClass.bind(null, tileGrid);
|
||||
|
||||
ol.source.TileImage.call(this, {
|
||||
attributions: options.attributions,
|
||||
cacheSize: options.cacheSize,
|
||||
@@ -150,57 +208,6 @@ ol.source.Zoomify = function(opt_options) {
|
||||
ol.inherits(ol.source.Zoomify, ol.source.TileImage);
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.ImageTile}
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
* @param {ol.TileState} state State.
|
||||
* @param {string} src Image source URI.
|
||||
* @param {?string} crossOrigin Cross origin.
|
||||
* @param {ol.TileLoadFunctionType} tileLoadFunction Tile load function.
|
||||
* @param {olx.TileOptions=} opt_options Tile options.
|
||||
* @private
|
||||
*/
|
||||
ol.source.Zoomify.Tile_ = function(
|
||||
tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options) {
|
||||
|
||||
ol.ImageTile.call(this, tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement}
|
||||
*/
|
||||
this.zoomifyImage_ = null;
|
||||
|
||||
};
|
||||
ol.inherits(ol.source.Zoomify.Tile_, ol.ImageTile);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.source.Zoomify.Tile_.prototype.getImage = function() {
|
||||
if (this.zoomifyImage_) {
|
||||
return this.zoomifyImage_;
|
||||
}
|
||||
var tileSize = this.tileSize_;
|
||||
var image = ol.ImageTile.prototype.getImage.call(this);
|
||||
if (this.state == ol.TileState.LOADED) {
|
||||
if (image.width == tileSize && image.height == tileSize) {
|
||||
this.zoomifyImage_ = image;
|
||||
return image;
|
||||
} else {
|
||||
var context = ol.dom.createCanvasContext2D(tileSize, tileSize);
|
||||
context.drawImage(image, 0, 0);
|
||||
this.zoomifyImage_ = context.canvas;
|
||||
return context.canvas;
|
||||
}
|
||||
} else {
|
||||
return image;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
* @private
|
||||
|
||||
Reference in New Issue
Block a user