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
+4 -4
View File
@@ -1,7 +1,7 @@
import Map from '../src/ol/Map.js'; import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js'; import View from '../src/ol/View.js';
import TileLayer from '../src/ol/layer/Tile.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 imgWidth = 9911;
var imgHeight = 6100; 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 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({ var layer = new TileLayer({
source: new _ol_source_Zoomify_({ source: new Zoomify({
url: zoomifyUrl, url: zoomifyUrl,
size: [imgWidth, imgHeight], size: [imgWidth, imgHeight],
crossOrigin: 'anonymous' crossOrigin: 'anonymous'
@@ -36,13 +36,13 @@ var control = document.getElementById('zoomifyProtocol');
control.addEventListener('change', function(event) { control.addEventListener('change', function(event) {
var value = event.currentTarget.value; var value = event.currentTarget.value;
if (value === 'iip') { if (value === 'iip') {
layer.setSource(new _ol_source_Zoomify_({ layer.setSource(new Zoomify({
url: iipUrl, url: iipUrl,
size: [imgWidth, imgHeight], size: [imgWidth, imgHeight],
crossOrigin: 'anonymous' crossOrigin: 'anonymous'
})); }));
} else if (value === 'zoomify') { } else if (value === 'zoomify') {
layer.setSource(new _ol_source_Zoomify_({ layer.setSource(new Zoomify({
url: zoomifyUrl, url: zoomifyUrl,
size: [imgWidth, imgHeight], size: [imgWidth, imgHeight],
crossOrigin: 'anonymous' crossOrigin: 'anonymous'
+11 -11
View File
@@ -23,14 +23,14 @@ import TileGrid from '../tilegrid/TileGrid.js';
* @param {olx.source.ZoomifyOptions=} opt_options Options. * @param {olx.source.ZoomifyOptions=} opt_options Options.
* @api * @api
*/ */
var _ol_source_Zoomify_ = function(opt_options) { var Zoomify = function(opt_options) {
var options = opt_options || {}; var options = opt_options || {};
var size = options.size; var size = options.size;
var tierSizeCalculation = options.tierSizeCalculation !== undefined ? var tierSizeCalculation = options.tierSizeCalculation !== undefined ?
options.tierSizeCalculation : options.tierSizeCalculation :
_ol_source_Zoomify_.TierSizeCalculation_.DEFAULT; Zoomify.TierSizeCalculation_.DEFAULT;
var imageWidth = size[0]; var imageWidth = size[0];
var imageHeight = size[1]; var imageHeight = size[1];
@@ -40,7 +40,7 @@ var _ol_source_Zoomify_ = function(opt_options) {
var tileSizeForTierSizeCalculation = tileSize; var tileSizeForTierSizeCalculation = tileSize;
switch (tierSizeCalculation) { switch (tierSizeCalculation) {
case _ol_source_Zoomify_.TierSizeCalculation_.DEFAULT: case Zoomify.TierSizeCalculation_.DEFAULT:
while (imageWidth > tileSizeForTierSizeCalculation || imageHeight > tileSizeForTierSizeCalculation) { while (imageWidth > tileSizeForTierSizeCalculation || imageHeight > tileSizeForTierSizeCalculation) {
tierSizeInTiles.push([ tierSizeInTiles.push([
Math.ceil(imageWidth / tileSizeForTierSizeCalculation), Math.ceil(imageWidth / tileSizeForTierSizeCalculation),
@@ -49,7 +49,7 @@ var _ol_source_Zoomify_ = function(opt_options) {
tileSizeForTierSizeCalculation += tileSizeForTierSizeCalculation; tileSizeForTierSizeCalculation += tileSizeForTierSizeCalculation;
} }
break; break;
case _ol_source_Zoomify_.TierSizeCalculation_.TRUNCATED: case Zoomify.TierSizeCalculation_.TRUNCATED:
var width = imageWidth; var width = imageWidth;
var height = imageHeight; var height = imageHeight;
while (width > tileSizeForTierSizeCalculation || height > tileSizeForTierSizeCalculation) { while (width > tileSizeForTierSizeCalculation || height > tileSizeForTierSizeCalculation) {
@@ -135,7 +135,7 @@ var _ol_source_Zoomify_ = function(opt_options) {
var tileUrlFunction = createFromTileUrlFunctions(urls.map(createFromTemplate)); 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, { TileImage.call(this, {
attributions: options.attributions, attributions: options.attributions,
@@ -151,7 +151,7 @@ var _ol_source_Zoomify_ = function(opt_options) {
}; };
inherits(_ol_source_Zoomify_, TileImage); inherits(Zoomify, TileImage);
/** /**
* @constructor * @constructor
@@ -165,7 +165,7 @@ inherits(_ol_source_Zoomify_, TileImage);
* @param {olx.TileOptions=} opt_options Tile options. * @param {olx.TileOptions=} opt_options Tile options.
* @private * @private
*/ */
_ol_source_Zoomify_.Tile_ = function( Zoomify.Tile_ = function(
tileGrid, tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options) { tileGrid, tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options) {
ImageTile.call(this, 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])); this.tileSize_ = _ol_size_.toSize(tileGrid.getTileSize(tileCoord[0]));
}; };
inherits(_ol_source_Zoomify_.Tile_, ImageTile); inherits(Zoomify.Tile_, ImageTile);
/** /**
* @inheritDoc * @inheritDoc
*/ */
_ol_source_Zoomify_.Tile_.prototype.getImage = function() { Zoomify.Tile_.prototype.getImage = function() {
if (this.zoomifyImage_) { if (this.zoomifyImage_) {
return this.zoomifyImage_; return this.zoomifyImage_;
} }
@@ -213,8 +213,8 @@ _ol_source_Zoomify_.Tile_.prototype.getImage = function() {
* @enum {string} * @enum {string}
* @private * @private
*/ */
_ol_source_Zoomify_.TierSizeCalculation_ = { Zoomify.TierSizeCalculation_ = {
DEFAULT: 'default', DEFAULT: 'default',
TRUNCATED: 'truncated' TRUNCATED: 'truncated'
}; };
export default _ol_source_Zoomify_; export default Zoomify;
+20 -20
View File
@@ -1,7 +1,7 @@
import {DEFAULT_TILE_SIZE} from '../../../../src/ol/tilegrid/common.js'; import {DEFAULT_TILE_SIZE} from '../../../../src/ol/tilegrid/common.js';
import _ol_events_ from '../../../../src/ol/events.js'; import _ol_events_ from '../../../../src/ol/events.js';
import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.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'; import TileGrid from '../../../../src/ol/tilegrid/TileGrid.js';
@@ -17,26 +17,26 @@ describe('ol.source.Zoomify', function() {
extent: [0, 0, w, h] extent: [0, 0, w, h]
}); });
function getZoomifySource() { function getZoomifySource() {
return new _ol_source_Zoomify_({ return new Zoomify({
url: zoomifyUrl, url: zoomifyUrl,
size: size size: size
}); });
} }
function getZoomifySourceWithExtentInFirstQuadrant() { function getZoomifySourceWithExtentInFirstQuadrant() {
return new _ol_source_Zoomify_({ return new Zoomify({
url: zoomifyUrl, url: zoomifyUrl,
size: size, size: size,
extent: [0, 0, size[0], size[1]] extent: [0, 0, size[0], size[1]]
}); });
} }
function getIIPSource() { function getIIPSource() {
return new _ol_source_Zoomify_({ return new Zoomify({
url: iipUrl, url: iipUrl,
size: size size: size
}); });
} }
function getZoomifySourceWith1024pxTiles() { function getZoomifySourceWith1024pxTiles() {
return new _ol_source_Zoomify_({ return new Zoomify({
url: zoomifyUrl, url: zoomifyUrl,
size: size, size: size,
tileSize: 1024 tileSize: 1024
@@ -50,29 +50,29 @@ describe('ol.source.Zoomify', function() {
// undefined config object // undefined config object
expect(function() { expect(function() {
source = new _ol_source_Zoomify_(); source = new Zoomify();
}).to.throwException(); }).to.throwException();
// empty object as config object // empty object as config object
expect(function() { expect(function() {
source = new _ol_source_Zoomify_({}); source = new Zoomify({});
}).to.throwException(); }).to.throwException();
// not passing "size" in config object // not passing "size" in config object
expect(function() { expect(function() {
source = new _ol_source_Zoomify_({ source = new Zoomify({
url: 'some-url' url: 'some-url'
}); });
}).to.throwException(); }).to.throwException();
// passing "size" in config object // passing "size" in config object
expect(function() { expect(function() {
source = new _ol_source_Zoomify_({ source = new Zoomify({
size: [47, 11] size: [47, 11]
}); });
}).to.not.throwException(); }).to.not.throwException();
// we got a source // 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 // also test our helper methods from above
expect(function() { expect(function() {
@@ -82,12 +82,12 @@ describe('ol.source.Zoomify', function() {
source = getIIPSource(); source = getIIPSource();
}).to.not.throwException(); }).to.not.throwException();
// we got a source // 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() { it('does not need "tierSizeCalculation" option', function() {
expect(function() { expect(function() {
new _ol_source_Zoomify_({ new Zoomify({
size: [47, 11] size: [47, 11]
}); });
}).to.not.throwException(); }).to.not.throwException();
@@ -95,7 +95,7 @@ describe('ol.source.Zoomify', function() {
it('accepts "tierSizeCalculation" option "default"', function() { it('accepts "tierSizeCalculation" option "default"', function() {
expect(function() { expect(function() {
new _ol_source_Zoomify_({ new Zoomify({
size: [47, 11], size: [47, 11],
tierSizeCalculation: 'default' tierSizeCalculation: 'default'
}); });
@@ -104,7 +104,7 @@ describe('ol.source.Zoomify', function() {
it('accepts "tierSizeCalculation" option "truncated"', function() { it('accepts "tierSizeCalculation" option "truncated"', function() {
expect(function() { expect(function() {
new _ol_source_Zoomify_({ new Zoomify({
size: [47, 11], size: [47, 11],
tierSizeCalculation: 'truncated' tierSizeCalculation: 'truncated'
}); });
@@ -114,7 +114,7 @@ describe('ol.source.Zoomify', function() {
it('throws on unexpected "tierSizeCalculation" ', function() { it('throws on unexpected "tierSizeCalculation" ', function() {
// passing unknown string will throw // passing unknown string will throw
expect(function() { expect(function() {
new _ol_source_Zoomify_({ new Zoomify({
size: [47, 11], size: [47, 11],
tierSizeCalculation: 'ace-of-spades' tierSizeCalculation: 'ace-of-spades'
}); });
@@ -199,14 +199,14 @@ describe('ol.source.Zoomify', function() {
it('influences resolutions', function() { it('influences resolutions', function() {
// not configured at all // not configured at all
var source = new _ol_source_Zoomify_({ var source = new Zoomify({
url: zoomifyUrl, url: zoomifyUrl,
size: [513, 256] size: [513, 256]
}); });
var tileGrid = source.getTileGrid(); var tileGrid = source.getTileGrid();
// explicitly set as 'default' // explicitly set as 'default'
var sourceDefault = new _ol_source_Zoomify_({ var sourceDefault = new Zoomify({
url: zoomifyUrl, url: zoomifyUrl,
size: [513, 256], size: [513, 256],
tierSizeCalculation: 'default' tierSizeCalculation: 'default'
@@ -214,7 +214,7 @@ describe('ol.source.Zoomify', function() {
var tileGridDefault = sourceDefault.getTileGrid(); var tileGridDefault = sourceDefault.getTileGrid();
// explicitly set to 'truncated' // explicitly set to 'truncated'
var sourceTruncated = new _ol_source_Zoomify_({ var sourceTruncated = new Zoomify({
url: zoomifyUrl, url: zoomifyUrl,
size: [513, 256], size: [513, 256],
tierSizeCalculation: 'truncated' tierSizeCalculation: 'truncated'
@@ -254,7 +254,7 @@ describe('ol.source.Zoomify', function() {
}); });
it('creates an expected tileUrlFunction without template', 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/', url: 'spec/ol/source/images/zoomify/',
size: size size: size
}); });
@@ -280,7 +280,7 @@ describe('ol.source.Zoomify', function() {
it('returns expected tileClass instances via "getTile"', function() { it('returns expected tileClass instances via "getTile"', function() {
var source = getZoomifySource(); var source = getZoomifySource();
var tile = source.getTile(0, 0, -1, 1, proj); 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() { it('"tile.getImage" returns and caches an unloaded image', function() {