Merge branch 'master' of github.com:openlayers/ol3 into vector
This commit is contained in:
@@ -410,7 +410,12 @@ ol.projection.getProj4jsProjectionFromCode_ = function(code) {
|
||||
var proj4jsProjection = proj4jsProjections[code];
|
||||
if (!goog.isDef(proj4jsProjection)) {
|
||||
var proj4jsProj = new Proj4js.Proj(code);
|
||||
proj4jsProjection = new ol.Proj4jsProjection_(code, proj4jsProj);
|
||||
var srsCode = proj4jsProj.srsCode;
|
||||
proj4jsProjection = proj4jsProjections[srsCode];
|
||||
if (!goog.isDef(proj4jsProjection)) {
|
||||
proj4jsProjection = new ol.Proj4jsProjection_(srsCode, proj4jsProj);
|
||||
proj4jsProjections[srsCode] = proj4jsProjection;
|
||||
}
|
||||
proj4jsProjections[code] = proj4jsProjection;
|
||||
}
|
||||
return proj4jsProjection;
|
||||
|
||||
@@ -158,8 +158,7 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
|
||||
|
||||
tileState = tile.getState();
|
||||
if (tileState == ol.TileState.IDLE) {
|
||||
goog.events.listenOnce(tile, goog.events.EventType.CHANGE,
|
||||
this.handleTileChange, false, this);
|
||||
this.listenToTileChange(tile);
|
||||
this.updateWantedTiles(frameState.wantedTiles, tileSource, tileCoord);
|
||||
tileCenter = tileGrid.getTileCoordCenter(tileCoord);
|
||||
frameState.tileQueue.enqueue(tile, tileSourceKey, tileCenter);
|
||||
|
||||
@@ -116,8 +116,7 @@ ol.renderer.dom.TileLayer.prototype.renderFrame =
|
||||
|
||||
tileState = tile.getState();
|
||||
if (tileState == ol.TileState.IDLE) {
|
||||
goog.events.listenOnce(tile, goog.events.EventType.CHANGE,
|
||||
this.handleTileChange, false, this);
|
||||
this.listenToTileChange(tile);
|
||||
this.updateWantedTiles(frameState.wantedTiles, tileSource, tileCoord);
|
||||
tileCenter = tileGrid.getTileCoordCenter(tileCoord);
|
||||
frameState.tileQueue.enqueue(tile, tileSourceKey, tileCenter);
|
||||
|
||||
@@ -40,6 +40,12 @@ ol.renderer.Layer = function(mapRenderer, layer) {
|
||||
*/
|
||||
this.layer_ = layer;
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {Object.<string, boolean>}
|
||||
*/
|
||||
this.observedTileKeys = {};
|
||||
|
||||
goog.events.listen(this.layer_,
|
||||
ol.Object.getChangedEventType(ol.layer.LayerProperty.BRIGHTNESS),
|
||||
this.handleLayerBrightnessChange, false, this);
|
||||
@@ -167,13 +173,29 @@ ol.renderer.Layer.prototype.handleLayerVisibleChange = function() {
|
||||
/**
|
||||
* Handle changes in tile state.
|
||||
* @param {goog.events.Event} event Tile change event.
|
||||
* @protected
|
||||
* @private
|
||||
*/
|
||||
ol.renderer.Layer.prototype.handleTileChange = function(event) {
|
||||
ol.renderer.Layer.prototype.handleTileChange_ = function(event) {
|
||||
var tile = /** @type {ol.Tile} */ (event.target);
|
||||
if (tile.getState() === ol.TileState.LOADED) {
|
||||
this.getMap().requestRenderFrame();
|
||||
}
|
||||
delete this.observedTileKeys[tile.getKey()];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Listen once to tileKey, le change event.
|
||||
* @param {ol.Tile} tile Tile.
|
||||
* @protected
|
||||
*/
|
||||
ol.renderer.Layer.prototype.listenToTileChange = function(tile) {
|
||||
var tileKey = tile.getKey();
|
||||
if (!(tileKey in this.observedTileKeys)) {
|
||||
this.observedTileKeys[tileKey] = true;
|
||||
goog.events.listenOnce(tile, goog.events.EventType.CHANGE,
|
||||
this.handleTileChange_, false, this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -391,8 +391,7 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
|
||||
|
||||
tileState = tile.getState();
|
||||
if (tileState == ol.TileState.IDLE) {
|
||||
goog.events.listenOnce(tile, goog.events.EventType.CHANGE,
|
||||
this.handleTileChange, false, this);
|
||||
this.listenToTileChange(tile);
|
||||
this.updateWantedTiles(frameState.wantedTiles, tileSource, tileCoord);
|
||||
tileCenter = tileGrid.getTileCoordCenter(tileCoord);
|
||||
frameState.tileQueue.enqueue(tile, tileSourceKey, tileCenter);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// FIXME should inQueue be private?
|
||||
|
||||
goog.provide('ol.Tile');
|
||||
goog.provide('ol.TileState');
|
||||
|
||||
@@ -28,6 +30,13 @@ ol.Tile = function(tileCoord) {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* A count incremented each time the tile is inQueue in a tile queue,
|
||||
* and decremented each time the tile is dequeued from a tile queue.
|
||||
* @type {number}
|
||||
*/
|
||||
this.inQueue = 0;
|
||||
|
||||
/**
|
||||
* @type {ol.TileCoord}
|
||||
*/
|
||||
|
||||
@@ -89,6 +89,8 @@ ol.TileQueue.prototype.dequeue_ = function() {
|
||||
}
|
||||
var tileKey = tile.getKey();
|
||||
delete this.queuedTileKeys_[tileKey];
|
||||
tile.inQueue--;
|
||||
goog.asserts.assert(tile.inQueue >= 0);
|
||||
return tile;
|
||||
};
|
||||
|
||||
@@ -110,6 +112,8 @@ ol.TileQueue.prototype.enqueue = function(tile, tileSourceKey, tileCenter) {
|
||||
this.heap_.push([priority, tile, tileSourceKey, tileCenter]);
|
||||
this.queuedTileKeys_[tileKey] = true;
|
||||
this.siftDown_(0, this.heap_.length - 1);
|
||||
tile.inQueue++;
|
||||
goog.asserts.assert(tile.inQueue > 0);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -246,6 +250,11 @@ ol.TileQueue.prototype.reprioritize = function() {
|
||||
if (priority == ol.TileQueue.DROP) {
|
||||
tileKey = tile.getKey();
|
||||
delete this.queuedTileKeys_[tileKey];
|
||||
tile.inQueue--;
|
||||
goog.asserts.assert(tile.inQueue >= 0);
|
||||
if (tile.inQueue === 0) {
|
||||
goog.events.removeAll(tile);
|
||||
}
|
||||
} else {
|
||||
node[0] = priority;
|
||||
heap[n++] = node;
|
||||
|
||||
Reference in New Issue
Block a user