Named exports from ol/structs/PriorityQueue
This commit is contained in:
@@ -27,7 +27,7 @@ import LayerGroup from './layer/Group.js';
|
|||||||
import {getMapRendererPlugins} from './plugins.js';
|
import {getMapRendererPlugins} from './plugins.js';
|
||||||
import RendererType from './renderer/Type.js';
|
import RendererType from './renderer/Type.js';
|
||||||
import {hasArea} from './size.js';
|
import {hasArea} from './size.js';
|
||||||
import PriorityQueue from './structs/PriorityQueue.js';
|
import {DROP} from './structs/PriorityQueue.js';
|
||||||
import {create as createTransform, apply as applyTransform} from './transform.js';
|
import {create as createTransform, apply as applyTransform} from './transform.js';
|
||||||
|
|
||||||
|
|
||||||
@@ -878,10 +878,10 @@ PluggableMap.prototype.getTilePriority = function(tile, tileSourceKey, tileCente
|
|||||||
// are outside the visible extent.
|
// are outside the visible extent.
|
||||||
const frameState = this.frameState_;
|
const frameState = this.frameState_;
|
||||||
if (!frameState || !(tileSourceKey in frameState.wantedTiles)) {
|
if (!frameState || !(tileSourceKey in frameState.wantedTiles)) {
|
||||||
return PriorityQueue.DROP;
|
return DROP;
|
||||||
}
|
}
|
||||||
if (!frameState.wantedTiles[tileSourceKey][tile.getKey()]) {
|
if (!frameState.wantedTiles[tileSourceKey][tile.getKey()]) {
|
||||||
return PriorityQueue.DROP;
|
return DROP;
|
||||||
}
|
}
|
||||||
// Prioritize the highest zoom level tiles closest to the focus.
|
// Prioritize the highest zoom level tiles closest to the focus.
|
||||||
// Tiles at higher zoom levels are prioritized using Math.log(tileResolution).
|
// Tiles at higher zoom levels are prioritized using Math.log(tileResolution).
|
||||||
|
|||||||
@@ -55,10 +55,9 @@ const PriorityQueue = function(priorityFunction, keyFunction) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
PriorityQueue.DROP = Infinity;
|
export const DROP = Infinity;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -102,7 +101,7 @@ PriorityQueue.prototype.enqueue = function(element) {
|
|||||||
assert(!(this.keyFunction_(element) in this.queuedElements_),
|
assert(!(this.keyFunction_(element) in this.queuedElements_),
|
||||||
31); // Tried to enqueue an `element` that was already added to the queue
|
31); // Tried to enqueue an `element` that was already added to the queue
|
||||||
const priority = this.priorityFunction_(element);
|
const priority = this.priorityFunction_(element);
|
||||||
if (priority != PriorityQueue.DROP) {
|
if (priority != DROP) {
|
||||||
this.elements_.push(element);
|
this.elements_.push(element);
|
||||||
this.priorities_.push(priority);
|
this.priorities_.push(priority);
|
||||||
this.queuedElements_[this.keyFunction_(element)] = true;
|
this.queuedElements_[this.keyFunction_(element)] = true;
|
||||||
@@ -262,7 +261,7 @@ PriorityQueue.prototype.reprioritize = function() {
|
|||||||
for (i = 0; i < n; ++i) {
|
for (i = 0; i < n; ++i) {
|
||||||
element = elements[i];
|
element = elements[i];
|
||||||
priority = priorityFunction(element);
|
priority = priorityFunction(element);
|
||||||
if (priority == PriorityQueue.DROP) {
|
if (priority == DROP) {
|
||||||
delete this.queuedElements_[this.keyFunction_(element)];
|
delete this.queuedElements_[this.keyFunction_(element)];
|
||||||
} else {
|
} else {
|
||||||
priorities[index] = priority;
|
priorities[index] = priority;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import PriorityQueue from '../../../../src/ol/structs/PriorityQueue.js';
|
import PriorityQueue, {DROP} from '../../../../src/ol/structs/PriorityQueue.js';
|
||||||
|
|
||||||
|
|
||||||
describe('ol.structs.PriorityQueue', function() {
|
describe('ol.structs.PriorityQueue', function() {
|
||||||
@@ -102,7 +102,7 @@ describe('ol.structs.PriorityQueue', function() {
|
|||||||
if (i++ % 2 === 0) {
|
if (i++ % 2 === 0) {
|
||||||
return Math.abs(element - target);
|
return Math.abs(element - target);
|
||||||
} else {
|
} else {
|
||||||
return PriorityQueue.DROP;
|
return DROP;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
pq.reprioritize();
|
pq.reprioritize();
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import Tile from '../../../src/ol/Tile.js';
|
|||||||
import TileQueue from '../../../src/ol/TileQueue.js';
|
import TileQueue from '../../../src/ol/TileQueue.js';
|
||||||
import TileState from '../../../src/ol/TileState.js';
|
import TileState from '../../../src/ol/TileState.js';
|
||||||
import ImageSource from '../../../src/ol/source/Image.js';
|
import ImageSource from '../../../src/ol/source/Image.js';
|
||||||
import PriorityQueue from '../../../src/ol/structs/PriorityQueue.js';
|
import {DROP} from '../../../src/ol/structs/PriorityQueue.js';
|
||||||
|
|
||||||
|
|
||||||
describe('ol.TileQueue', function() {
|
describe('ol.TileQueue', function() {
|
||||||
@@ -129,7 +129,7 @@ describe('ol.TileQueue', function() {
|
|||||||
let i = 0;
|
let i = 0;
|
||||||
tq.priorityFunction_ = function() {
|
tq.priorityFunction_ = function() {
|
||||||
if ((i++) % 2 === 0) {
|
if ((i++) % 2 === 0) {
|
||||||
return PriorityQueue.DROP;
|
return DROP;
|
||||||
}
|
}
|
||||||
return Math.floor(Math.random() * 100);
|
return Math.floor(Math.random() * 100);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user