Use Infinity rather than undefined to drop tiles

This commit is contained in:
Tom Payne
2013-01-19 15:10:22 +01:00
parent 4846a6a7b3
commit a8dc810696
3 changed files with 13 additions and 7 deletions

View File

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