From fc00aecd2e4aa4a797b18026f2f1a862c561bc17 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Fri, 22 Dec 2017 09:00:46 +0100 Subject: [PATCH] Rename _ol_TileState_ to TileState --- src/ol/ImageTile.js | 20 +++++------ src/ol/Tile.js | 10 +++--- src/ol/TileQueue.js | 10 +++--- src/ol/VectorImageTile.js | 30 ++++++++-------- src/ol/VectorTile.js | 12 +++---- src/ol/renderer/Layer.js | 4 +-- src/ol/renderer/canvas/TileLayer.js | 14 ++++---- src/ol/renderer/canvas/VectorTileLayer.js | 12 +++---- src/ol/renderer/webgl/TileLayer.js | 16 ++++----- src/ol/reproj/Tile.js | 36 +++++++++---------- src/ol/source/Tile.js | 4 +-- src/ol/source/TileDebug.js | 4 +-- src/ol/source/TileImage.js | 6 ++-- src/ol/source/TileUTFGrid.js | 14 ++++---- src/ol/source/UrlTile.js | 8 ++--- src/ol/source/VectorTile.js | 4 +-- src/ol/source/Zoomify.js | 4 +-- test/rendering/ol/reproj/tile.test.js | 6 ++-- test/spec/ol/imagetile.test.js | 34 +++++++++--------- .../renderer/canvas/vectortilelayer.test.js | 6 ++-- test/spec/ol/source/raster.test.js | 4 +-- test/spec/ol/source/tileimage.test.js | 10 +++--- test/spec/ol/tile.test.js | 28 +++++++-------- test/spec/ol/tilequeue.test.js | 4 +-- test/spec/ol/vectorimagetile.test.js | 18 +++++----- 25 files changed, 159 insertions(+), 159 deletions(-) diff --git a/src/ol/ImageTile.js b/src/ol/ImageTile.js index 2789c53423..2e9360fab5 100644 --- a/src/ol/ImageTile.js +++ b/src/ol/ImageTile.js @@ -3,7 +3,7 @@ */ import {inherits} from './index.js'; import _ol_Tile_ from './Tile.js'; -import _ol_TileState_ from './TileState.js'; +import TileState from './TileState.js'; import {createCanvasContext2D} from './dom.js'; import _ol_events_ from './events.js'; import EventType from './events/EventType.js'; @@ -66,14 +66,14 @@ inherits(_ol_ImageTile_, _ol_Tile_); * @inheritDoc */ _ol_ImageTile_.prototype.disposeInternal = function() { - if (this.state == _ol_TileState_.LOADING) { + if (this.state == TileState.LOADING) { this.unlistenImage_(); this.image_ = _ol_ImageTile_.getBlankImage(); } if (this.interimTile) { this.interimTile.dispose(); } - this.state = _ol_TileState_.ABORT; + this.state = TileState.ABORT; this.changed(); _ol_Tile_.prototype.disposeInternal.call(this); }; @@ -103,7 +103,7 @@ _ol_ImageTile_.prototype.getKey = function() { * @private */ _ol_ImageTile_.prototype.handleImageError_ = function() { - this.state = _ol_TileState_.ERROR; + this.state = TileState.ERROR; this.unlistenImage_(); this.image_ = _ol_ImageTile_.getBlankImage(); this.changed(); @@ -117,9 +117,9 @@ _ol_ImageTile_.prototype.handleImageError_ = function() { */ _ol_ImageTile_.prototype.handleImageLoad_ = function() { if (this.image_.naturalWidth && this.image_.naturalHeight) { - this.state = _ol_TileState_.LOADED; + this.state = TileState.LOADED; } else { - this.state = _ol_TileState_.EMPTY; + this.state = TileState.EMPTY; } this.unlistenImage_(); this.changed(); @@ -131,15 +131,15 @@ _ol_ImageTile_.prototype.handleImageLoad_ = function() { * @api */ _ol_ImageTile_.prototype.load = function() { - if (this.state == _ol_TileState_.ERROR) { - this.state = _ol_TileState_.IDLE; + if (this.state == TileState.ERROR) { + this.state = TileState.IDLE; this.image_ = new Image(); if (this.crossOrigin_ !== null) { this.image_.crossOrigin = this.crossOrigin_; } } - if (this.state == _ol_TileState_.IDLE) { - this.state = _ol_TileState_.LOADING; + if (this.state == TileState.IDLE) { + this.state = TileState.LOADING; this.changed(); this.imageListenerKeys_ = [ _ol_events_.listenOnce(this.image_, EventType.ERROR, diff --git a/src/ol/Tile.js b/src/ol/Tile.js index 7df8799c71..63430c4985 100644 --- a/src/ol/Tile.js +++ b/src/ol/Tile.js @@ -2,7 +2,7 @@ * @module ol/Tile */ import {inherits} from './index.js'; -import _ol_TileState_ from './TileState.js'; +import TileState from './TileState.js'; import {easeIn} from './easing.js'; import EventTarget from './events/EventTarget.js'; import EventType from './events/EventType.js'; @@ -102,7 +102,7 @@ _ol_Tile_.prototype.getInterimTile = function() { // of the list (all those tiles correspond to older requests and will be // cleaned up by refreshInterimChain) do { - if (tile.getState() == _ol_TileState_.LOADED) { + if (tile.getState() == TileState.LOADED) { return tile; } tile = tile.interimTile; @@ -125,17 +125,17 @@ _ol_Tile_.prototype.refreshInterimChain = function() { var prev = this; do { - if (tile.getState() == _ol_TileState_.LOADED) { + if (tile.getState() == TileState.LOADED) { //we have a loaded tile, we can discard the rest of the list //we would could abort any LOADING tile request //older than this tile (i.e. any LOADING tile following this entry in the chain) tile.interimTile = null; break; - } else if (tile.getState() == _ol_TileState_.LOADING) { + } else if (tile.getState() == TileState.LOADING) { //keep this LOADING tile any loaded tiles later in the chain are //older than this tile, so we're still interested in the request prev = tile; - } else if (tile.getState() == _ol_TileState_.IDLE) { + } else if (tile.getState() == TileState.IDLE) { //the head of the list is the most current tile, we don't need //to start any other requests for this chain prev.interimTile = tile.interimTile; diff --git a/src/ol/TileQueue.js b/src/ol/TileQueue.js index 47e13afc92..1788dd0eff 100644 --- a/src/ol/TileQueue.js +++ b/src/ol/TileQueue.js @@ -2,7 +2,7 @@ * @module ol/TileQueue */ import {inherits} from './index.js'; -import _ol_TileState_ from './TileState.js'; +import TileState from './TileState.js'; import _ol_events_ from './events.js'; import EventType from './events/EventType.js'; import PriorityQueue from './structs/PriorityQueue.js'; @@ -87,8 +87,8 @@ TileQueue.prototype.getTilesLoading = function() { TileQueue.prototype.handleTileChange = function(event) { var tile = /** @type {ol.Tile} */ (event.target); var state = tile.getState(); - if (state === _ol_TileState_.LOADED || state === _ol_TileState_.ERROR || - state === _ol_TileState_.EMPTY || state === _ol_TileState_.ABORT) { + if (state === TileState.LOADED || state === TileState.ERROR || + state === TileState.EMPTY || state === TileState.ABORT) { _ol_events_.unlisten(tile, EventType.CHANGE, this.handleTileChange, this); var tileKey = tile.getKey(); @@ -114,9 +114,9 @@ TileQueue.prototype.loadMoreTiles = function(maxTotalLoading, maxNewLoads) { tile = /** @type {ol.Tile} */ (this.dequeue()[0]); tileKey = tile.getKey(); state = tile.getState(); - if (state === _ol_TileState_.ABORT) { + if (state === TileState.ABORT) { abortedTiles = true; - } else if (state === _ol_TileState_.IDLE && !(tileKey in this.tilesLoadingKeys_)) { + } else if (state === TileState.IDLE && !(tileKey in this.tilesLoadingKeys_)) { this.tilesLoadingKeys_[tileKey] = true; ++this.tilesLoading_; ++newLoads; diff --git a/src/ol/VectorImageTile.js b/src/ol/VectorImageTile.js index d6ad4abb4e..bf635d876e 100644 --- a/src/ol/VectorImageTile.js +++ b/src/ol/VectorImageTile.js @@ -3,7 +3,7 @@ */ import {getUid, inherits} from './index.js'; import _ol_Tile_ from './Tile.js'; -import _ol_TileState_ from './TileState.js'; +import TileState from './TileState.js'; import {createCanvasContext2D} from './dom.js'; import _ol_events_ from './events.js'; import {getHeight, getIntersection, getWidth} from './extent.js'; @@ -107,7 +107,7 @@ var _ol_VectorImageTile_ = function(tileCoord, state, sourceRevision, format, if (!sourceTile) { var tileUrl = tileUrlFunction(sourceTileCoord, pixelRatio, projection); sourceTile = sourceTiles[sourceTileKey] = new tileClass(sourceTileCoord, - tileUrl == undefined ? _ol_TileState_.EMPTY : _ol_TileState_.IDLE, + tileUrl == undefined ? TileState.EMPTY : TileState.IDLE, tileUrl == undefined ? '' : tileUrl, format, tileLoadFunction); this.sourceTileListenerKeys_.push( @@ -128,7 +128,7 @@ inherits(_ol_VectorImageTile_, _ol_Tile_); * @inheritDoc */ _ol_VectorImageTile_.prototype.disposeInternal = function() { - this.state = _ol_TileState_.ABORT; + this.state = TileState.ABORT; this.changed(); if (this.interimTile) { this.interimTile.dispose(); @@ -223,23 +223,23 @@ _ol_VectorImageTile_.prototype.load = function() { // an ERROR state after another load attempt. var errorSourceTiles = {}; - if (this.state == _ol_TileState_.IDLE) { - this.setState(_ol_TileState_.LOADING); + if (this.state == TileState.IDLE) { + this.setState(TileState.LOADING); } - if (this.state == _ol_TileState_.LOADING) { + if (this.state == TileState.LOADING) { this.tileKeys.forEach(function(sourceTileKey) { var sourceTile = this.getTile(sourceTileKey); - if (sourceTile.state == _ol_TileState_.IDLE) { + if (sourceTile.state == TileState.IDLE) { sourceTile.setLoader(this.loader_); sourceTile.load(); } - if (sourceTile.state == _ol_TileState_.LOADING) { + if (sourceTile.state == TileState.LOADING) { var key = _ol_events_.listen(sourceTile, EventType.CHANGE, function(e) { var state = sourceTile.getState(); - if (state == _ol_TileState_.LOADED || - state == _ol_TileState_.ERROR) { + if (state == TileState.LOADED || + state == TileState.ERROR) { var uid = getUid(sourceTile); - if (state == _ol_TileState_.ERROR) { + if (state == TileState.ERROR) { errorSourceTiles[uid] = true; } else { --leftToLoad; @@ -269,19 +269,19 @@ _ol_VectorImageTile_.prototype.finishLoading_ = function() { var empty = 0; for (var i = loaded - 1; i >= 0; --i) { var state = this.getTile(this.tileKeys[i]).getState(); - if (state != _ol_TileState_.LOADED) { + if (state != TileState.LOADED) { --loaded; } - if (state == _ol_TileState_.EMPTY) { + if (state == TileState.EMPTY) { ++empty; } } if (loaded == this.tileKeys.length) { this.loadListenerKeys_.forEach(_ol_events_.unlistenByKey); this.loadListenerKeys_.length = 0; - this.setState(_ol_TileState_.LOADED); + this.setState(TileState.LOADED); } else { - this.setState(empty == this.tileKeys.length ? _ol_TileState_.EMPTY : _ol_TileState_.ERROR); + this.setState(empty == this.tileKeys.length ? TileState.EMPTY : TileState.ERROR); } }; diff --git a/src/ol/VectorTile.js b/src/ol/VectorTile.js index 8f5753cd6e..ff2ac75e98 100644 --- a/src/ol/VectorTile.js +++ b/src/ol/VectorTile.js @@ -3,7 +3,7 @@ */ import {getUid, inherits} from './index.js'; import _ol_Tile_ from './Tile.js'; -import _ol_TileState_ from './TileState.js'; +import TileState from './TileState.js'; /** * @constructor @@ -84,7 +84,7 @@ inherits(_ol_VectorTile_, _ol_Tile_); _ol_VectorTile_.prototype.disposeInternal = function() { this.features_ = null; this.replayGroups_ = {}; - this.state = _ol_TileState_.ABORT; + this.state = TileState.ABORT; this.changed(); _ol_Tile_.prototype.disposeInternal.call(this); }; @@ -154,8 +154,8 @@ _ol_VectorTile_.prototype.getReplayGroup = function(layer, key) { * @inheritDoc */ _ol_VectorTile_.prototype.load = function() { - if (this.state == _ol_TileState_.IDLE) { - this.setState(_ol_TileState_.LOADING); + if (this.state == TileState.IDLE) { + this.setState(TileState.LOADING); this.tileLoadFunction_(this, this.url_); this.loader_(null, NaN, null); } @@ -179,7 +179,7 @@ _ol_VectorTile_.prototype.onLoad = function(features, dataProjection, extent) { * Handler for tile load errors. */ _ol_VectorTile_.prototype.onError = function() { - this.setState(_ol_TileState_.ERROR); + this.setState(TileState.ERROR); }; @@ -208,7 +208,7 @@ _ol_VectorTile_.prototype.setExtent = function(extent) { */ _ol_VectorTile_.prototype.setFeatures = function(features) { this.features_ = features; - this.setState(_ol_TileState_.LOADED); + this.setState(TileState.LOADED); }; diff --git a/src/ol/renderer/Layer.js b/src/ol/renderer/Layer.js index 89e4010222..cd6521bca1 100644 --- a/src/ol/renderer/Layer.js +++ b/src/ol/renderer/Layer.js @@ -4,7 +4,7 @@ import {getUid, inherits, nullFunction} from '../index.js'; import ImageState from '../ImageState.js'; import _ol_Observable_ from '../Observable.js'; -import _ol_TileState_ from '../TileState.js'; +import TileState from '../TileState.js'; import _ol_events_ from '../events.js'; import EventType from '../events/EventType.js'; import {FALSE} from '../functions.js'; @@ -225,7 +225,7 @@ _ol_renderer_Layer_.prototype.manageTilePyramid = function( for (y = tileRange.minY; y <= tileRange.maxY; ++y) { if (currentZ - z <= preload) { tile = tileSource.getTile(z, x, y, pixelRatio, projection); - if (tile.getState() == _ol_TileState_.IDLE) { + if (tile.getState() == TileState.IDLE) { wantedTiles[tile.getKey()] = true; if (!tileQueue.isKeyQueued(tile.getKey())) { tileQueue.enqueue([tile, tileSourceKey, diff --git a/src/ol/renderer/canvas/TileLayer.js b/src/ol/renderer/canvas/TileLayer.js index 307bff2fa0..ed6a492caf 100644 --- a/src/ol/renderer/canvas/TileLayer.js +++ b/src/ol/renderer/canvas/TileLayer.js @@ -4,7 +4,7 @@ import {getUid, inherits} from '../../index.js'; import LayerType from '../../LayerType.js'; import TileRange from '../../TileRange.js'; -import _ol_TileState_ from '../../TileState.js'; +import TileState from '../../TileState.js'; import _ol_ViewHint_ from '../../ViewHint.js'; import {createCanvasContext2D} from '../../dom.js'; import {containsExtent, createEmpty, equals, getIntersection, isEmpty} from '../../extent.js'; @@ -111,9 +111,9 @@ _ol_renderer_canvas_TileLayer_['create'] = function(mapRenderer, layer) { _ol_renderer_canvas_TileLayer_.prototype.isDrawableTile_ = function(tile) { var tileState = tile.getState(); var useInterimTilesOnError = this.getLayer().getUseInterimTilesOnError(); - return tileState == _ol_TileState_.LOADED || - tileState == _ol_TileState_.EMPTY || - tileState == _ol_TileState_.ERROR && !useInterimTilesOnError; + return tileState == TileState.LOADED || + tileState == TileState.EMPTY || + tileState == TileState.ERROR && !useInterimTilesOnError; }; /** @@ -166,10 +166,10 @@ _ol_renderer_canvas_TileLayer_.prototype.prepareFrame = function(frameState, lay for (x = tileRange.minX; x <= tileRange.maxX; ++x) { for (y = tileRange.minY; y <= tileRange.maxY; ++y) { tile = tileSource.getTile(z, x, y, pixelRatio, projection); - if (tile.getState() == _ol_TileState_.ERROR) { + if (tile.getState() == TileState.ERROR) { if (!tileLayer.getUseInterimTilesOnError()) { // When useInterimTilesOnError is false, we consider the error tile as loaded. - tile.setState(_ol_TileState_.LOADED); + tile.setState(TileState.LOADED); } else if (tileLayer.getPreload() > 0) { // Preloaded tiles for lower resolutions might have finished loading. newTiles = true; @@ -180,7 +180,7 @@ _ol_renderer_canvas_TileLayer_.prototype.prepareFrame = function(frameState, lay } if (this.isDrawableTile_(tile)) { var uid = getUid(this); - if (tile.getState() == _ol_TileState_.LOADED) { + if (tile.getState() == TileState.LOADED) { tilesToDrawByZ[z][tile.tileCoord.toString()] = tile; var inTransition = tile.inTransition(uid); if (!newTiles && (inTransition || this.renderedTiles.indexOf(tile) === -1)) { diff --git a/src/ol/renderer/canvas/VectorTileLayer.js b/src/ol/renderer/canvas/VectorTileLayer.js index 876e7d4330..34bfdf829a 100644 --- a/src/ol/renderer/canvas/VectorTileLayer.js +++ b/src/ol/renderer/canvas/VectorTileLayer.js @@ -3,7 +3,7 @@ */ import {getUid, inherits} from '../../index.js'; import LayerType from '../../LayerType.js'; -import _ol_TileState_ from '../../TileState.js'; +import TileState from '../../TileState.js'; import {createCanvasContext2D} from '../../dom.js'; import _ol_events_ from '../../events.js'; import EventType from '../../events/EventType.js'; @@ -174,7 +174,7 @@ _ol_renderer_canvas_VectorTileLayer_.prototype.createReplayGroup_ = function( var zIndexKeys = {}; for (var t = 0, tt = tile.tileKeys.length; t < tt; ++t) { var sourceTile = tile.getTile(tile.tileKeys[t]); - if (sourceTile.getState() == _ol_TileState_.ERROR) { + if (sourceTile.getState() == TileState.ERROR) { continue; } @@ -292,7 +292,7 @@ _ol_renderer_canvas_VectorTileLayer_.prototype.forEachFeatureAtCoordinate = func } for (var t = 0, tt = tile.tileKeys.length; t < tt; ++t) { var sourceTile = tile.getTile(tile.tileKeys[t]); - if (sourceTile.getState() == _ol_TileState_.ERROR) { + if (sourceTile.getState() == TileState.ERROR) { continue; } replayGroup = sourceTile.getReplayGroup(layer, tile.tileCoord.toString()); @@ -393,7 +393,7 @@ _ol_renderer_canvas_VectorTileLayer_.prototype.postCompose = function(context, f var zs = []; for (var i = tiles.length - 1; i >= 0; --i) { var tile = /** @type {ol.VectorImageTile} */ (tiles[i]); - if (tile.getState() == _ol_TileState_.ABORT) { + if (tile.getState() == TileState.ABORT) { continue; } var tileCoord = tile.tileCoord; @@ -402,7 +402,7 @@ _ol_renderer_canvas_VectorTileLayer_.prototype.postCompose = function(context, f var transform = undefined; for (var t = 0, tt = tile.tileKeys.length; t < tt; ++t) { var sourceTile = tile.getTile(tile.tileKeys[t]); - if (sourceTile.getState() == _ol_TileState_.ERROR) { + if (sourceTile.getState() == TileState.ERROR) { continue; } var replayGroup = sourceTile.getReplayGroup(layer, tileCoord.toString()); @@ -507,7 +507,7 @@ _ol_renderer_canvas_VectorTileLayer_.prototype.renderTileImage_ = function( var tileExtent = tileGrid.getTileCoordExtent(tileCoord); for (var i = 0, ii = tile.tileKeys.length; i < ii; ++i) { var sourceTile = tile.getTile(tile.tileKeys[i]); - if (sourceTile.getState() == _ol_TileState_.ERROR) { + if (sourceTile.getState() == TileState.ERROR) { continue; } var pixelScale = pixelRatio / resolution; diff --git a/src/ol/renderer/webgl/TileLayer.js b/src/ol/renderer/webgl/TileLayer.js index 149f3c7815..a223738d9b 100644 --- a/src/ol/renderer/webgl/TileLayer.js +++ b/src/ol/renderer/webgl/TileLayer.js @@ -7,7 +7,7 @@ import {inherits} from '../../index.js'; import LayerType from '../../LayerType.js'; import TileRange from '../../TileRange.js'; -import _ol_TileState_ from '../../TileState.js'; +import TileState from '../../TileState.js'; import {numberSafeCompareFunction} from '../../array.js'; import {createEmpty, intersects} from '../../extent.js'; import {roundUpToPowerOfTwo} from '../../math.js'; @@ -262,20 +262,20 @@ _ol_renderer_webgl_TileLayer_.prototype.prepareFrame = function(frameState, laye } } tileState = tile.getState(); - drawable = tileState == _ol_TileState_.LOADED || - tileState == _ol_TileState_.EMPTY || - tileState == _ol_TileState_.ERROR && !useInterimTilesOnError; + drawable = tileState == TileState.LOADED || + tileState == TileState.EMPTY || + tileState == TileState.ERROR && !useInterimTilesOnError; if (!drawable) { tile = tile.getInterimTile(); } tileState = tile.getState(); - if (tileState == _ol_TileState_.LOADED) { + if (tileState == TileState.LOADED) { if (mapRenderer.isTileTextureLoaded(tile)) { tilesToDrawByZ[z][tile.tileCoord.toString()] = tile; continue; } - } else if (tileState == _ol_TileState_.EMPTY || - (tileState == _ol_TileState_.ERROR && + } else if (tileState == TileState.EMPTY || + (tileState == TileState.ERROR && !useInterimTilesOnError)) { continue; } @@ -342,7 +342,7 @@ _ol_renderer_webgl_TileLayer_.prototype.prepareFrame = function(frameState, laye * @param {ol.Tile} tile Tile. */ function(tile) { - if (tile.getState() == _ol_TileState_.LOADED && + if (tile.getState() == TileState.LOADED && !mapRenderer.isTileTextureLoaded(tile) && !tileTextureQueue.isKeyQueued(tile.getKey())) { tileTextureQueue.enqueue([ diff --git a/src/ol/reproj/Tile.js b/src/ol/reproj/Tile.js index dbab5f9f99..0875b9b30a 100644 --- a/src/ol/reproj/Tile.js +++ b/src/ol/reproj/Tile.js @@ -4,7 +4,7 @@ import {ERROR_THRESHOLD} from './common.js'; import {inherits} from '../index.js'; import _ol_Tile_ from '../Tile.js'; -import _ol_TileState_ from '../TileState.js'; +import TileState from '../TileState.js'; import _ol_events_ from '../events.js'; import EventType from '../events/EventType.js'; import {getArea, getCenter, getIntersection} from '../extent.js'; @@ -36,7 +36,7 @@ var _ol_reproj_Tile_ = function(sourceProj, sourceTileGrid, targetProj, targetTileGrid, tileCoord, wrappedTileCoord, pixelRatio, gutter, getTileFunction, opt_errorThreshold, opt_renderEdges) { - _ol_Tile_.call(this, tileCoord, _ol_TileState_.IDLE); + _ol_Tile_.call(this, tileCoord, TileState.IDLE); /** * @private @@ -108,7 +108,7 @@ var _ol_reproj_Tile_ = function(sourceProj, sourceTileGrid, if (getArea(limitedTargetExtent) === 0) { // Tile is completely outside range -> EMPTY // TODO: is it actually correct that the source even creates the tile ? - this.state = _ol_TileState_.EMPTY; + this.state = TileState.EMPTY; return; } @@ -131,7 +131,7 @@ var _ol_reproj_Tile_ = function(sourceProj, sourceTileGrid, if (!isFinite(sourceResolution) || sourceResolution <= 0) { // invalid sourceResolution -> EMPTY // probably edges of the projections when no extent is defined - this.state = _ol_TileState_.EMPTY; + this.state = TileState.EMPTY; return; } @@ -148,7 +148,7 @@ var _ol_reproj_Tile_ = function(sourceProj, sourceTileGrid, if (this.triangulation_.getTriangles().length === 0) { // no valid triangles -> EMPTY - this.state = _ol_TileState_.EMPTY; + this.state = TileState.EMPTY; return; } @@ -167,7 +167,7 @@ var _ol_reproj_Tile_ = function(sourceProj, sourceTileGrid, } if (!getArea(sourceExtent)) { - this.state = _ol_TileState_.EMPTY; + this.state = TileState.EMPTY; } else { var sourceRange = sourceTileGrid.getTileRangeForExtentAndZ( sourceExtent, this.sourceZ_); @@ -182,7 +182,7 @@ var _ol_reproj_Tile_ = function(sourceProj, sourceTileGrid, } if (this.sourceTiles_.length === 0) { - this.state = _ol_TileState_.EMPTY; + this.state = TileState.EMPTY; } } }; @@ -194,7 +194,7 @@ inherits(_ol_reproj_Tile_, _ol_Tile_); * @inheritDoc */ _ol_reproj_Tile_.prototype.disposeInternal = function() { - if (this.state == _ol_TileState_.LOADING) { + if (this.state == TileState.LOADING) { this.unlistenSources_(); } _ol_Tile_.prototype.disposeInternal.call(this); @@ -216,7 +216,7 @@ _ol_reproj_Tile_.prototype.getImage = function() { _ol_reproj_Tile_.prototype.reproject_ = function() { var sources = []; this.sourceTiles_.forEach(function(tile, i, arr) { - if (tile && tile.getState() == _ol_TileState_.LOADED) { + if (tile && tile.getState() == TileState.LOADED) { sources.push({ extent: this.sourceTileGrid_.getTileCoordExtent(tile.tileCoord), image: tile.getImage() @@ -226,7 +226,7 @@ _ol_reproj_Tile_.prototype.reproject_ = function() { this.sourceTiles_.length = 0; if (sources.length === 0) { - this.state = _ol_TileState_.ERROR; + this.state = TileState.ERROR; } else { var z = this.wrappedTileCoord_[0]; var size = this.targetTileGrid_.getTileSize(z); @@ -242,7 +242,7 @@ _ol_reproj_Tile_.prototype.reproject_ = function() { targetResolution, targetExtent, this.triangulation_, sources, this.gutter_, this.renderEdges_); - this.state = _ol_TileState_.LOADED; + this.state = TileState.LOADED; } this.changed(); }; @@ -252,8 +252,8 @@ _ol_reproj_Tile_.prototype.reproject_ = function() { * @inheritDoc */ _ol_reproj_Tile_.prototype.load = function() { - if (this.state == _ol_TileState_.IDLE) { - this.state = _ol_TileState_.LOADING; + if (this.state == TileState.IDLE) { + this.state = TileState.LOADING; this.changed(); var leftToLoad = 0; @@ -261,16 +261,16 @@ _ol_reproj_Tile_.prototype.load = function() { this.sourcesListenerKeys_ = []; this.sourceTiles_.forEach(function(tile, i, arr) { var state = tile.getState(); - if (state == _ol_TileState_.IDLE || state == _ol_TileState_.LOADING) { + if (state == TileState.IDLE || state == TileState.LOADING) { leftToLoad++; var sourceListenKey; sourceListenKey = _ol_events_.listen(tile, EventType.CHANGE, function(e) { var state = tile.getState(); - if (state == _ol_TileState_.LOADED || - state == _ol_TileState_.ERROR || - state == _ol_TileState_.EMPTY) { + if (state == TileState.LOADED || + state == TileState.ERROR || + state == TileState.EMPTY) { _ol_events_.unlistenByKey(sourceListenKey); leftToLoad--; if (leftToLoad === 0) { @@ -285,7 +285,7 @@ _ol_reproj_Tile_.prototype.load = function() { this.sourceTiles_.forEach(function(tile, i, arr) { var state = tile.getState(); - if (state == _ol_TileState_.IDLE) { + if (state == TileState.IDLE) { tile.load(); } }); diff --git a/src/ol/source/Tile.js b/src/ol/source/Tile.js index afc44f8674..c6c95ded6e 100644 --- a/src/ol/source/Tile.js +++ b/src/ol/source/Tile.js @@ -3,7 +3,7 @@ */ import {inherits, nullFunction} from '../index.js'; import TileCache from '../TileCache.js'; -import _ol_TileState_ from '../TileState.js'; +import TileState from '../TileState.js'; import Event from '../events/Event.js'; import {equivalent} from '../proj.js'; import _ol_size_ from '../size.js'; @@ -124,7 +124,7 @@ _ol_source_Tile_.prototype.forEachLoadedTile = function(projection, z, tileRange loaded = false; if (tileCache.containsKey(tileCoordKey)) { tile = /** @type {!ol.Tile} */ (tileCache.get(tileCoordKey)); - loaded = tile.getState() === _ol_TileState_.LOADED; + loaded = tile.getState() === TileState.LOADED; if (loaded) { loaded = (callback(tile) !== false); } diff --git a/src/ol/source/TileDebug.js b/src/ol/source/TileDebug.js index 28f703497b..a876113fc2 100644 --- a/src/ol/source/TileDebug.js +++ b/src/ol/source/TileDebug.js @@ -3,7 +3,7 @@ */ import {inherits} from '../index.js'; import _ol_Tile_ from '../Tile.js'; -import _ol_TileState_ from '../TileState.js'; +import TileState from '../TileState.js'; import {createCanvasContext2D} from '../dom.js'; import _ol_size_ from '../size.js'; import _ol_source_Tile_ from '../source/Tile.js'; @@ -66,7 +66,7 @@ _ol_source_TileDebug_.prototype.getTile = function(z, x, y) { */ _ol_source_TileDebug_.Tile_ = function(tileCoord, tileSize, text) { - _ol_Tile_.call(this, tileCoord, _ol_TileState_.LOADED); + _ol_Tile_.call(this, tileCoord, TileState.LOADED); /** * @private diff --git a/src/ol/source/TileImage.js b/src/ol/source/TileImage.js index b6c9b987b9..dde1d6211b 100644 --- a/src/ol/source/TileImage.js +++ b/src/ol/source/TileImage.js @@ -5,7 +5,7 @@ import {ENABLE_RASTER_REPROJECTION} from '../reproj/common.js'; import {getUid, inherits} from '../index.js'; import _ol_ImageTile_ from '../ImageTile.js'; import TileCache from '../TileCache.js'; -import _ol_TileState_ from '../TileState.js'; +import TileState from '../TileState.js'; import _ol_events_ from '../events.js'; import EventType from '../events/EventType.js'; import {equivalent, get as getProjection} from '../proj.js'; @@ -218,7 +218,7 @@ _ol_source_TileImage_.prototype.createTile_ = function(z, x, y, pixelRatio, proj this.tileUrlFunction(urlTileCoord, pixelRatio, projection) : undefined; var tile = new this.tileClass( tileCoord, - tileUrl !== undefined ? _ol_TileState_.IDLE : _ol_TileState_.EMPTY, + tileUrl !== undefined ? TileState.IDLE : TileState.EMPTY, tileUrl !== undefined ? tileUrl : '', this.crossOrigin, this.tileLoadFunction, @@ -304,7 +304,7 @@ _ol_source_TileImage_.prototype.getTileInternal = function(z, x, y, pixelRatio, tile = this.createTile_(z, x, y, pixelRatio, projection, key); //make the new tile the head of the list, - if (interimTile.getState() == _ol_TileState_.IDLE) { + if (interimTile.getState() == TileState.IDLE) { //the old tile hasn't begun loading yet, and is now outdated, so we can simply discard it tile.interimTile = interimTile.interimTile; } else { diff --git a/src/ol/source/TileUTFGrid.js b/src/ol/source/TileUTFGrid.js index 55cca8bfbf..3c8857f9eb 100644 --- a/src/ol/source/TileUTFGrid.js +++ b/src/ol/source/TileUTFGrid.js @@ -3,7 +3,7 @@ */ import {inherits} from '../index.js'; import _ol_Tile_ from '../Tile.js'; -import _ol_TileState_ from '../TileState.js'; +import TileState from '../TileState.js'; import {createFromTemplates, nullTileUrlFunction} from '../tileurlfunction.js'; import {assert} from '../asserts.js'; import _ol_events_ from '../events.js'; @@ -224,7 +224,7 @@ _ol_source_TileUTFGrid_.prototype.getTile = function(z, x, y, pixelRatio, projec var tileUrl = this.tileUrlFunction_(urlTileCoord, pixelRatio, projection); var tile = new _ol_source_TileUTFGrid_.Tile_( tileCoord, - tileUrl !== undefined ? _ol_TileState_.IDLE : _ol_TileState_.EMPTY, + tileUrl !== undefined ? TileState.IDLE : TileState.EMPTY, tileUrl !== undefined ? tileUrl : '', this.tileGrid.getTileCoordExtent(tileCoord), this.preemptive_, @@ -370,7 +370,7 @@ _ol_source_TileUTFGrid_.Tile_.prototype.getData = function(coordinate) { * @template T */ _ol_source_TileUTFGrid_.Tile_.prototype.forDataAtCoordinate = function(coordinate, callback, opt_this, opt_request) { - if (this.state == _ol_TileState_.IDLE && opt_request === true) { + if (this.state == TileState.IDLE && opt_request === true) { _ol_events_.listenOnce(this, EventType.CHANGE, function(e) { callback.call(opt_this, this.getData(coordinate)); }, this); @@ -399,7 +399,7 @@ _ol_source_TileUTFGrid_.Tile_.prototype.getKey = function() { * @private */ _ol_source_TileUTFGrid_.Tile_.prototype.handleError_ = function() { - this.state = _ol_TileState_.ERROR; + this.state = TileState.ERROR; this.changed(); }; @@ -413,7 +413,7 @@ _ol_source_TileUTFGrid_.Tile_.prototype.handleLoad_ = function(json) { this.keys_ = json.keys; this.data_ = json.data; - this.state = _ol_TileState_.EMPTY; + this.state = TileState.EMPTY; this.changed(); }; @@ -422,8 +422,8 @@ _ol_source_TileUTFGrid_.Tile_.prototype.handleLoad_ = function(json) { * @private */ _ol_source_TileUTFGrid_.Tile_.prototype.loadInternal_ = function() { - if (this.state == _ol_TileState_.IDLE) { - this.state = _ol_TileState_.LOADING; + if (this.state == TileState.IDLE) { + this.state = TileState.LOADING; if (this.jsonp_) { _ol_net_.jsonp(this.src_, this.handleLoad_.bind(this), this.handleError_.bind(this)); diff --git a/src/ol/source/UrlTile.js b/src/ol/source/UrlTile.js index 7c2bbedc81..db20bd83db 100644 --- a/src/ol/source/UrlTile.js +++ b/src/ol/source/UrlTile.js @@ -2,7 +2,7 @@ * @module ol/source/UrlTile */ import {getUid, inherits} from '../index.js'; -import _ol_TileState_ from '../TileState.js'; +import TileState from '../TileState.js'; import {expandUrl, createFromTemplates, nullTileUrlFunction} from '../tileurlfunction.js'; import _ol_source_Tile_ from '../source/Tile.js'; import TileEventType from '../source/TileEventType.js'; @@ -120,13 +120,13 @@ _ol_source_UrlTile_.prototype.handleTileChange = function(event) { var uid = getUid(tile); var tileState = tile.getState(); var type; - if (tileState == _ol_TileState_.LOADING) { + if (tileState == TileState.LOADING) { this.tileLoadingKeys_[uid] = true; type = TileEventType.TILELOADSTART; } else if (uid in this.tileLoadingKeys_) { delete this.tileLoadingKeys_[uid]; - type = tileState == _ol_TileState_.ERROR ? TileEventType.TILELOADERROR : - (tileState == _ol_TileState_.LOADED || tileState == _ol_TileState_.ABORT) ? + type = tileState == TileState.ERROR ? TileEventType.TILELOADERROR : + (tileState == TileState.LOADED || tileState == TileState.ABORT) ? TileEventType.TILELOADEND : undefined; } if (type != undefined) { diff --git a/src/ol/source/VectorTile.js b/src/ol/source/VectorTile.js index 0d4137c636..737a0f46fc 100644 --- a/src/ol/source/VectorTile.js +++ b/src/ol/source/VectorTile.js @@ -2,7 +2,7 @@ * @module ol/source/VectorTile */ import {inherits} from '../index.js'; -import _ol_TileState_ from '../TileState.js'; +import TileState from '../TileState.js'; import _ol_VectorImageTile_ from '../VectorImageTile.js'; import _ol_VectorTile_ from '../VectorTile.js'; import _ol_size_ from '../size.js'; @@ -120,7 +120,7 @@ _ol_source_VectorTile_.prototype.getTile = function(z, x, y, pixelRatio, project tileCoord, projection); var tile = new _ol_VectorImageTile_( tileCoord, - urlTileCoord !== null ? _ol_TileState_.IDLE : _ol_TileState_.EMPTY, + urlTileCoord !== null ? TileState.IDLE : TileState.EMPTY, this.getRevision(), this.format_, this.tileLoadFunction, urlTileCoord, this.tileUrlFunction, this.tileGrid, this.getTileGridForProjection(projection), diff --git a/src/ol/source/Zoomify.js b/src/ol/source/Zoomify.js index 86dfef8006..10208cd089 100644 --- a/src/ol/source/Zoomify.js +++ b/src/ol/source/Zoomify.js @@ -4,7 +4,7 @@ import {DEFAULT_TILE_SIZE} from '../tilegrid/common.js'; import {inherits} from '../index.js'; import _ol_ImageTile_ from '../ImageTile.js'; -import _ol_TileState_ from '../TileState.js'; +import TileState from '../TileState.js'; import {expandUrl, createFromTileUrlFunctions} from '../tileurlfunction.js'; import {assert} from '../asserts.js'; import {createCanvasContext2D} from '../dom.js'; @@ -193,7 +193,7 @@ _ol_source_Zoomify_.Tile_.prototype.getImage = function() { return this.zoomifyImage_; } var image = _ol_ImageTile_.prototype.getImage.call(this); - if (this.state == _ol_TileState_.LOADED) { + if (this.state == TileState.LOADED) { var tileSize = this.tileSize_; if (image.width == tileSize[0] && image.height == tileSize[1]) { this.zoomifyImage_ = image; diff --git a/test/rendering/ol/reproj/tile.test.js b/test/rendering/ol/reproj/tile.test.js index 6d9a397cfb..410df98ea5 100644 --- a/test/rendering/ol/reproj/tile.test.js +++ b/test/rendering/ol/reproj/tile.test.js @@ -1,4 +1,4 @@ -import _ol_TileState_ from '../../../../src/ol/TileState.js'; +import TileState from '../../../../src/ol/TileState.js'; import _ol_events_ from '../../../../src/ol/events.js'; import {get as getProjection} from '../../../../src/ol/proj.js'; import _ol_reproj_Tile_ from '../../../../src/ol/reproj/Tile.js'; @@ -23,9 +23,9 @@ describe('ol.rendering.reproj.Tile', function() { tilesRequested++; return source.getTile(z, x, y, pixelRatio, sourceProjection); }); - if (tile.getState() == _ol_TileState_.IDLE) { + if (tile.getState() == TileState.IDLE) { _ol_events_.listen(tile, 'change', function(e) { - if (tile.getState() == _ol_TileState_.LOADED) { + if (tile.getState() == TileState.LOADED) { expect(tilesRequested).to.be(expectedRequests); resembleCanvas(tile.getImage(), expectedUrl, 7.5, done); } diff --git a/test/spec/ol/imagetile.test.js b/test/spec/ol/imagetile.test.js index c9ce657052..e355e0fb95 100644 --- a/test/spec/ol/imagetile.test.js +++ b/test/spec/ol/imagetile.test.js @@ -1,5 +1,5 @@ import _ol_ImageTile_ from '../../../src/ol/ImageTile.js'; -import _ol_TileState_ from '../../../src/ol/TileState.js'; +import TileState from '../../../src/ol/TileState.js'; import _ol_events_ from '../../../src/ol/events.js'; import EventType from '../../../src/ol/events/EventType.js'; import _ol_source_Image_ from '../../../src/ol/source/Image.js'; @@ -11,7 +11,7 @@ describe('ol.ImageTile', function() { it('can load idle tile', function(done) { var tileCoord = [0, 0, 0]; - var state = _ol_TileState_.IDLE; + var state = TileState.IDLE; var src = 'spec/ol/data/osm-0-0-0.png'; var tileLoadFunction = _ol_source_Image_.defaultImageLoadFunction; var tile = new _ol_ImageTile_(tileCoord, state, src, null, tileLoadFunction); @@ -20,10 +20,10 @@ describe('ol.ImageTile', function() { _ol_events_.listen(tile, EventType.CHANGE, function(event) { var state = tile.getState(); - if (previousState == _ol_TileState_.IDLE) { - expect(state).to.be(_ol_TileState_.LOADING); - } else if (previousState == _ol_TileState_.LOADING) { - expect(state).to.be(_ol_TileState_.LOADED); + if (previousState == TileState.IDLE) { + expect(state).to.be(TileState.LOADING); + } else if (previousState == TileState.LOADING) { + expect(state).to.be(TileState.LOADED); done(); } else { expect().fail(); @@ -36,7 +36,7 @@ describe('ol.ImageTile', function() { it('can load error tile', function(done) { var tileCoord = [0, 0, 0]; - var state = _ol_TileState_.ERROR; + var state = TileState.ERROR; var src = 'spec/ol/data/osm-0-0-0.png'; var tileLoadFunction = _ol_source_Image_.defaultImageLoadFunction; var tile = new _ol_ImageTile_(tileCoord, state, src, null, tileLoadFunction); @@ -45,10 +45,10 @@ describe('ol.ImageTile', function() { _ol_events_.listen(tile, EventType.CHANGE, function(event) { var state = tile.getState(); - if (previousState == _ol_TileState_.ERROR) { - expect(state).to.be(_ol_TileState_.LOADING); - } else if (previousState == _ol_TileState_.LOADING) { - expect(state).to.be(_ol_TileState_.LOADED); + if (previousState == TileState.ERROR) { + expect(state).to.be(TileState.LOADING); + } else if (previousState == TileState.LOADING) { + expect(state).to.be(TileState.LOADED); done(); } else { expect().fail(); @@ -61,15 +61,15 @@ describe('ol.ImageTile', function() { it('loads an empty image on error ', function(done) { var tileCoord = [0, 0, 0]; - var state = _ol_TileState_.IDLE; + var state = TileState.IDLE; var src = 'spec/ol/data/osm-0-0-99.png'; var tileLoadFunction = _ol_source_Image_.defaultImageLoadFunction; var tile = new _ol_ImageTile_(tileCoord, state, src, null, tileLoadFunction); var key = _ol_events_.listen(tile, EventType.CHANGE, function(event) { var state = tile.getState(); - if (state == _ol_TileState_.ERROR) { - expect(state).to.be(_ol_TileState_.ERROR); + if (state == TileState.ERROR) { + expect(state).to.be(TileState.ERROR); expect(tile.image_).to.be.a(HTMLCanvasElement); _ol_events_.unlistenByKey(key); tile.load(); @@ -87,14 +87,14 @@ describe('ol.ImageTile', function() { it('sets image src to a blank image data uri', function() { var tileCoord = [0, 0, 0]; - var state = _ol_TileState_.IDLE; + var state = TileState.IDLE; var src = 'spec/ol/data/osm-0-0-0.png'; var tileLoadFunction = _ol_source_Image_.defaultImageLoadFunction; var tile = new _ol_ImageTile_(tileCoord, state, src, null, tileLoadFunction); tile.load(); - expect(tile.getState()).to.be(_ol_TileState_.LOADING); + expect(tile.getState()).to.be(TileState.LOADING); tile.dispose(); - expect(tile.getState()).to.be(_ol_TileState_.ABORT); + expect(tile.getState()).to.be(TileState.ABORT); expect(tile.getImage().src).to.be(_ol_ImageTile_.blankImageUrl); }); diff --git a/test/spec/ol/renderer/canvas/vectortilelayer.test.js b/test/spec/ol/renderer/canvas/vectortilelayer.test.js index 46163d858e..0af058c4c5 100644 --- a/test/spec/ol/renderer/canvas/vectortilelayer.test.js +++ b/test/spec/ol/renderer/canvas/vectortilelayer.test.js @@ -2,7 +2,7 @@ import {getUid, inherits} from '../../../../../src/ol/index.js'; import _ol_obj_ from '../../../../../src/ol/obj.js'; import _ol_Feature_ from '../../../../../src/ol/Feature.js'; import Map from '../../../../../src/ol/Map.js'; -import _ol_TileState_ from '../../../../../src/ol/TileState.js'; +import TileState from '../../../../../src/ol/TileState.js'; import _ol_VectorImageTile_ from '../../../../../src/ol/VectorImageTile.js'; import _ol_VectorTile_ from '../../../../../src/ol/VectorTile.js'; import _ol_View_ from '../../../../../src/ol/View.js'; @@ -74,7 +74,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() { }); source.getTile = function() { var tile = _ol_source_VectorTile_.prototype.getTile.apply(source, arguments); - tile.setState(_ol_TileState_.LOADED); + tile.setState(TileState.LOADED); return tile; }; layer = new _ol_layer_VectorTile_({ @@ -254,7 +254,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() { var tile = new _ol_VectorImageTile_([0, 0, 0]); tile.transition_ = 0; tile.wrappedTileCoord = [0, 0, 0]; - tile.setState(_ol_TileState_.LOADED); + tile.setState(TileState.LOADED); tile.getSourceTile = function() { return sourceTile; }; diff --git a/test/spec/ol/source/raster.test.js b/test/spec/ol/source/raster.test.js index 02f9726123..7436923872 100644 --- a/test/spec/ol/source/raster.test.js +++ b/test/spec/ol/source/raster.test.js @@ -1,5 +1,5 @@ import Map from '../../../../src/ol/Map.js'; -import _ol_TileState_ from '../../../../src/ol/TileState.js'; +import TileState from '../../../../src/ol/TileState.js'; import _ol_View_ from '../../../../src/ol/View.js'; import _ol_layer_Image_ from '../../../../src/ol/layer/Image.js'; import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js'; @@ -343,7 +343,7 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() { map2.once('moveend', function() { expect(tileCache.getCount()).to.equal(1); var state = tileCache.peekLast().getState(); - expect(state === _ol_TileState_.LOADED || state === _ol_TileState_.LOADED).to.be(true); + expect(state === TileState.LOADED || state === TileState.LOADED).to.be(true); done(); }); diff --git a/test/spec/ol/source/tileimage.test.js b/test/spec/ol/source/tileimage.test.js index fc6c9c90d2..b1f6abe85f 100644 --- a/test/spec/ol/source/tileimage.test.js +++ b/test/spec/ol/source/tileimage.test.js @@ -1,5 +1,5 @@ import _ol_ImageTile_ from '../../../../src/ol/ImageTile.js'; -import _ol_TileState_ from '../../../../src/ol/TileState.js'; +import TileState from '../../../../src/ol/TileState.js'; import {createFromTemplate} from '../../../../src/ol/tileurlfunction.js'; import _ol_events_ from '../../../../src/ol/events.js'; import {addCommon, clearAllProjections, get as getProjection} from '../../../../src/ol/proj.js'; @@ -188,7 +188,7 @@ describe('ol.source.TileImage', function() { it('dispatches tileloadstart and tileloadend events', function() { source.setTileLoadFunction(function(tile) { - tile.setState(_ol_TileState_.LOADED); + tile.setState(TileState.LOADED); }); var startSpy = sinon.spy(); source.on('tileloadstart', startSpy); @@ -203,15 +203,15 @@ describe('ol.source.TileImage', function() { it('works for loading-error-loading-loaded sequences', function(done) { source.setTileLoadFunction(function(tile) { tile.setState( - tile.state == _ol_TileState_.ERROR ? _ol_TileState_.LOADED : _ol_TileState_.ERROR); + tile.state == TileState.ERROR ? TileState.LOADED : TileState.ERROR); }); var startSpy = sinon.spy(); source.on('tileloadstart', startSpy); var errorSpy = sinon.spy(); source.on('tileloaderror', function(e) { setTimeout(function() { - e.tile.setState(_ol_TileState_.LOADING); - e.tile.setState(_ol_TileState_.LOADED); + e.tile.setState(TileState.LOADING); + e.tile.setState(TileState.LOADED); }, 0); errorSpy(); }); diff --git a/test/spec/ol/tile.test.js b/test/spec/ol/tile.test.js index 7c796392cb..c2ac4b3eb5 100644 --- a/test/spec/ol/tile.test.js +++ b/test/spec/ol/tile.test.js @@ -1,21 +1,21 @@ import {getUid} from '../../../src/ol/index.js'; import _ol_ImageTile_ from '../../../src/ol/ImageTile.js'; import _ol_Tile_ from '../../../src/ol/Tile.js'; -import _ol_TileState_ from '../../../src/ol/TileState.js'; +import TileState from '../../../src/ol/TileState.js'; describe('ol.Tile', function() { describe('constructor', function() { it('sets a default transition', function() { var coord = [0, 0, 0]; - var tile = new _ol_Tile_(coord, _ol_TileState_.IDLE); + var tile = new _ol_Tile_(coord, TileState.IDLE); expect(tile.transition_).to.equal(250); }); it('allows the transition to be set', function() { var coord = [0, 0, 0]; var transition = 500; - var tile = new _ol_Tile_(coord, _ol_TileState_.IDLE, {transition: transition}); + var tile = new _ol_Tile_(coord, TileState.IDLE, {transition: transition}); expect(tile.transition_).to.equal(transition); }); }); @@ -23,7 +23,7 @@ describe('ol.Tile', function() { describe('#getAlpha()', function() { it('returns the alpha value for a tile in transition', function() { var coord = [0, 0, 0]; - var tile = new _ol_Tile_(coord, _ol_TileState_.IDLE); + var tile = new _ol_Tile_(coord, TileState.IDLE); var id = 'test'; var time = Date.now(); @@ -45,7 +45,7 @@ describe('ol.Tile', function() { describe('#inTransition()', function() { it('determines if the tile is in transition', function() { var coord = [0, 0, 0]; - var tile = new _ol_Tile_(coord, _ol_TileState_.IDLE); + var tile = new _ol_Tile_(coord, TileState.IDLE); var id = 'test'; expect(tile.inTransition(id)).to.be(true); @@ -58,7 +58,7 @@ describe('ol.Tile', function() { var head, renderTile; beforeEach(function() { var tileCoord = [0, 0, 0]; - head = new _ol_ImageTile_(tileCoord, _ol_TileState_.IDLE); + head = new _ol_ImageTile_(tileCoord, TileState.IDLE); getUid(head); var addToChain = function(tile, state) { @@ -67,15 +67,15 @@ describe('ol.Tile', function() { tile.interimTile = next; return next; }; - var tail = addToChain(head, _ol_TileState_.IDLE); //discard, deprecated by head - tail = addToChain(tail, _ol_TileState_.LOADING); //keep, request already going - tail = addToChain(tail, _ol_TileState_.IDLE); //discard, deprecated by head - tail = addToChain(tail, _ol_TileState_.LOADED); //keep, use for rendering + var tail = addToChain(head, TileState.IDLE); //discard, deprecated by head + tail = addToChain(tail, TileState.LOADING); //keep, request already going + tail = addToChain(tail, TileState.IDLE); //discard, deprecated by head + tail = addToChain(tail, TileState.LOADED); //keep, use for rendering renderTile = tail; //store this tile for later tests - tail = addToChain(tail, _ol_TileState_.IDLE); //rest of list outdated by tile above - tail = addToChain(tail, _ol_TileState_.LOADED); - tail = addToChain(tail, _ol_TileState_.LOADING); - tail = addToChain(tail, _ol_TileState_.LOADED); + tail = addToChain(tail, TileState.IDLE); //rest of list outdated by tile above + tail = addToChain(tail, TileState.LOADED); + tail = addToChain(tail, TileState.LOADING); + tail = addToChain(tail, TileState.LOADED); }); diff --git a/test/spec/ol/tilequeue.test.js b/test/spec/ol/tilequeue.test.js index 07b654d368..9be9c7bcab 100644 --- a/test/spec/ol/tilequeue.test.js +++ b/test/spec/ol/tilequeue.test.js @@ -1,7 +1,7 @@ import _ol_ImageTile_ from '../../../src/ol/ImageTile.js'; import _ol_Tile_ from '../../../src/ol/Tile.js'; import TileQueue from '../../../src/ol/TileQueue.js'; -import _ol_TileState_ from '../../../src/ol/TileState.js'; +import TileState from '../../../src/ol/TileState.js'; import _ol_source_Image_ from '../../../src/ol/source/Image.js'; import PriorityQueue from '../../../src/ol/structs/PriorityQueue.js'; @@ -95,7 +95,7 @@ describe('ol.TileQueue', function() { var numTiles = 20; for (var i = 0; i < numTiles; ++i) { var tile = createImageTile(); - tile.state = _ol_TileState_.ABORT; + tile.state = TileState.ABORT; queue.enqueue([tile]); } var maxLoading = numTiles / 2; diff --git a/test/spec/ol/vectorimagetile.test.js b/test/spec/ol/vectorimagetile.test.js index 4e88bb3e1e..4ae70f4184 100644 --- a/test/spec/ol/vectorimagetile.test.js +++ b/test/spec/ol/vectorimagetile.test.js @@ -1,4 +1,4 @@ -import _ol_TileState_ from '../../../src/ol/TileState.js'; +import TileState from '../../../src/ol/TileState.js'; import _ol_VectorImageTile_ from '../../../src/ol/VectorImageTile.js'; import _ol_VectorTile_ from '../../../src/ol/VectorTile.js'; import _ol_events_ from '../../../src/ol/events.js'; @@ -47,12 +47,12 @@ describe('ol.VectorImageTile', function() { var calls = 0; _ol_events_.listen(tile, 'change', function(e) { ++calls; - expect(tile.getState()).to.be(calls == 2 ? _ol_TileState_.LOADED : _ol_TileState_.ERROR); + expect(tile.getState()).to.be(calls == 2 ? TileState.LOADED : TileState.ERROR); if (calls == 2) { done(); } else { setTimeout(function() { - sourceTile.setState(_ol_TileState_.LOADED); + sourceTile.setState(TileState.LOADED); }, 0); } }); @@ -70,7 +70,7 @@ describe('ol.VectorImageTile', function() { tile.load(); _ol_events_.listen(tile, 'change', function(e) { - expect(tile.getState()).to.be(_ol_TileState_.ERROR); + expect(tile.getState()).to.be(TileState.ERROR); done(); }); }); @@ -86,7 +86,7 @@ describe('ol.VectorImageTile', function() { tile.load(); _ol_events_.listen(tile, 'change', function() { - expect(tile.getState()).to.be(_ol_TileState_.EMPTY); + expect(tile.getState()).to.be(TileState.EMPTY); done(); }); }); @@ -123,12 +123,12 @@ describe('ol.VectorImageTile', function() { tile.load(); expect(tile.loadListenerKeys_.length).to.be(4); expect(tile.tileKeys.length).to.be(4); - expect(tile.getState()).to.be(_ol_TileState_.LOADING); + expect(tile.getState()).to.be(TileState.LOADING); tile.dispose(); expect(tile.loadListenerKeys_.length).to.be(0); expect(tile.tileKeys.length).to.be(0); expect(tile.sourceTiles_).to.be(null); - expect(tile.getState()).to.be(_ol_TileState_.ABORT); + expect(tile.getState()).to.be(TileState.ABORT); }); it('#dispose() when loaded', function(done) { @@ -142,13 +142,13 @@ describe('ol.VectorImageTile', function() { tile.load(); _ol_events_.listenOnce(tile, 'change', function() { - expect(tile.getState()).to.be(_ol_TileState_.LOADED); + expect(tile.getState()).to.be(TileState.LOADED); expect(tile.loadListenerKeys_.length).to.be(0); expect(tile.tileKeys.length).to.be(4); tile.dispose(); expect(tile.tileKeys.length).to.be(0); expect(tile.sourceTiles_).to.be(null); - expect(tile.getState()).to.be(_ol_TileState_.ABORT); + expect(tile.getState()).to.be(TileState.ABORT); done(); }); });