mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 06:36:11 +03:00
style changes, per @iangilman on openseadragon/openseadragon#315
This commit is contained in:
parent
24298dcbba
commit
ddde07b614
@ -49,45 +49,45 @@ $.IIIF1_1TileSource = function( options ){
|
|||||||
$.extend( true, this, options );
|
$.extend( true, this, options );
|
||||||
|
|
||||||
|
|
||||||
if( !(this.height && this.width && this['@id'] ) ){
|
if ( !( this.height && this.width && this['@id'] ) ){
|
||||||
throw new Error('IIIF required parameters not provided.');
|
throw new Error( 'IIIF required parameters not provided.' );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( (this.profile &&
|
if ( ( this.profile &&
|
||||||
this.profile == "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0" ) ){
|
this.profile == "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0" ) ){
|
||||||
// what if not reporting a profile?
|
// what if not reporting a profile?
|
||||||
throw new Error('IIIF Image API 1.1 compliance level 1 or greater is required.');
|
throw new Error( 'IIIF Image API 1.1 compliance level 1 or greater is required.' );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.tile_width) {
|
if ( this.tile_width ) {
|
||||||
options.tileSize = this.tile_width;
|
options.tileSize = this.tile_width;
|
||||||
} else if (this.tile_height) {
|
} else if ( this.tile_height ) {
|
||||||
options.tileSize = this.tile_height;
|
options.tileSize = this.tile_height;
|
||||||
} else {
|
} else {
|
||||||
// use the largest of tile_options that is smaller than the short
|
// use the largest of tileOptions that is smaller than the short
|
||||||
// dimension
|
// dimension
|
||||||
|
|
||||||
var short_dim = Math.min(this.height, this.width),
|
var shortDim = Math.min( this.height, this.width ),
|
||||||
tile_options = [256,512,1024],
|
tileOptions = [256,512,1024],
|
||||||
smaller_tiles = [];
|
smallerTiles = [];
|
||||||
|
|
||||||
for ( var c = 0; c < tile_options.length; c++ ) {
|
for ( var c = 0; c < tileOptions.length; c++ ) {
|
||||||
if ( tile_options[c] <= short_dim ) {
|
if ( tileOptions[c] <= shortDim ) {
|
||||||
smaller_tiles.push(tile_options[c]);
|
smallerTiles.push( tileOptions[c] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( smaller_tiles.length > 0 ) {
|
if ( smallerTiles.length > 0 ) {
|
||||||
options.tileSize = Math.max.apply(null, smaller_tiles);
|
options.tileSize = Math.max.apply( null, smallerTiles );
|
||||||
} else {
|
} else {
|
||||||
// If we're smaller than 256, just use the short side.
|
// If we're smaller than 256, just use the short side.
|
||||||
options.tileSize = short_dim;
|
options.tileSize = shortDim;
|
||||||
}
|
}
|
||||||
this.tile_width = options.tileSize; // So that 'full' gets used for
|
this.tile_width = options.tileSize; // So that 'full' gets used for
|
||||||
this.tile_height = options.tileSize; // the region below
|
this.tile_height = options.tileSize; // the region below
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! options.maxLevel ) {
|
if ( !options.maxLevel ) {
|
||||||
var mf = -1;
|
var mf = -1;
|
||||||
var scfs = this.scale_factors || this.scale_factor;
|
var scfs = this.scale_factors || this.scale_factor;
|
||||||
if ( scfs instanceof Array ) {
|
if ( scfs instanceof Array ) {
|
||||||
@ -96,7 +96,7 @@ $.IIIF1_1TileSource = function( options ){
|
|||||||
if ( !isNaN( cf ) && cf > mf ) { mf = cf; }
|
if ( !isNaN( cf ) && cf > mf ) { mf = cf; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( mf < 0 ) { options.maxLevel = Number(Math.ceil(Math.log(Math.max(this.width, this.height), 2))); }
|
if ( mf < 0 ) { options.maxLevel = Number( Math.ceil( Math.log( Math.max( this.width, this.height ), 2 ) ) ); }
|
||||||
else { options.maxLevel = mf; }
|
else { options.maxLevel = mf; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,34 +157,34 @@ $.extend( $.IIIF1_1TileSource.prototype, $.TileSource.prototype, /** @lends Open
|
|||||||
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
|
||||||
level_width = Math.ceil( this.width * scale ),
|
levelWidth = Math.ceil( this.width * scale ),
|
||||||
level_height = Math.ceil( this.height * scale ),
|
levelHeight = Math.ceil( this.height * scale ),
|
||||||
|
|
||||||
//## iiif region
|
//## iiif region
|
||||||
iiif_tile_size_width = Math.ceil( this.tileSize / scale ),
|
iiifTileSizeWidth = Math.ceil( this.tileSize / scale ),
|
||||||
iiif_tile_size_height = Math.ceil( this.tileSize / scale ),
|
iiifTileSizeHeight = Math.ceil( this.tileSize / scale ),
|
||||||
iiif_region,
|
iiifRegion,
|
||||||
iiif_tile_x,
|
iiifTileX,
|
||||||
iiif_tile_y,
|
iiifTileY,
|
||||||
iiif_tile_w,
|
iiifTileW,
|
||||||
iiif_tile_h,
|
iiifTileH,
|
||||||
iiif_size,
|
iiifSize,
|
||||||
uri;
|
uri;
|
||||||
|
|
||||||
if ( level_width < this.tile_width && level_height < this.tile_height ){
|
if ( levelWidth < this.tile_width && levelHeight < this.tile_height ){
|
||||||
iiif_size = level_width + ",";
|
iiifSize = levelWidth + ",";
|
||||||
iiif_region = 'full';
|
iiifRegion = 'full';
|
||||||
} else {
|
} else {
|
||||||
iiif_tile_x = x * iiif_tile_size_width;
|
iiifTileX = x * iiifTileSizeWidth;
|
||||||
iiif_tile_y = y * iiif_tile_size_height;
|
iiifTileY = y * iiifTileSizeHeight;
|
||||||
iiif_tile_w = Math.min( iiif_tile_size_width, this.width - iiif_tile_x );
|
iiifTileW = Math.min( iiifTileSizeWidth, this.width - iiifTileX );
|
||||||
iiif_tile_h = Math.min( iiif_tile_size_height, this.height - iiif_tile_y );
|
iiifTileH = Math.min( iiifTileSizeHeight, this.height - iiifTileY );
|
||||||
|
|
||||||
iiif_size = Math.ceil(iiif_tile_w * scale) + ",";
|
iiifSize = Math.ceil( iiifTileW * scale ) + ",";
|
||||||
|
|
||||||
iiif_region = [ iiif_tile_x, iiif_tile_y, iiif_tile_w, iiif_tile_h ].join(',');
|
iiifRegion = [ iiifTileX, iiifTileY, iiifTileW, iiifTileH ].join( ',' );
|
||||||
}
|
}
|
||||||
uri = [ this['@id'], iiif_region, iiif_size, IIIF_ROTATION, IIIF_QUALITY ].join('/');
|
uri = [ this['@id'], iiifRegion, iiifSize, IIIF_ROTATION, IIIF_QUALITY ].join( '/' );
|
||||||
return uri;
|
return uri;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user