Rename _ol_ImageTile_ to ImageTile

This commit is contained in:
Frederic Junod
2017-12-22 09:18:12 +01:00
parent 53c4113684
commit fd84f9378e
10 changed files with 42 additions and 42 deletions
+13 -13
View File
@@ -18,7 +18,7 @@ import EventType from './events/EventType.js';
* @param {ol.TileLoadFunctionType} tileLoadFunction Tile load function. * @param {ol.TileLoadFunctionType} tileLoadFunction Tile load function.
* @param {olx.TileOptions=} opt_options Tile options. * @param {olx.TileOptions=} opt_options Tile options.
*/ */
var _ol_ImageTile_ = function(tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options) { var ImageTile = function(tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options) {
_ol_Tile_.call(this, tileCoord, state, opt_options); _ol_Tile_.call(this, tileCoord, state, opt_options);
@@ -59,16 +59,16 @@ var _ol_ImageTile_ = function(tileCoord, state, src, crossOrigin, tileLoadFuncti
}; };
inherits(_ol_ImageTile_, _ol_Tile_); inherits(ImageTile, _ol_Tile_);
/** /**
* @inheritDoc * @inheritDoc
*/ */
_ol_ImageTile_.prototype.disposeInternal = function() { ImageTile.prototype.disposeInternal = function() {
if (this.state == TileState.LOADING) { if (this.state == TileState.LOADING) {
this.unlistenImage_(); this.unlistenImage_();
this.image_ = _ol_ImageTile_.getBlankImage(); this.image_ = ImageTile.getBlankImage();
} }
if (this.interimTile) { if (this.interimTile) {
this.interimTile.dispose(); this.interimTile.dispose();
@@ -84,7 +84,7 @@ _ol_ImageTile_.prototype.disposeInternal = function() {
* @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image. * @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image.
* @api * @api
*/ */
_ol_ImageTile_.prototype.getImage = function() { ImageTile.prototype.getImage = function() {
return this.image_; return this.image_;
}; };
@@ -92,7 +92,7 @@ _ol_ImageTile_.prototype.getImage = function() {
/** /**
* @inheritDoc * @inheritDoc
*/ */
_ol_ImageTile_.prototype.getKey = function() { ImageTile.prototype.getKey = function() {
return this.src_; return this.src_;
}; };
@@ -102,10 +102,10 @@ _ol_ImageTile_.prototype.getKey = function() {
* *
* @private * @private
*/ */
_ol_ImageTile_.prototype.handleImageError_ = function() { ImageTile.prototype.handleImageError_ = function() {
this.state = TileState.ERROR; this.state = TileState.ERROR;
this.unlistenImage_(); this.unlistenImage_();
this.image_ = _ol_ImageTile_.getBlankImage(); this.image_ = ImageTile.getBlankImage();
this.changed(); this.changed();
}; };
@@ -115,7 +115,7 @@ _ol_ImageTile_.prototype.handleImageError_ = function() {
* *
* @private * @private
*/ */
_ol_ImageTile_.prototype.handleImageLoad_ = function() { ImageTile.prototype.handleImageLoad_ = function() {
if (this.image_.naturalWidth && this.image_.naturalHeight) { if (this.image_.naturalWidth && this.image_.naturalHeight) {
this.state = TileState.LOADED; this.state = TileState.LOADED;
} else { } else {
@@ -130,7 +130,7 @@ _ol_ImageTile_.prototype.handleImageLoad_ = function() {
* @inheritDoc * @inheritDoc
* @api * @api
*/ */
_ol_ImageTile_.prototype.load = function() { ImageTile.prototype.load = function() {
if (this.state == TileState.ERROR) { if (this.state == TileState.ERROR) {
this.state = TileState.IDLE; this.state = TileState.IDLE;
this.image_ = new Image(); this.image_ = new Image();
@@ -157,7 +157,7 @@ _ol_ImageTile_.prototype.load = function() {
* *
* @private * @private
*/ */
_ol_ImageTile_.prototype.unlistenImage_ = function() { ImageTile.prototype.unlistenImage_ = function() {
this.imageListenerKeys_.forEach(_ol_events_.unlistenByKey); this.imageListenerKeys_.forEach(_ol_events_.unlistenByKey);
this.imageListenerKeys_ = null; this.imageListenerKeys_ = null;
}; };
@@ -167,10 +167,10 @@ _ol_ImageTile_.prototype.unlistenImage_ = function() {
* Get a 1-pixel blank image. * Get a 1-pixel blank image.
* @return {HTMLCanvasElement} Blank image. * @return {HTMLCanvasElement} Blank image.
*/ */
_ol_ImageTile_.getBlankImage = function() { ImageTile.getBlankImage = function() {
var ctx = createCanvasContext2D(1, 1); var ctx = createCanvasContext2D(1, 1);
ctx.fillStyle = 'rgba(0,0,0,0)'; ctx.fillStyle = 'rgba(0,0,0,0)';
ctx.fillRect(0, 0, 1, 1); ctx.fillRect(0, 0, 1, 1);
return ctx.canvas; return ctx.canvas;
}; };
export default _ol_ImageTile_; export default ImageTile;
+2 -2
View File
@@ -3,7 +3,7 @@
*/ */
import {ENABLE_RASTER_REPROJECTION} from '../reproj/common.js'; import {ENABLE_RASTER_REPROJECTION} from '../reproj/common.js';
import {getUid, inherits} from '../index.js'; import {getUid, inherits} from '../index.js';
import _ol_ImageTile_ from '../ImageTile.js'; import ImageTile from '../ImageTile.js';
import TileCache from '../TileCache.js'; import TileCache from '../TileCache.js';
import TileState from '../TileState.js'; import TileState from '../TileState.js';
import _ol_events_ from '../events.js'; import _ol_events_ from '../events.js';
@@ -57,7 +57,7 @@ var _ol_source_TileImage_ = function(options) {
* ?string, ol.TileLoadFunctionType, olx.TileOptions=)} * ?string, ol.TileLoadFunctionType, olx.TileOptions=)}
*/ */
this.tileClass = options.tileClass !== undefined ? this.tileClass = options.tileClass !== undefined ?
options.tileClass : _ol_ImageTile_; options.tileClass : ImageTile;
/** /**
* @protected * @protected
+4 -4
View File
@@ -3,7 +3,7 @@
*/ */
import {DEFAULT_TILE_SIZE} from '../tilegrid/common.js'; import {DEFAULT_TILE_SIZE} from '../tilegrid/common.js';
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import _ol_ImageTile_ from '../ImageTile.js'; import ImageTile from '../ImageTile.js';
import TileState from '../TileState.js'; import TileState from '../TileState.js';
import {expandUrl, createFromTileUrlFunctions} from '../tileurlfunction.js'; import {expandUrl, createFromTileUrlFunctions} from '../tileurlfunction.js';
import {assert} from '../asserts.js'; import {assert} from '../asserts.js';
@@ -168,7 +168,7 @@ inherits(_ol_source_Zoomify_, _ol_source_TileImage_);
_ol_source_Zoomify_.Tile_ = function( _ol_source_Zoomify_.Tile_ = function(
tileGrid, tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options) { tileGrid, tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options) {
_ol_ImageTile_.call(this, tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options); ImageTile.call(this, tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options);
/** /**
* @private * @private
@@ -182,7 +182,7 @@ _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_, _ol_ImageTile_); inherits(_ol_source_Zoomify_.Tile_, ImageTile);
/** /**
@@ -192,7 +192,7 @@ _ol_source_Zoomify_.Tile_.prototype.getImage = function() {
if (this.zoomifyImage_) { if (this.zoomifyImage_) {
return this.zoomifyImage_; return this.zoomifyImage_;
} }
var image = _ol_ImageTile_.prototype.getImage.call(this); var image = ImageTile.prototype.getImage.call(this);
if (this.state == TileState.LOADED) { if (this.state == TileState.LOADED) {
var tileSize = this.tileSize_; var tileSize = this.tileSize_;
if (image.width == tileSize[0] && image.height == tileSize[1]) { if (image.width == tileSize[0] && image.height == tileSize[1]) {
+6 -6
View File
@@ -1,4 +1,4 @@
import _ol_ImageTile_ from '../../../src/ol/ImageTile.js'; import ImageTile from '../../../src/ol/ImageTile.js';
import TileState from '../../../src/ol/TileState.js'; import TileState from '../../../src/ol/TileState.js';
import _ol_events_ from '../../../src/ol/events.js'; import _ol_events_ from '../../../src/ol/events.js';
import EventType from '../../../src/ol/events/EventType.js'; import EventType from '../../../src/ol/events/EventType.js';
@@ -14,7 +14,7 @@ describe('ol.ImageTile', function() {
var state = TileState.IDLE; var state = TileState.IDLE;
var src = 'spec/ol/data/osm-0-0-0.png'; var src = 'spec/ol/data/osm-0-0-0.png';
var tileLoadFunction = _ol_source_Image_.defaultImageLoadFunction; var tileLoadFunction = _ol_source_Image_.defaultImageLoadFunction;
var tile = new _ol_ImageTile_(tileCoord, state, src, null, tileLoadFunction); var tile = new ImageTile(tileCoord, state, src, null, tileLoadFunction);
var previousState = tile.getState(); var previousState = tile.getState();
@@ -39,7 +39,7 @@ describe('ol.ImageTile', function() {
var state = TileState.ERROR; var state = TileState.ERROR;
var src = 'spec/ol/data/osm-0-0-0.png'; var src = 'spec/ol/data/osm-0-0-0.png';
var tileLoadFunction = _ol_source_Image_.defaultImageLoadFunction; var tileLoadFunction = _ol_source_Image_.defaultImageLoadFunction;
var tile = new _ol_ImageTile_(tileCoord, state, src, null, tileLoadFunction); var tile = new ImageTile(tileCoord, state, src, null, tileLoadFunction);
var previousState = tile.getState(); var previousState = tile.getState();
@@ -64,7 +64,7 @@ describe('ol.ImageTile', function() {
var state = TileState.IDLE; var state = TileState.IDLE;
var src = 'spec/ol/data/osm-0-0-99.png'; var src = 'spec/ol/data/osm-0-0-99.png';
var tileLoadFunction = _ol_source_Image_.defaultImageLoadFunction; var tileLoadFunction = _ol_source_Image_.defaultImageLoadFunction;
var tile = new _ol_ImageTile_(tileCoord, state, src, null, tileLoadFunction); var tile = new ImageTile(tileCoord, state, src, null, tileLoadFunction);
var key = _ol_events_.listen(tile, EventType.CHANGE, function(event) { var key = _ol_events_.listen(tile, EventType.CHANGE, function(event) {
var state = tile.getState(); var state = tile.getState();
@@ -90,12 +90,12 @@ describe('ol.ImageTile', function() {
var state = TileState.IDLE; var state = TileState.IDLE;
var src = 'spec/ol/data/osm-0-0-0.png'; var src = 'spec/ol/data/osm-0-0-0.png';
var tileLoadFunction = _ol_source_Image_.defaultImageLoadFunction; var tileLoadFunction = _ol_source_Image_.defaultImageLoadFunction;
var tile = new _ol_ImageTile_(tileCoord, state, src, null, tileLoadFunction); var tile = new ImageTile(tileCoord, state, src, null, tileLoadFunction);
tile.load(); tile.load();
expect(tile.getState()).to.be(TileState.LOADING); expect(tile.getState()).to.be(TileState.LOADING);
tile.dispose(); tile.dispose();
expect(tile.getState()).to.be(TileState.ABORT); expect(tile.getState()).to.be(TileState.ABORT);
expect(tile.getImage().src).to.be(_ol_ImageTile_.blankImageUrl); expect(tile.getImage().src).to.be(ImageTile.blankImageUrl);
}); });
}); });
+2 -2
View File
@@ -1,4 +1,4 @@
import _ol_ImageTile_ from '../../../../src/ol/ImageTile.js'; import ImageTile from '../../../../src/ol/ImageTile.js';
import _ol_events_ from '../../../../src/ol/events.js'; import _ol_events_ from '../../../../src/ol/events.js';
import {addCommon, clearAllProjections, get as getProjection} from '../../../../src/ol/proj.js'; import {addCommon, clearAllProjections, get as getProjection} from '../../../../src/ol/proj.js';
import {register} from '../../../../src/ol/proj/proj4.js'; import {register} from '../../../../src/ol/proj/proj4.js';
@@ -31,7 +31,7 @@ describe('ol.reproj.Tile', function() {
proj3857, _ol_tilegrid_.createForProjection(proj3857), proj4326, proj3857, _ol_tilegrid_.createForProjection(proj3857), proj4326,
_ol_tilegrid_.createForProjection(proj4326, 3, opt_tileSize), _ol_tilegrid_.createForProjection(proj4326, 3, opt_tileSize),
[3, 2, -2], null, pixelRatio, 0, function(z, x, y, pixelRatio) { [3, 2, -2], null, pixelRatio, 0, function(z, x, y, pixelRatio) {
return new _ol_ImageTile_([z, x, y], 0, // IDLE return new ImageTile([z, x, y], 0, // IDLE
'data:image/gif;base64,' + 'data:image/gif;base64,' +
'R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=', null, 'R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=', null,
function(tile, src) { function(tile, src) {
+4 -4
View File
@@ -1,4 +1,4 @@
import _ol_ImageTile_ from '../../../../src/ol/ImageTile.js'; import ImageTile from '../../../../src/ol/ImageTile.js';
import _ol_source_TileArcGISRest_ from '../../../../src/ol/source/TileArcGISRest.js'; import _ol_source_TileArcGISRest_ from '../../../../src/ol/source/TileArcGISRest.js';
import {get as getProjection} from '../../../../src/ol/proj.js'; import {get as getProjection} from '../../../../src/ol/proj.js';
@@ -18,7 +18,7 @@ describe('ol.source.TileArcGISRest', function() {
it('returns a tile with the expected URL', function() { it('returns a tile with the expected URL', function() {
var source = new _ol_source_TileArcGISRest_(options); var source = new _ol_source_TileArcGISRest_(options);
var tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857')); var tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
expect(tile).to.be.an(_ol_ImageTile_); expect(tile).to.be.an(ImageTile);
var uri = new URL(tile.src_); var uri = new URL(tile.src_);
expect(uri.protocol).to.be('http:'); expect(uri.protocol).to.be('http:');
expect(uri.hostname).to.be('example.com'); expect(uri.hostname).to.be('example.com');
@@ -61,7 +61,7 @@ describe('ol.source.TileArcGISRest', function() {
var source = new _ol_source_TileArcGISRest_(options); var source = new _ol_source_TileArcGISRest_(options);
var tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857')); var tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
expect(tile).to.be.an(_ol_ImageTile_); expect(tile).to.be.an(ImageTile);
var uri = new URL(tile.src_); var uri = new URL(tile.src_);
expect(uri.protocol).to.be('http:'); expect(uri.protocol).to.be('http:');
expect(uri.hostname).to.match(/test[12]\.com/); expect(uri.hostname).to.match(/test[12]\.com/);
@@ -84,7 +84,7 @@ describe('ol.source.TileArcGISRest', function() {
options.url = 'http://example.com/ImageServer'; options.url = 'http://example.com/ImageServer';
var source = new _ol_source_TileArcGISRest_(options); var source = new _ol_source_TileArcGISRest_(options);
var tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857')); var tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
expect(tile).to.be.an(_ol_ImageTile_); expect(tile).to.be.an(ImageTile);
var uri = new URL(tile.src_); var uri = new URL(tile.src_);
expect(uri.protocol).to.be('http:'); expect(uri.protocol).to.be('http:');
expect(uri.hostname).to.be('example.com'); expect(uri.hostname).to.be('example.com');
+3 -3
View File
@@ -1,4 +1,4 @@
import _ol_ImageTile_ from '../../../../src/ol/ImageTile.js'; import ImageTile from '../../../../src/ol/ImageTile.js';
import TileState from '../../../../src/ol/TileState.js'; import TileState from '../../../../src/ol/TileState.js';
import {createFromTemplate} from '../../../../src/ol/tileurlfunction.js'; import {createFromTemplate} from '../../../../src/ol/tileurlfunction.js';
import _ol_events_ from '../../../../src/ol/events.js'; import _ol_events_ from '../../../../src/ol/events.js';
@@ -116,7 +116,7 @@ describe('ol.source.TileImage', function() {
it('does not do reprojection for identity', function() { it('does not do reprojection for identity', function() {
var source3857 = createSource('EPSG:3857'); var source3857 = createSource('EPSG:3857');
var tile3857 = source3857.getTile(0, 0, -1, 1, getProjection('EPSG:3857')); var tile3857 = source3857.getTile(0, 0, -1, 1, getProjection('EPSG:3857'));
expect(tile3857).to.be.a(_ol_ImageTile_); expect(tile3857).to.be.a(ImageTile);
expect(tile3857).not.to.be.a(_ol_reproj_Tile_); expect(tile3857).not.to.be.a(_ol_reproj_Tile_);
var projXXX = new _ol_proj_Projection_({ var projXXX = new _ol_proj_Projection_({
@@ -125,7 +125,7 @@ describe('ol.source.TileImage', function() {
}); });
var sourceXXX = createSource(projXXX); var sourceXXX = createSource(projXXX);
var tileXXX = sourceXXX.getTile(0, 0, -1, 1, projXXX); var tileXXX = sourceXXX.getTile(0, 0, -1, 1, projXXX);
expect(tileXXX).to.be.a(_ol_ImageTile_); expect(tileXXX).to.be.a(ImageTile);
expect(tileXXX).not.to.be.a(_ol_reproj_Tile_); expect(tileXXX).not.to.be.a(_ol_reproj_Tile_);
}); });
+3 -3
View File
@@ -1,4 +1,4 @@
import _ol_ImageTile_ from '../../../../src/ol/ImageTile.js'; import ImageTile from '../../../../src/ol/ImageTile.js';
import {get as getProjection} from '../../../../src/ol/proj.js'; import {get as getProjection} from '../../../../src/ol/proj.js';
import _ol_source_TileWMS_ from '../../../../src/ol/source/TileWMS.js'; import _ol_source_TileWMS_ from '../../../../src/ol/source/TileWMS.js';
import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js'; import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js';
@@ -39,7 +39,7 @@ describe('ol.source.TileWMS', function() {
it('returns a tile with the expected URL', function() { it('returns a tile with the expected URL', function() {
var source = new _ol_source_TileWMS_(options); var source = new _ol_source_TileWMS_(options);
var tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857')); var tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
expect(tile).to.be.an(_ol_ImageTile_); expect(tile).to.be.an(ImageTile);
var uri = new URL(tile.src_); var uri = new URL(tile.src_);
expect(uri.protocol).to.be('http:'); expect(uri.protocol).to.be('http:');
expect(uri.hostname).to.be('example.com'); expect(uri.hostname).to.be('example.com');
@@ -68,7 +68,7 @@ describe('ol.source.TileWMS', function() {
options.gutter = 16; options.gutter = 16;
var source = new _ol_source_TileWMS_(options); var source = new _ol_source_TileWMS_(options);
var tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857')); var tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
expect(tile).to.be.an(_ol_ImageTile_); expect(tile).to.be.an(ImageTile);
var uri = new URL(tile.src_); var uri = new URL(tile.src_);
var queryData = uri.searchParams; var queryData = uri.searchParams;
var bbox = queryData.get('BBOX').split(','); var bbox = queryData.get('BBOX').split(',');
+3 -3
View File
@@ -1,5 +1,5 @@
import {getUid} from '../../../src/ol/index.js'; import {getUid} from '../../../src/ol/index.js';
import _ol_ImageTile_ from '../../../src/ol/ImageTile.js'; import ImageTile from '../../../src/ol/ImageTile.js';
import _ol_Tile_ from '../../../src/ol/Tile.js'; import _ol_Tile_ from '../../../src/ol/Tile.js';
import TileState from '../../../src/ol/TileState.js'; import TileState from '../../../src/ol/TileState.js';
@@ -58,11 +58,11 @@ describe('ol.Tile', function() {
var head, renderTile; var head, renderTile;
beforeEach(function() { beforeEach(function() {
var tileCoord = [0, 0, 0]; var tileCoord = [0, 0, 0];
head = new _ol_ImageTile_(tileCoord, TileState.IDLE); head = new ImageTile(tileCoord, TileState.IDLE);
getUid(head); getUid(head);
var addToChain = function(tile, state) { var addToChain = function(tile, state) {
var next = new _ol_ImageTile_(tileCoord, state); var next = new ImageTile(tileCoord, state);
getUid(next); getUid(next);
tile.interimTile = next; tile.interimTile = next;
return next; return next;
+2 -2
View File
@@ -1,4 +1,4 @@
import _ol_ImageTile_ from '../../../src/ol/ImageTile.js'; import ImageTile from '../../../src/ol/ImageTile.js';
import _ol_Tile_ from '../../../src/ol/Tile.js'; import _ol_Tile_ from '../../../src/ol/Tile.js';
import TileQueue from '../../../src/ol/TileQueue.js'; import TileQueue from '../../../src/ol/TileQueue.js';
import TileState from '../../../src/ol/TileState.js'; import TileState from '../../../src/ol/TileState.js';
@@ -33,7 +33,7 @@ describe('ol.TileQueue', function() {
var tileLoadFunction = opt_tileLoadFunction ? var tileLoadFunction = opt_tileLoadFunction ?
opt_tileLoadFunction : _ol_source_Image_.defaultImageLoadFunction; opt_tileLoadFunction : _ol_source_Image_.defaultImageLoadFunction;
return new _ol_ImageTile_(tileCoord, state, src, null, tileLoadFunction); return new ImageTile(tileCoord, state, src, null, tileLoadFunction);
} }
describe('#loadMoreTiles()', function() { describe('#loadMoreTiles()', function() {