Remove state enum from tile constructor

This commit is contained in:
Tim Schaub
2016-12-27 09:49:21 -07:00
parent 3852c0da83
commit 895a506025
22 changed files with 134 additions and 128 deletions

View File

@@ -4450,7 +4450,7 @@ olx.source.TileUTFGridOptions.prototype.url;
* reprojectionErrorThreshold: (number|undefined), * reprojectionErrorThreshold: (number|undefined),
* state: (ol.source.State|undefined), * state: (ol.source.State|undefined),
* tileClass: (function(new: ol.ImageTile, ol.TileCoord, * tileClass: (function(new: ol.ImageTile, ol.TileCoord,
* ol.Tile.State, string, ?string, * ol.TileState, string, ?string,
* ol.TileLoadFunctionType)|undefined), * ol.TileLoadFunctionType)|undefined),
* tileGrid: (ol.tilegrid.TileGrid|undefined), * tileGrid: (ol.tilegrid.TileGrid|undefined),
* tileLoadFunction: (ol.TileLoadFunctionType|undefined), * tileLoadFunction: (ol.TileLoadFunctionType|undefined),
@@ -4535,7 +4535,7 @@ olx.source.TileImageOptions.prototype.state;
/** /**
* Class used to instantiate image tiles. Default is {@link ol.ImageTile}. * Class used to instantiate image tiles. Default is {@link ol.ImageTile}.
* @type {function(new: ol.ImageTile, ol.TileCoord, * @type {function(new: ol.ImageTile, ol.TileCoord,
* ol.Tile.State, string, ?string, * ol.TileState, string, ?string,
* ol.TileLoadFunctionType)|undefined} * ol.TileLoadFunctionType)|undefined}
* @api * @api
*/ */
@@ -4620,7 +4620,7 @@ olx.source.TileImageOptions.prototype.wrapX;
* projection: ol.ProjectionLike, * projection: ol.ProjectionLike,
* state: (ol.source.State|undefined), * state: (ol.source.State|undefined),
* tileClass: (function(new: ol.VectorTile, ol.TileCoord, * tileClass: (function(new: ol.VectorTile, ol.TileCoord,
* ol.Tile.State, string, ol.format.Feature, * ol.TileState, string, ol.format.Feature,
* ol.TileLoadFunctionType)|undefined), * ol.TileLoadFunctionType)|undefined),
* tileGrid: (ol.tilegrid.TileGrid|undefined), * tileGrid: (ol.tilegrid.TileGrid|undefined),
* tileLoadFunction: (ol.TileLoadFunctionType|undefined), * tileLoadFunction: (ol.TileLoadFunctionType|undefined),
@@ -4696,7 +4696,7 @@ olx.source.VectorTileOptions.prototype.state;
/** /**
* Class used to instantiate image tiles. Default is {@link ol.VectorTile}. * Class used to instantiate image tiles. Default is {@link ol.VectorTile}.
* @type {function(new: ol.VectorTile, ol.TileCoord, * @type {function(new: ol.VectorTile, ol.TileCoord,
* ol.Tile.State, string, ol.format.Feature, * ol.TileState, string, ol.format.Feature,
* ol.TileLoadFunctionType)|undefined} * ol.TileLoadFunctionType)|undefined}
* @api * @api
*/ */
@@ -6206,7 +6206,7 @@ olx.source.VectorOptions.prototype.wrapX;
* tileLoadFunction: (ol.TileLoadFunctionType|undefined), * tileLoadFunction: (ol.TileLoadFunctionType|undefined),
* urls: (Array.<string>|undefined), * urls: (Array.<string>|undefined),
* tileClass: (function(new: ol.ImageTile, ol.TileCoord, * tileClass: (function(new: ol.ImageTile, ol.TileCoord,
* ol.Tile.State, string, ?string, * ol.TileState, string, ?string,
* ol.TileLoadFunctionType)|undefined), * ol.TileLoadFunctionType)|undefined),
* wrapX: (boolean|undefined)}} * wrapX: (boolean|undefined)}}
*/ */
@@ -6301,7 +6301,7 @@ olx.source.WMTSOptions.prototype.style;
/** /**
* Class used to instantiate image tiles. Default is {@link ol.ImageTile}. * Class used to instantiate image tiles. Default is {@link ol.ImageTile}.
* @type {function(new: ol.ImageTile, ol.TileCoord, * @type {function(new: ol.ImageTile, ol.TileCoord,
* ol.Tile.State, string, ?string, * ol.TileState, string, ?string,
* ol.TileLoadFunctionType)|undefined} * ol.TileLoadFunctionType)|undefined}
* @api * @api
*/ */

View File

@@ -2,6 +2,7 @@ goog.provide('ol.ImageTile');
goog.require('ol'); goog.require('ol');
goog.require('ol.Tile'); goog.require('ol.Tile');
goog.require('ol.TileState');
goog.require('ol.events'); goog.require('ol.events');
goog.require('ol.events.EventType'); goog.require('ol.events.EventType');
@@ -10,7 +11,7 @@ goog.require('ol.events.EventType');
* @constructor * @constructor
* @extends {ol.Tile} * @extends {ol.Tile}
* @param {ol.TileCoord} tileCoord Tile coordinate. * @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {ol.Tile.State} state State. * @param {ol.TileState} state State.
* @param {string} src Image source URI. * @param {string} src Image source URI.
* @param {?string} crossOrigin Cross origin. * @param {?string} crossOrigin Cross origin.
* @param {ol.TileLoadFunctionType} tileLoadFunction Tile load function. * @param {ol.TileLoadFunctionType} tileLoadFunction Tile load function.
@@ -56,13 +57,13 @@ ol.inherits(ol.ImageTile, ol.Tile);
* @inheritDoc * @inheritDoc
*/ */
ol.ImageTile.prototype.disposeInternal = function() { ol.ImageTile.prototype.disposeInternal = function() {
if (this.state == ol.Tile.State.LOADING) { if (this.state == ol.TileState.LOADING) {
this.unlistenImage_(); this.unlistenImage_();
} }
if (this.interimTile) { if (this.interimTile) {
this.interimTile.dispose(); this.interimTile.dispose();
} }
this.state = ol.Tile.State.ABORT; this.state = ol.TileState.ABORT;
this.changed(); this.changed();
ol.Tile.prototype.disposeInternal.call(this); ol.Tile.prototype.disposeInternal.call(this);
}; };
@@ -92,7 +93,7 @@ ol.ImageTile.prototype.getKey = function() {
* @private * @private
*/ */
ol.ImageTile.prototype.handleImageError_ = function() { ol.ImageTile.prototype.handleImageError_ = function() {
this.state = ol.Tile.State.ERROR; this.state = ol.TileState.ERROR;
this.unlistenImage_(); this.unlistenImage_();
this.changed(); this.changed();
}; };
@@ -105,9 +106,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.Tile.State.LOADED; this.state = ol.TileState.LOADED;
} else { } else {
this.state = ol.Tile.State.EMPTY; this.state = ol.TileState.EMPTY;
} }
this.unlistenImage_(); this.unlistenImage_();
this.changed(); this.changed();
@@ -121,8 +122,8 @@ ol.ImageTile.prototype.handleImageLoad_ = function() {
* @api * @api
*/ */
ol.ImageTile.prototype.load = function() { ol.ImageTile.prototype.load = function() {
if (this.state == ol.Tile.State.IDLE || this.state == ol.Tile.State.ERROR) { if (this.state == ol.TileState.IDLE || this.state == ol.TileState.ERROR) {
this.state = ol.Tile.State.LOADING; this.state = ol.TileState.LOADING;
this.changed(); this.changed();
ol.DEBUG && console.assert(!this.imageListenerKeys_, ol.DEBUG && console.assert(!this.imageListenerKeys_,
'this.imageListenerKeys_ should be null'); 'this.imageListenerKeys_ should be null');

View File

@@ -164,7 +164,7 @@ ol.OVERVIEWMAP_MIN_RATIO = 0.1;
* This can happen if the developer defines projections improperly and/or * This can happen if the developer defines projections improperly and/or
* with unlimited extents. * with unlimited extents.
* If too many tiles are required, no tiles are loaded and * If too many tiles are required, no tiles are loaded and
* `ol.Tile.State.ERROR` state is set. Default is `100`. * `ol.TileState.ERROR` state is set. Default is `100`.
*/ */
ol.RASTER_REPROJECTION_MAX_SOURCE_TILES = 100; ol.RASTER_REPROJECTION_MAX_SOURCE_TILES = 100;

View File

@@ -3,14 +3,14 @@
goog.provide('ol.renderer.canvas.TileLayer'); goog.provide('ol.renderer.canvas.TileLayer');
goog.require('ol'); goog.require('ol');
goog.require('ol.transform');
goog.require('ol.TileRange'); goog.require('ol.TileRange');
goog.require('ol.Tile'); goog.require('ol.TileState');
goog.require('ol.ViewHint'); goog.require('ol.ViewHint');
goog.require('ol.array'); goog.require('ol.array');
goog.require('ol.dom'); goog.require('ol.dom');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.renderer.canvas.IntermediateCanvas'); goog.require('ol.renderer.canvas.IntermediateCanvas');
goog.require('ol.transform');
/** /**
@@ -88,9 +88,9 @@ ol.inherits(ol.renderer.canvas.TileLayer, ol.renderer.canvas.IntermediateCanvas)
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.Tile.State.LOADED || return tileState == ol.TileState.LOADED ||
tileState == ol.Tile.State.EMPTY || tileState == ol.TileState.EMPTY ||
tileState == ol.Tile.State.ERROR && !useInterimTilesOnError; tileState == ol.TileState.ERROR && !useInterimTilesOnError;
}; };
/** /**
@@ -147,7 +147,7 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame = function(frameState, layer
tile = tile.getInterimTile(); tile = tile.getInterimTile();
} }
if (this.isDrawableTile_(tile)) { if (this.isDrawableTile_(tile)) {
if (tile.getState() == ol.Tile.State.LOADED) { if (tile.getState() == ol.TileState.LOADED) {
tilesToDrawByZ[z][tile.tileCoord.toString()] = tile; tilesToDrawByZ[z][tile.tileCoord.toString()] = tile;
if (!newTiles && this.renderedTiles.indexOf(tile) == -1) { if (!newTiles && this.renderedTiles.indexOf(tile) == -1) {
newTiles = true; newTiles = true;

View File

@@ -3,7 +3,7 @@ goog.provide('ol.renderer.Layer');
goog.require('ol'); goog.require('ol');
goog.require('ol.ImageState'); goog.require('ol.ImageState');
goog.require('ol.Observable'); goog.require('ol.Observable');
goog.require('ol.Tile'); goog.require('ol.TileState');
goog.require('ol.asserts'); goog.require('ol.asserts');
goog.require('ol.events'); goog.require('ol.events');
goog.require('ol.events.EventType'); goog.require('ol.events.EventType');
@@ -269,7 +269,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.Tile.State.IDLE) { if (tile.getState() == ol.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 @@
goog.provide('ol.renderer.webgl.TileLayer'); goog.provide('ol.renderer.webgl.TileLayer');
goog.require('ol'); goog.require('ol');
goog.require('ol.Tile'); goog.require('ol.TileState');
goog.require('ol.TileRange'); goog.require('ol.TileRange');
goog.require('ol.array'); goog.require('ol.array');
goog.require('ol.extent'); goog.require('ol.extent');
@@ -242,20 +242,20 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame = function(frameState, layerS
} }
} }
tileState = tile.getState(); tileState = tile.getState();
drawable = tileState == ol.Tile.State.LOADED || drawable = tileState == ol.TileState.LOADED ||
tileState == ol.Tile.State.EMPTY || tileState == ol.TileState.EMPTY ||
tileState == ol.Tile.State.ERROR && !useInterimTilesOnError; tileState == ol.TileState.ERROR && !useInterimTilesOnError;
if (!drawable) { if (!drawable) {
tile = tile.getInterimTile(); tile = tile.getInterimTile();
} }
tileState = tile.getState(); tileState = tile.getState();
if (tileState == ol.Tile.State.LOADED) { if (tileState == ol.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.Tile.State.EMPTY || } else if (tileState == ol.TileState.EMPTY ||
(tileState == ol.Tile.State.ERROR && (tileState == ol.TileState.ERROR &&
!useInterimTilesOnError)) { !useInterimTilesOnError)) {
continue; continue;
} }
@@ -322,7 +322,7 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame = function(frameState, layerS
* @param {ol.Tile} tile Tile. * @param {ol.Tile} tile Tile.
*/ */
function(tile) { function(tile) {
if (tile.getState() == ol.Tile.State.LOADED && if (tile.getState() == ol.TileState.LOADED &&
!mapRenderer.isTileTextureLoaded(tile) && !mapRenderer.isTileTextureLoaded(tile) &&
!tileTextureQueue.isKeyQueued(tile.getKey())) { !tileTextureQueue.isKeyQueued(tile.getKey())) {
tileTextureQueue.enqueue([ tileTextureQueue.enqueue([

View File

@@ -2,6 +2,7 @@ goog.provide('ol.reproj.Tile');
goog.require('ol'); goog.require('ol');
goog.require('ol.Tile'); goog.require('ol.Tile');
goog.require('ol.TileState');
goog.require('ol.events'); goog.require('ol.events');
goog.require('ol.events.EventType'); goog.require('ol.events.EventType');
goog.require('ol.extent'); goog.require('ol.extent');
@@ -35,7 +36,7 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
pixelRatio, gutter, getTileFunction, pixelRatio, gutter, getTileFunction,
opt_errorThreshold, opt_errorThreshold,
opt_renderEdges) { opt_renderEdges) {
ol.Tile.call(this, tileCoord, ol.Tile.State.IDLE); ol.Tile.call(this, tileCoord, ol.TileState.IDLE);
/** /**
* @private * @private
@@ -107,7 +108,7 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
if (ol.extent.getArea(limitedTargetExtent) === 0) { if (ol.extent.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.Tile.State.EMPTY; this.state = ol.TileState.EMPTY;
return; return;
} }
@@ -131,7 +132,7 @@ 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.Tile.State.EMPTY; this.state = ol.TileState.EMPTY;
return; return;
} }
@@ -148,7 +149,7 @@ 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.Tile.State.EMPTY; this.state = ol.TileState.EMPTY;
return; return;
} }
@@ -167,7 +168,7 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
} }
if (!ol.extent.getArea(sourceExtent)) { if (!ol.extent.getArea(sourceExtent)) {
this.state = ol.Tile.State.EMPTY; this.state = ol.TileState.EMPTY;
} else { } else {
var sourceRange = sourceTileGrid.getTileRangeForExtentAndZ( var sourceRange = sourceTileGrid.getTileRangeForExtentAndZ(
sourceExtent, this.sourceZ_); sourceExtent, this.sourceZ_);
@@ -175,7 +176,7 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
var tilesRequired = sourceRange.getWidth() * sourceRange.getHeight(); var tilesRequired = sourceRange.getWidth() * sourceRange.getHeight();
if (ol.DEBUG && !(tilesRequired < ol.RASTER_REPROJECTION_MAX_SOURCE_TILES)) { if (ol.DEBUG && !(tilesRequired < ol.RASTER_REPROJECTION_MAX_SOURCE_TILES)) {
console.assert(false, 'reasonable number of tiles is required'); console.assert(false, 'reasonable number of tiles is required');
this.state = ol.Tile.State.ERROR; this.state = ol.TileState.ERROR;
return; return;
} }
for (var srcX = sourceRange.minX; srcX <= sourceRange.maxX; srcX++) { for (var srcX = sourceRange.minX; srcX <= sourceRange.maxX; srcX++) {
@@ -188,7 +189,7 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
} }
if (this.sourceTiles_.length === 0) { if (this.sourceTiles_.length === 0) {
this.state = ol.Tile.State.EMPTY; this.state = ol.TileState.EMPTY;
} }
} }
}; };
@@ -199,7 +200,7 @@ ol.inherits(ol.reproj.Tile, ol.Tile);
* @inheritDoc * @inheritDoc
*/ */
ol.reproj.Tile.prototype.disposeInternal = function() { ol.reproj.Tile.prototype.disposeInternal = function() {
if (this.state == ol.Tile.State.LOADING) { if (this.state == ol.TileState.LOADING) {
this.unlistenSources_(); this.unlistenSources_();
} }
ol.Tile.prototype.disposeInternal.call(this); ol.Tile.prototype.disposeInternal.call(this);
@@ -220,7 +221,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.Tile.State.LOADED) { if (tile && tile.getState() == ol.TileState.LOADED) {
sources.push({ sources.push({
extent: this.sourceTileGrid_.getTileCoordExtent(tile.tileCoord), extent: this.sourceTileGrid_.getTileCoordExtent(tile.tileCoord),
image: tile.getImage() image: tile.getImage()
@@ -230,7 +231,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.Tile.State.ERROR; this.state = ol.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);
@@ -246,7 +247,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.Tile.State.LOADED; this.state = ol.TileState.LOADED;
} }
this.changed(); this.changed();
}; };
@@ -256,8 +257,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.Tile.State.IDLE) { if (this.state == ol.TileState.IDLE) {
this.state = ol.Tile.State.LOADING; this.state = ol.TileState.LOADING;
this.changed(); this.changed();
var leftToLoad = 0; var leftToLoad = 0;
@@ -268,16 +269,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.Tile.State.IDLE || state == ol.Tile.State.LOADING) { if (state == ol.TileState.IDLE || state == ol.TileState.LOADING) {
leftToLoad++; leftToLoad++;
var sourceListenKey; var sourceListenKey;
sourceListenKey = ol.events.listen(tile, ol.events.EventType.CHANGE, sourceListenKey = ol.events.listen(tile, ol.events.EventType.CHANGE,
function(e) { function(e) {
var state = tile.getState(); var state = tile.getState();
if (state == ol.Tile.State.LOADED || if (state == ol.TileState.LOADED ||
state == ol.Tile.State.ERROR || state == ol.TileState.ERROR ||
state == ol.Tile.State.EMPTY) { state == ol.TileState.EMPTY) {
ol.events.unlistenByKey(sourceListenKey); ol.events.unlistenByKey(sourceListenKey);
leftToLoad--; leftToLoad--;
ol.DEBUG && console.assert(leftToLoad >= 0, ol.DEBUG && console.assert(leftToLoad >= 0,
@@ -294,7 +295,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.Tile.State.IDLE) { if (state == ol.TileState.IDLE) {
tile.load(); tile.load();
} }
}); });

View File

@@ -1,8 +1,8 @@
goog.provide('ol.source.Tile'); goog.provide('ol.source.Tile');
goog.require('ol'); goog.require('ol');
goog.require('ol.Tile');
goog.require('ol.TileCache'); goog.require('ol.TileCache');
goog.require('ol.TileState');
goog.require('ol.events.Event'); goog.require('ol.events.Event');
goog.require('ol.proj'); goog.require('ol.proj');
goog.require('ol.size'); goog.require('ol.size');
@@ -117,7 +117,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.Tile.State.LOADED; loaded = tile.getState() === ol.TileState.LOADED;
if (loaded) { if (loaded) {
loaded = (callback(tile) !== false); loaded = (callback(tile) !== false);
} }

View File

@@ -2,6 +2,7 @@ goog.provide('ol.source.TileDebug');
goog.require('ol'); goog.require('ol');
goog.require('ol.Tile'); goog.require('ol.Tile');
goog.require('ol.TileState');
goog.require('ol.dom'); goog.require('ol.dom');
goog.require('ol.size'); goog.require('ol.size');
goog.require('ol.source.Tile'); goog.require('ol.source.Tile');
@@ -63,7 +64,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.Tile.State.LOADED); ol.Tile.call(this, tileCoord, ol.TileState.LOADED);
/** /**
* @private * @private

View File

@@ -2,8 +2,8 @@ goog.provide('ol.source.TileImage');
goog.require('ol'); goog.require('ol');
goog.require('ol.ImageTile'); goog.require('ol.ImageTile');
goog.require('ol.Tile');
goog.require('ol.TileCache'); goog.require('ol.TileCache');
goog.require('ol.TileState');
goog.require('ol.events'); goog.require('ol.events');
goog.require('ol.events.EventType'); goog.require('ol.events.EventType');
goog.require('ol.proj'); goog.require('ol.proj');
@@ -51,7 +51,7 @@ ol.source.TileImage = function(options) {
/** /**
* @protected * @protected
* @type {function(new: ol.ImageTile, ol.TileCoord, ol.Tile.State, string, * @type {function(new: ol.ImageTile, ol.TileCoord, ol.TileState, string,
* ?string, ol.TileLoadFunctionType)} * ?string, ol.TileLoadFunctionType)}
*/ */
this.tileClass = options.tileClass !== undefined ? this.tileClass = options.tileClass !== undefined ?
@@ -219,7 +219,7 @@ ol.source.TileImage.prototype.createTile_ = function(z, x, y, pixelRatio, projec
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.Tile.State.IDLE : ol.Tile.State.EMPTY, tileUrl !== undefined ? ol.TileState.IDLE : ol.TileState.EMPTY,
tileUrl !== undefined ? tileUrl : '', tileUrl !== undefined ? tileUrl : '',
this.crossOrigin, this.crossOrigin,
this.tileLoadFunction); this.tileLoadFunction);
@@ -305,7 +305,7 @@ ol.source.TileImage.prototype.getTileInternal = function(z, x, y, pixelRatio, pr
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.Tile.State.IDLE) { if (interimTile.getState() == ol.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,6 +3,7 @@ goog.provide('ol.source.TileUTFGrid');
goog.require('ol'); goog.require('ol');
goog.require('ol.Attribution'); goog.require('ol.Attribution');
goog.require('ol.Tile'); goog.require('ol.Tile');
goog.require('ol.TileState');
goog.require('ol.TileUrlFunction'); goog.require('ol.TileUrlFunction');
goog.require('ol.asserts'); goog.require('ol.asserts');
goog.require('ol.events'); goog.require('ol.events');
@@ -236,7 +237,7 @@ ol.source.TileUTFGrid.prototype.getTile = function(z, x, y, pixelRatio, projecti
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.Tile.State.IDLE : ol.Tile.State.EMPTY, tileUrl !== undefined ? ol.TileState.IDLE : ol.TileState.EMPTY,
tileUrl !== undefined ? tileUrl : '', tileUrl !== undefined ? tileUrl : '',
this.tileGrid.getTileCoordExtent(tileCoord), this.tileGrid.getTileCoordExtent(tileCoord),
this.preemptive_, this.preemptive_,
@@ -262,7 +263,7 @@ ol.source.TileUTFGrid.prototype.useTile = function(z, x, y) {
* @constructor * @constructor
* @extends {ol.Tile} * @extends {ol.Tile}
* @param {ol.TileCoord} tileCoord Tile coordinate. * @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {ol.Tile.State} state State. * @param {ol.TileState} state State.
* @param {string} src Image source URI. * @param {string} src Image source URI.
* @param {ol.Extent} extent Extent of the tile. * @param {ol.Extent} extent Extent of the tile.
* @param {boolean} preemptive Load the tile when visible (before it's needed). * @param {boolean} preemptive Load the tile when visible (before it's needed).
@@ -382,7 +383,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.Tile.State.IDLE && opt_request === true) { if (this.state == ol.TileState.IDLE && opt_request === true) {
ol.events.listenOnce(this, ol.events.EventType.CHANGE, function(e) { ol.events.listenOnce(this, ol.events.EventType.CHANGE, function(e) {
callback.call(opt_this, this.getData(coordinate)); callback.call(opt_this, this.getData(coordinate));
}, this); }, this);
@@ -411,7 +412,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.Tile.State.ERROR; this.state = ol.TileState.ERROR;
this.changed(); this.changed();
}; };
@@ -425,7 +426,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.Tile.State.EMPTY; this.state = ol.TileState.EMPTY;
this.changed(); this.changed();
}; };
@@ -434,8 +435,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.Tile.State.IDLE) { if (this.state == ol.TileState.IDLE) {
this.state = ol.Tile.State.LOADING; this.state = ol.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

@@ -1,7 +1,7 @@
goog.provide('ol.source.UrlTile'); goog.provide('ol.source.UrlTile');
goog.require('ol'); goog.require('ol');
goog.require('ol.Tile'); goog.require('ol.TileState');
goog.require('ol.TileUrlFunction'); goog.require('ol.TileUrlFunction');
goog.require('ol.source.Tile'); goog.require('ol.source.Tile');
@@ -109,15 +109,15 @@ ol.source.UrlTile.prototype.getUrls = function() {
ol.source.UrlTile.prototype.handleTileChange = function(event) { ol.source.UrlTile.prototype.handleTileChange = function(event) {
var tile = /** @type {ol.Tile} */ (event.target); var tile = /** @type {ol.Tile} */ (event.target);
switch (tile.getState()) { switch (tile.getState()) {
case ol.Tile.State.LOADING: case ol.TileState.LOADING:
this.dispatchEvent( this.dispatchEvent(
new ol.source.Tile.Event(ol.source.Tile.EventType.TILELOADSTART, tile)); new ol.source.Tile.Event(ol.source.Tile.EventType.TILELOADSTART, tile));
break; break;
case ol.Tile.State.LOADED: case ol.TileState.LOADED:
this.dispatchEvent( this.dispatchEvent(
new ol.source.Tile.Event(ol.source.Tile.EventType.TILELOADEND, tile)); new ol.source.Tile.Event(ol.source.Tile.EventType.TILELOADEND, tile));
break; break;
case ol.Tile.State.ERROR: case ol.TileState.ERROR:
this.dispatchEvent( this.dispatchEvent(
new ol.source.Tile.Event(ol.source.Tile.EventType.TILELOADERROR, tile)); new ol.source.Tile.Event(ol.source.Tile.EventType.TILELOADERROR, tile));
break; break;

View File

@@ -1,7 +1,7 @@
goog.provide('ol.source.VectorTile'); goog.provide('ol.source.VectorTile');
goog.require('ol'); goog.require('ol');
goog.require('ol.Tile'); goog.require('ol.TileState');
goog.require('ol.VectorTile'); goog.require('ol.VectorTile');
goog.require('ol.events'); goog.require('ol.events');
goog.require('ol.events.EventType'); goog.require('ol.events.EventType');
@@ -59,7 +59,7 @@ ol.source.VectorTile = function(options) {
/** /**
* @protected * @protected
* @type {function(new: ol.VectorTile, ol.TileCoord, ol.Tile.State, string, * @type {function(new: ol.VectorTile, ol.TileCoord, ol.TileState, string,
* ol.format.Feature, ol.TileLoadFunctionType)} * ol.format.Feature, ol.TileLoadFunctionType)}
*/ */
this.tileClass = options.tileClass ? options.tileClass : ol.VectorTile; this.tileClass = options.tileClass ? options.tileClass : ol.VectorTile;
@@ -91,7 +91,7 @@ ol.source.VectorTile.prototype.getTile = function(z, x, y, pixelRatio, projectio
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.Tile.State.IDLE : ol.Tile.State.EMPTY, tileUrl !== undefined ? ol.TileState.IDLE : ol.TileState.EMPTY,
tileUrl !== undefined ? tileUrl : '', tileUrl !== undefined ? tileUrl : '',
this.format_, this.tileLoadFunction); this.format_, this.tileLoadFunction);
ol.events.listen(tile, ol.events.EventType.CHANGE, ol.events.listen(tile, ol.events.EventType.CHANGE,

View File

@@ -2,7 +2,7 @@ goog.provide('ol.source.Zoomify');
goog.require('ol'); goog.require('ol');
goog.require('ol.ImageTile'); goog.require('ol.ImageTile');
goog.require('ol.Tile'); goog.require('ol.TileState');
goog.require('ol.asserts'); goog.require('ol.asserts');
goog.require('ol.dom'); goog.require('ol.dom');
goog.require('ol.extent'); goog.require('ol.extent');
@@ -127,7 +127,7 @@ ol.inherits(ol.source.Zoomify, ol.source.TileImage);
* @constructor * @constructor
* @extends {ol.ImageTile} * @extends {ol.ImageTile}
* @param {ol.TileCoord} tileCoord Tile coordinate. * @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {ol.Tile.State} state State. * @param {ol.TileState} state State.
* @param {string} src Image source URI. * @param {string} src Image source URI.
* @param {?string} crossOrigin Cross origin. * @param {?string} crossOrigin Cross origin.
* @param {ol.TileLoadFunctionType} tileLoadFunction Tile load function. * @param {ol.TileLoadFunctionType} tileLoadFunction Tile load function.
@@ -157,7 +157,7 @@ ol.source.Zoomify.Tile_.prototype.getImage = function() {
} }
var tileSize = ol.DEFAULT_TILE_SIZE; var tileSize = ol.DEFAULT_TILE_SIZE;
var image = ol.ImageTile.prototype.getImage.call(this); var image = ol.ImageTile.prototype.getImage.call(this);
if (this.state == ol.Tile.State.LOADED) { if (this.state == ol.TileState.LOADED) {
if (image.width == tileSize && image.height == tileSize) { if (image.width == tileSize && image.height == tileSize) {
this.zoomifyImage_ = image; this.zoomifyImage_ = image;
return image; return image;

View File

@@ -1,6 +1,7 @@
goog.provide('ol.Tile'); goog.provide('ol.Tile');
goog.require('ol'); goog.require('ol');
goog.require('ol.TileState');
goog.require('ol.events.EventTarget'); goog.require('ol.events.EventTarget');
goog.require('ol.events.EventType'); goog.require('ol.events.EventType');
@@ -12,7 +13,7 @@ goog.require('ol.events.EventType');
* @constructor * @constructor
* @extends {ol.events.EventTarget} * @extends {ol.events.EventTarget}
* @param {ol.TileCoord} tileCoord Tile coordinate. * @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {ol.Tile.State} state State. * @param {ol.TileState} state State.
*/ */
ol.Tile = function(tileCoord, state) { ol.Tile = function(tileCoord, state) {
@@ -25,7 +26,7 @@ ol.Tile = function(tileCoord, state) {
/** /**
* @protected * @protected
* @type {ol.Tile.State} * @type {ol.TileState}
*/ */
this.state = state; this.state = state;
@@ -90,7 +91,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.Tile.State.LOADED) { if (tile.getState() == ol.TileState.LOADED) {
return tile; return tile;
} }
tile = tile.interimTile; tile = tile.interimTile;
@@ -113,17 +114,17 @@ ol.Tile.prototype.refreshInterimChain = function() {
var prev = this; var prev = this;
do { do {
if (tile.getState() == ol.Tile.State.LOADED) { if (tile.getState() == ol.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.Tile.State.LOADING) { } else if (tile.getState() == ol.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.Tile.State.IDLE) { } else if (tile.getState() == ol.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;
@@ -145,7 +146,7 @@ ol.Tile.prototype.getTileCoord = function() {
/** /**
* @return {ol.Tile.State} State. * @return {ol.TileState} State.
*/ */
ol.Tile.prototype.getState = function() { ol.Tile.prototype.getState = function() {
return this.state; return this.state;
@@ -160,16 +161,3 @@ ol.Tile.prototype.getState = function() {
* @api * @api
*/ */
ol.Tile.prototype.load = function() {}; ol.Tile.prototype.load = function() {};
/**
* @enum {number}
*/
ol.Tile.State = {
IDLE: 0,
LOADING: 1,
LOADED: 2,
ERROR: 3,
EMPTY: 4,
ABORT: 5
};

View File

@@ -1,7 +1,7 @@
goog.provide('ol.TileQueue'); goog.provide('ol.TileQueue');
goog.require('ol'); goog.require('ol');
goog.require('ol.Tile'); goog.require('ol.TileState');
goog.require('ol.events'); goog.require('ol.events');
goog.require('ol.events.EventType'); goog.require('ol.events.EventType');
goog.require('ol.structs.PriorityQueue'); goog.require('ol.structs.PriorityQueue');
@@ -86,8 +86,8 @@ ol.TileQueue.prototype.getTilesLoading = function() {
ol.TileQueue.prototype.handleTileChange = function(event) { ol.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.Tile.State.LOADED || state === ol.Tile.State.ERROR || if (state === ol.TileState.LOADED || state === ol.TileState.ERROR ||
state === ol.Tile.State.EMPTY || state === ol.Tile.State.ABORT) { state === ol.TileState.EMPTY || state === ol.TileState.ABORT) {
ol.events.unlisten(tile, ol.events.EventType.CHANGE, ol.events.unlisten(tile, ol.events.EventType.CHANGE,
this.handleTileChange, this); this.handleTileChange, this);
var tileKey = tile.getKey(); var tileKey = tile.getKey();
@@ -112,7 +112,7 @@ ol.TileQueue.prototype.loadMoreTiles = function(maxTotalLoading, maxNewLoads) {
this.getCount() > 0) { this.getCount() > 0) {
tile = /** @type {ol.Tile} */ (this.dequeue()[0]); tile = /** @type {ol.Tile} */ (this.dequeue()[0]);
tileKey = tile.getKey(); tileKey = tile.getKey();
if (tile.getState() === ol.Tile.State.IDLE && !(tileKey in this.tilesLoadingKeys_)) { if (tile.getState() === ol.TileState.IDLE && !(tileKey in this.tilesLoadingKeys_)) {
this.tilesLoadingKeys_[tileKey] = true; this.tilesLoadingKeys_[tileKey] = true;
++this.tilesLoading_; ++this.tilesLoading_;
++newLoads; ++newLoads;

13
src/ol/tilestate.js Normal file
View File

@@ -0,0 +1,13 @@
goog.provide('ol.TileState');
/**
* @enum {number}
*/
ol.TileState = {
IDLE: 0,
LOADING: 1,
LOADED: 2,
ERROR: 3,
EMPTY: 4,
ABORT: 5
};

View File

@@ -2,6 +2,7 @@ goog.provide('ol.VectorTile');
goog.require('ol'); goog.require('ol');
goog.require('ol.Tile'); goog.require('ol.Tile');
goog.require('ol.TileState');
goog.require('ol.dom'); goog.require('ol.dom');
goog.require('ol.featureloader'); goog.require('ol.featureloader');
@@ -10,7 +11,7 @@ goog.require('ol.featureloader');
* @constructor * @constructor
* @extends {ol.Tile} * @extends {ol.Tile}
* @param {ol.TileCoord} tileCoord Tile coordinate. * @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {ol.Tile.State} state State. * @param {ol.TileState} state State.
* @param {string} src Data source url. * @param {string} src Data source url.
* @param {ol.format.Feature} format Feature format. * @param {ol.format.Feature} format Feature format.
* @param {ol.TileLoadFunctionType} tileLoadFunction Tile load function. * @param {ol.TileLoadFunctionType} tileLoadFunction Tile load function.
@@ -141,8 +142,8 @@ ol.VectorTile.prototype.getProjection = function() {
* Load the tile. * Load the tile.
*/ */
ol.VectorTile.prototype.load = function() { ol.VectorTile.prototype.load = function() {
if (this.state == ol.Tile.State.IDLE) { if (this.state == ol.TileState.IDLE) {
this.setState(ol.Tile.State.LOADING); this.setState(ol.TileState.LOADING);
this.tileLoadFunction_(this, this.url_); this.tileLoadFunction_(this, this.url_);
this.loader_(null, NaN, null); this.loader_(null, NaN, null);
} }
@@ -164,7 +165,7 @@ ol.VectorTile.prototype.onLoad_ = function(features, dataProjection) {
* Handler for tile load errors. * Handler for tile load errors.
*/ */
ol.VectorTile.prototype.onError_ = function() { ol.VectorTile.prototype.onError_ = function() {
this.setState(ol.Tile.State.ERROR); this.setState(ol.TileState.ERROR);
}; };
@@ -174,7 +175,7 @@ ol.VectorTile.prototype.onError_ = function() {
*/ */
ol.VectorTile.prototype.setFeatures = function(features) { ol.VectorTile.prototype.setFeatures = function(features) {
this.features_ = features; this.features_ = features;
this.setState(ol.Tile.State.LOADED); this.setState(ol.TileState.LOADED);
}; };
@@ -189,7 +190,7 @@ ol.VectorTile.prototype.setProjection = function(projection) {
/** /**
* @param {ol.Tile.State} tileState Tile state. * @param {ol.TileState} tileState Tile state.
*/ */
ol.VectorTile.prototype.setState = function(tileState) { ol.VectorTile.prototype.setState = function(tileState) {
this.state = tileState; this.state = tileState;

View File

@@ -1,7 +1,7 @@
goog.provide('ol.test.ImageTile'); goog.provide('ol.test.ImageTile');
goog.require('ol.ImageTile'); goog.require('ol.ImageTile');
goog.require('ol.Tile'); goog.require('ol.TileState');
goog.require('ol.events'); goog.require('ol.events');
goog.require('ol.events.EventType'); goog.require('ol.events.EventType');
goog.require('ol.source.Image'); goog.require('ol.source.Image');
@@ -13,7 +13,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.Tile.State.IDLE; var state = ol.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);
@@ -22,10 +22,10 @@ describe('ol.ImageTile', function() {
ol.events.listen(tile, ol.events.EventType.CHANGE, function(event) { ol.events.listen(tile, ol.events.EventType.CHANGE, function(event) {
var state = tile.getState(); var state = tile.getState();
if (previousState == ol.Tile.State.IDLE) { if (previousState == ol.TileState.IDLE) {
expect(state).to.be(ol.Tile.State.LOADING); expect(state).to.be(ol.TileState.LOADING);
} else if (previousState == ol.Tile.State.LOADING) { } else if (previousState == ol.TileState.LOADING) {
expect(state).to.be(ol.Tile.State.LOADED); expect(state).to.be(ol.TileState.LOADED);
done(); done();
} else { } else {
expect().fail(); expect().fail();
@@ -38,7 +38,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.Tile.State.ERROR; var state = ol.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);
@@ -47,10 +47,10 @@ describe('ol.ImageTile', function() {
ol.events.listen(tile, ol.events.EventType.CHANGE, function(event) { ol.events.listen(tile, ol.events.EventType.CHANGE, function(event) {
var state = tile.getState(); var state = tile.getState();
if (previousState == ol.Tile.State.ERROR) { if (previousState == ol.TileState.ERROR) {
expect(state).to.be(ol.Tile.State.LOADING); expect(state).to.be(ol.TileState.LOADING);
} else if (previousState == ol.Tile.State.LOADING) { } else if (previousState == ol.TileState.LOADING) {
expect(state).to.be(ol.Tile.State.LOADED); expect(state).to.be(ol.TileState.LOADED);
done(); done();
} else { } else {
expect().fail(); expect().fail();

View File

@@ -248,7 +248,7 @@ describe('ol.source.Tile', function() {
* *
* @constructor * @constructor
* @extends {ol.source.Tile} * @extends {ol.source.Tile}
* @param {Object.<string, ol.Tile.State>} tileStates Lookup of tile key to * @param {Object.<string, ol.TileState>} tileStates Lookup of tile key to
* tile state. * tile state.
*/ */
ol.test.source.TileMock = function(tileStates) { ol.test.source.TileMock = function(tileStates) {

View File

@@ -1,13 +1,13 @@
goog.provide('ol.test.Tile'); goog.provide('ol.test.Tile');
goog.require('ol.Tile'); goog.require('ol.TileState');
describe('ol.Tile', function() { describe('ol.Tile', function() {
describe('interimChain', function() { describe('interimChain', 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.Tile.State.IDLE); head = new ol.ImageTile(tileCoord, ol.TileState.IDLE);
ol.getUid(head); ol.getUid(head);
var addToChain = function(tile, state) { var addToChain = function(tile, state) {
@@ -16,15 +16,15 @@ describe('ol.Tile', function() {
tile.interimTile = next; tile.interimTile = next;
return next; return next;
}; };
var tail = addToChain(head, ol.Tile.State.IDLE); //discard, deprecated by head var tail = addToChain(head, ol.TileState.IDLE); //discard, deprecated by head
tail = addToChain(tail, ol.Tile.State.LOADING); //keep, request already going tail = addToChain(tail, ol.TileState.LOADING); //keep, request already going
tail = addToChain(tail, ol.Tile.State.IDLE); //discard, deprecated by head tail = addToChain(tail, ol.TileState.IDLE); //discard, deprecated by head
tail = addToChain(tail, ol.Tile.State.LOADED); //keep, use for rendering tail = addToChain(tail, ol.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.Tile.State.IDLE); //rest of list outdated by tile above tail = addToChain(tail, ol.TileState.IDLE); //rest of list outdated by tile above
tail = addToChain(tail, ol.Tile.State.LOADED); tail = addToChain(tail, ol.TileState.LOADED);
tail = addToChain(tail, ol.Tile.State.LOADING); tail = addToChain(tail, ol.TileState.LOADING);
tail = addToChain(tail, ol.Tile.State.LOADED); tail = addToChain(tail, ol.TileState.LOADED);
}); });

View File

@@ -1,6 +1,6 @@
goog.provide('ol.test.rendering.reproj.Tile'); goog.provide('ol.test.rendering.reproj.Tile');
goog.require('ol.Tile'); goog.require('ol.TileState');
goog.require('ol.events'); goog.require('ol.events');
goog.require('ol.proj'); goog.require('ol.proj');
goog.require('ol.reproj.Tile'); goog.require('ol.reproj.Tile');
@@ -24,9 +24,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.Tile.State.IDLE) { if (tile.getState() == ol.TileState.IDLE) {
ol.events.listen(tile, 'change', function(e) { ol.events.listen(tile, 'change', function(e) {
if (tile.getState() == ol.Tile.State.LOADED) { if (tile.getState() == ol.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);
} }