Move State to ol.Tile
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
goog.provide('ol.reproj.Tile');
|
||||
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.events.EventType');
|
||||
goog.require('ol.extent');
|
||||
@@ -36,7 +35,7 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
|
||||
pixelRatio, gutter, getTileFunction,
|
||||
opt_errorThreshold,
|
||||
opt_renderEdges) {
|
||||
ol.Tile.call(this, tileCoord, ol.TileState.IDLE);
|
||||
ol.Tile.call(this, tileCoord, ol.Tile.State.IDLE);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -114,7 +113,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.TileState.EMPTY;
|
||||
this.state = ol.Tile.State.EMPTY;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -138,7 +137,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.TileState.EMPTY;
|
||||
this.state = ol.Tile.State.EMPTY;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -155,7 +154,7 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
|
||||
|
||||
if (this.triangulation_.getTriangles().length === 0) {
|
||||
// no valid triangles -> EMPTY
|
||||
this.state = ol.TileState.EMPTY;
|
||||
this.state = ol.Tile.State.EMPTY;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -174,7 +173,7 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
|
||||
}
|
||||
|
||||
if (!ol.extent.getArea(sourceExtent)) {
|
||||
this.state = ol.TileState.EMPTY;
|
||||
this.state = ol.Tile.State.EMPTY;
|
||||
} else {
|
||||
var sourceRange = sourceTileGrid.getTileRangeForExtentAndZ(
|
||||
sourceExtent, this.sourceZ_);
|
||||
@@ -182,7 +181,7 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
|
||||
var tilesRequired = sourceRange.getWidth() * sourceRange.getHeight();
|
||||
if (goog.DEBUG && !(tilesRequired < ol.RASTER_REPROJECTION_MAX_SOURCE_TILES)) {
|
||||
console.assert(false, 'reasonable number of tiles is required');
|
||||
this.state = ol.TileState.ERROR;
|
||||
this.state = ol.Tile.State.ERROR;
|
||||
return;
|
||||
}
|
||||
for (var srcX = sourceRange.minX; srcX <= sourceRange.maxX; srcX++) {
|
||||
@@ -195,7 +194,7 @@ ol.reproj.Tile = function(sourceProj, sourceTileGrid,
|
||||
}
|
||||
|
||||
if (this.sourceTiles_.length === 0) {
|
||||
this.state = ol.TileState.EMPTY;
|
||||
this.state = ol.Tile.State.EMPTY;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -206,7 +205,7 @@ ol.inherits(ol.reproj.Tile, ol.Tile);
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.reproj.Tile.prototype.disposeInternal = function() {
|
||||
if (this.state == ol.TileState.LOADING) {
|
||||
if (this.state == ol.Tile.State.LOADING) {
|
||||
this.unlistenSources_();
|
||||
}
|
||||
ol.Tile.prototype.disposeInternal.call(this);
|
||||
@@ -241,7 +240,7 @@ ol.reproj.Tile.prototype.getImage = function(opt_context) {
|
||||
ol.reproj.Tile.prototype.reproject_ = function() {
|
||||
var sources = [];
|
||||
this.sourceTiles_.forEach(function(tile, i, arr) {
|
||||
if (tile && tile.getState() == ol.TileState.LOADED) {
|
||||
if (tile && tile.getState() == ol.Tile.State.LOADED) {
|
||||
sources.push({
|
||||
extent: this.sourceTileGrid_.getTileCoordExtent(tile.tileCoord),
|
||||
image: tile.getImage()
|
||||
@@ -251,7 +250,7 @@ ol.reproj.Tile.prototype.reproject_ = function() {
|
||||
this.sourceTiles_.length = 0;
|
||||
|
||||
if (sources.length === 0) {
|
||||
this.state = ol.TileState.ERROR;
|
||||
this.state = ol.Tile.State.ERROR;
|
||||
} else {
|
||||
var z = this.wrappedTileCoord_[0];
|
||||
var size = this.targetTileGrid_.getTileSize(z);
|
||||
@@ -267,7 +266,7 @@ ol.reproj.Tile.prototype.reproject_ = function() {
|
||||
targetResolution, targetExtent, this.triangulation_, sources,
|
||||
this.gutter_, this.renderEdges_);
|
||||
|
||||
this.state = ol.TileState.LOADED;
|
||||
this.state = ol.Tile.State.LOADED;
|
||||
}
|
||||
this.changed();
|
||||
};
|
||||
@@ -277,8 +276,8 @@ ol.reproj.Tile.prototype.reproject_ = function() {
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.reproj.Tile.prototype.load = function() {
|
||||
if (this.state == ol.TileState.IDLE) {
|
||||
this.state = ol.TileState.LOADING;
|
||||
if (this.state == ol.Tile.State.IDLE) {
|
||||
this.state = ol.Tile.State.LOADING;
|
||||
this.changed();
|
||||
|
||||
var leftToLoad = 0;
|
||||
@@ -289,16 +288,16 @@ ol.reproj.Tile.prototype.load = function() {
|
||||
this.sourcesListenerKeys_ = [];
|
||||
this.sourceTiles_.forEach(function(tile, i, arr) {
|
||||
var state = tile.getState();
|
||||
if (state == ol.TileState.IDLE || state == ol.TileState.LOADING) {
|
||||
if (state == ol.Tile.State.IDLE || state == ol.Tile.State.LOADING) {
|
||||
leftToLoad++;
|
||||
|
||||
var sourceListenKey;
|
||||
sourceListenKey = ol.events.listen(tile, ol.events.EventType.CHANGE,
|
||||
function(e) {
|
||||
var state = tile.getState();
|
||||
if (state == ol.TileState.LOADED ||
|
||||
state == ol.TileState.ERROR ||
|
||||
state == ol.TileState.EMPTY) {
|
||||
if (state == ol.Tile.State.LOADED ||
|
||||
state == ol.Tile.State.ERROR ||
|
||||
state == ol.Tile.State.EMPTY) {
|
||||
ol.events.unlistenByKey(sourceListenKey);
|
||||
leftToLoad--;
|
||||
goog.DEBUG && console.assert(leftToLoad >= 0,
|
||||
@@ -315,7 +314,7 @@ ol.reproj.Tile.prototype.load = function() {
|
||||
|
||||
this.sourceTiles_.forEach(function(tile, i, arr) {
|
||||
var state = tile.getState();
|
||||
if (state == ol.TileState.IDLE) {
|
||||
if (state == ol.Tile.State.IDLE) {
|
||||
tile.load();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user