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

@@ -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();
}
});