mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-02-16 23:03:13 +03:00
support iiif level 1
This commit is contained in:
parent
efaced5446
commit
e9c2b502c1
@ -45,22 +45,44 @@
|
|||||||
*/
|
*/
|
||||||
$.IIIF1_1TileSource = function( options ){
|
$.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.tile_width && this.tile_height) ) {
|
if( (this.profile &&
|
||||||
// use the short dimension if there aren't tile sizes provided.
|
this.profile == "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0" ) ){
|
||||||
options.tileSize = Math.min(this.height, this.width);
|
// what if not reporting a profile?
|
||||||
} else {
|
throw new Error('IIIF Image API 1.1 compliance level 1 or greater is required.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.tile_width) {
|
||||||
options.tileSize = this.tile_width;
|
options.tileSize = this.tile_width;
|
||||||
|
} else if (this.tile_height) {
|
||||||
|
options.tileSize = this.tile_height;
|
||||||
|
} else {
|
||||||
|
// use the largest of tile_options that is smaller than the short
|
||||||
|
// dimension
|
||||||
|
|
||||||
|
var short_dim = Math.min(this.height, this.width),
|
||||||
|
tile_options = [128,256,512,1024],
|
||||||
|
smaller_tiles = [];
|
||||||
|
|
||||||
|
for ( var c = 0; c < tile_options.length; c++ ) {
|
||||||
|
if ( tile_options[c] <= short_dim ) {
|
||||||
|
smaller_tiles.push(tile_options[c]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
options.tileSize = Math.max.apply(null, smaller_tiles);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 ) {
|
||||||
for ( var i = 0; i < scfs.length; i++ ) {
|
for ( var i = 0; i < scfs.length; i++ ) {
|
||||||
var cf = Number( scfs[i] );
|
var cf = Number( scfs[i] );
|
||||||
@ -82,13 +104,9 @@ $.extend( $.IIIF1_1TileSource.prototype, $.TileSource.prototype, /** @lends Open
|
|||||||
* @param {Object|Array} data
|
* @param {Object|Array} data
|
||||||
* @param {String} optional - url
|
* @param {String} optional - url
|
||||||
*/
|
*/
|
||||||
supports: function( data, url ){
|
supports: function( data, url ) {
|
||||||
return data.profile && (
|
return ( data['@context'] &&
|
||||||
"http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0" == data.profile ||
|
data['@context'] == "http://library.stanford.edu/iiif/image-api/1.1/context.json" );
|
||||||
"http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level1" == data.profile ||
|
|
||||||
"http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2" == data.profile ||
|
|
||||||
"http://library.stanford.edu/iiif/image-api/1.1/compliance.html" == data.profile
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -124,6 +142,7 @@ $.extend( $.IIIF1_1TileSource.prototype, $.TileSource.prototype, /** @lends Open
|
|||||||
getTileUrl: function( level, x, y ){
|
getTileUrl: function( level, x, y ){
|
||||||
|
|
||||||
//# constants
|
//# constants
|
||||||
|
|
||||||
var IIIF_ROTATION = '0',
|
var IIIF_ROTATION = '0',
|
||||||
IIIF_QUALITY = 'native.jpg',
|
IIIF_QUALITY = 'native.jpg',
|
||||||
|
|
||||||
@ -153,7 +172,14 @@ $.extend( $.IIIF1_1TileSource.prototype, $.TileSource.prototype, /** @lends Open
|
|||||||
iiif_tile_y = y * iiif_tile_size_height;
|
iiif_tile_y = y * iiif_tile_size_height;
|
||||||
iiif_tile_w = Math.min( iiif_tile_size_width, this.width - iiif_tile_x );
|
iiif_tile_w = Math.min( iiif_tile_size_width, this.width - iiif_tile_x );
|
||||||
iiif_tile_h = Math.min( iiif_tile_size_height, this.height - iiif_tile_y );
|
iiif_tile_h = Math.min( iiif_tile_size_height, this.height - iiif_tile_y );
|
||||||
iiif_size = Math.ceil(iiif_tile_w * scale) + "," + Math.ceil(iiif_tile_h * scale);
|
|
||||||
|
if( (this.profile &&
|
||||||
|
this.profile == "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level1" ) ){
|
||||||
|
iiif_size = Math.ceil(iiif_tile_w * scale) + ",";
|
||||||
|
} else {
|
||||||
|
iiif_size = Math.ceil(iiif_tile_w * scale) + "," + Math.ceil(iiif_tile_h * scale);
|
||||||
|
}
|
||||||
|
|
||||||
iiif_region = [ iiif_tile_x, iiif_tile_y, iiif_tile_w, iiif_tile_h ].join(',');
|
iiif_region = [ iiif_tile_x, iiif_tile_y, iiif_tile_w, iiif_tile_h ].join(',');
|
||||||
}
|
}
|
||||||
uri = [ this['@id'], iiif_region, iiif_size, IIIF_ROTATION, IIIF_QUALITY ].join('/');
|
uri = [ this['@id'], iiif_region, iiif_size, IIIF_ROTATION, IIIF_QUALITY ].join('/');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user