Merge pull request #2206 from filak/master

Update iiiftilesource.js
This commit is contained in:
Ian Gilman 2022-12-07 14:21:47 -08:00 committed by GitHub
commit de4eac5a06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -134,7 +134,7 @@ $.IIIFTileSource = function( options ){
if (!options.maxLevel && !this.emulateLegacyImagePyramid) { if (!options.maxLevel && !this.emulateLegacyImagePyramid) {
if (!this.scale_factors) { if (!this.scale_factors) {
options.maxLevel = Number(Math.ceil(Math.log(Math.max(this.width, this.height), 2))); options.maxLevel = Number(Math.round(Math.log(Math.max(this.width, this.height), 2)));
} else { } else {
var maxScaleFactor = Math.max.apply(null, this.scale_factors); var maxScaleFactor = Math.max.apply(null, this.scale_factors);
options.maxLevel = Math.round(Math.log(maxScaleFactor) * Math.LOG2E); options.maxLevel = Math.round(Math.log(maxScaleFactor) * Math.LOG2E);
@ -377,8 +377,8 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, /** @lends OpenSea
scale = Math.pow( 0.5, this.maxLevel - level ), scale = Math.pow( 0.5, this.maxLevel - level ),
//# image dimensions at this level //# image dimensions at this level
levelWidth = Math.ceil( this.width * scale ), levelWidth = Math.round( this.width * scale ),
levelHeight = Math.ceil( this.height * scale ), levelHeight = Math.round( this.height * scale ),
//## iiif region //## iiif region
tileWidth, tileWidth,
@ -398,8 +398,8 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, /** @lends OpenSea
tileWidth = this.getTileWidth(level); tileWidth = this.getTileWidth(level);
tileHeight = this.getTileHeight(level); tileHeight = this.getTileHeight(level);
iiifTileSizeWidth = Math.ceil( tileWidth / scale ); iiifTileSizeWidth = Math.round( tileWidth / scale );
iiifTileSizeHeight = Math.ceil( tileHeight / scale ); iiifTileSizeHeight = Math.round( tileHeight / scale );
if (this.version === 1) { if (this.version === 1) {
iiifQuality = "native." + this.tileFormat; iiifQuality = "native." + this.tileFormat;
} else { } else {
@ -426,8 +426,8 @@ $.extend( $.IIIFTileSource.prototype, $.TileSource.prototype, /** @lends OpenSea
} else { } else {
iiifRegion = [ iiifTileX, iiifTileY, iiifTileW, iiifTileH ].join( ',' ); iiifRegion = [ iiifTileX, iiifTileY, iiifTileW, iiifTileH ].join( ',' );
} }
iiifSizeW = Math.ceil( iiifTileW * scale ); iiifSizeW = Math.round( iiifTileW * scale );
iiifSizeH = Math.ceil( iiifTileH * scale ); iiifSizeH = Math.round( iiifTileH * scale );
if ( this.version === 2 && iiifSizeW === this.width ) { if ( this.version === 2 && iiifSizeW === this.width ) {
iiifSize = "full"; iiifSize = "full";
} else if ( this.version === 3 && iiifSizeW === this.width && iiifSizeH === this.height ) { } else if ( this.version === 3 && iiifSizeW === this.width && iiifSizeH === this.height ) {