Use Infinity rather than undefined to drop tiles
This commit is contained in:
@@ -455,17 +455,17 @@ ol.Map.prototype.getOverlayContainer = function() {
|
||||
* @param {ol.Tile} tile Tile.
|
||||
* @param {string} tileSourceKey Tile source key.
|
||||
* @param {ol.Coordinate} tileCenter Tile center.
|
||||
* @return {number|undefined} Tile priority.
|
||||
* @return {number} Tile priority.
|
||||
*/
|
||||
ol.Map.prototype.getTilePriority = function(tile, tileSourceKey, tileCenter) {
|
||||
var frameState = this.frameState_;
|
||||
if (goog.isNull(frameState) || !(tileSourceKey in frameState.wantedTiles)) {
|
||||
return undefined;
|
||||
return ol.TileQueue.DROP;
|
||||
}
|
||||
var zKey = tile.tileCoord.z.toString();
|
||||
if (!(zKey in frameState.wantedTiles[tileSourceKey]) ||
|
||||
!frameState.wantedTiles[tileSourceKey][zKey].contains(tile.tileCoord)) {
|
||||
return undefined;
|
||||
return ol.TileQueue.DROP;
|
||||
}
|
||||
var center = frameState.view2DState.center;
|
||||
var deltaX = tileCenter.x - center.x;
|
||||
|
||||
@@ -21,7 +21,7 @@ goog.require('ol.TileState');
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {function(ol.Tile, string, ol.Coordinate): (number|undefined)}
|
||||
* @typedef {function(ol.Tile, string, ol.Coordinate): number}
|
||||
*/
|
||||
ol.TilePriorityFunction;
|
||||
|
||||
@@ -67,6 +67,12 @@ ol.TileQueue = function(tilePriorityFunction) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @const {number}
|
||||
*/
|
||||
ol.TileQueue.DROP = Infinity;
|
||||
|
||||
|
||||
/**
|
||||
* FIXME empty description for jsdoc
|
||||
*/
|
||||
@@ -112,7 +118,7 @@ ol.TileQueue.prototype.enqueue = function(tile, tileSourceKey, tileCenter) {
|
||||
var tileKey = tile.getKey();
|
||||
if (!(tileKey in this.queuedTileKeys_)) {
|
||||
var priority = this.tilePriorityFunction_(tile, tileSourceKey, tileCenter);
|
||||
if (goog.isDef(priority)) {
|
||||
if (priority != ol.TileQueue.DROP) {
|
||||
this.heap_.push([priority, tile, tileSourceKey, tileCenter]);
|
||||
this.queuedTileKeys_[tileKey] = true;
|
||||
this.siftDown_(0, this.heap_.length - 1);
|
||||
@@ -252,7 +258,7 @@ ol.TileQueue.prototype.reprioritize = function() {
|
||||
tileSourceKey = /** @type {string} */ (node[2]);
|
||||
tileCenter = /** @type {ol.Coordinate} */ (node[3]);
|
||||
priority = this.tilePriorityFunction_(tile, tileSourceKey, tileCenter);
|
||||
if (goog.isDef(priority)) {
|
||||
if (priority != ol.TileQueue.DROP) {
|
||||
node[0] = priority;
|
||||
} else {
|
||||
goog.array.removeAt(heap, i);
|
||||
|
||||
@@ -53,7 +53,7 @@ describe('ol.TileQueue', function() {
|
||||
var i = 0;
|
||||
tq.tilePriorityFunction_ = function() {
|
||||
if ((i++) % 2 === 0) {
|
||||
return undefined;
|
||||
return ol.TileQueue.DROP;
|
||||
}
|
||||
return Math.floor(Math.random() * 100);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user