mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 13:16:10 +03:00
Remove TileSource.tileSize. Convert IIIFTileSource to override TileSource.getTileWidth and TileSource.getTileHeight.
This commit is contained in:
parent
201ca8a422
commit
d11c4fe107
@ -182,19 +182,34 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, /** @lends OpenSea
|
||||
},
|
||||
|
||||
/**
|
||||
* Return the tileSize for the given level.
|
||||
* Return the tileWidth for the given level.
|
||||
* @function
|
||||
* @param {Number} level
|
||||
*/
|
||||
getTileSize: function( level ){
|
||||
*/
|
||||
getTileWidth: function( level ) {
|
||||
var scaleFactor = Math.pow(2, this.maxLevel - level);
|
||||
// cache it in case any external code is going to read it directly
|
||||
|
||||
if (this.tileSizePerScaleFactor && this.tileSizePerScaleFactor[scaleFactor]) {
|
||||
this.tileSize = this.tileSizePerScaleFactor[scaleFactor];
|
||||
return this.tileSizePerScaleFactor[scaleFactor];
|
||||
}
|
||||
return this.tileSize;
|
||||
return this._tileWidth;
|
||||
},
|
||||
|
||||
/**
|
||||
* Return the tileHeight for the given level.
|
||||
* @function
|
||||
* @param {Number} level
|
||||
*/
|
||||
getTileHeight: function( level ) {
|
||||
var scaleFactor = Math.pow(2, this.maxLevel - level);
|
||||
|
||||
if (this.tileSizePerScaleFactor && this.tileSizePerScaleFactor[scaleFactor]) {
|
||||
return this.tileSizePerScaleFactor[scaleFactor];
|
||||
}
|
||||
return this._tileHeight;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Responsible for retreiving the url which will return an image for the
|
||||
* region specified by the given x, y, and level components.
|
||||
@ -216,7 +231,8 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, /** @lends OpenSea
|
||||
levelHeight = Math.ceil( this.height * scale ),
|
||||
|
||||
//## iiif region
|
||||
tileSize,
|
||||
tileWidth,
|
||||
tileHeight,
|
||||
iiifTileSizeWidth,
|
||||
iiifTileSizeHeight,
|
||||
iiifRegion,
|
||||
@ -228,9 +244,10 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, /** @lends OpenSea
|
||||
iiifQuality,
|
||||
uri;
|
||||
|
||||
tileSize = this.getTileSize(level);
|
||||
iiifTileSizeWidth = Math.ceil( tileSize / scale );
|
||||
iiifTileSizeHeight = iiifTileSizeWidth;
|
||||
tileWidth = this.getTileSize(level);
|
||||
tileHeight = this.getTileHeight(level);
|
||||
iiifTileSizeWidth = Math.ceil( tileWidth / scale );
|
||||
iiifTileSizeHeight = Math.ceil( tileHeight / scale );
|
||||
|
||||
if ( this['@context'].indexOf('/1.0/context.json') > -1 ||
|
||||
this['@context'].indexOf('/1.1/context.json') > -1 ||
|
||||
@ -240,7 +257,7 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, /** @lends OpenSea
|
||||
iiifQuality = "default.jpg";
|
||||
}
|
||||
|
||||
if ( levelWidth < tileSize && levelHeight < tileSize ){
|
||||
if ( levelWidth < tileWidth && levelHeight < tileHeight ){
|
||||
iiifSize = levelWidth + ",";
|
||||
iiifRegion = 'full';
|
||||
} else {
|
||||
|
@ -142,13 +142,6 @@ $.TileSource = function( width, height, tileSize, tileOverlap, minLevel, maxLeve
|
||||
* @member {OpenSeadragon.Point} dimensions
|
||||
* @memberof OpenSeadragon.TileSource#
|
||||
*/
|
||||
/**
|
||||
* The size of the image tiles used to compose the image.
|
||||
* Please note that tileSize may be deprecated in a future release.
|
||||
* Instead the getTileSize(level) function should be used.
|
||||
* @member {Number} tileSize
|
||||
* @memberof OpenSeadragon.TileSource#
|
||||
*/
|
||||
/**
|
||||
* The overlap in pixels each tile shares with its adjacent neighbors.
|
||||
* @member {Number} tileOverlap
|
||||
@ -179,7 +172,8 @@ $.TileSource = function( width, height, tileSize, tileOverlap, minLevel, maxLeve
|
||||
//async mechanism set some safe defaults first
|
||||
this.aspectRatio = 1;
|
||||
this.dimensions = new $.Point( 10, 10 );
|
||||
this.tileSize = 0;
|
||||
this._tileWidth = 0;
|
||||
this._tileHeight = 0;
|
||||
this.tileOverlap = 0;
|
||||
this.minLevel = 0;
|
||||
this.maxLevel = 0;
|
||||
@ -197,9 +191,12 @@ $.TileSource = function( width, height, tileSize, tileOverlap, minLevel, maxLeve
|
||||
( options.width / options.height ) : 1;
|
||||
this.dimensions = new $.Point( options.width, options.height );
|
||||
|
||||
this.tileSize = options.tileSize ? options.tileSize : 0;
|
||||
this.tileWidth = options.tileWidth;
|
||||
this.tileHeight = options.tileHeight;
|
||||
if ( options.tileSize ){
|
||||
this._tileWidth = this._tileHeight = options.tileSize;
|
||||
} else {
|
||||
this._tileWidth = options.tileWidth ? options.tileWidth : 0;
|
||||
this._tileHeight = options.tileHeight ? options.tileHeight: 0;
|
||||
}
|
||||
|
||||
this.tileOverlap = options.tileOverlap ? options.tileOverlap : 0;
|
||||
this.minLevel = options.minLevel ? options.minLevel : 0;
|
||||
@ -221,21 +218,12 @@ $.TileSource = function( width, height, tileSize, tileOverlap, minLevel, maxLeve
|
||||
|
||||
$.TileSource.prototype = /** @lends OpenSeadragon.TileSource.prototype */{
|
||||
|
||||
/**
|
||||
* Return the tileSize for a given level.
|
||||
* Subclasses should override this if tileSizes can be different at different levels
|
||||
* such as in IIIFTileSource. Code should use this function rather than reading
|
||||
* from .tileSize directly. tileSize may be deprecated in a future release.
|
||||
* @deprecated
|
||||
* @function
|
||||
* @param {Number} level
|
||||
*/
|
||||
getTileSize: function( level ) {
|
||||
$.console.error(
|
||||
"[TileSource.getTileSize] is deprecated." +
|
||||
"Use TileSource.getTileWidth() and TileSource.getTileHeight() instead"
|
||||
);
|
||||
return this.tileSize;
|
||||
return this._tileWidth;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -247,11 +235,10 @@ $.TileSource.prototype = /** @lends OpenSeadragon.TileSource.prototype */{
|
||||
* @param {Number} level
|
||||
*/
|
||||
getTileWidth: function( level ) {
|
||||
// If tileWidth was not set, fallback by setting it to tileSize
|
||||
if( this.tileWidth === undefined){
|
||||
this.tileWidth = this.tileSize;
|
||||
if (!this._tileWidth) {
|
||||
return this.getTileSize(level);
|
||||
}
|
||||
return this.tileWidth;
|
||||
return this._tileWidth;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -263,11 +250,10 @@ $.TileSource.prototype = /** @lends OpenSeadragon.TileSource.prototype */{
|
||||
* @param {Number} level
|
||||
*/
|
||||
getTileHeight: function( level ) {
|
||||
// If tileHeight was not set, fallback by setting it to tileSize
|
||||
if( this.tileHeight === undefined ){
|
||||
this.tileHeight = this.tileSize;
|
||||
if (!this._tileHeight) {
|
||||
return this.getTileSize(level);
|
||||
}
|
||||
return this.tileHeight;
|
||||
return this._tileHeight;
|
||||
},
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user