Merge pull request #7619 from fredj/more_rename

More variable renaming
This commit is contained in:
Frédéric Junod
2017-12-17 09:57:49 +01:00
committed by GitHub
23 changed files with 159 additions and 160 deletions
+5 -5
View File
@@ -12,7 +12,7 @@ import _ol_MapEventType_ from './MapEventType.js';
import _ol_MapProperty_ from './MapProperty.js'; import _ol_MapProperty_ from './MapProperty.js';
import _ol_Object_ from './Object.js'; import _ol_Object_ from './Object.js';
import _ol_ObjectEventType_ from './ObjectEventType.js'; import _ol_ObjectEventType_ from './ObjectEventType.js';
import _ol_TileQueue_ from './TileQueue.js'; import TileQueue from './TileQueue.js';
import _ol_View_ from './View.js'; import _ol_View_ from './View.js';
import _ol_ViewHint_ from './ViewHint.js'; import _ol_ViewHint_ from './ViewHint.js';
import _ol_asserts_ from './asserts.js'; import _ol_asserts_ from './asserts.js';
@@ -27,7 +27,7 @@ import _ol_layer_Group_ from './layer/Group.js';
import _ol_plugins_ from './plugins.js'; import _ol_plugins_ from './plugins.js';
import _ol_renderer_Type_ from './renderer/Type.js'; import _ol_renderer_Type_ from './renderer/Type.js';
import _ol_size_ from './size.js'; import _ol_size_ from './size.js';
import _ol_structs_PriorityQueue_ from './structs/PriorityQueue.js'; import PriorityQueue from './structs/PriorityQueue.js';
import _ol_transform_ from './transform.js'; import _ol_transform_ from './transform.js';
@@ -325,7 +325,7 @@ var _ol_PluggableMap_ = function(options) {
* @private * @private
* @type {ol.TileQueue} * @type {ol.TileQueue}
*/ */
this.tileQueue_ = new _ol_TileQueue_( this.tileQueue_ = new TileQueue(
this.getTilePriority.bind(this), this.getTilePriority.bind(this),
this.handleTileChange_.bind(this)); this.handleTileChange_.bind(this));
@@ -875,10 +875,10 @@ _ol_PluggableMap_.prototype.getTilePriority = function(tile, tileSourceKey, tile
// are outside the visible extent. // are outside the visible extent.
var frameState = this.frameState_; var frameState = this.frameState_;
if (!frameState || !(tileSourceKey in frameState.wantedTiles)) { if (!frameState || !(tileSourceKey in frameState.wantedTiles)) {
return _ol_structs_PriorityQueue_.DROP; return PriorityQueue.DROP;
} }
if (!frameState.wantedTiles[tileSourceKey][tile.getKey()]) { if (!frameState.wantedTiles[tileSourceKey][tile.getKey()]) {
return _ol_structs_PriorityQueue_.DROP; return PriorityQueue.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).
+7 -7
View File
@@ -2,7 +2,7 @@
* @module ol/TileCache * @module ol/TileCache
*/ */
import {inherits} from './index.js'; import {inherits} from './index.js';
import _ol_structs_LRUCache_ from './structs/LRUCache.js'; import LRUCache from './structs/LRUCache.js';
import _ol_tilecoord_ from './tilecoord.js'; import _ol_tilecoord_ from './tilecoord.js';
/** /**
@@ -11,19 +11,19 @@ import _ol_tilecoord_ from './tilecoord.js';
* @param {number=} opt_highWaterMark High water mark. * @param {number=} opt_highWaterMark High water mark.
* @struct * @struct
*/ */
var _ol_TileCache_ = function(opt_highWaterMark) { var TileCache = function(opt_highWaterMark) {
_ol_structs_LRUCache_.call(this, opt_highWaterMark); LRUCache.call(this, opt_highWaterMark);
}; };
inherits(_ol_TileCache_, _ol_structs_LRUCache_); inherits(TileCache, LRUCache);
/** /**
* @param {Object.<string, ol.TileRange>} usedTiles Used tiles. * @param {Object.<string, ol.TileRange>} usedTiles Used tiles.
*/ */
_ol_TileCache_.prototype.expireCache = function(usedTiles) { TileCache.prototype.expireCache = function(usedTiles) {
var tile, zKey; var tile, zKey;
while (this.canExpireCache()) { while (this.canExpireCache()) {
tile = this.peekLast(); tile = this.peekLast();
@@ -40,7 +40,7 @@ _ol_TileCache_.prototype.expireCache = function(usedTiles) {
/** /**
* Prune all tiles from the cache that don't have the same z as the newest tile. * Prune all tiles from the cache that don't have the same z as the newest tile.
*/ */
_ol_TileCache_.prototype.pruneExceptNewestZ = function() { TileCache.prototype.pruneExceptNewestZ = function() {
if (this.getCount() === 0) { if (this.getCount() === 0) {
return; return;
} }
@@ -54,4 +54,4 @@ _ol_TileCache_.prototype.pruneExceptNewestZ = function() {
} }
}, this); }, this);
}; };
export default _ol_TileCache_; export default TileCache;
+10 -10
View File
@@ -5,7 +5,7 @@ import {inherits} from './index.js';
import _ol_TileState_ from './TileState.js'; import _ol_TileState_ from './TileState.js';
import _ol_events_ from './events.js'; import _ol_events_ from './events.js';
import EventType from './events/EventType.js'; import EventType from './events/EventType.js';
import _ol_structs_PriorityQueue_ from './structs/PriorityQueue.js'; import PriorityQueue from './structs/PriorityQueue.js';
/** /**
* @constructor * @constructor
@@ -16,9 +16,9 @@ import _ol_structs_PriorityQueue_ from './structs/PriorityQueue.js';
* Function called on each tile change event. * Function called on each tile change event.
* @struct * @struct
*/ */
var _ol_TileQueue_ = function(tilePriorityFunction, tileChangeCallback) { var TileQueue = function(tilePriorityFunction, tileChangeCallback) {
_ol_structs_PriorityQueue_.call( PriorityQueue.call(
this, this,
/** /**
* @param {Array} element Element. * @param {Array} element Element.
@@ -55,14 +55,14 @@ var _ol_TileQueue_ = function(tilePriorityFunction, tileChangeCallback) {
}; };
inherits(_ol_TileQueue_, _ol_structs_PriorityQueue_); inherits(TileQueue, PriorityQueue);
/** /**
* @inheritDoc * @inheritDoc
*/ */
_ol_TileQueue_.prototype.enqueue = function(element) { TileQueue.prototype.enqueue = function(element) {
var added = _ol_structs_PriorityQueue_.prototype.enqueue.call(this, element); var added = PriorityQueue.prototype.enqueue.call(this, element);
if (added) { if (added) {
var tile = element[0]; var tile = element[0];
_ol_events_.listen(tile, EventType.CHANGE, _ol_events_.listen(tile, EventType.CHANGE,
@@ -75,7 +75,7 @@ _ol_TileQueue_.prototype.enqueue = function(element) {
/** /**
* @return {number} Number of tiles loading. * @return {number} Number of tiles loading.
*/ */
_ol_TileQueue_.prototype.getTilesLoading = function() { TileQueue.prototype.getTilesLoading = function() {
return this.tilesLoading_; return this.tilesLoading_;
}; };
@@ -84,7 +84,7 @@ _ol_TileQueue_.prototype.getTilesLoading = function() {
* @param {ol.events.Event} event Event. * @param {ol.events.Event} event Event.
* @protected * @protected
*/ */
_ol_TileQueue_.prototype.handleTileChange = function(event) { TileQueue.prototype.handleTileChange = function(event) {
var tile = /** @type {ol.Tile} */ (event.target); var tile = /** @type {ol.Tile} */ (event.target);
var state = tile.getState(); var state = tile.getState();
if (state === _ol_TileState_.LOADED || state === _ol_TileState_.ERROR || if (state === _ol_TileState_.LOADED || state === _ol_TileState_.ERROR ||
@@ -105,7 +105,7 @@ _ol_TileQueue_.prototype.handleTileChange = function(event) {
* @param {number} maxTotalLoading Maximum number tiles to load simultaneously. * @param {number} maxTotalLoading Maximum number tiles to load simultaneously.
* @param {number} maxNewLoads Maximum number of new tiles to load. * @param {number} maxNewLoads Maximum number of new tiles to load.
*/ */
_ol_TileQueue_.prototype.loadMoreTiles = function(maxTotalLoading, maxNewLoads) { TileQueue.prototype.loadMoreTiles = function(maxTotalLoading, maxNewLoads) {
var newLoads = 0; var newLoads = 0;
var abortedTiles = false; var abortedTiles = false;
var state, tile, tileKey; var state, tile, tileKey;
@@ -129,4 +129,4 @@ _ol_TileQueue_.prototype.loadMoreTiles = function(maxTotalLoading, maxNewLoads)
this.tileChangeCallback_(); this.tileChangeCallback_();
} }
}; };
export default _ol_TileQueue_; export default TileQueue;
+2 -2
View File
@@ -21,7 +21,7 @@ import _ol_interaction_Pointer_ from '../interaction/Pointer.js';
import _ol_layer_Vector_ from '../layer/Vector.js'; import _ol_layer_Vector_ from '../layer/Vector.js';
import _ol_source_Vector_ from '../source/Vector.js'; import _ol_source_Vector_ from '../source/Vector.js';
import _ol_source_VectorEventType_ from '../source/VectorEventType.js'; import _ol_source_VectorEventType_ from '../source/VectorEventType.js';
import _ol_structs_RBush_ from '../structs/RBush.js'; import RBush from '../structs/RBush.js';
import _ol_style_Style_ from '../style/Style.js'; import _ol_style_Style_ from '../style/Style.js';
/** /**
@@ -123,7 +123,7 @@ var _ol_interaction_Modify_ = function(options) {
* @type {ol.structs.RBush.<ol.ModifySegmentDataType>} * @type {ol.structs.RBush.<ol.ModifySegmentDataType>}
* @private * @private
*/ */
this.rBush_ = new _ol_structs_RBush_(); this.rBush_ = new RBush();
/** /**
* @type {number} * @type {number}
+2 -2
View File
@@ -15,7 +15,7 @@ import _ol_interaction_Pointer_ from '../interaction/Pointer.js';
import _ol_obj_ from '../obj.js'; import _ol_obj_ from '../obj.js';
import _ol_source_Vector_ from '../source/Vector.js'; import _ol_source_Vector_ from '../source/Vector.js';
import _ol_source_VectorEventType_ from '../source/VectorEventType.js'; import _ol_source_VectorEventType_ from '../source/VectorEventType.js';
import _ol_structs_RBush_ from '../structs/RBush.js'; import RBush from '../structs/RBush.js';
/** /**
* @classdesc * @classdesc
@@ -128,7 +128,7 @@ var _ol_interaction_Snap_ = function(opt_options) {
* @type {ol.structs.RBush.<ol.SnapSegmentDataType>} * @type {ol.structs.RBush.<ol.SnapSegmentDataType>}
* @private * @private
*/ */
this.rBush_ = new _ol_structs_RBush_(); this.rBush_ = new RBush();
/** /**
+2 -2
View File
@@ -4,7 +4,7 @@
import _ol_css_ from '../css.js'; import _ol_css_ from '../css.js';
import {createCanvasContext2D} from '../dom.js'; import {createCanvasContext2D} from '../dom.js';
import _ol_obj_ from '../obj.js'; import _ol_obj_ from '../obj.js';
import _ol_structs_LRUCache_ from '../structs/LRUCache.js'; import LRUCache from '../structs/LRUCache.js';
import _ol_transform_ from '../transform.js'; import _ol_transform_ from '../transform.js';
var _ol_render_canvas_ = {}; var _ol_render_canvas_ = {};
@@ -96,7 +96,7 @@ _ol_render_canvas_.defaultLineWidth = 1;
/** /**
* @type {ol.structs.LRUCache.<HTMLCanvasElement>} * @type {ol.structs.LRUCache.<HTMLCanvasElement>}
*/ */
_ol_render_canvas_.labelCache = new _ol_structs_LRUCache_(); _ol_render_canvas_.labelCache = new LRUCache();
/** /**
+8 -8
View File
@@ -15,8 +15,8 @@ import _ol_render_webgl_LineStringReplay_ from '../webgl/LineStringReplay.js';
import _ol_render_webgl_Replay_ from '../webgl/Replay.js'; import _ol_render_webgl_Replay_ from '../webgl/Replay.js';
import _ol_render_webgl_ from '../webgl.js'; import _ol_render_webgl_ from '../webgl.js';
import _ol_style_Stroke_ from '../../style/Stroke.js'; import _ol_style_Stroke_ from '../../style/Stroke.js';
import _ol_structs_LinkedList_ from '../../structs/LinkedList.js'; import LinkedList from '../../structs/LinkedList.js';
import _ol_structs_RBush_ from '../../structs/RBush.js'; import RBush from '../../structs/RBush.js';
import _ol_webgl_ from '../../webgl.js'; import _ol_webgl_ from '../../webgl.js';
import _ol_webgl_Buffer_ from '../../webgl/Buffer.js'; import _ol_webgl_Buffer_ from '../../webgl/Buffer.js';
@@ -76,8 +76,8 @@ inherits(_ol_render_webgl_PolygonReplay_, _ol_render_webgl_Replay_);
_ol_render_webgl_PolygonReplay_.prototype.drawCoordinates_ = function( _ol_render_webgl_PolygonReplay_.prototype.drawCoordinates_ = function(
flatCoordinates, holeFlatCoordinates, stride) { flatCoordinates, holeFlatCoordinates, stride) {
// Triangulate the polygon // Triangulate the polygon
var outerRing = new _ol_structs_LinkedList_(); var outerRing = new LinkedList();
var rtree = new _ol_structs_RBush_(); var rtree = new RBush();
// Initialize the outer ring // Initialize the outer ring
this.processFlatCoordinates_(flatCoordinates, stride, outerRing, rtree, true); this.processFlatCoordinates_(flatCoordinates, stride, outerRing, rtree, true);
var maxCoords = this.getMaxCoords_(outerRing); var maxCoords = this.getMaxCoords_(outerRing);
@@ -88,9 +88,9 @@ _ol_render_webgl_PolygonReplay_.prototype.drawCoordinates_ = function(
var holeLists = []; var holeLists = [];
for (i = 0, ii = holeFlatCoordinates.length; i < ii; ++i) { for (i = 0, ii = holeFlatCoordinates.length; i < ii; ++i) {
var holeList = { var holeList = {
list: new _ol_structs_LinkedList_(), list: new LinkedList(),
maxCoords: undefined, maxCoords: undefined,
rtree: new _ol_structs_RBush_() rtree: new RBush()
}; };
holeLists.push(holeList); holeLists.push(holeList);
this.processFlatCoordinates_(holeFlatCoordinates[i], this.processFlatCoordinates_(holeFlatCoordinates[i],
@@ -553,8 +553,8 @@ _ol_render_webgl_PolygonReplay_.prototype.splitPolygon_ = function(list, rtree)
var intersection = this.calculateIntersection_(s0.p0, var intersection = this.calculateIntersection_(s0.p0,
s0.p1, s1.p0, s1.p1); s0.p1, s1.p0, s1.p1);
var p = this.createPoint_(intersection[0], intersection[1], n); var p = this.createPoint_(intersection[0], intersection[1], n);
var newPolygon = new _ol_structs_LinkedList_(); var newPolygon = new LinkedList();
var newRtree = new _ol_structs_RBush_(); var newRtree = new RBush();
this.insertItem_(p, s0.p1, newPolygon, newRtree); this.insertItem_(p, s0.p1, newPolygon, newRtree);
s0.p1 = p; s0.p1 = p;
rtree.update([Math.min(s0.p0.x, p.x), Math.min(s0.p0.y, p.y), rtree.update([Math.min(s0.p0.x, p.x), Math.min(s0.p0.y, p.y),
+4 -4
View File
@@ -15,8 +15,8 @@ import _ol_render_webgl_Immediate_ from '../../render/webgl/Immediate.js';
import _ol_renderer_Map_ from '../Map.js'; import _ol_renderer_Map_ from '../Map.js';
import _ol_renderer_Type_ from '../Type.js'; import _ol_renderer_Type_ from '../Type.js';
import _ol_source_State_ from '../../source/State.js'; import _ol_source_State_ from '../../source/State.js';
import _ol_structs_LRUCache_ from '../../structs/LRUCache.js'; import LRUCache from '../../structs/LRUCache.js';
import _ol_structs_PriorityQueue_ from '../../structs/PriorityQueue.js'; import PriorityQueue from '../../structs/PriorityQueue.js';
import _ol_webgl_ from '../../webgl.js'; import _ol_webgl_ from '../../webgl.js';
import _ol_webgl_Context_ from '../../webgl/Context.js'; import _ol_webgl_Context_ from '../../webgl/Context.js';
import _ol_webgl_ContextEventType_ from '../../webgl/ContextEventType.js'; import _ol_webgl_ContextEventType_ from '../../webgl/ContextEventType.js';
@@ -101,7 +101,7 @@ var _ol_renderer_webgl_Map_ = function(container, map) {
* @private * @private
* @type {ol.structs.LRUCache.<ol.WebglTextureCacheEntry|null>} * @type {ol.structs.LRUCache.<ol.WebglTextureCacheEntry|null>}
*/ */
this.textureCache_ = new _ol_structs_LRUCache_(); this.textureCache_ = new LRUCache();
/** /**
* @private * @private
@@ -113,7 +113,7 @@ var _ol_renderer_webgl_Map_ = function(container, map) {
* @private * @private
* @type {ol.structs.PriorityQueue.<Array>} * @type {ol.structs.PriorityQueue.<Array>}
*/ */
this.tileTextureQueue_ = new _ol_structs_PriorityQueue_( this.tileTextureQueue_ = new PriorityQueue(
/** /**
* @param {Array.<*>} element Element. * @param {Array.<*>} element Element.
* @return {number} Priority. * @return {number} Priority.
+2 -2
View File
@@ -3,7 +3,7 @@
*/ */
import {getUid, inherits} from '../index.js'; import {getUid, inherits} from '../index.js';
import _ol_ImageCanvas_ from '../ImageCanvas.js'; import _ol_ImageCanvas_ from '../ImageCanvas.js';
import _ol_TileQueue_ from '../TileQueue.js'; import TileQueue from '../TileQueue.js';
import {createCanvasContext2D} from '../dom.js'; import {createCanvasContext2D} from '../dom.js';
import _ol_events_ from '../events.js'; import _ol_events_ from '../events.js';
import Event from '../events/Event.js'; import Event from '../events/Event.js';
@@ -69,7 +69,7 @@ var _ol_source_Raster_ = function(options) {
* @private * @private
* @type {ol.TileQueue} * @type {ol.TileQueue}
*/ */
this.tileQueue_ = new _ol_TileQueue_( this.tileQueue_ = new TileQueue(
function() { function() {
return 1; return 1;
}, },
+2 -2
View File
@@ -2,7 +2,7 @@
* @module ol/source/Tile * @module ol/source/Tile
*/ */
import {inherits, nullFunction} from '../index.js'; import {inherits, nullFunction} from '../index.js';
import _ol_TileCache_ from '../TileCache.js'; import TileCache from '../TileCache.js';
import _ol_TileState_ from '../TileState.js'; import _ol_TileState_ from '../TileState.js';
import Event from '../events/Event.js'; import Event from '../events/Event.js';
import {equivalent} from '../proj.js'; import {equivalent} from '../proj.js';
@@ -56,7 +56,7 @@ var _ol_source_Tile_ = function(options) {
* @protected * @protected
* @type {ol.TileCache} * @type {ol.TileCache}
*/ */
this.tileCache = new _ol_TileCache_(options.cacheSize); this.tileCache = new TileCache(options.cacheSize);
/** /**
* @protected * @protected
+2 -2
View File
@@ -4,7 +4,7 @@
import {ENABLE_RASTER_REPROJECTION} from '../reproj/common.js'; import {ENABLE_RASTER_REPROJECTION} from '../reproj/common.js';
import {getUid, inherits} from '../index.js'; import {getUid, inherits} from '../index.js';
import _ol_ImageTile_ from '../ImageTile.js'; import _ol_ImageTile_ from '../ImageTile.js';
import _ol_TileCache_ from '../TileCache.js'; import TileCache from '../TileCache.js';
import _ol_TileState_ from '../TileState.js'; import _ol_TileState_ from '../TileState.js';
import _ol_events_ from '../events.js'; import _ol_events_ from '../events.js';
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
@@ -193,7 +193,7 @@ _ol_source_TileImage_.prototype.getTileCacheForProjection = function(projection)
} else { } else {
var projKey = getUid(projection).toString(); var projKey = getUid(projection).toString();
if (!(projKey in this.tileCacheForProjection)) { if (!(projKey in this.tileCacheForProjection)) {
this.tileCacheForProjection[projKey] = new _ol_TileCache_(this.tileCache.highWaterMark); this.tileCacheForProjection[projKey] = new TileCache(this.tileCache.highWaterMark);
} }
return this.tileCacheForProjection[projKey]; return this.tileCacheForProjection[projKey];
} }
+3 -3
View File
@@ -19,7 +19,7 @@ import _ol_obj_ from '../obj.js';
import _ol_source_Source_ from '../source/Source.js'; import _ol_source_Source_ from '../source/Source.js';
import _ol_source_State_ from '../source/State.js'; import _ol_source_State_ from '../source/State.js';
import _ol_source_VectorEventType_ from '../source/VectorEventType.js'; import _ol_source_VectorEventType_ from '../source/VectorEventType.js';
import _ol_structs_RBush_ from '../structs/RBush.js'; import RBush from '../structs/RBush.js';
/** /**
* @classdesc * @classdesc
@@ -90,13 +90,13 @@ var _ol_source_Vector_ = function(opt_options) {
* @private * @private
* @type {ol.structs.RBush.<ol.Feature>} * @type {ol.structs.RBush.<ol.Feature>}
*/ */
this.featuresRtree_ = useSpatialIndex ? new _ol_structs_RBush_() : null; this.featuresRtree_ = useSpatialIndex ? new RBush() : null;
/** /**
* @private * @private
* @type {ol.structs.RBush.<{extent: ol.Extent}>} * @type {ol.structs.RBush.<{extent: ol.Extent}>}
*/ */
this.loadedExtentsRtree_ = new _ol_structs_RBush_(); this.loadedExtentsRtree_ = new RBush();
/** /**
* @private * @private
+19 -19
View File
@@ -17,7 +17,7 @@ import EventType from '../events/EventType.js';
* @template T * @template T
* @param {number=} opt_highWaterMark High water mark. * @param {number=} opt_highWaterMark High water mark.
*/ */
var _ol_structs_LRUCache_ = function(opt_highWaterMark) { var LRUCache = function(opt_highWaterMark) {
EventTarget.call(this); EventTarget.call(this);
@@ -52,13 +52,13 @@ var _ol_structs_LRUCache_ = function(opt_highWaterMark) {
}; };
inherits(_ol_structs_LRUCache_, EventTarget); inherits(LRUCache, EventTarget);
/** /**
* @return {boolean} Can expire cache. * @return {boolean} Can expire cache.
*/ */
_ol_structs_LRUCache_.prototype.canExpireCache = function() { LRUCache.prototype.canExpireCache = function() {
return this.getCount() > this.highWaterMark; return this.getCount() > this.highWaterMark;
}; };
@@ -66,7 +66,7 @@ _ol_structs_LRUCache_.prototype.canExpireCache = function() {
/** /**
* FIXME empty description for jsdoc * FIXME empty description for jsdoc
*/ */
_ol_structs_LRUCache_.prototype.clear = function() { LRUCache.prototype.clear = function() {
this.count_ = 0; this.count_ = 0;
this.entries_ = {}; this.entries_ = {};
this.oldest_ = null; this.oldest_ = null;
@@ -79,7 +79,7 @@ _ol_structs_LRUCache_.prototype.clear = function() {
* @param {string} key Key. * @param {string} key Key.
* @return {boolean} Contains key. * @return {boolean} Contains key.
*/ */
_ol_structs_LRUCache_.prototype.containsKey = function(key) { LRUCache.prototype.containsKey = function(key) {
return this.entries_.hasOwnProperty(key); return this.entries_.hasOwnProperty(key);
}; };
@@ -92,7 +92,7 @@ _ol_structs_LRUCache_.prototype.containsKey = function(key) {
* @param {S=} opt_this The object to use as `this` in `f`. * @param {S=} opt_this The object to use as `this` in `f`.
* @template S * @template S
*/ */
_ol_structs_LRUCache_.prototype.forEach = function(f, opt_this) { LRUCache.prototype.forEach = function(f, opt_this) {
var entry = this.oldest_; var entry = this.oldest_;
while (entry) { while (entry) {
f.call(opt_this, entry.value_, entry.key_, this); f.call(opt_this, entry.value_, entry.key_, this);
@@ -105,7 +105,7 @@ _ol_structs_LRUCache_.prototype.forEach = function(f, opt_this) {
* @param {string} key Key. * @param {string} key Key.
* @return {T} Value. * @return {T} Value.
*/ */
_ol_structs_LRUCache_.prototype.get = function(key) { LRUCache.prototype.get = function(key) {
var entry = this.entries_[key]; var entry = this.entries_[key];
_ol_asserts_.assert(entry !== undefined, _ol_asserts_.assert(entry !== undefined,
15); // Tried to get a value for a key that does not exist in the cache 15); // Tried to get a value for a key that does not exist in the cache
@@ -131,7 +131,7 @@ _ol_structs_LRUCache_.prototype.get = function(key) {
* @param {string} key The entry key. * @param {string} key The entry key.
* @return {T} The removed entry. * @return {T} The removed entry.
*/ */
_ol_structs_LRUCache_.prototype.remove = function(key) { LRUCache.prototype.remove = function(key) {
var entry = this.entries_[key]; var entry = this.entries_[key];
_ol_asserts_.assert(entry !== undefined, 15); // Tried to get a value for a key that does not exist in the cache _ol_asserts_.assert(entry !== undefined, 15); // Tried to get a value for a key that does not exist in the cache
if (entry === this.newest_) { if (entry === this.newest_) {
@@ -157,7 +157,7 @@ _ol_structs_LRUCache_.prototype.remove = function(key) {
/** /**
* @return {number} Count. * @return {number} Count.
*/ */
_ol_structs_LRUCache_.prototype.getCount = function() { LRUCache.prototype.getCount = function() {
return this.count_; return this.count_;
}; };
@@ -165,7 +165,7 @@ _ol_structs_LRUCache_.prototype.getCount = function() {
/** /**
* @return {Array.<string>} Keys. * @return {Array.<string>} Keys.
*/ */
_ol_structs_LRUCache_.prototype.getKeys = function() { LRUCache.prototype.getKeys = function() {
var keys = new Array(this.count_); var keys = new Array(this.count_);
var i = 0; var i = 0;
var entry; var entry;
@@ -179,7 +179,7 @@ _ol_structs_LRUCache_.prototype.getKeys = function() {
/** /**
* @return {Array.<T>} Values. * @return {Array.<T>} Values.
*/ */
_ol_structs_LRUCache_.prototype.getValues = function() { LRUCache.prototype.getValues = function() {
var values = new Array(this.count_); var values = new Array(this.count_);
var i = 0; var i = 0;
var entry; var entry;
@@ -193,7 +193,7 @@ _ol_structs_LRUCache_.prototype.getValues = function() {
/** /**
* @return {T} Last value. * @return {T} Last value.
*/ */
_ol_structs_LRUCache_.prototype.peekLast = function() { LRUCache.prototype.peekLast = function() {
return this.oldest_.value_; return this.oldest_.value_;
}; };
@@ -201,7 +201,7 @@ _ol_structs_LRUCache_.prototype.peekLast = function() {
/** /**
* @return {string} Last key. * @return {string} Last key.
*/ */
_ol_structs_LRUCache_.prototype.peekLastKey = function() { LRUCache.prototype.peekLastKey = function() {
return this.oldest_.key_; return this.oldest_.key_;
}; };
@@ -210,7 +210,7 @@ _ol_structs_LRUCache_.prototype.peekLastKey = function() {
* Get the key of the newest item in the cache. Throws if the cache is empty. * Get the key of the newest item in the cache. Throws if the cache is empty.
* @return {string} The newest key. * @return {string} The newest key.
*/ */
_ol_structs_LRUCache_.prototype.peekFirstKey = function() { LRUCache.prototype.peekFirstKey = function() {
return this.newest_.key_; return this.newest_.key_;
}; };
@@ -218,7 +218,7 @@ _ol_structs_LRUCache_.prototype.peekFirstKey = function() {
/** /**
* @return {T} value Value. * @return {T} value Value.
*/ */
_ol_structs_LRUCache_.prototype.pop = function() { LRUCache.prototype.pop = function() {
var entry = this.oldest_; var entry = this.oldest_;
delete this.entries_[entry.key_]; delete this.entries_[entry.key_];
if (entry.newer) { if (entry.newer) {
@@ -237,7 +237,7 @@ _ol_structs_LRUCache_.prototype.pop = function() {
* @param {string} key Key. * @param {string} key Key.
* @param {T} value Value. * @param {T} value Value.
*/ */
_ol_structs_LRUCache_.prototype.replace = function(key, value) { LRUCache.prototype.replace = function(key, value) {
this.get(key); // update `newest_` this.get(key); // update `newest_`
this.entries_[key].value_ = value; this.entries_[key].value_ = value;
}; };
@@ -247,7 +247,7 @@ _ol_structs_LRUCache_.prototype.replace = function(key, value) {
* @param {string} key Key. * @param {string} key Key.
* @param {T} value Value. * @param {T} value Value.
*/ */
_ol_structs_LRUCache_.prototype.set = function(key, value) { LRUCache.prototype.set = function(key, value) {
_ol_asserts_.assert(!(key in this.entries_), _ol_asserts_.assert(!(key in this.entries_),
16); // Tried to set a value for a key that is used already 16); // Tried to set a value for a key that is used already
var entry = /** @type {ol.LRUCacheEntry} */ ({ var entry = /** @type {ol.LRUCacheEntry} */ ({
@@ -270,9 +270,9 @@ _ol_structs_LRUCache_.prototype.set = function(key, value) {
/** /**
* Prune the cache. * Prune the cache.
*/ */
_ol_structs_LRUCache_.prototype.prune = function() { LRUCache.prototype.prune = function() {
while (this.canExpireCache()) { while (this.canExpireCache()) {
this.pop(); this.pop();
} }
}; };
export default _ol_structs_LRUCache_; export default LRUCache;
+15 -14
View File
@@ -1,6 +1,7 @@
/** /**
* @module ol/structs/LinkedList * @module ol/structs/LinkedList
*/ */
/** /**
* Creates an empty linked list structure. * Creates an empty linked list structure.
* *
@@ -9,7 +10,7 @@
* @param {boolean=} opt_circular The last item is connected to the first one, * @param {boolean=} opt_circular The last item is connected to the first one,
* and the first item to the last one. Default is true. * and the first item to the last one. Default is true.
*/ */
var _ol_structs_LinkedList_ = function(opt_circular) { var LinkedList = function(opt_circular) {
/** /**
* @private * @private
@@ -47,7 +48,7 @@ var _ol_structs_LinkedList_ = function(opt_circular) {
* *
* @param {?} data Item data. * @param {?} data Item data.
*/ */
_ol_structs_LinkedList_.prototype.insertItem = function(data) { LinkedList.prototype.insertItem = function(data) {
/** @type {ol.LinkedListItem} */ /** @type {ol.LinkedListItem} */
var item = { var item = {
@@ -88,7 +89,7 @@ _ol_structs_LinkedList_.prototype.insertItem = function(data) {
* Removes the current item from the list. Sets the cursor to the next item, * Removes the current item from the list. Sets the cursor to the next item,
* if possible. * if possible.
*/ */
_ol_structs_LinkedList_.prototype.removeItem = function() { LinkedList.prototype.removeItem = function() {
var head = this.head_; var head = this.head_;
if (head) { if (head) {
var next = head.next; var next = head.next;
@@ -119,7 +120,7 @@ _ol_structs_LinkedList_.prototype.removeItem = function() {
* *
* @return {?} Item data. * @return {?} Item data.
*/ */
_ol_structs_LinkedList_.prototype.firstItem = function() { LinkedList.prototype.firstItem = function() {
this.head_ = this.first_; this.head_ = this.first_;
if (this.head_) { if (this.head_) {
return this.head_.data; return this.head_.data;
@@ -132,7 +133,7 @@ _ol_structs_LinkedList_.prototype.firstItem = function() {
* *
* @return {?} Item data. * @return {?} Item data.
*/ */
_ol_structs_LinkedList_.prototype.lastItem = function() { LinkedList.prototype.lastItem = function() {
this.head_ = this.last_; this.head_ = this.last_;
if (this.head_) { if (this.head_) {
return this.head_.data; return this.head_.data;
@@ -145,7 +146,7 @@ _ol_structs_LinkedList_.prototype.lastItem = function() {
* *
* @return {?} Item data. * @return {?} Item data.
*/ */
_ol_structs_LinkedList_.prototype.nextItem = function() { LinkedList.prototype.nextItem = function() {
if (this.head_ && this.head_.next) { if (this.head_ && this.head_.next) {
this.head_ = this.head_.next; this.head_ = this.head_.next;
return this.head_.data; return this.head_.data;
@@ -158,7 +159,7 @@ _ol_structs_LinkedList_.prototype.nextItem = function() {
* *
* @return {?} Item data. * @return {?} Item data.
*/ */
_ol_structs_LinkedList_.prototype.getNextItem = function() { LinkedList.prototype.getNextItem = function() {
if (this.head_ && this.head_.next) { if (this.head_ && this.head_.next) {
return this.head_.next.data; return this.head_.next.data;
} }
@@ -170,7 +171,7 @@ _ol_structs_LinkedList_.prototype.getNextItem = function() {
* *
* @return {?} Item data. * @return {?} Item data.
*/ */
_ol_structs_LinkedList_.prototype.prevItem = function() { LinkedList.prototype.prevItem = function() {
if (this.head_ && this.head_.prev) { if (this.head_ && this.head_.prev) {
this.head_ = this.head_.prev; this.head_ = this.head_.prev;
return this.head_.data; return this.head_.data;
@@ -183,7 +184,7 @@ _ol_structs_LinkedList_.prototype.prevItem = function() {
* *
* @return {?} Item data. * @return {?} Item data.
*/ */
_ol_structs_LinkedList_.prototype.getPrevItem = function() { LinkedList.prototype.getPrevItem = function() {
if (this.head_ && this.head_.prev) { if (this.head_ && this.head_.prev) {
return this.head_.prev.data; return this.head_.prev.data;
} }
@@ -195,7 +196,7 @@ _ol_structs_LinkedList_.prototype.getPrevItem = function() {
* *
* @return {?} Item data. * @return {?} Item data.
*/ */
_ol_structs_LinkedList_.prototype.getCurrItem = function() { LinkedList.prototype.getCurrItem = function() {
if (this.head_) { if (this.head_) {
return this.head_.data; return this.head_.data;
} }
@@ -206,7 +207,7 @@ _ol_structs_LinkedList_.prototype.getCurrItem = function() {
* Sets the first item of the list. This only works for circular lists, and sets * Sets the first item of the list. This only works for circular lists, and sets
* the last item accordingly. * the last item accordingly.
*/ */
_ol_structs_LinkedList_.prototype.setFirstItem = function() { LinkedList.prototype.setFirstItem = function() {
if (this.circular_ && this.head_) { if (this.circular_ && this.head_) {
this.first_ = this.head_; this.first_ = this.head_;
this.last_ = this.head_.prev; this.last_ = this.head_.prev;
@@ -217,7 +218,7 @@ _ol_structs_LinkedList_.prototype.setFirstItem = function() {
* Concatenates two lists. * Concatenates two lists.
* @param {ol.structs.LinkedList} list List to merge into the current list. * @param {ol.structs.LinkedList} list List to merge into the current list.
*/ */
_ol_structs_LinkedList_.prototype.concat = function(list) { LinkedList.prototype.concat = function(list) {
if (list.head_) { if (list.head_) {
if (this.head_) { if (this.head_) {
var end = this.head_.next; var end = this.head_.next;
@@ -244,7 +245,7 @@ _ol_structs_LinkedList_.prototype.concat = function(list) {
* *
* @return {number} Length. * @return {number} Length.
*/ */
_ol_structs_LinkedList_.prototype.getLength = function() { LinkedList.prototype.getLength = function() {
return this.length_; return this.length_;
}; };
export default _ol_structs_LinkedList_; export default LinkedList;
+19 -19
View File
@@ -19,7 +19,7 @@ import _ol_obj_ from '../obj.js';
* @struct * @struct
* @template T * @template T
*/ */
var _ol_structs_PriorityQueue_ = function(priorityFunction, keyFunction) { var PriorityQueue = function(priorityFunction, keyFunction) {
/** /**
* @type {function(T): number} * @type {function(T): number}
@@ -58,13 +58,13 @@ var _ol_structs_PriorityQueue_ = function(priorityFunction, keyFunction) {
* @const * @const
* @type {number} * @type {number}
*/ */
_ol_structs_PriorityQueue_.DROP = Infinity; PriorityQueue.DROP = Infinity;
/** /**
* FIXME empty description for jsdoc * FIXME empty description for jsdoc
*/ */
_ol_structs_PriorityQueue_.prototype.clear = function() { PriorityQueue.prototype.clear = function() {
this.elements_.length = 0; this.elements_.length = 0;
this.priorities_.length = 0; this.priorities_.length = 0;
_ol_obj_.clear(this.queuedElements_); _ol_obj_.clear(this.queuedElements_);
@@ -75,7 +75,7 @@ _ol_structs_PriorityQueue_.prototype.clear = function() {
* Remove and return the highest-priority element. O(log N). * Remove and return the highest-priority element. O(log N).
* @return {T} Element. * @return {T} Element.
*/ */
_ol_structs_PriorityQueue_.prototype.dequeue = function() { PriorityQueue.prototype.dequeue = function() {
var elements = this.elements_; var elements = this.elements_;
var priorities = this.priorities_; var priorities = this.priorities_;
var element = elements[0]; var element = elements[0];
@@ -98,11 +98,11 @@ _ol_structs_PriorityQueue_.prototype.dequeue = function() {
* @param {T} element Element. * @param {T} element Element.
* @return {boolean} The element was added to the queue. * @return {boolean} The element was added to the queue.
*/ */
_ol_structs_PriorityQueue_.prototype.enqueue = function(element) { PriorityQueue.prototype.enqueue = function(element) {
_ol_asserts_.assert(!(this.keyFunction_(element) in this.queuedElements_), _ol_asserts_.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
var priority = this.priorityFunction_(element); var priority = this.priorityFunction_(element);
if (priority != _ol_structs_PriorityQueue_.DROP) { if (priority != PriorityQueue.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;
@@ -116,7 +116,7 @@ _ol_structs_PriorityQueue_.prototype.enqueue = function(element) {
/** /**
* @return {number} Count. * @return {number} Count.
*/ */
_ol_structs_PriorityQueue_.prototype.getCount = function() { PriorityQueue.prototype.getCount = function() {
return this.elements_.length; return this.elements_.length;
}; };
@@ -127,7 +127,7 @@ _ol_structs_PriorityQueue_.prototype.getCount = function() {
* @return {number} The index of the left child. * @return {number} The index of the left child.
* @private * @private
*/ */
_ol_structs_PriorityQueue_.prototype.getLeftChildIndex_ = function(index) { PriorityQueue.prototype.getLeftChildIndex_ = function(index) {
return index * 2 + 1; return index * 2 + 1;
}; };
@@ -138,7 +138,7 @@ _ol_structs_PriorityQueue_.prototype.getLeftChildIndex_ = function(index) {
* @return {number} The index of the right child. * @return {number} The index of the right child.
* @private * @private
*/ */
_ol_structs_PriorityQueue_.prototype.getRightChildIndex_ = function(index) { PriorityQueue.prototype.getRightChildIndex_ = function(index) {
return index * 2 + 2; return index * 2 + 2;
}; };
@@ -149,7 +149,7 @@ _ol_structs_PriorityQueue_.prototype.getRightChildIndex_ = function(index) {
* @return {number} The index of the parent. * @return {number} The index of the parent.
* @private * @private
*/ */
_ol_structs_PriorityQueue_.prototype.getParentIndex_ = function(index) { PriorityQueue.prototype.getParentIndex_ = function(index) {
return (index - 1) >> 1; return (index - 1) >> 1;
}; };
@@ -158,7 +158,7 @@ _ol_structs_PriorityQueue_.prototype.getParentIndex_ = function(index) {
* Make this a heap. O(N). * Make this a heap. O(N).
* @private * @private
*/ */
_ol_structs_PriorityQueue_.prototype.heapify_ = function() { PriorityQueue.prototype.heapify_ = function() {
var i; var i;
for (i = (this.elements_.length >> 1) - 1; i >= 0; i--) { for (i = (this.elements_.length >> 1) - 1; i >= 0; i--) {
this.siftUp_(i); this.siftUp_(i);
@@ -169,7 +169,7 @@ _ol_structs_PriorityQueue_.prototype.heapify_ = function() {
/** /**
* @return {boolean} Is empty. * @return {boolean} Is empty.
*/ */
_ol_structs_PriorityQueue_.prototype.isEmpty = function() { PriorityQueue.prototype.isEmpty = function() {
return this.elements_.length === 0; return this.elements_.length === 0;
}; };
@@ -178,7 +178,7 @@ _ol_structs_PriorityQueue_.prototype.isEmpty = function() {
* @param {string} key Key. * @param {string} key Key.
* @return {boolean} Is key queued. * @return {boolean} Is key queued.
*/ */
_ol_structs_PriorityQueue_.prototype.isKeyQueued = function(key) { PriorityQueue.prototype.isKeyQueued = function(key) {
return key in this.queuedElements_; return key in this.queuedElements_;
}; };
@@ -187,7 +187,7 @@ _ol_structs_PriorityQueue_.prototype.isKeyQueued = function(key) {
* @param {T} element Element. * @param {T} element Element.
* @return {boolean} Is queued. * @return {boolean} Is queued.
*/ */
_ol_structs_PriorityQueue_.prototype.isQueued = function(element) { PriorityQueue.prototype.isQueued = function(element) {
return this.isKeyQueued(this.keyFunction_(element)); return this.isKeyQueued(this.keyFunction_(element));
}; };
@@ -196,7 +196,7 @@ _ol_structs_PriorityQueue_.prototype.isQueued = function(element) {
* @param {number} index The index of the node to move down. * @param {number} index The index of the node to move down.
* @private * @private
*/ */
_ol_structs_PriorityQueue_.prototype.siftUp_ = function(index) { PriorityQueue.prototype.siftUp_ = function(index) {
var elements = this.elements_; var elements = this.elements_;
var priorities = this.priorities_; var priorities = this.priorities_;
var count = elements.length; var count = elements.length;
@@ -228,7 +228,7 @@ _ol_structs_PriorityQueue_.prototype.siftUp_ = function(index) {
* @param {number} index The index of the node to move up. * @param {number} index The index of the node to move up.
* @private * @private
*/ */
_ol_structs_PriorityQueue_.prototype.siftDown_ = function(startIndex, index) { PriorityQueue.prototype.siftDown_ = function(startIndex, index) {
var elements = this.elements_; var elements = this.elements_;
var priorities = this.priorities_; var priorities = this.priorities_;
var element = elements[index]; var element = elements[index];
@@ -252,7 +252,7 @@ _ol_structs_PriorityQueue_.prototype.siftDown_ = function(startIndex, index) {
/** /**
* FIXME empty description for jsdoc * FIXME empty description for jsdoc
*/ */
_ol_structs_PriorityQueue_.prototype.reprioritize = function() { PriorityQueue.prototype.reprioritize = function() {
var priorityFunction = this.priorityFunction_; var priorityFunction = this.priorityFunction_;
var elements = this.elements_; var elements = this.elements_;
var priorities = this.priorities_; var priorities = this.priorities_;
@@ -262,7 +262,7 @@ _ol_structs_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 == _ol_structs_PriorityQueue_.DROP) { if (priority == PriorityQueue.DROP) {
delete this.queuedElements_[this.keyFunction_(element)]; delete this.queuedElements_[this.keyFunction_(element)];
} else { } else {
priorities[index] = priority; priorities[index] = priority;
@@ -273,4 +273,4 @@ _ol_structs_PriorityQueue_.prototype.reprioritize = function() {
priorities.length = index; priorities.length = index;
this.heapify_(); this.heapify_();
}; };
export default _ol_structs_PriorityQueue_; export default PriorityQueue;
+15 -15
View File
@@ -15,7 +15,7 @@ import _ol_obj_ from '../obj.js';
* @struct * @struct
* @template T * @template T
*/ */
var _ol_structs_RBush_ = function(opt_maxEntries) { var RBush = function(opt_maxEntries) {
/** /**
* @private * @private
@@ -38,7 +38,7 @@ var _ol_structs_RBush_ = function(opt_maxEntries) {
* @param {ol.Extent} extent Extent. * @param {ol.Extent} extent Extent.
* @param {T} value Value. * @param {T} value Value.
*/ */
_ol_structs_RBush_.prototype.insert = function(extent, value) { RBush.prototype.insert = function(extent, value) {
/** @type {ol.RBushEntry} */ /** @type {ol.RBushEntry} */
var item = { var item = {
minX: extent[0], minX: extent[0],
@@ -58,7 +58,7 @@ _ol_structs_RBush_.prototype.insert = function(extent, value) {
* @param {Array.<ol.Extent>} extents Extents. * @param {Array.<ol.Extent>} extents Extents.
* @param {Array.<T>} values Values. * @param {Array.<T>} values Values.
*/ */
_ol_structs_RBush_.prototype.load = function(extents, values) { RBush.prototype.load = function(extents, values) {
var items = new Array(values.length); var items = new Array(values.length);
for (var i = 0, l = values.length; i < l; i++) { for (var i = 0, l = values.length; i < l; i++) {
var extent = extents[i]; var extent = extents[i];
@@ -84,7 +84,7 @@ _ol_structs_RBush_.prototype.load = function(extents, values) {
* @param {T} value Value. * @param {T} value Value.
* @return {boolean} Removed. * @return {boolean} Removed.
*/ */
_ol_structs_RBush_.prototype.remove = function(value) { RBush.prototype.remove = function(value) {
var uid = getUid(value); var uid = getUid(value);
// get the object in which the value was wrapped when adding to the // get the object in which the value was wrapped when adding to the
@@ -100,7 +100,7 @@ _ol_structs_RBush_.prototype.remove = function(value) {
* @param {ol.Extent} extent Extent. * @param {ol.Extent} extent Extent.
* @param {T} value Value. * @param {T} value Value.
*/ */
_ol_structs_RBush_.prototype.update = function(extent, value) { RBush.prototype.update = function(extent, value) {
var item = this.items_[getUid(value)]; var item = this.items_[getUid(value)];
var bbox = [item.minX, item.minY, item.maxX, item.maxY]; var bbox = [item.minX, item.minY, item.maxX, item.maxY];
if (!equals(bbox, extent)) { if (!equals(bbox, extent)) {
@@ -114,7 +114,7 @@ _ol_structs_RBush_.prototype.update = function(extent, value) {
* Return all values in the RBush. * Return all values in the RBush.
* @return {Array.<T>} All. * @return {Array.<T>} All.
*/ */
_ol_structs_RBush_.prototype.getAll = function() { RBush.prototype.getAll = function() {
var items = this.rbush_.all(); var items = this.rbush_.all();
return items.map(function(item) { return items.map(function(item) {
return item.value; return item.value;
@@ -127,7 +127,7 @@ _ol_structs_RBush_.prototype.getAll = function() {
* @param {ol.Extent} extent Extent. * @param {ol.Extent} extent Extent.
* @return {Array.<T>} All in extent. * @return {Array.<T>} All in extent.
*/ */
_ol_structs_RBush_.prototype.getInExtent = function(extent) { RBush.prototype.getInExtent = function(extent) {
/** @type {ol.RBushEntry} */ /** @type {ol.RBushEntry} */
var bbox = { var bbox = {
minX: extent[0], minX: extent[0],
@@ -151,7 +151,7 @@ _ol_structs_RBush_.prototype.getInExtent = function(extent) {
* @return {*} Callback return value. * @return {*} Callback return value.
* @template S * @template S
*/ */
_ol_structs_RBush_.prototype.forEach = function(callback, opt_this) { RBush.prototype.forEach = function(callback, opt_this) {
return this.forEach_(this.getAll(), callback, opt_this); return this.forEach_(this.getAll(), callback, opt_this);
}; };
@@ -164,7 +164,7 @@ _ol_structs_RBush_.prototype.forEach = function(callback, opt_this) {
* @return {*} Callback return value. * @return {*} Callback return value.
* @template S * @template S
*/ */
_ol_structs_RBush_.prototype.forEachInExtent = function(extent, callback, opt_this) { RBush.prototype.forEachInExtent = function(extent, callback, opt_this) {
return this.forEach_(this.getInExtent(extent), callback, opt_this); return this.forEach_(this.getInExtent(extent), callback, opt_this);
}; };
@@ -177,7 +177,7 @@ _ol_structs_RBush_.prototype.forEachInExtent = function(extent, callback, opt_th
* @return {*} Callback return value. * @return {*} Callback return value.
* @template S * @template S
*/ */
_ol_structs_RBush_.prototype.forEach_ = function(values, callback, opt_this) { RBush.prototype.forEach_ = function(values, callback, opt_this) {
var result; var result;
for (var i = 0, l = values.length; i < l; i++) { for (var i = 0, l = values.length; i < l; i++) {
result = callback.call(opt_this, values[i]); result = callback.call(opt_this, values[i]);
@@ -192,7 +192,7 @@ _ol_structs_RBush_.prototype.forEach_ = function(values, callback, opt_this) {
/** /**
* @return {boolean} Is empty. * @return {boolean} Is empty.
*/ */
_ol_structs_RBush_.prototype.isEmpty = function() { RBush.prototype.isEmpty = function() {
return _ol_obj_.isEmpty(this.items_); return _ol_obj_.isEmpty(this.items_);
}; };
@@ -200,7 +200,7 @@ _ol_structs_RBush_.prototype.isEmpty = function() {
/** /**
* Remove all values from the RBush. * Remove all values from the RBush.
*/ */
_ol_structs_RBush_.prototype.clear = function() { RBush.prototype.clear = function() {
this.rbush_.clear(); this.rbush_.clear();
this.items_ = {}; this.items_ = {};
}; };
@@ -210,7 +210,7 @@ _ol_structs_RBush_.prototype.clear = function() {
* @param {ol.Extent=} opt_extent Extent. * @param {ol.Extent=} opt_extent Extent.
* @return {ol.Extent} Extent. * @return {ol.Extent} Extent.
*/ */
_ol_structs_RBush_.prototype.getExtent = function(opt_extent) { RBush.prototype.getExtent = function(opt_extent) {
// FIXME add getExtent() to rbush // FIXME add getExtent() to rbush
var data = this.rbush_.data; var data = this.rbush_.data;
return createOrUpdate(data.minX, data.minY, data.maxX, data.maxY, opt_extent); return createOrUpdate(data.minX, data.minY, data.maxX, data.maxY, opt_extent);
@@ -220,10 +220,10 @@ _ol_structs_RBush_.prototype.getExtent = function(opt_extent) {
/** /**
* @param {ol.structs.RBush} rbush R-Tree. * @param {ol.structs.RBush} rbush R-Tree.
*/ */
_ol_structs_RBush_.prototype.concat = function(rbush) { RBush.prototype.concat = function(rbush) {
this.rbush_.load(rbush.rbush_.all()); this.rbush_.load(rbush.rbush_.all());
for (var i in rbush.items_) { for (var i in rbush.items_) {
this.items_[i | 0] = rbush.items_[i | 0]; this.items_[i | 0] = rbush.items_[i | 0];
} }
}; };
export default _ol_structs_RBush_; export default RBush;
@@ -5,8 +5,8 @@ import Polygon from '../../../../../src/ol/geom/Polygon.js';
import _ol_render_webgl_PolygonReplay_ from '../../../../../src/ol/render/webgl/PolygonReplay.js'; import _ol_render_webgl_PolygonReplay_ from '../../../../../src/ol/render/webgl/PolygonReplay.js';
import _ol_render_webgl_polygonreplay_defaultshader_ from '../../../../../src/ol/render/webgl/polygonreplay/defaultshader.js'; import _ol_render_webgl_polygonreplay_defaultshader_ from '../../../../../src/ol/render/webgl/polygonreplay/defaultshader.js';
import _ol_render_webgl_polygonreplay_defaultshader_Locations_ from '../../../../../src/ol/render/webgl/polygonreplay/defaultshader/Locations.js'; import _ol_render_webgl_polygonreplay_defaultshader_Locations_ from '../../../../../src/ol/render/webgl/polygonreplay/defaultshader/Locations.js';
import _ol_structs_LinkedList_ from '../../../../../src/ol/structs/LinkedList.js'; import LinkedList from '../../../../../src/ol/structs/LinkedList.js';
import _ol_structs_RBush_ from '../../../../../src/ol/structs/RBush.js'; import RBush from '../../../../../src/ol/structs/RBush.js';
import _ol_style_Fill_ from '../../../../../src/ol/style/Fill.js'; import _ol_style_Fill_ from '../../../../../src/ol/style/Fill.js';
import _ol_style_Stroke_ from '../../../../../src/ol/style/Stroke.js'; import _ol_style_Stroke_ from '../../../../../src/ol/style/Stroke.js';
@@ -83,8 +83,8 @@ describe('ol.render.webgl.PolygonReplay', function() {
describe('triangulating functions', function() { describe('triangulating functions', function() {
var list, rtree; var list, rtree;
beforeEach(function() { beforeEach(function() {
list = new _ol_structs_LinkedList_(); list = new LinkedList();
rtree = new _ol_structs_RBush_(); rtree = new RBush();
}); });
describe('#createPoint_', function() { describe('#createPoint_', function() {
+6 -6
View File
@@ -1,11 +1,11 @@
import _ol_structs_LinkedList_ from '../../../../src/ol/structs/LinkedList.js'; import LinkedList from '../../../../src/ol/structs/LinkedList.js';
describe('ol.structs.LinkedList', function() { describe('ol.structs.LinkedList', function() {
var ll; var ll;
var item = {}; var item = {};
var item2 = {}; var item2 = {};
beforeEach(function() { beforeEach(function() {
ll = new _ol_structs_LinkedList_(); ll = new LinkedList();
}); });
it('defaults to circular', function() { it('defaults to circular', function() {
@@ -59,7 +59,7 @@ describe('ol.structs.LinkedList', function() {
}); });
it('otherwise sets the cursor to the prevous item', function() { it('otherwise sets the cursor to the prevous item', function() {
ll = new _ol_structs_LinkedList_(false); ll = new LinkedList(false);
ll.insertItem(item); ll.insertItem(item);
ll.insertItem(item2); ll.insertItem(item2);
ll.insertItem(item3); ll.insertItem(item3);
@@ -68,7 +68,7 @@ describe('ol.structs.LinkedList', function() {
}); });
it('empties a list with only one item', function() { it('empties a list with only one item', function() {
ll = new _ol_structs_LinkedList_(); ll = new LinkedList();
ll.insertItem(item); ll.insertItem(item);
ll.removeItem(); ll.removeItem();
expect(ll.length_).to.be(0); expect(ll.length_).to.be(0);
@@ -202,7 +202,7 @@ describe('ol.structs.LinkedList', function() {
var ll2, item3; var ll2, item3;
beforeEach(function() { beforeEach(function() {
item3 = {}; item3 = {};
ll2 = new _ol_structs_LinkedList_(); ll2 = new LinkedList();
ll2.insertItem(item); ll2.insertItem(item);
ll2.insertItem(item2); ll2.insertItem(item2);
ll2.insertItem(item3); ll2.insertItem(item3);
@@ -242,7 +242,7 @@ describe('ol.structs.LinkedList', function() {
describe('when circular', function() { describe('when circular', function() {
beforeEach(function() { beforeEach(function() {
ll = new _ol_structs_LinkedList_(); ll = new LinkedList();
ll.insertItem(item); ll.insertItem(item);
}); });
+10 -10
View File
@@ -1,4 +1,4 @@
import _ol_structs_LRUCache_ from '../../../../src/ol/structs/LRUCache.js'; import LRUCache from '../../../../src/ol/structs/LRUCache.js';
describe('ol.structs.LRUCache', function() { describe('ol.structs.LRUCache', function() {
@@ -13,7 +13,7 @@ describe('ol.structs.LRUCache', function() {
} }
beforeEach(function() { beforeEach(function() {
lruCache = new _ol_structs_LRUCache_(); lruCache = new LRUCache();
}); });
describe('empty cache', function() { describe('empty cache', function() {
@@ -164,7 +164,7 @@ describe('ol.structs.LRUCache', function() {
describe('#peekFirstKey()', function() { describe('#peekFirstKey()', function() {
it('returns the newest key in the cache', function() { it('returns the newest key in the cache', function() {
var cache = new _ol_structs_LRUCache_(); var cache = new LRUCache();
cache.set('oldest', 'oldest'); cache.set('oldest', 'oldest');
cache.set('oldish', 'oldish'); cache.set('oldish', 'oldish');
cache.set('newish', 'newish'); cache.set('newish', 'newish');
@@ -173,13 +173,13 @@ describe('ol.structs.LRUCache', function() {
}); });
it('works if the cache has one item', function() { it('works if the cache has one item', function() {
var cache = new _ol_structs_LRUCache_(); var cache = new LRUCache();
cache.set('key', 'value'); cache.set('key', 'value');
expect(cache.peekFirstKey()).to.eql('key'); expect(cache.peekFirstKey()).to.eql('key');
}); });
it('throws if the cache is empty', function() { it('throws if the cache is empty', function() {
var cache = new _ol_structs_LRUCache_(); var cache = new LRUCache();
expect(function() { expect(function() {
cache.peekFirstKey(); cache.peekFirstKey();
}).to.throwException(); }).to.throwException();
@@ -212,7 +212,7 @@ describe('ol.structs.LRUCache', function() {
describe('#remove()', function() { describe('#remove()', function() {
it('removes an item from the cache', function() { it('removes an item from the cache', function() {
var cache = new _ol_structs_LRUCache_(); var cache = new LRUCache();
cache.set('oldest', 'oldest'); cache.set('oldest', 'oldest');
cache.set('oldish', 'oldish'); cache.set('oldish', 'oldish');
cache.set('newish', 'newish'); cache.set('newish', 'newish');
@@ -224,7 +224,7 @@ describe('ol.structs.LRUCache', function() {
}); });
it('works when removing the oldest item', function() { it('works when removing the oldest item', function() {
var cache = new _ol_structs_LRUCache_(); var cache = new LRUCache();
cache.set('oldest', 'oldest'); cache.set('oldest', 'oldest');
cache.set('oldish', 'oldish'); cache.set('oldish', 'oldish');
cache.set('newish', 'newish'); cache.set('newish', 'newish');
@@ -237,7 +237,7 @@ describe('ol.structs.LRUCache', function() {
}); });
it('works when removing the newest item', function() { it('works when removing the newest item', function() {
var cache = new _ol_structs_LRUCache_(); var cache = new LRUCache();
cache.set('oldest', 'oldest'); cache.set('oldest', 'oldest');
cache.set('oldish', 'oldish'); cache.set('oldish', 'oldish');
cache.set('newish', 'newish'); cache.set('newish', 'newish');
@@ -250,7 +250,7 @@ describe('ol.structs.LRUCache', function() {
}); });
it('returns the removed item', function() { it('returns the removed item', function() {
var cache = new _ol_structs_LRUCache_(); var cache = new LRUCache();
var item = {}; var item = {};
cache.set('key', item); cache.set('key', item);
@@ -259,7 +259,7 @@ describe('ol.structs.LRUCache', function() {
}); });
it('throws if the key does not exist', function() { it('throws if the key does not exist', function() {
var cache = new _ol_structs_LRUCache_(); var cache = new LRUCache();
cache.set('foo', 'foo'); cache.set('foo', 'foo');
cache.set('bar', 'bar'); cache.set('bar', 'bar');
+6 -8
View File
@@ -1,4 +1,4 @@
import _ol_structs_PriorityQueue_ from '../../../../src/ol/structs/PriorityQueue.js'; import PriorityQueue from '../../../../src/ol/structs/PriorityQueue.js';
describe('ol.structs.PriorityQueue', function() { describe('ol.structs.PriorityQueue', function() {
@@ -11,7 +11,7 @@ describe('ol.structs.PriorityQueue', function() {
var pq; var pq;
beforeEach(function() { beforeEach(function() {
pq = new _ol_structs_PriorityQueue_(identity, identity); pq = new PriorityQueue(identity, identity);
}); });
it('is empty', function() { it('is empty', function() {
@@ -39,8 +39,7 @@ describe('ol.structs.PriorityQueue', function() {
var elements, pq; var elements, pq;
beforeEach(function() { beforeEach(function() {
elements = []; elements = [];
pq = new _ol_structs_PriorityQueue_( pq = new PriorityQueue(identity, identity);
identity, identity);
var element, i; var element, i;
for (i = 0; i < 32; ++i) { for (i = 0; i < 32; ++i) {
element = Math.random(); element = Math.random();
@@ -65,7 +64,7 @@ describe('ol.structs.PriorityQueue', function() {
var pq, target; var pq, target;
beforeEach(function() { beforeEach(function() {
target = 0.5; target = 0.5;
pq = new _ol_structs_PriorityQueue_(function(element) { pq = new PriorityQueue(function(element) {
return Math.abs(element - target); return Math.abs(element - target);
}, identity); }, identity);
var i; var i;
@@ -103,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 _ol_structs_PriorityQueue_.DROP; return PriorityQueue.DROP;
} }
}; };
pq.reprioritize(); pq.reprioritize();
@@ -123,8 +122,7 @@ describe('ol.structs.PriorityQueue', function() {
var pq; var pq;
beforeEach(function() { beforeEach(function() {
pq = new _ol_structs_PriorityQueue_( pq = new PriorityQueue(identity, identity);
identity, identity);
pq.enqueue('a'); pq.enqueue('a');
pq.enqueue('b'); pq.enqueue('b');
pq.enqueue('c'); pq.enqueue('c');
+4 -4
View File
@@ -1,11 +1,11 @@
import _ol_structs_RBush_ from '../../../../src/ol/structs/RBush.js'; import RBush from '../../../../src/ol/structs/RBush.js';
describe('ol.structs.RBush', function() { describe('ol.structs.RBush', function() {
var rBush; var rBush;
beforeEach(function() { beforeEach(function() {
rBush = new _ol_structs_RBush_(); rBush = new RBush();
}); });
describe('when empty', function() { describe('when empty', function() {
@@ -316,7 +316,7 @@ describe('ol.structs.RBush', function() {
it('concatenates two RBush objects', function() { it('concatenates two RBush objects', function() {
var obj1 = {}; var obj1 = {};
var obj2 = {}; var obj2 = {};
var rBush2 = new _ol_structs_RBush_(); var rBush2 = new RBush();
rBush.insert([0, 0, 1, 1], obj1); rBush.insert([0, 0, 1, 1], obj1);
rBush2.insert([0, 0, 2, 2], obj2); rBush2.insert([0, 0, 2, 2], obj2);
rBush.concat(rBush2); rBush.concat(rBush2);
@@ -327,7 +327,7 @@ describe('ol.structs.RBush', function() {
it('preserves the concatenated object\'s references', function() { it('preserves the concatenated object\'s references', function() {
var obj1 = {}; var obj1 = {};
var obj2 = {}; var obj2 = {};
var rBush2 = new _ol_structs_RBush_(); var rBush2 = new RBush();
rBush.insert([0, 0, 1, 1], obj1); rBush.insert([0, 0, 1, 1], obj1);
rBush2.insert([0, 0, 2, 2], obj2); rBush2.insert([0, 0, 2, 2], obj2);
rBush.concat(rBush2); rBush.concat(rBush2);
+2 -2
View File
@@ -1,5 +1,5 @@
import _ol_Tile_ from '../../../src/ol/Tile.js'; import _ol_Tile_ from '../../../src/ol/Tile.js';
import _ol_TileCache_ from '../../../src/ol/TileCache.js'; import TileCache from '../../../src/ol/TileCache.js';
import _ol_tilecoord_ from '../../../src/ol/tilecoord.js'; import _ol_tilecoord_ from '../../../src/ol/tilecoord.js';
@@ -16,7 +16,7 @@ describe('ol.TileCache', function() {
new _ol_Tile_([2, 2, 0]), new _ol_Tile_([2, 2, 0]),
new _ol_Tile_([2, 3, 0]) // newest tile at z: 2 new _ol_Tile_([2, 3, 0]) // newest tile at z: 2
]; ];
var cache = new _ol_TileCache_(); var cache = new TileCache();
sinon.spy(tiles[0], 'dispose'); sinon.spy(tiles[0], 'dispose');
+10 -10
View File
@@ -1,9 +1,9 @@
import _ol_ImageTile_ from '../../../src/ol/ImageTile.js'; import _ol_ImageTile_ from '../../../src/ol/ImageTile.js';
import _ol_Tile_ from '../../../src/ol/Tile.js'; import _ol_Tile_ from '../../../src/ol/Tile.js';
import _ol_TileQueue_ from '../../../src/ol/TileQueue.js'; import TileQueue from '../../../src/ol/TileQueue.js';
import _ol_TileState_ from '../../../src/ol/TileState.js'; import _ol_TileState_ from '../../../src/ol/TileState.js';
import _ol_source_Image_ from '../../../src/ol/source/Image.js'; import _ol_source_Image_ from '../../../src/ol/source/Image.js';
import _ol_structs_PriorityQueue_ from '../../../src/ol/structs/PriorityQueue.js'; import PriorityQueue from '../../../src/ol/structs/PriorityQueue.js';
describe('ol.TileQueue', function() { describe('ol.TileQueue', function() {
@@ -40,8 +40,8 @@ describe('ol.TileQueue', function() {
var noop = function() {}; var noop = function() {};
it('works when tile queues share tiles', function(done) { it('works when tile queues share tiles', function(done) {
var q1 = new _ol_TileQueue_(noop, noop); var q1 = new TileQueue(noop, noop);
var q2 = new _ol_TileQueue_(noop, noop); var q2 = new TileQueue(noop, noop);
var numTiles = 20; var numTiles = 20;
for (var i = 0; i < numTiles; ++i) { for (var i = 0; i < numTiles; ++i) {
@@ -91,7 +91,7 @@ describe('ol.TileQueue', function() {
it('calls #tileChangeCallback_ when all wanted tiles are aborted', function() { it('calls #tileChangeCallback_ when all wanted tiles are aborted', function() {
var tileChangeCallback = sinon.spy(); var tileChangeCallback = sinon.spy();
var queue = new _ol_TileQueue_(noop, tileChangeCallback); var queue = new TileQueue(noop, tileChangeCallback);
var numTiles = 20; var numTiles = 20;
for (var i = 0; i < numTiles; ++i) { for (var i = 0; i < numTiles; ++i) {
var tile = createImageTile(); var tile = createImageTile();
@@ -108,7 +108,7 @@ describe('ol.TileQueue', function() {
describe('heapify', function() { describe('heapify', function() {
it('does convert an arbitrary array into a heap', function() { it('does convert an arbitrary array into a heap', function() {
var tq = new _ol_TileQueue_(function() {}); var tq = new TileQueue(function() {});
addRandomPriorityTiles(tq, 100); addRandomPriorityTiles(tq, 100);
tq.heapify_(); tq.heapify_();
@@ -118,7 +118,7 @@ describe('ol.TileQueue', function() {
describe('reprioritize', function() { describe('reprioritize', function() {
it('does reprioritize the array', function() { it('does reprioritize the array', function() {
var tq = new _ol_TileQueue_(function() {}); var tq = new TileQueue(function() {});
addRandomPriorityTiles(tq, 100); addRandomPriorityTiles(tq, 100);
tq.heapify_(); tq.heapify_();
@@ -129,7 +129,7 @@ describe('ol.TileQueue', function() {
var i = 0; var i = 0;
tq.priorityFunction_ = function() { tq.priorityFunction_ = function() {
if ((i++) % 2 === 0) { if ((i++) % 2 === 0) {
return _ol_structs_PriorityQueue_.DROP; return PriorityQueue.DROP;
} }
return Math.floor(Math.random() * 100); return Math.floor(Math.random() * 100);
}; };
@@ -145,7 +145,7 @@ describe('ol.TileQueue', function() {
var noop = function() {}; var noop = function() {};
it('abort queued tiles', function() { it('abort queued tiles', function() {
var tq = new _ol_TileQueue_(noop, noop); var tq = new TileQueue(noop, noop);
var tile = createImageTile(); var tile = createImageTile();
expect(tile.hasListener('change')).to.be(false); expect(tile.hasListener('change')).to.be(false);
@@ -158,7 +158,7 @@ describe('ol.TileQueue', function() {
}); });
it('abort loading tiles', function() { it('abort loading tiles', function() {
var tq = new _ol_TileQueue_(noop, noop); var tq = new TileQueue(noop, noop);
var tile = createImageTile(noop); var tile = createImageTile(noop);
tq.enqueue([tile]); tq.enqueue([tile]);