mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 22:56:11 +03:00
supports IIIF 1.1 syntax
This commit is contained in:
parent
890ec0c848
commit
1a52656ed6
@ -32,18 +32,11 @@
|
||||
* 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( $ ){
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @class
|
||||
@ -58,11 +51,6 @@ $.IIIF11TileSource = function( options ){
|
||||
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;
|
||||
|
||||
if (! options.maxLevel ) {
|
||||
@ -104,39 +92,27 @@ $.extend( $.IIIF11TileSource.prototype, $.TileSource.prototype, {
|
||||
*
|
||||
* @function
|
||||
* @name OpenSeadragon.IIIF11TileSource.prototype.configure
|
||||
* @param {Object|XMLDocument} 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.
|
||||
* @param {Object} data - the raw configuration
|
||||
*/
|
||||
configure: function( data, url ){
|
||||
// var service,
|
||||
// options,
|
||||
// host;
|
||||
|
||||
|
||||
// options = configureFromObject( this, data );
|
||||
|
||||
// if( url && !options.tilesUrl ){
|
||||
// service = url.split('/');
|
||||
// service.pop(); //info.json
|
||||
// service = service.join('/');
|
||||
// if( 'http' !== url.substring( 0, 4 ) ){
|
||||
// host = location.protocol + '//' + location.host;
|
||||
// service = host + service;
|
||||
// }
|
||||
// options.tilesUrl = service.replace(
|
||||
// data.identifier,
|
||||
// ''
|
||||
// );
|
||||
// }
|
||||
|
||||
return configureFromObject( this, data );
|
||||
// IIIF 1.1 Info Looks like this (XML syntax is no more):
|
||||
// {
|
||||
// "@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"
|
||||
// }
|
||||
configure: function( data ){
|
||||
return data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @name OpenSeadragon.IIIF11TileSource.prototype.getTileUrl
|
||||
* @param {Number} level - z index
|
||||
@ -157,15 +133,6 @@ $.extend( $.IIIF11TileSource.prototype, $.TileSource.prototype, {
|
||||
level_width = Math.ceil( this.width * 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_tile_size_width = 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_y,
|
||||
iiif_tile_w,
|
||||
iiif_tile_h;
|
||||
|
||||
|
||||
iiif_tile_h,
|
||||
iiif_size,
|
||||
uri;
|
||||
|
||||
if ( level_width < this.tile_width && level_height < this.tile_height ){
|
||||
iiif_size = level_width + "," + level_height;
|
||||
iiif_region = 'full';
|
||||
} else {
|
||||
iiif_tile_x = x * iiif_tile_size_width;
|
||||
iiif_tile_y = y * iiif_tile_size_height;
|
||||
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_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(',');
|
||||
}
|
||||
|
||||
return [
|
||||
this['@id'],
|
||||
iiif_region,
|
||||
iiif_size,
|
||||
IIIF_ROTATION,
|
||||
IIIF_QUALITY
|
||||
].join('/');
|
||||
uri = [ this['@id'], iiif_region, iiif_size, IIIF_ROTATION, IIIF_QUALITY ].join('/');
|
||||
return uri;
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @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 ));
|
||||
|
Loading…
Reference in New Issue
Block a user