Rename _ol_source_Zoomify_ to Zoomify

This commit is contained in:
Tim Schaub
2018-01-08 16:07:55 -07:00
parent 2440d52ebe
commit 3e127a6169
3 changed files with 35 additions and 35 deletions

View File

@@ -1,7 +1,7 @@
import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js';
import TileLayer from '../src/ol/layer/Tile.js';
import _ol_source_Zoomify_ from '../src/ol/source/Zoomify.js';
import Zoomify from '../src/ol/source/Zoomify.js';
var imgWidth = 9911;
var imgHeight = 6100;
@@ -11,7 +11,7 @@ var zoomifyUrl = 'http://vips.vtech.fr/cgi-bin/iipsrv.fcgi?zoomify=' +
var iipUrl = 'http://vips.vtech.fr/cgi-bin/iipsrv.fcgi?FIF=' + '/mnt/MD1/AD00/plan_CHU-4HD-01/FOND.TIF' + '&JTL={z},{tileIndex}';
var layer = new TileLayer({
source: new _ol_source_Zoomify_({
source: new Zoomify({
url: zoomifyUrl,
size: [imgWidth, imgHeight],
crossOrigin: 'anonymous'
@@ -36,13 +36,13 @@ var control = document.getElementById('zoomifyProtocol');
control.addEventListener('change', function(event) {
var value = event.currentTarget.value;
if (value === 'iip') {
layer.setSource(new _ol_source_Zoomify_({
layer.setSource(new Zoomify({
url: iipUrl,
size: [imgWidth, imgHeight],
crossOrigin: 'anonymous'
}));
} else if (value === 'zoomify') {
layer.setSource(new _ol_source_Zoomify_({
layer.setSource(new Zoomify({
url: zoomifyUrl,
size: [imgWidth, imgHeight],
crossOrigin: 'anonymous'

View File

@@ -23,14 +23,14 @@ import TileGrid from '../tilegrid/TileGrid.js';
* @param {olx.source.ZoomifyOptions=} opt_options Options.
* @api
*/
var _ol_source_Zoomify_ = function(opt_options) {
var Zoomify = function(opt_options) {
var options = opt_options || {};
var size = options.size;
var tierSizeCalculation = options.tierSizeCalculation !== undefined ?
options.tierSizeCalculation :
_ol_source_Zoomify_.TierSizeCalculation_.DEFAULT;
Zoomify.TierSizeCalculation_.DEFAULT;
var imageWidth = size[0];
var imageHeight = size[1];
@@ -40,7 +40,7 @@ var _ol_source_Zoomify_ = function(opt_options) {
var tileSizeForTierSizeCalculation = tileSize;
switch (tierSizeCalculation) {
case _ol_source_Zoomify_.TierSizeCalculation_.DEFAULT:
case Zoomify.TierSizeCalculation_.DEFAULT:
while (imageWidth > tileSizeForTierSizeCalculation || imageHeight > tileSizeForTierSizeCalculation) {
tierSizeInTiles.push([
Math.ceil(imageWidth / tileSizeForTierSizeCalculation),
@@ -49,7 +49,7 @@ var _ol_source_Zoomify_ = function(opt_options) {
tileSizeForTierSizeCalculation += tileSizeForTierSizeCalculation;
}
break;
case _ol_source_Zoomify_.TierSizeCalculation_.TRUNCATED:
case Zoomify.TierSizeCalculation_.TRUNCATED:
var width = imageWidth;
var height = imageHeight;
while (width > tileSizeForTierSizeCalculation || height > tileSizeForTierSizeCalculation) {
@@ -135,7 +135,7 @@ var _ol_source_Zoomify_ = function(opt_options) {
var tileUrlFunction = createFromTileUrlFunctions(urls.map(createFromTemplate));
var ZoomifyTileClass = _ol_source_Zoomify_.Tile_.bind(null, tileGrid);
var ZoomifyTileClass = Zoomify.Tile_.bind(null, tileGrid);
TileImage.call(this, {
attributions: options.attributions,
@@ -151,7 +151,7 @@ var _ol_source_Zoomify_ = function(opt_options) {
};
inherits(_ol_source_Zoomify_, TileImage);
inherits(Zoomify, TileImage);
/**
* @constructor
@@ -165,7 +165,7 @@ inherits(_ol_source_Zoomify_, TileImage);
* @param {olx.TileOptions=} opt_options Tile options.
* @private
*/
_ol_source_Zoomify_.Tile_ = function(
Zoomify.Tile_ = function(
tileGrid, tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options) {
ImageTile.call(this, tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options);
@@ -182,13 +182,13 @@ _ol_source_Zoomify_.Tile_ = function(
*/
this.tileSize_ = _ol_size_.toSize(tileGrid.getTileSize(tileCoord[0]));
};
inherits(_ol_source_Zoomify_.Tile_, ImageTile);
inherits(Zoomify.Tile_, ImageTile);
/**
* @inheritDoc
*/
_ol_source_Zoomify_.Tile_.prototype.getImage = function() {
Zoomify.Tile_.prototype.getImage = function() {
if (this.zoomifyImage_) {
return this.zoomifyImage_;
}
@@ -213,8 +213,8 @@ _ol_source_Zoomify_.Tile_.prototype.getImage = function() {
* @enum {string}
* @private
*/
_ol_source_Zoomify_.TierSizeCalculation_ = {
Zoomify.TierSizeCalculation_ = {
DEFAULT: 'default',
TRUNCATED: 'truncated'
};
export default _ol_source_Zoomify_;
export default Zoomify;

View File

@@ -1,7 +1,7 @@
import {DEFAULT_TILE_SIZE} from '../../../../src/ol/tilegrid/common.js';
import _ol_events_ from '../../../../src/ol/events.js';
import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js';
import _ol_source_Zoomify_ from '../../../../src/ol/source/Zoomify.js';
import Zoomify from '../../../../src/ol/source/Zoomify.js';
import TileGrid from '../../../../src/ol/tilegrid/TileGrid.js';
@@ -17,26 +17,26 @@ describe('ol.source.Zoomify', function() {
extent: [0, 0, w, h]
});
function getZoomifySource() {
return new _ol_source_Zoomify_({
return new Zoomify({
url: zoomifyUrl,
size: size
});
}
function getZoomifySourceWithExtentInFirstQuadrant() {
return new _ol_source_Zoomify_({
return new Zoomify({
url: zoomifyUrl,
size: size,
extent: [0, 0, size[0], size[1]]
});
}
function getIIPSource() {
return new _ol_source_Zoomify_({
return new Zoomify({
url: iipUrl,
size: size
});
}
function getZoomifySourceWith1024pxTiles() {
return new _ol_source_Zoomify_({
return new Zoomify({
url: zoomifyUrl,
size: size,
tileSize: 1024
@@ -50,29 +50,29 @@ describe('ol.source.Zoomify', function() {
// undefined config object
expect(function() {
source = new _ol_source_Zoomify_();
source = new Zoomify();
}).to.throwException();
// empty object as config object
expect(function() {
source = new _ol_source_Zoomify_({});
source = new Zoomify({});
}).to.throwException();
// not passing "size" in config object
expect(function() {
source = new _ol_source_Zoomify_({
source = new Zoomify({
url: 'some-url'
});
}).to.throwException();
// passing "size" in config object
expect(function() {
source = new _ol_source_Zoomify_({
source = new Zoomify({
size: [47, 11]
});
}).to.not.throwException();
// we got a source
expect(source).to.be.a(_ol_source_Zoomify_);
expect(source).to.be.a(Zoomify);
// also test our helper methods from above
expect(function() {
@@ -82,12 +82,12 @@ describe('ol.source.Zoomify', function() {
source = getIIPSource();
}).to.not.throwException();
// we got a source
expect(source).to.be.a(_ol_source_Zoomify_);
expect(source).to.be.a(Zoomify);
});
it('does not need "tierSizeCalculation" option', function() {
expect(function() {
new _ol_source_Zoomify_({
new Zoomify({
size: [47, 11]
});
}).to.not.throwException();
@@ -95,7 +95,7 @@ describe('ol.source.Zoomify', function() {
it('accepts "tierSizeCalculation" option "default"', function() {
expect(function() {
new _ol_source_Zoomify_({
new Zoomify({
size: [47, 11],
tierSizeCalculation: 'default'
});
@@ -104,7 +104,7 @@ describe('ol.source.Zoomify', function() {
it('accepts "tierSizeCalculation" option "truncated"', function() {
expect(function() {
new _ol_source_Zoomify_({
new Zoomify({
size: [47, 11],
tierSizeCalculation: 'truncated'
});
@@ -114,7 +114,7 @@ describe('ol.source.Zoomify', function() {
it('throws on unexpected "tierSizeCalculation" ', function() {
// passing unknown string will throw
expect(function() {
new _ol_source_Zoomify_({
new Zoomify({
size: [47, 11],
tierSizeCalculation: 'ace-of-spades'
});
@@ -199,14 +199,14 @@ describe('ol.source.Zoomify', function() {
it('influences resolutions', function() {
// not configured at all
var source = new _ol_source_Zoomify_({
var source = new Zoomify({
url: zoomifyUrl,
size: [513, 256]
});
var tileGrid = source.getTileGrid();
// explicitly set as 'default'
var sourceDefault = new _ol_source_Zoomify_({
var sourceDefault = new Zoomify({
url: zoomifyUrl,
size: [513, 256],
tierSizeCalculation: 'default'
@@ -214,7 +214,7 @@ describe('ol.source.Zoomify', function() {
var tileGridDefault = sourceDefault.getTileGrid();
// explicitly set to 'truncated'
var sourceTruncated = new _ol_source_Zoomify_({
var sourceTruncated = new Zoomify({
url: zoomifyUrl,
size: [513, 256],
tierSizeCalculation: 'truncated'
@@ -254,7 +254,7 @@ describe('ol.source.Zoomify', function() {
});
it('creates an expected tileUrlFunction without template', function() {
var source = new _ol_source_Zoomify_({
var source = new Zoomify({
url: 'spec/ol/source/images/zoomify/',
size: size
});
@@ -280,7 +280,7 @@ describe('ol.source.Zoomify', function() {
it('returns expected tileClass instances via "getTile"', function() {
var source = getZoomifySource();
var tile = source.getTile(0, 0, -1, 1, proj);
expect(tile).to.be.an(_ol_source_Zoomify_.Tile_);
expect(tile).to.be.an(Zoomify.Tile_);
});
it('"tile.getImage" returns and caches an unloaded image', function() {