Remove state enum from tile constructor
This commit is contained in:
@@ -4450,7 +4450,7 @@ olx.source.TileUTFGridOptions.prototype.url;
|
||||
* reprojectionErrorThreshold: (number|undefined),
|
||||
* state: (ol.source.State|undefined),
|
||||
* tileClass: (function(new: ol.ImageTile, ol.TileCoord,
|
||||
* ol.Tile.State, string, ?string,
|
||||
* ol.TileState, string, ?string,
|
||||
* ol.TileLoadFunctionType)|undefined),
|
||||
* tileGrid: (ol.tilegrid.TileGrid|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}.
|
||||
* @type {function(new: ol.ImageTile, ol.TileCoord,
|
||||
* ol.Tile.State, string, ?string,
|
||||
* ol.TileState, string, ?string,
|
||||
* ol.TileLoadFunctionType)|undefined}
|
||||
* @api
|
||||
*/
|
||||
@@ -4620,7 +4620,7 @@ olx.source.TileImageOptions.prototype.wrapX;
|
||||
* projection: ol.ProjectionLike,
|
||||
* state: (ol.source.State|undefined),
|
||||
* tileClass: (function(new: ol.VectorTile, ol.TileCoord,
|
||||
* ol.Tile.State, string, ol.format.Feature,
|
||||
* ol.TileState, string, ol.format.Feature,
|
||||
* ol.TileLoadFunctionType)|undefined),
|
||||
* tileGrid: (ol.tilegrid.TileGrid|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}.
|
||||
* @type {function(new: ol.VectorTile, ol.TileCoord,
|
||||
* ol.Tile.State, string, ol.format.Feature,
|
||||
* ol.TileState, string, ol.format.Feature,
|
||||
* ol.TileLoadFunctionType)|undefined}
|
||||
* @api
|
||||
*/
|
||||
@@ -6206,7 +6206,7 @@ olx.source.VectorOptions.prototype.wrapX;
|
||||
* tileLoadFunction: (ol.TileLoadFunctionType|undefined),
|
||||
* urls: (Array.<string>|undefined),
|
||||
* tileClass: (function(new: ol.ImageTile, ol.TileCoord,
|
||||
* ol.Tile.State, string, ?string,
|
||||
* ol.TileState, string, ?string,
|
||||
* ol.TileLoadFunctionType)|undefined),
|
||||
* wrapX: (boolean|undefined)}}
|
||||
*/
|
||||
@@ -6301,7 +6301,7 @@ olx.source.WMTSOptions.prototype.style;
|
||||
/**
|
||||
* Class used to instantiate image tiles. Default is {@link ol.ImageTile}.
|
||||
* @type {function(new: ol.ImageTile, ol.TileCoord,
|
||||
* ol.Tile.State, string, ?string,
|
||||
* ol.TileState, string, ?string,
|
||||
* ol.TileLoadFunctionType)|undefined}
|
||||
* @api
|
||||
*/
|
||||
|
||||
@@ -2,6 +2,7 @@ goog.provide('ol.ImageTile');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.events.EventType');
|
||||
|
||||
@@ -10,7 +11,7 @@ goog.require('ol.events.EventType');
|
||||
* @constructor
|
||||
* @extends {ol.Tile}
|
||||
* @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} crossOrigin Cross origin.
|
||||
* @param {ol.TileLoadFunctionType} tileLoadFunction Tile load function.
|
||||
@@ -56,13 +57,13 @@ ol.inherits(ol.ImageTile, ol.Tile);
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.ImageTile.prototype.disposeInternal = function() {
|
||||
if (this.state == ol.Tile.State.LOADING) {
|
||||
if (this.state == ol.TileState.LOADING) {
|
||||
this.unlistenImage_();
|
||||
}
|
||||
if (this.interimTile) {
|
||||
this.interimTile.dispose();
|
||||
}
|
||||
this.state = ol.Tile.State.ABORT;
|
||||
this.state = ol.TileState.ABORT;
|
||||
this.changed();
|
||||
ol.Tile.prototype.disposeInternal.call(this);
|
||||
};
|
||||
@@ -92,7 +93,7 @@ ol.ImageTile.prototype.getKey = function() {
|
||||
* @private
|
||||
*/
|
||||
ol.ImageTile.prototype.handleImageError_ = function() {
|
||||
this.state = ol.Tile.State.ERROR;
|
||||
this.state = ol.TileState.ERROR;
|
||||
this.unlistenImage_();
|
||||
this.changed();
|
||||
};
|
||||
@@ -105,9 +106,9 @@ ol.ImageTile.prototype.handleImageError_ = function() {
|
||||
*/
|
||||
ol.ImageTile.prototype.handleImageLoad_ = function() {
|
||||
if (this.image_.naturalWidth && this.image_.naturalHeight) {
|
||||
this.state = ol.Tile.State.LOADED;
|
||||
this.state = ol.TileState.LOADED;
|
||||
} else {
|
||||
this.state = ol.Tile.State.EMPTY;
|
||||
this.state = ol.TileState.EMPTY;
|
||||
}
|
||||
this.unlistenImage_();
|
||||
this.changed();
|
||||
@@ -121,8 +122,8 @@ ol.ImageTile.prototype.handleImageLoad_ = function() {
|
||||
* @api
|
||||
*/
|
||||
ol.ImageTile.prototype.load = function() {
|
||||
if (this.state == ol.Tile.State.IDLE || this.state == ol.Tile.State.ERROR) {
|
||||
this.state = ol.Tile.State.LOADING;
|
||||
if (this.state == ol.TileState.IDLE || this.state == ol.TileState.ERROR) {
|
||||
this.state = ol.TileState.LOADING;
|
||||
this.changed();
|
||||
ol.DEBUG && console.assert(!this.imageListenerKeys_,
|
||||
'this.imageListenerKeys_ should be null');
|
||||
|
||||
@@ -164,7 +164,7 @@ ol.OVERVIEWMAP_MIN_RATIO = 0.1;
|
||||
* This can happen if the developer defines projections improperly and/or
|
||||
* with unlimited extents.
|
||||
* 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;
|
||||
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
goog.provide('ol.renderer.canvas.TileLayer');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.transform');
|
||||
goog.require('ol.TileRange');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.ViewHint');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.dom');
|
||||
goog.require('ol.extent');
|
||||
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) {
|
||||
var tileState = tile.getState();
|
||||
var useInterimTilesOnError = this.getLayer().getUseInterimTilesOnError();
|
||||
return tileState == ol.Tile.State.LOADED ||
|
||||
tileState == ol.Tile.State.EMPTY ||
|
||||
tileState == ol.Tile.State.ERROR && !useInterimTilesOnError;
|
||||
return tileState == ol.TileState.LOADED ||
|
||||
tileState == ol.TileState.EMPTY ||
|
||||
tileState == ol.TileState.ERROR && !useInterimTilesOnError;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -147,7 +147,7 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame = function(frameState, layer
|
||||
tile = tile.getInterimTile();
|
||||
}
|
||||
if (this.isDrawableTile_(tile)) {
|
||||
if (tile.getState() == ol.Tile.State.LOADED) {
|
||||
if (tile.getState() == ol.TileState.LOADED) {
|
||||
tilesToDrawByZ[z][tile.tileCoord.toString()] = tile;
|
||||
if (!newTiles && this.renderedTiles.indexOf(tile) == -1) {
|
||||
newTiles = true;
|
||||
|
||||
@@ -3,7 +3,7 @@ goog.provide('ol.renderer.Layer');
|
||||
goog.require('ol');
|
||||
goog.require('ol.ImageState');
|
||||
goog.require('ol.Observable');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.asserts');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.events.EventType');
|
||||
@@ -269,7 +269,7 @@ ol.renderer.Layer.prototype.manageTilePyramid = function(
|
||||
for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
|
||||
if (currentZ - z <= preload) {
|
||||
tile = tileSource.getTile(z, x, y, pixelRatio, projection);
|
||||
if (tile.getState() == ol.Tile.State.IDLE) {
|
||||
if (tile.getState() == ol.TileState.IDLE) {
|
||||
wantedTiles[tile.getKey()] = true;
|
||||
if (!tileQueue.isKeyQueued(tile.getKey())) {
|
||||
tileQueue.enqueue([tile, tileSourceKey,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
goog.provide('ol.renderer.webgl.TileLayer');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.TileRange');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.extent');
|
||||
@@ -242,20 +242,20 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame = function(frameState, layerS
|
||||
}
|
||||
}
|
||||
tileState = tile.getState();
|
||||
drawable = tileState == ol.Tile.State.LOADED ||
|
||||
tileState == ol.Tile.State.EMPTY ||
|
||||
tileState == ol.Tile.State.ERROR && !useInterimTilesOnError;
|
||||
drawable = tileState == ol.TileState.LOADED ||
|
||||
tileState == ol.TileState.EMPTY ||
|
||||
tileState == ol.TileState.ERROR && !useInterimTilesOnError;
|
||||
if (!drawable) {
|
||||
tile = tile.getInterimTile();
|
||||
}
|
||||
tileState = tile.getState();
|
||||
if (tileState == ol.Tile.State.LOADED) {
|
||||
if (tileState == ol.TileState.LOADED) {
|
||||
if (mapRenderer.isTileTextureLoaded(tile)) {
|
||||
tilesToDrawByZ[z][tile.tileCoord.toString()] = tile;
|
||||
continue;
|
||||
}
|
||||
} else if (tileState == ol.Tile.State.EMPTY ||
|
||||
(tileState == ol.Tile.State.ERROR &&
|
||||
} else if (tileState == ol.TileState.EMPTY ||
|
||||
(tileState == ol.TileState.ERROR &&
|
||||
!useInterimTilesOnError)) {
|
||||
continue;
|
||||
}
|
||||
@@ -322,7 +322,7 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame = function(frameState, layerS
|
||||
* @param {ol.Tile} tile Tile.
|
||||
*/
|
||||
function(tile) {
|
||||
if (tile.getState() == ol.Tile.State.LOADED &&
|
||||
if (tile.getState() == ol.TileState.LOADED &&
|
||||
!mapRenderer.isTileTextureLoaded(tile) &&
|
||||
!tileTextureQueue.isKeyQueued(tile.getKey())) {
|
||||
tileTextureQueue.enqueue([
|
||||
|
||||
@@ -2,6 +2,7 @@ goog.provide('ol.reproj.Tile');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.events.EventType');
|
||||
goog.require('ol.extent');
|
||||
@@ -35,7 +36,7 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
|
||||
pixelRatio, gutter, getTileFunction,
|
||||
opt_errorThreshold,
|
||||
opt_renderEdges) {
|
||||
ol.Tile.call(this, tileCoord, ol.Tile.State.IDLE);
|
||||
ol.Tile.call(this, tileCoord, ol.TileState.IDLE);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -107,7 +108,7 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
|
||||
if (ol.extent.getArea(limitedTargetExtent) === 0) {
|
||||
// Tile is completely outside range -> EMPTY
|
||||
// TODO: is it actually correct that the source even creates the tile ?
|
||||
this.state = ol.Tile.State.EMPTY;
|
||||
this.state = ol.TileState.EMPTY;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -131,7 +132,7 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
|
||||
if (!isFinite(sourceResolution) || sourceResolution <= 0) {
|
||||
// invalid sourceResolution -> EMPTY
|
||||
// probably edges of the projections when no extent is defined
|
||||
this.state = ol.Tile.State.EMPTY;
|
||||
this.state = ol.TileState.EMPTY;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -148,7 +149,7 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
|
||||
|
||||
if (this.triangulation_.getTriangles().length === 0) {
|
||||
// no valid triangles -> EMPTY
|
||||
this.state = ol.Tile.State.EMPTY;
|
||||
this.state = ol.TileState.EMPTY;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -167,7 +168,7 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
|
||||
}
|
||||
|
||||
if (!ol.extent.getArea(sourceExtent)) {
|
||||
this.state = ol.Tile.State.EMPTY;
|
||||
this.state = ol.TileState.EMPTY;
|
||||
} else {
|
||||
var sourceRange = sourceTileGrid.getTileRangeForExtentAndZ(
|
||||
sourceExtent, this.sourceZ_);
|
||||
@@ -175,7 +176,7 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
|
||||
var tilesRequired = sourceRange.getWidth() * sourceRange.getHeight();
|
||||
if (ol.DEBUG && !(tilesRequired < ol.RASTER_REPROJECTION_MAX_SOURCE_TILES)) {
|
||||
console.assert(false, 'reasonable number of tiles is required');
|
||||
this.state = ol.Tile.State.ERROR;
|
||||
this.state = ol.TileState.ERROR;
|
||||
return;
|
||||
}
|
||||
for (var srcX = sourceRange.minX; srcX <= sourceRange.maxX; srcX++) {
|
||||
@@ -188,7 +189,7 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
|
||||
}
|
||||
|
||||
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
|
||||
*/
|
||||
ol.reproj.Tile.prototype.disposeInternal = function() {
|
||||
if (this.state == ol.Tile.State.LOADING) {
|
||||
if (this.state == ol.TileState.LOADING) {
|
||||
this.unlistenSources_();
|
||||
}
|
||||
ol.Tile.prototype.disposeInternal.call(this);
|
||||
@@ -220,7 +221,7 @@ ol.reproj.Tile.prototype.getImage = function() {
|
||||
ol.reproj.Tile.prototype.reproject_ = function() {
|
||||
var sources = [];
|
||||
this.sourceTiles_.forEach(function(tile, i, arr) {
|
||||
if (tile && tile.getState() == ol.Tile.State.LOADED) {
|
||||
if (tile && tile.getState() == ol.TileState.LOADED) {
|
||||
sources.push({
|
||||
extent: this.sourceTileGrid_.getTileCoordExtent(tile.tileCoord),
|
||||
image: tile.getImage()
|
||||
@@ -230,7 +231,7 @@ ol.reproj.Tile.prototype.reproject_ = function() {
|
||||
this.sourceTiles_.length = 0;
|
||||
|
||||
if (sources.length === 0) {
|
||||
this.state = ol.Tile.State.ERROR;
|
||||
this.state = ol.TileState.ERROR;
|
||||
} else {
|
||||
var z = this.wrappedTileCoord_[0];
|
||||
var size = this.targetTileGrid_.getTileSize(z);
|
||||
@@ -246,7 +247,7 @@ ol.reproj.Tile.prototype.reproject_ = function() {
|
||||
targetResolution, targetExtent, this.triangulation_, sources,
|
||||
this.gutter_, this.renderEdges_);
|
||||
|
||||
this.state = ol.Tile.State.LOADED;
|
||||
this.state = ol.TileState.LOADED;
|
||||
}
|
||||
this.changed();
|
||||
};
|
||||
@@ -256,8 +257,8 @@ ol.reproj.Tile.prototype.reproject_ = function() {
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.reproj.Tile.prototype.load = function() {
|
||||
if (this.state == ol.Tile.State.IDLE) {
|
||||
this.state = ol.Tile.State.LOADING;
|
||||
if (this.state == ol.TileState.IDLE) {
|
||||
this.state = ol.TileState.LOADING;
|
||||
this.changed();
|
||||
|
||||
var leftToLoad = 0;
|
||||
@@ -268,16 +269,16 @@ ol.reproj.Tile.prototype.load = function() {
|
||||
this.sourcesListenerKeys_ = [];
|
||||
this.sourceTiles_.forEach(function(tile, i, arr) {
|
||||
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++;
|
||||
|
||||
var sourceListenKey;
|
||||
sourceListenKey = ol.events.listen(tile, ol.events.EventType.CHANGE,
|
||||
function(e) {
|
||||
var state = tile.getState();
|
||||
if (state == ol.Tile.State.LOADED ||
|
||||
state == ol.Tile.State.ERROR ||
|
||||
state == ol.Tile.State.EMPTY) {
|
||||
if (state == ol.TileState.LOADED ||
|
||||
state == ol.TileState.ERROR ||
|
||||
state == ol.TileState.EMPTY) {
|
||||
ol.events.unlistenByKey(sourceListenKey);
|
||||
leftToLoad--;
|
||||
ol.DEBUG && console.assert(leftToLoad >= 0,
|
||||
@@ -294,7 +295,7 @@ ol.reproj.Tile.prototype.load = function() {
|
||||
|
||||
this.sourceTiles_.forEach(function(tile, i, arr) {
|
||||
var state = tile.getState();
|
||||
if (state == ol.Tile.State.IDLE) {
|
||||
if (state == ol.TileState.IDLE) {
|
||||
tile.load();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
goog.provide('ol.source.Tile');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileCache');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.events.Event');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.size');
|
||||
@@ -117,7 +117,7 @@ ol.source.Tile.prototype.forEachLoadedTile = function(projection, z, tileRange,
|
||||
loaded = false;
|
||||
if (tileCache.containsKey(tileCoordKey)) {
|
||||
tile = /** @type {!ol.Tile} */ (tileCache.get(tileCoordKey));
|
||||
loaded = tile.getState() === ol.Tile.State.LOADED;
|
||||
loaded = tile.getState() === ol.TileState.LOADED;
|
||||
if (loaded) {
|
||||
loaded = (callback(tile) !== false);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ goog.provide('ol.source.TileDebug');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.dom');
|
||||
goog.require('ol.size');
|
||||
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.Tile.call(this, tileCoord, ol.Tile.State.LOADED);
|
||||
ol.Tile.call(this, tileCoord, ol.TileState.LOADED);
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -2,8 +2,8 @@ goog.provide('ol.source.TileImage');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.ImageTile');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileCache');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.events.EventType');
|
||||
goog.require('ol.proj');
|
||||
@@ -51,7 +51,7 @@ ol.source.TileImage = function(options) {
|
||||
|
||||
/**
|
||||
* @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)}
|
||||
*/
|
||||
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;
|
||||
var tile = new this.tileClass(
|
||||
tileCoord,
|
||||
tileUrl !== undefined ? ol.Tile.State.IDLE : ol.Tile.State.EMPTY,
|
||||
tileUrl !== undefined ? ol.TileState.IDLE : ol.TileState.EMPTY,
|
||||
tileUrl !== undefined ? tileUrl : '',
|
||||
this.crossOrigin,
|
||||
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);
|
||||
|
||||
//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
|
||||
tile.interimTile = interimTile.interimTile;
|
||||
} else {
|
||||
|
||||
@@ -3,6 +3,7 @@ goog.provide('ol.source.TileUTFGrid');
|
||||
goog.require('ol');
|
||||
goog.require('ol.Attribution');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.TileUrlFunction');
|
||||
goog.require('ol.asserts');
|
||||
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 tile = new ol.source.TileUTFGrid.Tile_(
|
||||
tileCoord,
|
||||
tileUrl !== undefined ? ol.Tile.State.IDLE : ol.Tile.State.EMPTY,
|
||||
tileUrl !== undefined ? ol.TileState.IDLE : ol.TileState.EMPTY,
|
||||
tileUrl !== undefined ? tileUrl : '',
|
||||
this.tileGrid.getTileCoordExtent(tileCoord),
|
||||
this.preemptive_,
|
||||
@@ -262,7 +263,7 @@ ol.source.TileUTFGrid.prototype.useTile = function(z, x, y) {
|
||||
* @constructor
|
||||
* @extends {ol.Tile}
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
* @param {ol.Tile.State} state State.
|
||||
* @param {ol.TileState} state State.
|
||||
* @param {string} src Image source URI.
|
||||
* @param {ol.Extent} extent Extent of the tile.
|
||||
* @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
|
||||
*/
|
||||
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) {
|
||||
callback.call(opt_this, this.getData(coordinate));
|
||||
}, this);
|
||||
@@ -411,7 +412,7 @@ ol.source.TileUTFGrid.Tile_.prototype.getKey = function() {
|
||||
* @private
|
||||
*/
|
||||
ol.source.TileUTFGrid.Tile_.prototype.handleError_ = function() {
|
||||
this.state = ol.Tile.State.ERROR;
|
||||
this.state = ol.TileState.ERROR;
|
||||
this.changed();
|
||||
};
|
||||
|
||||
@@ -425,7 +426,7 @@ ol.source.TileUTFGrid.Tile_.prototype.handleLoad_ = function(json) {
|
||||
this.keys_ = json.keys;
|
||||
this.data_ = json.data;
|
||||
|
||||
this.state = ol.Tile.State.EMPTY;
|
||||
this.state = ol.TileState.EMPTY;
|
||||
this.changed();
|
||||
};
|
||||
|
||||
@@ -434,8 +435,8 @@ ol.source.TileUTFGrid.Tile_.prototype.handleLoad_ = function(json) {
|
||||
* @private
|
||||
*/
|
||||
ol.source.TileUTFGrid.Tile_.prototype.loadInternal_ = function() {
|
||||
if (this.state == ol.Tile.State.IDLE) {
|
||||
this.state = ol.Tile.State.LOADING;
|
||||
if (this.state == ol.TileState.IDLE) {
|
||||
this.state = ol.TileState.LOADING;
|
||||
if (this.jsonp_) {
|
||||
ol.net.jsonp(this.src_, this.handleLoad_.bind(this),
|
||||
this.handleError_.bind(this));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
goog.provide('ol.source.UrlTile');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.TileUrlFunction');
|
||||
goog.require('ol.source.Tile');
|
||||
|
||||
@@ -109,15 +109,15 @@ ol.source.UrlTile.prototype.getUrls = function() {
|
||||
ol.source.UrlTile.prototype.handleTileChange = function(event) {
|
||||
var tile = /** @type {ol.Tile} */ (event.target);
|
||||
switch (tile.getState()) {
|
||||
case ol.Tile.State.LOADING:
|
||||
case ol.TileState.LOADING:
|
||||
this.dispatchEvent(
|
||||
new ol.source.Tile.Event(ol.source.Tile.EventType.TILELOADSTART, tile));
|
||||
break;
|
||||
case ol.Tile.State.LOADED:
|
||||
case ol.TileState.LOADED:
|
||||
this.dispatchEvent(
|
||||
new ol.source.Tile.Event(ol.source.Tile.EventType.TILELOADEND, tile));
|
||||
break;
|
||||
case ol.Tile.State.ERROR:
|
||||
case ol.TileState.ERROR:
|
||||
this.dispatchEvent(
|
||||
new ol.source.Tile.Event(ol.source.Tile.EventType.TILELOADERROR, tile));
|
||||
break;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
goog.provide('ol.source.VectorTile');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.VectorTile');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.events.EventType');
|
||||
@@ -59,7 +59,7 @@ ol.source.VectorTile = function(options) {
|
||||
|
||||
/**
|
||||
* @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)}
|
||||
*/
|
||||
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;
|
||||
var tile = new this.tileClass(
|
||||
tileCoord,
|
||||
tileUrl !== undefined ? ol.Tile.State.IDLE : ol.Tile.State.EMPTY,
|
||||
tileUrl !== undefined ? ol.TileState.IDLE : ol.TileState.EMPTY,
|
||||
tileUrl !== undefined ? tileUrl : '',
|
||||
this.format_, this.tileLoadFunction);
|
||||
ol.events.listen(tile, ol.events.EventType.CHANGE,
|
||||
|
||||
@@ -2,7 +2,7 @@ goog.provide('ol.source.Zoomify');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.ImageTile');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.asserts');
|
||||
goog.require('ol.dom');
|
||||
goog.require('ol.extent');
|
||||
@@ -127,7 +127,7 @@ ol.inherits(ol.source.Zoomify, ol.source.TileImage);
|
||||
* @constructor
|
||||
* @extends {ol.ImageTile}
|
||||
* @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} crossOrigin Cross origin.
|
||||
* @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 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) {
|
||||
this.zoomifyImage_ = image;
|
||||
return image;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
goog.provide('ol.Tile');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.events.EventTarget');
|
||||
goog.require('ol.events.EventType');
|
||||
|
||||
@@ -12,7 +13,7 @@ goog.require('ol.events.EventType');
|
||||
* @constructor
|
||||
* @extends {ol.events.EventTarget}
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
* @param {ol.Tile.State} state State.
|
||||
* @param {ol.TileState} state State.
|
||||
*/
|
||||
ol.Tile = function(tileCoord, state) {
|
||||
|
||||
@@ -25,7 +26,7 @@ ol.Tile = function(tileCoord, state) {
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {ol.Tile.State}
|
||||
* @type {ol.TileState}
|
||||
*/
|
||||
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
|
||||
// cleaned up by refreshInterimChain)
|
||||
do {
|
||||
if (tile.getState() == ol.Tile.State.LOADED) {
|
||||
if (tile.getState() == ol.TileState.LOADED) {
|
||||
return tile;
|
||||
}
|
||||
tile = tile.interimTile;
|
||||
@@ -113,17 +114,17 @@ ol.Tile.prototype.refreshInterimChain = function() {
|
||||
var prev = this;
|
||||
|
||||
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 would could abort any LOADING tile request
|
||||
//older than this tile (i.e. any LOADING tile following this entry in the chain)
|
||||
tile.interimTile = null;
|
||||
break;
|
||||
} else if (tile.getState() == ol.Tile.State.LOADING) {
|
||||
} else if (tile.getState() == ol.TileState.LOADING) {
|
||||
//keep this LOADING tile any loaded tiles later in the chain are
|
||||
//older than this tile, so we're still interested in the request
|
||||
prev = tile;
|
||||
} else if (tile.getState() == ol.Tile.State.IDLE) {
|
||||
} else if (tile.getState() == ol.TileState.IDLE) {
|
||||
//the head of the list is the most current tile, we don't need
|
||||
//to start any other requests for this chain
|
||||
prev.interimTile = tile.interimTile;
|
||||
@@ -145,7 +146,7 @@ ol.Tile.prototype.getTileCoord = function() {
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.Tile.State} State.
|
||||
* @return {ol.TileState} State.
|
||||
*/
|
||||
ol.Tile.prototype.getState = function() {
|
||||
return this.state;
|
||||
@@ -160,16 +161,3 @@ ol.Tile.prototype.getState = function() {
|
||||
* @api
|
||||
*/
|
||||
ol.Tile.prototype.load = function() {};
|
||||
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
ol.Tile.State = {
|
||||
IDLE: 0,
|
||||
LOADING: 1,
|
||||
LOADED: 2,
|
||||
ERROR: 3,
|
||||
EMPTY: 4,
|
||||
ABORT: 5
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
goog.provide('ol.TileQueue');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.events.EventType');
|
||||
goog.require('ol.structs.PriorityQueue');
|
||||
@@ -86,8 +86,8 @@ ol.TileQueue.prototype.getTilesLoading = function() {
|
||||
ol.TileQueue.prototype.handleTileChange = function(event) {
|
||||
var tile = /** @type {ol.Tile} */ (event.target);
|
||||
var state = tile.getState();
|
||||
if (state === ol.Tile.State.LOADED || state === ol.Tile.State.ERROR ||
|
||||
state === ol.Tile.State.EMPTY || state === ol.Tile.State.ABORT) {
|
||||
if (state === ol.TileState.LOADED || state === ol.TileState.ERROR ||
|
||||
state === ol.TileState.EMPTY || state === ol.TileState.ABORT) {
|
||||
ol.events.unlisten(tile, ol.events.EventType.CHANGE,
|
||||
this.handleTileChange, this);
|
||||
var tileKey = tile.getKey();
|
||||
@@ -112,7 +112,7 @@ ol.TileQueue.prototype.loadMoreTiles = function(maxTotalLoading, maxNewLoads) {
|
||||
this.getCount() > 0) {
|
||||
tile = /** @type {ol.Tile} */ (this.dequeue()[0]);
|
||||
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.tilesLoading_;
|
||||
++newLoads;
|
||||
|
||||
13
src/ol/tilestate.js
Normal file
13
src/ol/tilestate.js
Normal 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
|
||||
};
|
||||
@@ -2,6 +2,7 @@ goog.provide('ol.VectorTile');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.dom');
|
||||
goog.require('ol.featureloader');
|
||||
|
||||
@@ -10,7 +11,7 @@ goog.require('ol.featureloader');
|
||||
* @constructor
|
||||
* @extends {ol.Tile}
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
* @param {ol.Tile.State} state State.
|
||||
* @param {ol.TileState} state State.
|
||||
* @param {string} src Data source url.
|
||||
* @param {ol.format.Feature} format Feature format.
|
||||
* @param {ol.TileLoadFunctionType} tileLoadFunction Tile load function.
|
||||
@@ -141,8 +142,8 @@ ol.VectorTile.prototype.getProjection = function() {
|
||||
* Load the tile.
|
||||
*/
|
||||
ol.VectorTile.prototype.load = function() {
|
||||
if (this.state == ol.Tile.State.IDLE) {
|
||||
this.setState(ol.Tile.State.LOADING);
|
||||
if (this.state == ol.TileState.IDLE) {
|
||||
this.setState(ol.TileState.LOADING);
|
||||
this.tileLoadFunction_(this, this.url_);
|
||||
this.loader_(null, NaN, null);
|
||||
}
|
||||
@@ -164,7 +165,7 @@ ol.VectorTile.prototype.onLoad_ = function(features, dataProjection) {
|
||||
* Handler for tile load errors.
|
||||
*/
|
||||
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) {
|
||||
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) {
|
||||
this.state = tileState;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
goog.provide('ol.test.ImageTile');
|
||||
|
||||
goog.require('ol.ImageTile');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.events.EventType');
|
||||
goog.require('ol.source.Image');
|
||||
@@ -13,7 +13,7 @@ describe('ol.ImageTile', function() {
|
||||
|
||||
it('can load idle tile', function(done) {
|
||||
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 tileLoadFunction = ol.source.Image.defaultImageLoadFunction;
|
||||
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) {
|
||||
var state = tile.getState();
|
||||
if (previousState == ol.Tile.State.IDLE) {
|
||||
expect(state).to.be(ol.Tile.State.LOADING);
|
||||
} else if (previousState == ol.Tile.State.LOADING) {
|
||||
expect(state).to.be(ol.Tile.State.LOADED);
|
||||
if (previousState == ol.TileState.IDLE) {
|
||||
expect(state).to.be(ol.TileState.LOADING);
|
||||
} else if (previousState == ol.TileState.LOADING) {
|
||||
expect(state).to.be(ol.TileState.LOADED);
|
||||
done();
|
||||
} else {
|
||||
expect().fail();
|
||||
@@ -38,7 +38,7 @@ describe('ol.ImageTile', function() {
|
||||
|
||||
it('can load error tile', function(done) {
|
||||
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 tileLoadFunction = ol.source.Image.defaultImageLoadFunction;
|
||||
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) {
|
||||
var state = tile.getState();
|
||||
if (previousState == ol.Tile.State.ERROR) {
|
||||
expect(state).to.be(ol.Tile.State.LOADING);
|
||||
} else if (previousState == ol.Tile.State.LOADING) {
|
||||
expect(state).to.be(ol.Tile.State.LOADED);
|
||||
if (previousState == ol.TileState.ERROR) {
|
||||
expect(state).to.be(ol.TileState.LOADING);
|
||||
} else if (previousState == ol.TileState.LOADING) {
|
||||
expect(state).to.be(ol.TileState.LOADED);
|
||||
done();
|
||||
} else {
|
||||
expect().fail();
|
||||
|
||||
@@ -248,7 +248,7 @@ describe('ol.source.Tile', function() {
|
||||
*
|
||||
* @constructor
|
||||
* @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.
|
||||
*/
|
||||
ol.test.source.TileMock = function(tileStates) {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
goog.provide('ol.test.Tile');
|
||||
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileState');
|
||||
|
||||
describe('ol.Tile', function() {
|
||||
describe('interimChain', function() {
|
||||
var head, renderTile;
|
||||
beforeEach(function() {
|
||||
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);
|
||||
|
||||
var addToChain = function(tile, state) {
|
||||
@@ -16,15 +16,15 @@ describe('ol.Tile', function() {
|
||||
tile.interimTile = next;
|
||||
return next;
|
||||
};
|
||||
var tail = addToChain(head, ol.Tile.State.IDLE); //discard, deprecated by head
|
||||
tail = addToChain(tail, ol.Tile.State.LOADING); //keep, request already going
|
||||
tail = addToChain(tail, ol.Tile.State.IDLE); //discard, deprecated by head
|
||||
tail = addToChain(tail, ol.Tile.State.LOADED); //keep, use for rendering
|
||||
var tail = addToChain(head, ol.TileState.IDLE); //discard, deprecated by head
|
||||
tail = addToChain(tail, ol.TileState.LOADING); //keep, request already going
|
||||
tail = addToChain(tail, ol.TileState.IDLE); //discard, deprecated by head
|
||||
tail = addToChain(tail, ol.TileState.LOADED); //keep, use for rendering
|
||||
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.Tile.State.LOADED);
|
||||
tail = addToChain(tail, ol.Tile.State.LOADING);
|
||||
tail = addToChain(tail, ol.Tile.State.LOADED);
|
||||
tail = addToChain(tail, ol.TileState.IDLE); //rest of list outdated by tile above
|
||||
tail = addToChain(tail, ol.TileState.LOADED);
|
||||
tail = addToChain(tail, ol.TileState.LOADING);
|
||||
tail = addToChain(tail, ol.TileState.LOADED);
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
goog.provide('ol.test.rendering.reproj.Tile');
|
||||
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.reproj.Tile');
|
||||
@@ -24,9 +24,9 @@ describe('ol.rendering.reproj.Tile', function() {
|
||||
tilesRequested++;
|
||||
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) {
|
||||
if (tile.getState() == ol.Tile.State.LOADED) {
|
||||
if (tile.getState() == ol.TileState.LOADED) {
|
||||
expect(tilesRequested).to.be(expectedRequests);
|
||||
resembleCanvas(tile.getImage(), expectedUrl, 7.5, done);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user