Rename _ol_TileState_ to TileState

This commit is contained in:
Frederic Junod
2017-12-22 09:00:46 +01:00
parent 2130ce7481
commit fc00aecd2e
25 changed files with 159 additions and 159 deletions

View File

@@ -3,7 +3,7 @@
*/ */
import {inherits} from './index.js'; import {inherits} from './index.js';
import _ol_Tile_ from './Tile.js'; import _ol_Tile_ from './Tile.js';
import _ol_TileState_ from './TileState.js'; import TileState from './TileState.js';
import {createCanvasContext2D} from './dom.js'; import {createCanvasContext2D} from './dom.js';
import _ol_events_ from './events.js'; import _ol_events_ from './events.js';
import EventType from './events/EventType.js'; import EventType from './events/EventType.js';
@@ -66,14 +66,14 @@ inherits(_ol_ImageTile_, _ol_Tile_);
* @inheritDoc * @inheritDoc
*/ */
_ol_ImageTile_.prototype.disposeInternal = function() { _ol_ImageTile_.prototype.disposeInternal = function() {
if (this.state == _ol_TileState_.LOADING) { if (this.state == TileState.LOADING) {
this.unlistenImage_(); this.unlistenImage_();
this.image_ = _ol_ImageTile_.getBlankImage(); this.image_ = _ol_ImageTile_.getBlankImage();
} }
if (this.interimTile) { if (this.interimTile) {
this.interimTile.dispose(); this.interimTile.dispose();
} }
this.state = _ol_TileState_.ABORT; this.state = TileState.ABORT;
this.changed(); this.changed();
_ol_Tile_.prototype.disposeInternal.call(this); _ol_Tile_.prototype.disposeInternal.call(this);
}; };
@@ -103,7 +103,7 @@ _ol_ImageTile_.prototype.getKey = function() {
* @private * @private
*/ */
_ol_ImageTile_.prototype.handleImageError_ = function() { _ol_ImageTile_.prototype.handleImageError_ = function() {
this.state = _ol_TileState_.ERROR; this.state = TileState.ERROR;
this.unlistenImage_(); this.unlistenImage_();
this.image_ = _ol_ImageTile_.getBlankImage(); this.image_ = _ol_ImageTile_.getBlankImage();
this.changed(); this.changed();
@@ -117,9 +117,9 @@ _ol_ImageTile_.prototype.handleImageError_ = function() {
*/ */
_ol_ImageTile_.prototype.handleImageLoad_ = function() { _ol_ImageTile_.prototype.handleImageLoad_ = function() {
if (this.image_.naturalWidth && this.image_.naturalHeight) { if (this.image_.naturalWidth && this.image_.naturalHeight) {
this.state = _ol_TileState_.LOADED; this.state = TileState.LOADED;
} else { } else {
this.state = _ol_TileState_.EMPTY; this.state = TileState.EMPTY;
} }
this.unlistenImage_(); this.unlistenImage_();
this.changed(); this.changed();
@@ -131,15 +131,15 @@ _ol_ImageTile_.prototype.handleImageLoad_ = function() {
* @api * @api
*/ */
_ol_ImageTile_.prototype.load = function() { _ol_ImageTile_.prototype.load = function() {
if (this.state == _ol_TileState_.ERROR) { if (this.state == TileState.ERROR) {
this.state = _ol_TileState_.IDLE; this.state = TileState.IDLE;
this.image_ = new Image(); this.image_ = new Image();
if (this.crossOrigin_ !== null) { if (this.crossOrigin_ !== null) {
this.image_.crossOrigin = this.crossOrigin_; this.image_.crossOrigin = this.crossOrigin_;
} }
} }
if (this.state == _ol_TileState_.IDLE) { if (this.state == TileState.IDLE) {
this.state = _ol_TileState_.LOADING; this.state = TileState.LOADING;
this.changed(); this.changed();
this.imageListenerKeys_ = [ this.imageListenerKeys_ = [
_ol_events_.listenOnce(this.image_, EventType.ERROR, _ol_events_.listenOnce(this.image_, EventType.ERROR,

View File

@@ -2,7 +2,7 @@
* @module ol/Tile * @module ol/Tile
*/ */
import {inherits} from './index.js'; import {inherits} from './index.js';
import _ol_TileState_ from './TileState.js'; import TileState from './TileState.js';
import {easeIn} from './easing.js'; import {easeIn} from './easing.js';
import EventTarget from './events/EventTarget.js'; import EventTarget from './events/EventTarget.js';
import EventType from './events/EventType.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 // of the list (all those tiles correspond to older requests and will be
// cleaned up by refreshInterimChain) // cleaned up by refreshInterimChain)
do { do {
if (tile.getState() == _ol_TileState_.LOADED) { if (tile.getState() == TileState.LOADED) {
return tile; return tile;
} }
tile = tile.interimTile; tile = tile.interimTile;
@@ -125,17 +125,17 @@ _ol_Tile_.prototype.refreshInterimChain = function() {
var prev = this; var prev = this;
do { 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 have a loaded tile, we can discard the rest of the list
//we would could abort any LOADING tile request //we would could abort any LOADING tile request
//older than this tile (i.e. any LOADING tile following this entry in the chain) //older than this tile (i.e. any LOADING tile following this entry in the chain)
tile.interimTile = null; tile.interimTile = null;
break; 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 //keep this LOADING tile any loaded tiles later in the chain are
//older than this tile, so we're still interested in the request //older than this tile, so we're still interested in the request
prev = tile; 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 //the head of the list is the most current tile, we don't need
//to start any other requests for this chain //to start any other requests for this chain
prev.interimTile = tile.interimTile; prev.interimTile = tile.interimTile;

View File

@@ -2,7 +2,7 @@
* @module ol/TileQueue * @module ol/TileQueue
*/ */
import {inherits} from './index.js'; import {inherits} from './index.js';
import _ol_TileState_ from './TileState.js'; import TileState from './TileState.js';
import _ol_events_ from './events.js'; import _ol_events_ from './events.js';
import EventType from './events/EventType.js'; import EventType from './events/EventType.js';
import PriorityQueue from './structs/PriorityQueue.js'; import PriorityQueue from './structs/PriorityQueue.js';
@@ -87,8 +87,8 @@ TileQueue.prototype.getTilesLoading = function() {
TileQueue.prototype.handleTileChange = function(event) { TileQueue.prototype.handleTileChange = function(event) {
var tile = /** @type {ol.Tile} */ (event.target); var tile = /** @type {ol.Tile} */ (event.target);
var state = tile.getState(); var state = tile.getState();
if (state === _ol_TileState_.LOADED || state === _ol_TileState_.ERROR || if (state === TileState.LOADED || state === TileState.ERROR ||
state === _ol_TileState_.EMPTY || state === _ol_TileState_.ABORT) { state === TileState.EMPTY || state === TileState.ABORT) {
_ol_events_.unlisten(tile, EventType.CHANGE, _ol_events_.unlisten(tile, EventType.CHANGE,
this.handleTileChange, this); this.handleTileChange, this);
var tileKey = tile.getKey(); var tileKey = tile.getKey();
@@ -114,9 +114,9 @@ TileQueue.prototype.loadMoreTiles = function(maxTotalLoading, maxNewLoads) {
tile = /** @type {ol.Tile} */ (this.dequeue()[0]); tile = /** @type {ol.Tile} */ (this.dequeue()[0]);
tileKey = tile.getKey(); tileKey = tile.getKey();
state = tile.getState(); state = tile.getState();
if (state === _ol_TileState_.ABORT) { if (state === TileState.ABORT) {
abortedTiles = true; 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.tilesLoadingKeys_[tileKey] = true;
++this.tilesLoading_; ++this.tilesLoading_;
++newLoads; ++newLoads;

View File

@@ -3,7 +3,7 @@
*/ */
import {getUid, inherits} from './index.js'; import {getUid, inherits} from './index.js';
import _ol_Tile_ from './Tile.js'; import _ol_Tile_ from './Tile.js';
import _ol_TileState_ from './TileState.js'; import TileState from './TileState.js';
import {createCanvasContext2D} from './dom.js'; import {createCanvasContext2D} from './dom.js';
import _ol_events_ from './events.js'; import _ol_events_ from './events.js';
import {getHeight, getIntersection, getWidth} from './extent.js'; import {getHeight, getIntersection, getWidth} from './extent.js';
@@ -107,7 +107,7 @@ var _ol_VectorImageTile_ = function(tileCoord, state, sourceRevision, format,
if (!sourceTile) { if (!sourceTile) {
var tileUrl = tileUrlFunction(sourceTileCoord, pixelRatio, projection); var tileUrl = tileUrlFunction(sourceTileCoord, pixelRatio, projection);
sourceTile = sourceTiles[sourceTileKey] = new tileClass(sourceTileCoord, sourceTile = sourceTiles[sourceTileKey] = new tileClass(sourceTileCoord,
tileUrl == undefined ? _ol_TileState_.EMPTY : _ol_TileState_.IDLE, tileUrl == undefined ? TileState.EMPTY : TileState.IDLE,
tileUrl == undefined ? '' : tileUrl, tileUrl == undefined ? '' : tileUrl,
format, tileLoadFunction); format, tileLoadFunction);
this.sourceTileListenerKeys_.push( this.sourceTileListenerKeys_.push(
@@ -128,7 +128,7 @@ inherits(_ol_VectorImageTile_, _ol_Tile_);
* @inheritDoc * @inheritDoc
*/ */
_ol_VectorImageTile_.prototype.disposeInternal = function() { _ol_VectorImageTile_.prototype.disposeInternal = function() {
this.state = _ol_TileState_.ABORT; this.state = TileState.ABORT;
this.changed(); this.changed();
if (this.interimTile) { if (this.interimTile) {
this.interimTile.dispose(); this.interimTile.dispose();
@@ -223,23 +223,23 @@ _ol_VectorImageTile_.prototype.load = function() {
// an ERROR state after another load attempt. // an ERROR state after another load attempt.
var errorSourceTiles = {}; var errorSourceTiles = {};
if (this.state == _ol_TileState_.IDLE) { if (this.state == TileState.IDLE) {
this.setState(_ol_TileState_.LOADING); this.setState(TileState.LOADING);
} }
if (this.state == _ol_TileState_.LOADING) { if (this.state == TileState.LOADING) {
this.tileKeys.forEach(function(sourceTileKey) { this.tileKeys.forEach(function(sourceTileKey) {
var sourceTile = this.getTile(sourceTileKey); var sourceTile = this.getTile(sourceTileKey);
if (sourceTile.state == _ol_TileState_.IDLE) { if (sourceTile.state == TileState.IDLE) {
sourceTile.setLoader(this.loader_); sourceTile.setLoader(this.loader_);
sourceTile.load(); sourceTile.load();
} }
if (sourceTile.state == _ol_TileState_.LOADING) { if (sourceTile.state == TileState.LOADING) {
var key = _ol_events_.listen(sourceTile, EventType.CHANGE, function(e) { var key = _ol_events_.listen(sourceTile, EventType.CHANGE, function(e) {
var state = sourceTile.getState(); var state = sourceTile.getState();
if (state == _ol_TileState_.LOADED || if (state == TileState.LOADED ||
state == _ol_TileState_.ERROR) { state == TileState.ERROR) {
var uid = getUid(sourceTile); var uid = getUid(sourceTile);
if (state == _ol_TileState_.ERROR) { if (state == TileState.ERROR) {
errorSourceTiles[uid] = true; errorSourceTiles[uid] = true;
} else { } else {
--leftToLoad; --leftToLoad;
@@ -269,19 +269,19 @@ _ol_VectorImageTile_.prototype.finishLoading_ = function() {
var empty = 0; var empty = 0;
for (var i = loaded - 1; i >= 0; --i) { for (var i = loaded - 1; i >= 0; --i) {
var state = this.getTile(this.tileKeys[i]).getState(); var state = this.getTile(this.tileKeys[i]).getState();
if (state != _ol_TileState_.LOADED) { if (state != TileState.LOADED) {
--loaded; --loaded;
} }
if (state == _ol_TileState_.EMPTY) { if (state == TileState.EMPTY) {
++empty; ++empty;
} }
} }
if (loaded == this.tileKeys.length) { if (loaded == this.tileKeys.length) {
this.loadListenerKeys_.forEach(_ol_events_.unlistenByKey); this.loadListenerKeys_.forEach(_ol_events_.unlistenByKey);
this.loadListenerKeys_.length = 0; this.loadListenerKeys_.length = 0;
this.setState(_ol_TileState_.LOADED); this.setState(TileState.LOADED);
} else { } else {
this.setState(empty == this.tileKeys.length ? _ol_TileState_.EMPTY : _ol_TileState_.ERROR); this.setState(empty == this.tileKeys.length ? TileState.EMPTY : TileState.ERROR);
} }
}; };

View File

@@ -3,7 +3,7 @@
*/ */
import {getUid, inherits} from './index.js'; import {getUid, inherits} from './index.js';
import _ol_Tile_ from './Tile.js'; import _ol_Tile_ from './Tile.js';
import _ol_TileState_ from './TileState.js'; import TileState from './TileState.js';
/** /**
* @constructor * @constructor
@@ -84,7 +84,7 @@ inherits(_ol_VectorTile_, _ol_Tile_);
_ol_VectorTile_.prototype.disposeInternal = function() { _ol_VectorTile_.prototype.disposeInternal = function() {
this.features_ = null; this.features_ = null;
this.replayGroups_ = {}; this.replayGroups_ = {};
this.state = _ol_TileState_.ABORT; this.state = TileState.ABORT;
this.changed(); this.changed();
_ol_Tile_.prototype.disposeInternal.call(this); _ol_Tile_.prototype.disposeInternal.call(this);
}; };
@@ -154,8 +154,8 @@ _ol_VectorTile_.prototype.getReplayGroup = function(layer, key) {
* @inheritDoc * @inheritDoc
*/ */
_ol_VectorTile_.prototype.load = function() { _ol_VectorTile_.prototype.load = function() {
if (this.state == _ol_TileState_.IDLE) { if (this.state == TileState.IDLE) {
this.setState(_ol_TileState_.LOADING); this.setState(TileState.LOADING);
this.tileLoadFunction_(this, this.url_); this.tileLoadFunction_(this, this.url_);
this.loader_(null, NaN, null); this.loader_(null, NaN, null);
} }
@@ -179,7 +179,7 @@ _ol_VectorTile_.prototype.onLoad = function(features, dataProjection, extent) {
* Handler for tile load errors. * Handler for tile load errors.
*/ */
_ol_VectorTile_.prototype.onError = function() { _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) { _ol_VectorTile_.prototype.setFeatures = function(features) {
this.features_ = features; this.features_ = features;
this.setState(_ol_TileState_.LOADED); this.setState(TileState.LOADED);
}; };

View File

@@ -4,7 +4,7 @@
import {getUid, inherits, nullFunction} from '../index.js'; import {getUid, inherits, nullFunction} from '../index.js';
import ImageState from '../ImageState.js'; import ImageState from '../ImageState.js';
import _ol_Observable_ from '../Observable.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 _ol_events_ from '../events.js';
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
import {FALSE} from '../functions.js'; import {FALSE} from '../functions.js';
@@ -225,7 +225,7 @@ _ol_renderer_Layer_.prototype.manageTilePyramid = function(
for (y = tileRange.minY; y <= tileRange.maxY; ++y) { for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
if (currentZ - z <= preload) { if (currentZ - z <= preload) {
tile = tileSource.getTile(z, x, y, pixelRatio, projection); tile = tileSource.getTile(z, x, y, pixelRatio, projection);
if (tile.getState() == _ol_TileState_.IDLE) { if (tile.getState() == TileState.IDLE) {
wantedTiles[tile.getKey()] = true; wantedTiles[tile.getKey()] = true;
if (!tileQueue.isKeyQueued(tile.getKey())) { if (!tileQueue.isKeyQueued(tile.getKey())) {
tileQueue.enqueue([tile, tileSourceKey, tileQueue.enqueue([tile, tileSourceKey,

View File

@@ -4,7 +4,7 @@
import {getUid, inherits} from '../../index.js'; import {getUid, inherits} from '../../index.js';
import LayerType from '../../LayerType.js'; import LayerType from '../../LayerType.js';
import TileRange from '../../TileRange.js'; import TileRange from '../../TileRange.js';
import _ol_TileState_ from '../../TileState.js'; import TileState from '../../TileState.js';
import _ol_ViewHint_ from '../../ViewHint.js'; import _ol_ViewHint_ from '../../ViewHint.js';
import {createCanvasContext2D} from '../../dom.js'; import {createCanvasContext2D} from '../../dom.js';
import {containsExtent, createEmpty, equals, getIntersection, isEmpty} from '../../extent.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) { _ol_renderer_canvas_TileLayer_.prototype.isDrawableTile_ = function(tile) {
var tileState = tile.getState(); var tileState = tile.getState();
var useInterimTilesOnError = this.getLayer().getUseInterimTilesOnError(); var useInterimTilesOnError = this.getLayer().getUseInterimTilesOnError();
return tileState == _ol_TileState_.LOADED || return tileState == TileState.LOADED ||
tileState == _ol_TileState_.EMPTY || tileState == TileState.EMPTY ||
tileState == _ol_TileState_.ERROR && !useInterimTilesOnError; 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 (x = tileRange.minX; x <= tileRange.maxX; ++x) {
for (y = tileRange.minY; y <= tileRange.maxY; ++y) { for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
tile = tileSource.getTile(z, x, y, pixelRatio, projection); tile = tileSource.getTile(z, x, y, pixelRatio, projection);
if (tile.getState() == _ol_TileState_.ERROR) { if (tile.getState() == TileState.ERROR) {
if (!tileLayer.getUseInterimTilesOnError()) { if (!tileLayer.getUseInterimTilesOnError()) {
// When useInterimTilesOnError is false, we consider the error tile as loaded. // 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) { } else if (tileLayer.getPreload() > 0) {
// Preloaded tiles for lower resolutions might have finished loading. // Preloaded tiles for lower resolutions might have finished loading.
newTiles = true; newTiles = true;
@@ -180,7 +180,7 @@ _ol_renderer_canvas_TileLayer_.prototype.prepareFrame = function(frameState, lay
} }
if (this.isDrawableTile_(tile)) { if (this.isDrawableTile_(tile)) {
var uid = getUid(this); var uid = getUid(this);
if (tile.getState() == _ol_TileState_.LOADED) { if (tile.getState() == TileState.LOADED) {
tilesToDrawByZ[z][tile.tileCoord.toString()] = tile; tilesToDrawByZ[z][tile.tileCoord.toString()] = tile;
var inTransition = tile.inTransition(uid); var inTransition = tile.inTransition(uid);
if (!newTiles && (inTransition || this.renderedTiles.indexOf(tile) === -1)) { if (!newTiles && (inTransition || this.renderedTiles.indexOf(tile) === -1)) {

View File

@@ -3,7 +3,7 @@
*/ */
import {getUid, inherits} from '../../index.js'; import {getUid, inherits} from '../../index.js';
import LayerType from '../../LayerType.js'; import LayerType from '../../LayerType.js';
import _ol_TileState_ from '../../TileState.js'; import TileState from '../../TileState.js';
import {createCanvasContext2D} from '../../dom.js'; import {createCanvasContext2D} from '../../dom.js';
import _ol_events_ from '../../events.js'; import _ol_events_ from '../../events.js';
import EventType from '../../events/EventType.js'; import EventType from '../../events/EventType.js';
@@ -174,7 +174,7 @@ _ol_renderer_canvas_VectorTileLayer_.prototype.createReplayGroup_ = function(
var zIndexKeys = {}; var zIndexKeys = {};
for (var t = 0, tt = tile.tileKeys.length; t < tt; ++t) { for (var t = 0, tt = tile.tileKeys.length; t < tt; ++t) {
var sourceTile = tile.getTile(tile.tileKeys[t]); var sourceTile = tile.getTile(tile.tileKeys[t]);
if (sourceTile.getState() == _ol_TileState_.ERROR) { if (sourceTile.getState() == TileState.ERROR) {
continue; continue;
} }
@@ -292,7 +292,7 @@ _ol_renderer_canvas_VectorTileLayer_.prototype.forEachFeatureAtCoordinate = func
} }
for (var t = 0, tt = tile.tileKeys.length; t < tt; ++t) { for (var t = 0, tt = tile.tileKeys.length; t < tt; ++t) {
var sourceTile = tile.getTile(tile.tileKeys[t]); var sourceTile = tile.getTile(tile.tileKeys[t]);
if (sourceTile.getState() == _ol_TileState_.ERROR) { if (sourceTile.getState() == TileState.ERROR) {
continue; continue;
} }
replayGroup = sourceTile.getReplayGroup(layer, tile.tileCoord.toString()); replayGroup = sourceTile.getReplayGroup(layer, tile.tileCoord.toString());
@@ -393,7 +393,7 @@ _ol_renderer_canvas_VectorTileLayer_.prototype.postCompose = function(context, f
var zs = []; var zs = [];
for (var i = tiles.length - 1; i >= 0; --i) { for (var i = tiles.length - 1; i >= 0; --i) {
var tile = /** @type {ol.VectorImageTile} */ (tiles[i]); var tile = /** @type {ol.VectorImageTile} */ (tiles[i]);
if (tile.getState() == _ol_TileState_.ABORT) { if (tile.getState() == TileState.ABORT) {
continue; continue;
} }
var tileCoord = tile.tileCoord; var tileCoord = tile.tileCoord;
@@ -402,7 +402,7 @@ _ol_renderer_canvas_VectorTileLayer_.prototype.postCompose = function(context, f
var transform = undefined; var transform = undefined;
for (var t = 0, tt = tile.tileKeys.length; t < tt; ++t) { for (var t = 0, tt = tile.tileKeys.length; t < tt; ++t) {
var sourceTile = tile.getTile(tile.tileKeys[t]); var sourceTile = tile.getTile(tile.tileKeys[t]);
if (sourceTile.getState() == _ol_TileState_.ERROR) { if (sourceTile.getState() == TileState.ERROR) {
continue; continue;
} }
var replayGroup = sourceTile.getReplayGroup(layer, tileCoord.toString()); var replayGroup = sourceTile.getReplayGroup(layer, tileCoord.toString());
@@ -507,7 +507,7 @@ _ol_renderer_canvas_VectorTileLayer_.prototype.renderTileImage_ = function(
var tileExtent = tileGrid.getTileCoordExtent(tileCoord); var tileExtent = tileGrid.getTileCoordExtent(tileCoord);
for (var i = 0, ii = tile.tileKeys.length; i < ii; ++i) { for (var i = 0, ii = tile.tileKeys.length; i < ii; ++i) {
var sourceTile = tile.getTile(tile.tileKeys[i]); var sourceTile = tile.getTile(tile.tileKeys[i]);
if (sourceTile.getState() == _ol_TileState_.ERROR) { if (sourceTile.getState() == TileState.ERROR) {
continue; continue;
} }
var pixelScale = pixelRatio / resolution; var pixelScale = pixelRatio / resolution;

View File

@@ -7,7 +7,7 @@
import {inherits} from '../../index.js'; import {inherits} from '../../index.js';
import LayerType from '../../LayerType.js'; import LayerType from '../../LayerType.js';
import TileRange from '../../TileRange.js'; import TileRange from '../../TileRange.js';
import _ol_TileState_ from '../../TileState.js'; import TileState from '../../TileState.js';
import {numberSafeCompareFunction} from '../../array.js'; import {numberSafeCompareFunction} from '../../array.js';
import {createEmpty, intersects} from '../../extent.js'; import {createEmpty, intersects} from '../../extent.js';
import {roundUpToPowerOfTwo} from '../../math.js'; import {roundUpToPowerOfTwo} from '../../math.js';
@@ -262,20 +262,20 @@ _ol_renderer_webgl_TileLayer_.prototype.prepareFrame = function(frameState, laye
} }
} }
tileState = tile.getState(); tileState = tile.getState();
drawable = tileState == _ol_TileState_.LOADED || drawable = tileState == TileState.LOADED ||
tileState == _ol_TileState_.EMPTY || tileState == TileState.EMPTY ||
tileState == _ol_TileState_.ERROR && !useInterimTilesOnError; tileState == TileState.ERROR && !useInterimTilesOnError;
if (!drawable) { if (!drawable) {
tile = tile.getInterimTile(); tile = tile.getInterimTile();
} }
tileState = tile.getState(); tileState = tile.getState();
if (tileState == _ol_TileState_.LOADED) { if (tileState == TileState.LOADED) {
if (mapRenderer.isTileTextureLoaded(tile)) { if (mapRenderer.isTileTextureLoaded(tile)) {
tilesToDrawByZ[z][tile.tileCoord.toString()] = tile; tilesToDrawByZ[z][tile.tileCoord.toString()] = tile;
continue; continue;
} }
} else if (tileState == _ol_TileState_.EMPTY || } else if (tileState == TileState.EMPTY ||
(tileState == _ol_TileState_.ERROR && (tileState == TileState.ERROR &&
!useInterimTilesOnError)) { !useInterimTilesOnError)) {
continue; continue;
} }
@@ -342,7 +342,7 @@ _ol_renderer_webgl_TileLayer_.prototype.prepareFrame = function(frameState, laye
* @param {ol.Tile} tile Tile. * @param {ol.Tile} tile Tile.
*/ */
function(tile) { function(tile) {
if (tile.getState() == _ol_TileState_.LOADED && if (tile.getState() == TileState.LOADED &&
!mapRenderer.isTileTextureLoaded(tile) && !mapRenderer.isTileTextureLoaded(tile) &&
!tileTextureQueue.isKeyQueued(tile.getKey())) { !tileTextureQueue.isKeyQueued(tile.getKey())) {
tileTextureQueue.enqueue([ tileTextureQueue.enqueue([

View File

@@ -4,7 +4,7 @@
import {ERROR_THRESHOLD} from './common.js'; import {ERROR_THRESHOLD} from './common.js';
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import _ol_Tile_ from '../Tile.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 _ol_events_ from '../events.js';
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
import {getArea, getCenter, getIntersection} from '../extent.js'; import {getArea, getCenter, getIntersection} from '../extent.js';
@@ -36,7 +36,7 @@ var _ol_reproj_Tile_ = function(sourceProj, sourceTileGrid,
targetProj, targetTileGrid, tileCoord, wrappedTileCoord, targetProj, targetTileGrid, tileCoord, wrappedTileCoord,
pixelRatio, gutter, getTileFunction, pixelRatio, gutter, getTileFunction,
opt_errorThreshold, opt_renderEdges) { opt_errorThreshold, opt_renderEdges) {
_ol_Tile_.call(this, tileCoord, _ol_TileState_.IDLE); _ol_Tile_.call(this, tileCoord, TileState.IDLE);
/** /**
* @private * @private
@@ -108,7 +108,7 @@ var _ol_reproj_Tile_ = function(sourceProj, sourceTileGrid,
if (getArea(limitedTargetExtent) === 0) { if (getArea(limitedTargetExtent) === 0) {
// Tile is completely outside range -> EMPTY // Tile is completely outside range -> EMPTY
// TODO: is it actually correct that the source even creates the tile ? // TODO: is it actually correct that the source even creates the tile ?
this.state = _ol_TileState_.EMPTY; this.state = TileState.EMPTY;
return; return;
} }
@@ -131,7 +131,7 @@ var _ol_reproj_Tile_ = function(sourceProj, sourceTileGrid,
if (!isFinite(sourceResolution) || sourceResolution <= 0) { if (!isFinite(sourceResolution) || sourceResolution <= 0) {
// invalid sourceResolution -> EMPTY // invalid sourceResolution -> EMPTY
// probably edges of the projections when no extent is defined // probably edges of the projections when no extent is defined
this.state = _ol_TileState_.EMPTY; this.state = TileState.EMPTY;
return; return;
} }
@@ -148,7 +148,7 @@ var _ol_reproj_Tile_ = function(sourceProj, sourceTileGrid,
if (this.triangulation_.getTriangles().length === 0) { if (this.triangulation_.getTriangles().length === 0) {
// no valid triangles -> EMPTY // no valid triangles -> EMPTY
this.state = _ol_TileState_.EMPTY; this.state = TileState.EMPTY;
return; return;
} }
@@ -167,7 +167,7 @@ var _ol_reproj_Tile_ = function(sourceProj, sourceTileGrid,
} }
if (!getArea(sourceExtent)) { if (!getArea(sourceExtent)) {
this.state = _ol_TileState_.EMPTY; this.state = TileState.EMPTY;
} else { } else {
var sourceRange = sourceTileGrid.getTileRangeForExtentAndZ( var sourceRange = sourceTileGrid.getTileRangeForExtentAndZ(
sourceExtent, this.sourceZ_); sourceExtent, this.sourceZ_);
@@ -182,7 +182,7 @@ var _ol_reproj_Tile_ = function(sourceProj, sourceTileGrid,
} }
if (this.sourceTiles_.length === 0) { 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 * @inheritDoc
*/ */
_ol_reproj_Tile_.prototype.disposeInternal = function() { _ol_reproj_Tile_.prototype.disposeInternal = function() {
if (this.state == _ol_TileState_.LOADING) { if (this.state == TileState.LOADING) {
this.unlistenSources_(); this.unlistenSources_();
} }
_ol_Tile_.prototype.disposeInternal.call(this); _ol_Tile_.prototype.disposeInternal.call(this);
@@ -216,7 +216,7 @@ _ol_reproj_Tile_.prototype.getImage = function() {
_ol_reproj_Tile_.prototype.reproject_ = function() { _ol_reproj_Tile_.prototype.reproject_ = function() {
var sources = []; var sources = [];
this.sourceTiles_.forEach(function(tile, i, arr) { this.sourceTiles_.forEach(function(tile, i, arr) {
if (tile && tile.getState() == _ol_TileState_.LOADED) { if (tile && tile.getState() == TileState.LOADED) {
sources.push({ sources.push({
extent: this.sourceTileGrid_.getTileCoordExtent(tile.tileCoord), extent: this.sourceTileGrid_.getTileCoordExtent(tile.tileCoord),
image: tile.getImage() image: tile.getImage()
@@ -226,7 +226,7 @@ _ol_reproj_Tile_.prototype.reproject_ = function() {
this.sourceTiles_.length = 0; this.sourceTiles_.length = 0;
if (sources.length === 0) { if (sources.length === 0) {
this.state = _ol_TileState_.ERROR; this.state = TileState.ERROR;
} else { } else {
var z = this.wrappedTileCoord_[0]; var z = this.wrappedTileCoord_[0];
var size = this.targetTileGrid_.getTileSize(z); var size = this.targetTileGrid_.getTileSize(z);
@@ -242,7 +242,7 @@ _ol_reproj_Tile_.prototype.reproject_ = function() {
targetResolution, targetExtent, this.triangulation_, sources, targetResolution, targetExtent, this.triangulation_, sources,
this.gutter_, this.renderEdges_); this.gutter_, this.renderEdges_);
this.state = _ol_TileState_.LOADED; this.state = TileState.LOADED;
} }
this.changed(); this.changed();
}; };
@@ -252,8 +252,8 @@ _ol_reproj_Tile_.prototype.reproject_ = function() {
* @inheritDoc * @inheritDoc
*/ */
_ol_reproj_Tile_.prototype.load = function() { _ol_reproj_Tile_.prototype.load = function() {
if (this.state == _ol_TileState_.IDLE) { if (this.state == TileState.IDLE) {
this.state = _ol_TileState_.LOADING; this.state = TileState.LOADING;
this.changed(); this.changed();
var leftToLoad = 0; var leftToLoad = 0;
@@ -261,16 +261,16 @@ _ol_reproj_Tile_.prototype.load = function() {
this.sourcesListenerKeys_ = []; this.sourcesListenerKeys_ = [];
this.sourceTiles_.forEach(function(tile, i, arr) { this.sourceTiles_.forEach(function(tile, i, arr) {
var state = tile.getState(); var state = tile.getState();
if (state == _ol_TileState_.IDLE || state == _ol_TileState_.LOADING) { if (state == TileState.IDLE || state == TileState.LOADING) {
leftToLoad++; leftToLoad++;
var sourceListenKey; var sourceListenKey;
sourceListenKey = _ol_events_.listen(tile, EventType.CHANGE, sourceListenKey = _ol_events_.listen(tile, EventType.CHANGE,
function(e) { function(e) {
var state = tile.getState(); var state = tile.getState();
if (state == _ol_TileState_.LOADED || if (state == TileState.LOADED ||
state == _ol_TileState_.ERROR || state == TileState.ERROR ||
state == _ol_TileState_.EMPTY) { state == TileState.EMPTY) {
_ol_events_.unlistenByKey(sourceListenKey); _ol_events_.unlistenByKey(sourceListenKey);
leftToLoad--; leftToLoad--;
if (leftToLoad === 0) { if (leftToLoad === 0) {
@@ -285,7 +285,7 @@ _ol_reproj_Tile_.prototype.load = function() {
this.sourceTiles_.forEach(function(tile, i, arr) { this.sourceTiles_.forEach(function(tile, i, arr) {
var state = tile.getState(); var state = tile.getState();
if (state == _ol_TileState_.IDLE) { if (state == TileState.IDLE) {
tile.load(); tile.load();
} }
}); });

View File

@@ -3,7 +3,7 @@
*/ */
import {inherits, nullFunction} from '../index.js'; import {inherits, nullFunction} from '../index.js';
import TileCache from '../TileCache.js'; import TileCache from '../TileCache.js';
import _ol_TileState_ from '../TileState.js'; import TileState from '../TileState.js';
import Event from '../events/Event.js'; import Event from '../events/Event.js';
import {equivalent} from '../proj.js'; import {equivalent} from '../proj.js';
import _ol_size_ from '../size.js'; import _ol_size_ from '../size.js';
@@ -124,7 +124,7 @@ _ol_source_Tile_.prototype.forEachLoadedTile = function(projection, z, tileRange
loaded = false; loaded = false;
if (tileCache.containsKey(tileCoordKey)) { if (tileCache.containsKey(tileCoordKey)) {
tile = /** @type {!ol.Tile} */ (tileCache.get(tileCoordKey)); tile = /** @type {!ol.Tile} */ (tileCache.get(tileCoordKey));
loaded = tile.getState() === _ol_TileState_.LOADED; loaded = tile.getState() === TileState.LOADED;
if (loaded) { if (loaded) {
loaded = (callback(tile) !== false); loaded = (callback(tile) !== false);
} }

View File

@@ -3,7 +3,7 @@
*/ */
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import _ol_Tile_ from '../Tile.js'; import _ol_Tile_ from '../Tile.js';
import _ol_TileState_ from '../TileState.js'; import TileState from '../TileState.js';
import {createCanvasContext2D} from '../dom.js'; import {createCanvasContext2D} from '../dom.js';
import _ol_size_ from '../size.js'; import _ol_size_ from '../size.js';
import _ol_source_Tile_ from '../source/Tile.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_source_TileDebug_.Tile_ = function(tileCoord, tileSize, text) {
_ol_Tile_.call(this, tileCoord, _ol_TileState_.LOADED); _ol_Tile_.call(this, tileCoord, TileState.LOADED);
/** /**
* @private * @private

View File

@@ -5,7 +5,7 @@ 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 _ol_ImageTile_ from '../ImageTile.js';
import TileCache from '../TileCache.js'; import TileCache from '../TileCache.js';
import _ol_TileState_ from '../TileState.js'; import TileState from '../TileState.js';
import _ol_events_ from '../events.js'; import _ol_events_ from '../events.js';
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
import {equivalent, get as getProjection} from '../proj.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; this.tileUrlFunction(urlTileCoord, pixelRatio, projection) : undefined;
var tile = new this.tileClass( var tile = new this.tileClass(
tileCoord, tileCoord,
tileUrl !== undefined ? _ol_TileState_.IDLE : _ol_TileState_.EMPTY, tileUrl !== undefined ? TileState.IDLE : TileState.EMPTY,
tileUrl !== undefined ? tileUrl : '', tileUrl !== undefined ? tileUrl : '',
this.crossOrigin, this.crossOrigin,
this.tileLoadFunction, 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); tile = this.createTile_(z, x, y, pixelRatio, projection, key);
//make the new tile the head of the list, //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 //the old tile hasn't begun loading yet, and is now outdated, so we can simply discard it
tile.interimTile = interimTile.interimTile; tile.interimTile = interimTile.interimTile;
} else { } else {

View File

@@ -3,7 +3,7 @@
*/ */
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import _ol_Tile_ from '../Tile.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 {createFromTemplates, nullTileUrlFunction} from '../tileurlfunction.js';
import {assert} from '../asserts.js'; import {assert} from '../asserts.js';
import _ol_events_ from '../events.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 tileUrl = this.tileUrlFunction_(urlTileCoord, pixelRatio, projection);
var tile = new _ol_source_TileUTFGrid_.Tile_( var tile = new _ol_source_TileUTFGrid_.Tile_(
tileCoord, tileCoord,
tileUrl !== undefined ? _ol_TileState_.IDLE : _ol_TileState_.EMPTY, tileUrl !== undefined ? TileState.IDLE : TileState.EMPTY,
tileUrl !== undefined ? tileUrl : '', tileUrl !== undefined ? tileUrl : '',
this.tileGrid.getTileCoordExtent(tileCoord), this.tileGrid.getTileCoordExtent(tileCoord),
this.preemptive_, this.preemptive_,
@@ -370,7 +370,7 @@ _ol_source_TileUTFGrid_.Tile_.prototype.getData = function(coordinate) {
* @template T * @template T
*/ */
_ol_source_TileUTFGrid_.Tile_.prototype.forDataAtCoordinate = function(coordinate, callback, opt_this, opt_request) { _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) { _ol_events_.listenOnce(this, EventType.CHANGE, function(e) {
callback.call(opt_this, this.getData(coordinate)); callback.call(opt_this, this.getData(coordinate));
}, this); }, this);
@@ -399,7 +399,7 @@ _ol_source_TileUTFGrid_.Tile_.prototype.getKey = function() {
* @private * @private
*/ */
_ol_source_TileUTFGrid_.Tile_.prototype.handleError_ = function() { _ol_source_TileUTFGrid_.Tile_.prototype.handleError_ = function() {
this.state = _ol_TileState_.ERROR; this.state = TileState.ERROR;
this.changed(); this.changed();
}; };
@@ -413,7 +413,7 @@ _ol_source_TileUTFGrid_.Tile_.prototype.handleLoad_ = function(json) {
this.keys_ = json.keys; this.keys_ = json.keys;
this.data_ = json.data; this.data_ = json.data;
this.state = _ol_TileState_.EMPTY; this.state = TileState.EMPTY;
this.changed(); this.changed();
}; };
@@ -422,8 +422,8 @@ _ol_source_TileUTFGrid_.Tile_.prototype.handleLoad_ = function(json) {
* @private * @private
*/ */
_ol_source_TileUTFGrid_.Tile_.prototype.loadInternal_ = function() { _ol_source_TileUTFGrid_.Tile_.prototype.loadInternal_ = function() {
if (this.state == _ol_TileState_.IDLE) { if (this.state == TileState.IDLE) {
this.state = _ol_TileState_.LOADING; this.state = TileState.LOADING;
if (this.jsonp_) { if (this.jsonp_) {
_ol_net_.jsonp(this.src_, this.handleLoad_.bind(this), _ol_net_.jsonp(this.src_, this.handleLoad_.bind(this),
this.handleError_.bind(this)); this.handleError_.bind(this));

View File

@@ -2,7 +2,7 @@
* @module ol/source/UrlTile * @module ol/source/UrlTile
*/ */
import {getUid, inherits} from '../index.js'; 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 {expandUrl, createFromTemplates, nullTileUrlFunction} from '../tileurlfunction.js';
import _ol_source_Tile_ from '../source/Tile.js'; import _ol_source_Tile_ from '../source/Tile.js';
import TileEventType from '../source/TileEventType.js'; import TileEventType from '../source/TileEventType.js';
@@ -120,13 +120,13 @@ _ol_source_UrlTile_.prototype.handleTileChange = function(event) {
var uid = getUid(tile); var uid = getUid(tile);
var tileState = tile.getState(); var tileState = tile.getState();
var type; var type;
if (tileState == _ol_TileState_.LOADING) { if (tileState == TileState.LOADING) {
this.tileLoadingKeys_[uid] = true; this.tileLoadingKeys_[uid] = true;
type = TileEventType.TILELOADSTART; type = TileEventType.TILELOADSTART;
} else if (uid in this.tileLoadingKeys_) { } else if (uid in this.tileLoadingKeys_) {
delete this.tileLoadingKeys_[uid]; delete this.tileLoadingKeys_[uid];
type = tileState == _ol_TileState_.ERROR ? TileEventType.TILELOADERROR : type = tileState == TileState.ERROR ? TileEventType.TILELOADERROR :
(tileState == _ol_TileState_.LOADED || tileState == _ol_TileState_.ABORT) ? (tileState == TileState.LOADED || tileState == TileState.ABORT) ?
TileEventType.TILELOADEND : undefined; TileEventType.TILELOADEND : undefined;
} }
if (type != undefined) { if (type != undefined) {

View File

@@ -2,7 +2,7 @@
* @module ol/source/VectorTile * @module ol/source/VectorTile
*/ */
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import _ol_TileState_ from '../TileState.js'; import TileState from '../TileState.js';
import _ol_VectorImageTile_ from '../VectorImageTile.js'; import _ol_VectorImageTile_ from '../VectorImageTile.js';
import _ol_VectorTile_ from '../VectorTile.js'; import _ol_VectorTile_ from '../VectorTile.js';
import _ol_size_ from '../size.js'; import _ol_size_ from '../size.js';
@@ -120,7 +120,7 @@ _ol_source_VectorTile_.prototype.getTile = function(z, x, y, pixelRatio, project
tileCoord, projection); tileCoord, projection);
var tile = new _ol_VectorImageTile_( var tile = new _ol_VectorImageTile_(
tileCoord, tileCoord,
urlTileCoord !== null ? _ol_TileState_.IDLE : _ol_TileState_.EMPTY, urlTileCoord !== null ? TileState.IDLE : TileState.EMPTY,
this.getRevision(), this.getRevision(),
this.format_, this.tileLoadFunction, urlTileCoord, this.tileUrlFunction, this.format_, this.tileLoadFunction, urlTileCoord, this.tileUrlFunction,
this.tileGrid, this.getTileGridForProjection(projection), this.tileGrid, this.getTileGridForProjection(projection),

View File

@@ -4,7 +4,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 _ol_ImageTile_ from '../ImageTile.js';
import _ol_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';
import {createCanvasContext2D} from '../dom.js'; import {createCanvasContext2D} from '../dom.js';
@@ -193,7 +193,7 @@ _ol_source_Zoomify_.Tile_.prototype.getImage = function() {
return this.zoomifyImage_; return this.zoomifyImage_;
} }
var image = _ol_ImageTile_.prototype.getImage.call(this); var image = _ol_ImageTile_.prototype.getImage.call(this);
if (this.state == _ol_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]) {
this.zoomifyImage_ = image; this.zoomifyImage_ = image;

View File

@@ -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 _ol_events_ from '../../../../src/ol/events.js';
import {get as getProjection} from '../../../../src/ol/proj.js'; import {get as getProjection} from '../../../../src/ol/proj.js';
import _ol_reproj_Tile_ from '../../../../src/ol/reproj/Tile.js'; import _ol_reproj_Tile_ from '../../../../src/ol/reproj/Tile.js';
@@ -23,9 +23,9 @@ describe('ol.rendering.reproj.Tile', function() {
tilesRequested++; tilesRequested++;
return source.getTile(z, x, y, pixelRatio, sourceProjection); 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) { _ol_events_.listen(tile, 'change', function(e) {
if (tile.getState() == _ol_TileState_.LOADED) { if (tile.getState() == TileState.LOADED) {
expect(tilesRequested).to.be(expectedRequests); expect(tilesRequested).to.be(expectedRequests);
resembleCanvas(tile.getImage(), expectedUrl, 7.5, done); resembleCanvas(tile.getImage(), expectedUrl, 7.5, done);
} }

View File

@@ -1,5 +1,5 @@
import _ol_ImageTile_ from '../../../src/ol/ImageTile.js'; 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 _ol_events_ from '../../../src/ol/events.js';
import EventType from '../../../src/ol/events/EventType.js'; import EventType from '../../../src/ol/events/EventType.js';
import _ol_source_Image_ from '../../../src/ol/source/Image.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) { it('can load idle tile', function(done) {
var tileCoord = [0, 0, 0]; 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 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 _ol_ImageTile_(tileCoord, state, src, null, tileLoadFunction);
@@ -20,10 +20,10 @@ describe('ol.ImageTile', function() {
_ol_events_.listen(tile, EventType.CHANGE, function(event) { _ol_events_.listen(tile, EventType.CHANGE, function(event) {
var state = tile.getState(); var state = tile.getState();
if (previousState == _ol_TileState_.IDLE) { if (previousState == TileState.IDLE) {
expect(state).to.be(_ol_TileState_.LOADING); expect(state).to.be(TileState.LOADING);
} else if (previousState == _ol_TileState_.LOADING) { } else if (previousState == TileState.LOADING) {
expect(state).to.be(_ol_TileState_.LOADED); expect(state).to.be(TileState.LOADED);
done(); done();
} else { } else {
expect().fail(); expect().fail();
@@ -36,7 +36,7 @@ describe('ol.ImageTile', function() {
it('can load error tile', function(done) { it('can load error tile', function(done) {
var tileCoord = [0, 0, 0]; 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 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 _ol_ImageTile_(tileCoord, state, src, null, tileLoadFunction);
@@ -45,10 +45,10 @@ describe('ol.ImageTile', function() {
_ol_events_.listen(tile, EventType.CHANGE, function(event) { _ol_events_.listen(tile, EventType.CHANGE, function(event) {
var state = tile.getState(); var state = tile.getState();
if (previousState == _ol_TileState_.ERROR) { if (previousState == TileState.ERROR) {
expect(state).to.be(_ol_TileState_.LOADING); expect(state).to.be(TileState.LOADING);
} else if (previousState == _ol_TileState_.LOADING) { } else if (previousState == TileState.LOADING) {
expect(state).to.be(_ol_TileState_.LOADED); expect(state).to.be(TileState.LOADED);
done(); done();
} else { } else {
expect().fail(); expect().fail();
@@ -61,15 +61,15 @@ describe('ol.ImageTile', function() {
it('loads an empty image on error ', function(done) { it('loads an empty image on error ', function(done) {
var tileCoord = [0, 0, 0]; 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 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 _ol_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();
if (state == _ol_TileState_.ERROR) { if (state == TileState.ERROR) {
expect(state).to.be(_ol_TileState_.ERROR); expect(state).to.be(TileState.ERROR);
expect(tile.image_).to.be.a(HTMLCanvasElement); expect(tile.image_).to.be.a(HTMLCanvasElement);
_ol_events_.unlistenByKey(key); _ol_events_.unlistenByKey(key);
tile.load(); tile.load();
@@ -87,14 +87,14 @@ describe('ol.ImageTile', function() {
it('sets image src to a blank image data uri', function() { it('sets image src to a blank image data uri', function() {
var tileCoord = [0, 0, 0]; 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 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 _ol_ImageTile_(tileCoord, state, src, null, tileLoadFunction);
tile.load(); tile.load();
expect(tile.getState()).to.be(_ol_TileState_.LOADING); expect(tile.getState()).to.be(TileState.LOADING);
tile.dispose(); 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); expect(tile.getImage().src).to.be(_ol_ImageTile_.blankImageUrl);
}); });

View File

@@ -2,7 +2,7 @@ import {getUid, inherits} from '../../../../../src/ol/index.js';
import _ol_obj_ from '../../../../../src/ol/obj.js'; import _ol_obj_ from '../../../../../src/ol/obj.js';
import _ol_Feature_ from '../../../../../src/ol/Feature.js'; import _ol_Feature_ from '../../../../../src/ol/Feature.js';
import Map from '../../../../../src/ol/Map.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_VectorImageTile_ from '../../../../../src/ol/VectorImageTile.js';
import _ol_VectorTile_ from '../../../../../src/ol/VectorTile.js'; import _ol_VectorTile_ from '../../../../../src/ol/VectorTile.js';
import _ol_View_ from '../../../../../src/ol/View.js'; import _ol_View_ from '../../../../../src/ol/View.js';
@@ -74,7 +74,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
}); });
source.getTile = function() { source.getTile = function() {
var tile = _ol_source_VectorTile_.prototype.getTile.apply(source, arguments); var tile = _ol_source_VectorTile_.prototype.getTile.apply(source, arguments);
tile.setState(_ol_TileState_.LOADED); tile.setState(TileState.LOADED);
return tile; return tile;
}; };
layer = new _ol_layer_VectorTile_({ layer = new _ol_layer_VectorTile_({
@@ -254,7 +254,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
var tile = new _ol_VectorImageTile_([0, 0, 0]); var tile = new _ol_VectorImageTile_([0, 0, 0]);
tile.transition_ = 0; tile.transition_ = 0;
tile.wrappedTileCoord = [0, 0, 0]; tile.wrappedTileCoord = [0, 0, 0];
tile.setState(_ol_TileState_.LOADED); tile.setState(TileState.LOADED);
tile.getSourceTile = function() { tile.getSourceTile = function() {
return sourceTile; return sourceTile;
}; };

View File

@@ -1,5 +1,5 @@
import Map from '../../../../src/ol/Map.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_View_ from '../../../../src/ol/View.js'; import _ol_View_ from '../../../../src/ol/View.js';
import _ol_layer_Image_ from '../../../../src/ol/layer/Image.js'; import _ol_layer_Image_ from '../../../../src/ol/layer/Image.js';
import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.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() { map2.once('moveend', function() {
expect(tileCache.getCount()).to.equal(1); expect(tileCache.getCount()).to.equal(1);
var state = tileCache.peekLast().getState(); 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(); done();
}); });

View File

@@ -1,5 +1,5 @@
import _ol_ImageTile_ from '../../../../src/ol/ImageTile.js'; 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 {createFromTemplate} from '../../../../src/ol/tileurlfunction.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';
@@ -188,7 +188,7 @@ describe('ol.source.TileImage', function() {
it('dispatches tileloadstart and tileloadend events', function() { it('dispatches tileloadstart and tileloadend events', function() {
source.setTileLoadFunction(function(tile) { source.setTileLoadFunction(function(tile) {
tile.setState(_ol_TileState_.LOADED); tile.setState(TileState.LOADED);
}); });
var startSpy = sinon.spy(); var startSpy = sinon.spy();
source.on('tileloadstart', startSpy); source.on('tileloadstart', startSpy);
@@ -203,15 +203,15 @@ describe('ol.source.TileImage', function() {
it('works for loading-error-loading-loaded sequences', function(done) { it('works for loading-error-loading-loaded sequences', function(done) {
source.setTileLoadFunction(function(tile) { source.setTileLoadFunction(function(tile) {
tile.setState( 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(); var startSpy = sinon.spy();
source.on('tileloadstart', startSpy); source.on('tileloadstart', startSpy);
var errorSpy = sinon.spy(); var errorSpy = sinon.spy();
source.on('tileloaderror', function(e) { source.on('tileloaderror', function(e) {
setTimeout(function() { setTimeout(function() {
e.tile.setState(_ol_TileState_.LOADING); e.tile.setState(TileState.LOADING);
e.tile.setState(_ol_TileState_.LOADED); e.tile.setState(TileState.LOADED);
}, 0); }, 0);
errorSpy(); errorSpy();
}); });

View File

@@ -1,21 +1,21 @@
import {getUid} from '../../../src/ol/index.js'; import {getUid} from '../../../src/ol/index.js';
import _ol_ImageTile_ from '../../../src/ol/ImageTile.js'; import _ol_ImageTile_ from '../../../src/ol/ImageTile.js';
import _ol_Tile_ from '../../../src/ol/Tile.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('ol.Tile', function() {
describe('constructor', function() { describe('constructor', function() {
it('sets a default transition', function() { it('sets a default transition', function() {
var coord = [0, 0, 0]; 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); expect(tile.transition_).to.equal(250);
}); });
it('allows the transition to be set', function() { it('allows the transition to be set', function() {
var coord = [0, 0, 0]; var coord = [0, 0, 0];
var transition = 500; 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); expect(tile.transition_).to.equal(transition);
}); });
}); });
@@ -23,7 +23,7 @@ describe('ol.Tile', function() {
describe('#getAlpha()', function() { describe('#getAlpha()', function() {
it('returns the alpha value for a tile in transition', function() { it('returns the alpha value for a tile in transition', function() {
var coord = [0, 0, 0]; 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 id = 'test';
var time = Date.now(); var time = Date.now();
@@ -45,7 +45,7 @@ describe('ol.Tile', function() {
describe('#inTransition()', function() { describe('#inTransition()', function() {
it('determines if the tile is in transition', function() { it('determines if the tile is in transition', function() {
var coord = [0, 0, 0]; 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 id = 'test';
expect(tile.inTransition(id)).to.be(true); expect(tile.inTransition(id)).to.be(true);
@@ -58,7 +58,7 @@ 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, _ol_TileState_.IDLE); head = new _ol_ImageTile_(tileCoord, TileState.IDLE);
getUid(head); getUid(head);
var addToChain = function(tile, state) { var addToChain = function(tile, state) {
@@ -67,15 +67,15 @@ describe('ol.Tile', function() {
tile.interimTile = next; tile.interimTile = next;
return next; return next;
}; };
var tail = addToChain(head, _ol_TileState_.IDLE); //discard, deprecated by head var tail = addToChain(head, TileState.IDLE); //discard, deprecated by head
tail = addToChain(tail, _ol_TileState_.LOADING); //keep, request already going tail = addToChain(tail, TileState.LOADING); //keep, request already going
tail = addToChain(tail, _ol_TileState_.IDLE); //discard, deprecated by head tail = addToChain(tail, TileState.IDLE); //discard, deprecated by head
tail = addToChain(tail, _ol_TileState_.LOADED); //keep, use for rendering tail = addToChain(tail, TileState.LOADED); //keep, use for rendering
renderTile = tail; //store this tile for later tests renderTile = tail; //store this tile for later tests
tail = addToChain(tail, _ol_TileState_.IDLE); //rest of list outdated by tile above tail = addToChain(tail, TileState.IDLE); //rest of list outdated by tile above
tail = addToChain(tail, _ol_TileState_.LOADED); tail = addToChain(tail, TileState.LOADED);
tail = addToChain(tail, _ol_TileState_.LOADING); tail = addToChain(tail, TileState.LOADING);
tail = addToChain(tail, _ol_TileState_.LOADED); tail = addToChain(tail, TileState.LOADED);
}); });

View File

@@ -1,7 +1,7 @@
import _ol_ImageTile_ from '../../../src/ol/ImageTile.js'; import _ol_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 _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 _ol_source_Image_ from '../../../src/ol/source/Image.js';
import PriorityQueue from '../../../src/ol/structs/PriorityQueue.js'; import PriorityQueue from '../../../src/ol/structs/PriorityQueue.js';
@@ -95,7 +95,7 @@ describe('ol.TileQueue', function() {
var numTiles = 20; var numTiles = 20;
for (var i = 0; i < numTiles; ++i) { for (var i = 0; i < numTiles; ++i) {
var tile = createImageTile(); var tile = createImageTile();
tile.state = _ol_TileState_.ABORT; tile.state = TileState.ABORT;
queue.enqueue([tile]); queue.enqueue([tile]);
} }
var maxLoading = numTiles / 2; var maxLoading = numTiles / 2;

View File

@@ -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_VectorImageTile_ from '../../../src/ol/VectorImageTile.js';
import _ol_VectorTile_ from '../../../src/ol/VectorTile.js'; import _ol_VectorTile_ from '../../../src/ol/VectorTile.js';
import _ol_events_ from '../../../src/ol/events.js'; import _ol_events_ from '../../../src/ol/events.js';
@@ -47,12 +47,12 @@ describe('ol.VectorImageTile', function() {
var calls = 0; var calls = 0;
_ol_events_.listen(tile, 'change', function(e) { _ol_events_.listen(tile, 'change', function(e) {
++calls; ++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) { if (calls == 2) {
done(); done();
} else { } else {
setTimeout(function() { setTimeout(function() {
sourceTile.setState(_ol_TileState_.LOADED); sourceTile.setState(TileState.LOADED);
}, 0); }, 0);
} }
}); });
@@ -70,7 +70,7 @@ describe('ol.VectorImageTile', function() {
tile.load(); tile.load();
_ol_events_.listen(tile, 'change', function(e) { _ol_events_.listen(tile, 'change', function(e) {
expect(tile.getState()).to.be(_ol_TileState_.ERROR); expect(tile.getState()).to.be(TileState.ERROR);
done(); done();
}); });
}); });
@@ -86,7 +86,7 @@ describe('ol.VectorImageTile', function() {
tile.load(); tile.load();
_ol_events_.listen(tile, 'change', function() { _ol_events_.listen(tile, 'change', function() {
expect(tile.getState()).to.be(_ol_TileState_.EMPTY); expect(tile.getState()).to.be(TileState.EMPTY);
done(); done();
}); });
}); });
@@ -123,12 +123,12 @@ describe('ol.VectorImageTile', function() {
tile.load(); tile.load();
expect(tile.loadListenerKeys_.length).to.be(4); expect(tile.loadListenerKeys_.length).to.be(4);
expect(tile.tileKeys.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(); tile.dispose();
expect(tile.loadListenerKeys_.length).to.be(0); expect(tile.loadListenerKeys_.length).to.be(0);
expect(tile.tileKeys.length).to.be(0); expect(tile.tileKeys.length).to.be(0);
expect(tile.sourceTiles_).to.be(null); 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) { it('#dispose() when loaded', function(done) {
@@ -142,13 +142,13 @@ describe('ol.VectorImageTile', function() {
tile.load(); tile.load();
_ol_events_.listenOnce(tile, 'change', function() { _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.loadListenerKeys_.length).to.be(0);
expect(tile.tileKeys.length).to.be(4); expect(tile.tileKeys.length).to.be(4);
tile.dispose(); tile.dispose();
expect(tile.tileKeys.length).to.be(0); expect(tile.tileKeys.length).to.be(0);
expect(tile.sourceTiles_).to.be(null); expect(tile.sourceTiles_).to.be(null);
expect(tile.getState()).to.be(_ol_TileState_.ABORT); expect(tile.getState()).to.be(TileState.ABORT);
done(); done();
}); });
}); });