mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-26 07:06:10 +03:00
supports IIIF 1.1 syntax
This commit is contained in:
parent
4b4325c5ff
commit
5665ac82a1
@ -32,18 +32,11 @@
|
|||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
* The getTileUrl implementation is based on Jon Stroop's Python version,
|
|
||||||
* which is released under the New BSD license:
|
|
||||||
* https://gist.github.com/jpstroop/4624253
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
(function( $ ){
|
(function( $ ){
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A client implementation of the International Image Interoperability
|
* A client implementation of the International Image Interoperability
|
||||||
* Format: Image API Draft 0.2 - Please read more about the specification
|
* Format: Image API 1.1 - Please read more about the specification
|
||||||
* at
|
* at
|
||||||
*
|
*
|
||||||
* @class
|
* @class
|
||||||
@ -58,11 +51,6 @@ $.IIIF11TileSource = function( options ){
|
|||||||
throw new Error('IIIF required parameters not provided.');
|
throw new Error('IIIF required parameters not provided.');
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: at this point the base tile source implementation assumes
|
|
||||||
// a tile is a square and so only has one property tileSize
|
|
||||||
// to store it. It may be possible to make tileSize a vector
|
|
||||||
// OpenSeadraon.Point but would require careful implementation
|
|
||||||
// to preserve backward compatibility.
|
|
||||||
options.tileSize = this.tile_width;
|
options.tileSize = this.tile_width;
|
||||||
|
|
||||||
if (! options.maxLevel ) {
|
if (! options.maxLevel ) {
|
||||||
@ -104,39 +92,27 @@ $.extend( $.IIIF11TileSource.prototype, $.TileSource.prototype, {
|
|||||||
*
|
*
|
||||||
* @function
|
* @function
|
||||||
* @name OpenSeadragon.IIIF11TileSource.prototype.configure
|
* @name OpenSeadragon.IIIF11TileSource.prototype.configure
|
||||||
* @param {Object|XMLDocument} data - the raw configuration
|
* @param {Object} data - the raw configuration
|
||||||
* @param {String} url - the url the data was retreived from if any.
|
|
||||||
* @return {Object} options - A dictionary of keyword arguments sufficient
|
|
||||||
* to configure this tile source via it's constructor.
|
|
||||||
*/
|
*/
|
||||||
configure: function( data, url ){
|
// IIIF 1.1 Info Looks like this (XML syntax is no more):
|
||||||
// var service,
|
// {
|
||||||
// options,
|
// "@context" : "http://library.stanford.edu/iiif/image-api/1.1/context.json",
|
||||||
// host;
|
// "@id" : "http://iiif.example.com/prefix/1E34750D-38DB-4825-A38A-B60A345E591C",
|
||||||
|
// "width" : 6000,
|
||||||
|
// "height" : 4000,
|
||||||
// options = configureFromObject( this, data );
|
// "scale_factors" : [ 1, 2, 4 ],
|
||||||
|
// "tile_width" : 1024,
|
||||||
// if( url && !options.tilesUrl ){
|
// "tile_height" : 1024,
|
||||||
// service = url.split('/');
|
// "formats" : [ "jpg", "png" ],
|
||||||
// service.pop(); //info.json
|
// "qualities" : [ "native", "grey" ]
|
||||||
// service = service.join('/');
|
// "profile" : "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0"
|
||||||
// if( 'http' !== url.substring( 0, 4 ) ){
|
|
||||||
// host = location.protocol + '//' + location.host;
|
|
||||||
// service = host + service;
|
|
||||||
// }
|
// }
|
||||||
// options.tilesUrl = service.replace(
|
configure: function( data ){
|
||||||
// data.identifier,
|
return data;
|
||||||
// ''
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
return configureFromObject( this, data );
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Responsible for retreiving the url which will return an image for the
|
* Responsible for retreiving the url which will return an image for the
|
||||||
* region speified by the given x, y, and level components.
|
* region specified by the given x, y, and level components.
|
||||||
* @function
|
* @function
|
||||||
* @name OpenSeadragon.IIIF11TileSource.prototype.getTileUrl
|
* @name OpenSeadragon.IIIF11TileSource.prototype.getTileUrl
|
||||||
* @param {Number} level - z index
|
* @param {Number} level - z index
|
||||||
@ -157,15 +133,6 @@ $.extend( $.IIIF11TileSource.prototype, $.TileSource.prototype, {
|
|||||||
level_width = Math.ceil( this.width * scale ),
|
level_width = Math.ceil( this.width * scale ),
|
||||||
level_height = Math.ceil( this.height * scale ),
|
level_height = Math.ceil( this.height * scale ),
|
||||||
|
|
||||||
//## get iiif size
|
|
||||||
// Note that this uses pixels rather than percents (as in
|
|
||||||
// IIIF11TileSource), which will be more precise (i.e. the 'right
|
|
||||||
// 50% of 11px' case') and easier to pre-bake without worring about
|
|
||||||
// different browsers' decimal precision (if desired).
|
|
||||||
|
|
||||||
// iiif_size = level_width + "," + level_height,
|
|
||||||
iiif_size = this.tileSize + "," + this.tileSize,
|
|
||||||
|
|
||||||
//## iiif region
|
//## iiif region
|
||||||
iiif_tile_size_width = Math.ceil( this.tileSize / scale ),
|
iiif_tile_size_width = Math.ceil( this.tileSize / scale ),
|
||||||
iiif_tile_size_height = Math.ceil( this.tileSize / scale ),
|
iiif_tile_size_height = Math.ceil( this.tileSize / scale ),
|
||||||
@ -173,54 +140,24 @@ $.extend( $.IIIF11TileSource.prototype, $.TileSource.prototype, {
|
|||||||
iiif_tile_x,
|
iiif_tile_x,
|
||||||
iiif_tile_y,
|
iiif_tile_y,
|
||||||
iiif_tile_w,
|
iiif_tile_w,
|
||||||
iiif_tile_h;
|
iiif_tile_h,
|
||||||
|
iiif_size,
|
||||||
|
uri;
|
||||||
|
|
||||||
if ( level_width < this.tile_width && level_height < this.tile_height ){
|
if ( level_width < this.tile_width && level_height < this.tile_height ){
|
||||||
|
iiif_size = level_width + "," + level_height;
|
||||||
iiif_region = 'full';
|
iiif_region = 'full';
|
||||||
} else {
|
} else {
|
||||||
iiif_tile_x = x * iiif_tile_size_width;
|
iiif_tile_x = x * iiif_tile_size_width;
|
||||||
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);
|
||||||
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('/');
|
||||||
return [
|
return uri;
|
||||||
this['@id'],
|
|
||||||
iiif_region,
|
|
||||||
iiif_size,
|
|
||||||
IIIF_ROTATION,
|
|
||||||
IIIF_QUALITY
|
|
||||||
].join('/');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @inner
|
|
||||||
* @function
|
|
||||||
*
|
|
||||||
{
|
|
||||||
"@context" : "http://library.stanford.edu/iiif/image-api/1.1/context.json",
|
|
||||||
"@id" : "http://iiif.example.com/prefix/1E34750D-38DB-4825-A38A-B60A345E591C",
|
|
||||||
"width" : 6000,
|
|
||||||
"height" : 4000,
|
|
||||||
"scale_factors" : [ 1, 2, 4 ],
|
|
||||||
"tile_width" : 1024,
|
|
||||||
"tile_height" : 1024,
|
|
||||||
"formats" : [ "jpg", "png" ],
|
|
||||||
"qualities" : [ "native", "grey" ]
|
|
||||||
"profile" : "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0"
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
function configureFromObject( tileSource, configuration ){
|
|
||||||
configuration.tilesUrl = configuration["@id"];
|
|
||||||
return configuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
}( OpenSeadragon ));
|
}( OpenSeadragon ));
|
||||||
|
Loading…
Reference in New Issue
Block a user