src/iiiftilesource.js
function( level, x, y ){

        if(this.emulateLegacyImagePyramid) {
            var url = null;
            if ( this.levels.length > 0 && level >= this.minLevel && level <= this.maxLevel ) {
                url = this.levels[ level ].url;
            }
            return url;
        }

        //# constants
        var IIIF_ROTATION = '0',
            //## get the scale (level as a decimal)
            scale = Math.pow( 0.5, this.maxLevel - level ),

            //# image dimensions at this level
            levelWidth = Math.ceil( this.width * scale ),
            levelHeight = Math.ceil( this.height * scale ),

            //## iiif region
            tileWidth,
            tileHeight,
            iiifTileSizeWidth,
            iiifTileSizeHeight,
            iiifRegion,
            iiifTileX,
            iiifTileY,
            iiifTileW,
            iiifTileH,
            iiifSize,
            iiifSizeW,
            iiifQuality,
            uri,
            isv1;

        tileWidth = this.getTileWidth(level);
        tileHeight = this.getTileHeight(level);
        iiifTileSizeWidth = Math.ceil( tileWidth / scale );
        iiifTileSizeHeight = Math.ceil( tileHeight / scale );
        isv1 = ( this['@context'].indexOf('/1.0/context.json') > -1 ||
             this['@context'].indexOf('/1.1/context.json') > -1 ||
             this['@context'].indexOf('/1/context.json') > -1 );
        if (isv1) {
            iiifQuality = "native." + this.tileFormat;
        } else {
            iiifQuality = "default." + this.tileFormat;
        }
        if ( levelWidth < tileWidth && levelHeight < tileHeight ){
            if ( isv1 || levelWidth !== this.width ) {
                iiifSize = levelWidth + ",";
            } else {
                iiifSize = "max";
            }
            iiifRegion = 'full';
        } else {
            iiifTileX = x * iiifTileSizeWidth;
            iiifTileY = y * iiifTileSizeHeight;
            iiifTileW = Math.min( iiifTileSizeWidth, this.width - iiifTileX );
            iiifTileH = Math.min( iiifTileSizeHeight, this.height - iiifTileY );
            if ( x === 0 && y === 0 && iiifTileW === this.width && iiifTileH === this.height ) {
                iiifRegion = "full";
            } else {
                iiifRegion = [ iiifTileX, iiifTileY, iiifTileW, iiifTileH ].join( ',' );
            }
            iiifSizeW = Math.ceil( iiifTileW * scale );
            if ( (!isv1) && iiifSizeW === this.width ) {
                iiifSize = "max";
            } else {
                iiifSize = iiifSizeW + ",";
            }
        }
        uri = [ this['@id'], iiifRegion, iiifSize, IIIF_ROTATION, iiifQuality ].join( '/' );

        return uri;
    }
function( level, x, y ){

        if(this.emulateLegacyImagePyramid) {
            var url = null;
            if ( this.levels.length > 0 && level >= this.minLevel && level <= this.maxLevel ) {
                url = this.levels[ level ].url;
            }
            return url;
        }

        //# constants
        var IIIF_ROTATION = '0',
            //## get the scale (level as a decimal)
            scale = Math.pow( 0.5, this.maxLevel - level ),

            //# image dimensions at this level
            levelWidth = Math.ceil( this.width * scale ),
            levelHeight = Math.ceil( this.height * scale ),

            //## iiif region
            tileWidth,
            tileHeight,
            iiifTileSizeWidth,
            iiifTileSizeHeight,
            iiifRegion,
            iiifTileX,
            iiifTileY,
            iiifTileW,
            iiifTileH,
            iiifSize,
            iiifSizeW,
            iiifQuality,
            uri,
            isv1;

        tileWidth = this.getTileWidth(level);
        tileHeight = this.getTileHeight(level);
        iiifTileSizeWidth = Math.ceil( tileWidth / scale );
        iiifTileSizeHeight = Math.ceil( tileHeight / scale );
        isv1 = ( this['@context'].indexOf('/1.0/context.json') > -1 ||
             this['@context'].indexOf('/1.1/context.json') > -1 ||
             this['@context'].indexOf('/1/context.json') > -1 );
        if (isv1) {
            iiifQuality = "native." + this.tileFormat;
        } else {
            iiifQuality = "default." + this.tileFormat;
        }
        if ( levelWidth < tileWidth && levelHeight < tileHeight ){
            if ( isv1 || levelWidth !== this.width ) {
                iiifSize = levelWidth + ",";
            } else {
                iiifSize = "max";
            }
            iiifRegion = 'full';
        } else {
            iiifTileX = x * iiifTileSizeWidth;
            iiifTileY = y * iiifTileSizeHeight;
            iiifTileW = Math.min( iiifTileSizeWidth, this.width - iiifTileX );
            iiifTileH = Math.min( iiifTileSizeHeight, this.height - iiifTileY );
            if ( x === 0 && y === 0 && iiifTileW === this.width && iiifTileH === this.height ) {
                iiifRegion = "full";
            } else {
                iiifRegion = [ iiifTileX, iiifTileY, iiifTileW, iiifTileH ].join( ',' );
            }
            iiifSizeW = Math.ceil( iiifTileW * scale );
            if ( (!isv1) && iiifSizeW === this.width ) {
                iiifSize = "max";
            } else {
                iiifSize = iiifSizeW + ",";
            }
        }
        uri = [ this['@id'], iiifRegion, iiifSize, IIIF_ROTATION, iiifQuality ].join( '/' );

        return uri;
    }
function ( level , x , y ) { if ( this . emulateLegacyImagePyramid ) { var url = null ; if ( this . levels . length > 0 && level >= this . minLevel && level <= this . maxLevel ) { url = this . levels [ level ] . url ; } return url ; } //# constants var IIIF_ROTATION = '0' , //## get the scale (level as a decimal) scale = Math . pow ( 0.5 , this . maxLevel - level ) , //# image dimensions at this level levelWidth = Math . ceil ( this . width * scale ) , levelHeight = Math . ceil ( this . height * scale ) , //## iiif region tileWidth , tileHeight , iiifTileSizeWidth , iiifTileSizeHeight , iiifRegion , iiifTileX , iiifTileY , iiifTileW , iiifTileH , iiifSize , iiifSizeW , iiifQuality , uri , isv1 ; tileWidth = this . getTileWidth ( level ) ; tileHeight = this . getTileHeight ( level ) ; iiifTileSizeWidth = Math . ceil ( tileWidth / scale ) ; iiifTileSizeHeight = Math . ceil ( tileHeight / scale ) ; isv1 = ( this [ '@context' ] . indexOf ( '/1.0/context.json' ) > - 1 || this [ '@context' ] . indexOf ( '/1.1/context.json' ) > - 1 || this [ '@context' ] . indexOf ( '/1/context.json' ) > - 1 ) ; if ( isv1 ) { iiifQuality = "native." + this . tileFormat ; } else { iiifQuality = "default." + this . tileFormat ; } if ( levelWidth < tileWidth && levelHeight < tileHeight ) { if ( isv1 || levelWidth !== this . width ) { iiifSize = levelWidth + "," ; } else { iiifSize = "max" ; } iiifRegion = 'full' ; } else { iiifTileX = x * iiifTileSizeWidth ; iiifTileY = y * iiifTileSizeHeight ; iiifTileW = Math . min ( iiifTileSizeWidth , this . width - iiifTileX ) ; iiifTileH = Math . min ( iiifTileSizeHeight , this . height - iiifTileY ) ; if ( x === 0 && y === 0 && iiifTileW === this . width && iiifTileH === this . height ) { iiifRegion = "full" ; } else { iiifRegion = [ iiifTileX , iiifTileY , iiifTileW , iiifTileH ] . join ( ',' ) ; } iiifSizeW = Math . ceil ( iiifTileW * scale ) ; if ( ( ! isv1 ) && iiifSizeW === this . width ) { iiifSize = "max" ; } else { iiifSize = iiifSizeW + "," ; } } uri = [ this [ '@id' ] , iiifRegion , iiifSize , IIIF_ROTATION , iiifQuality ] . join ( '/' ) ; return uri ; }
Responsible for retrieving the url which will return an image for the
region specified by the given x, y, and level components.
@function
@param {Number} level - z index
@param {Number} x
@param {Number} y
@throws {Error}
Responsible for retrieving the url which will return an image for the region specified by the given x y and level components .