Merge pull request #3895 from planetlabs/greedy-multi-queue

Rework the tile queue for multiple queues.
This commit is contained in:
Tim Schaub
2015-07-10 16:33:49 -06:00
2 changed files with 81 additions and 8 deletions

View File

@@ -89,14 +89,17 @@ ol.TileQueue.prototype.handleTileChange = function(event) {
* @param {number} maxNewLoads Maximum number of new tiles to load.
*/
ol.TileQueue.prototype.loadMoreTiles = function(maxTotalLoading, maxNewLoads) {
var newLoads = Math.min(
maxTotalLoading - this.getTilesLoading(), maxNewLoads, this.getCount());
var i, tile;
for (i = 0; i < newLoads; ++i) {
var newLoads = 0;
var tile;
while (this.tilesLoading_ < maxTotalLoading && newLoads < maxNewLoads &&
this.getCount() > 0) {
tile = /** @type {ol.Tile} */ (this.dequeue()[0]);
goog.events.listen(tile, goog.events.EventType.CHANGE,
this.handleTileChange, false, this);
tile.load();
if (tile.getState() === ol.TileState.IDLE) {
goog.events.listen(tile, goog.events.EventType.CHANGE,
this.handleTileChange, false, this);
tile.load();
++this.tilesLoading_;
++newLoads;
}
}
this.tilesLoading_ += newLoads;
};