@deck.gl/geo-layers 8.6.0-beta.1 → 8.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/dist.dev.js +1449 -1449
  2. package/dist/es5/great-circle-layer/great-circle-layer.js +1 -26
  3. package/dist/es5/great-circle-layer/great-circle-layer.js.map +1 -1
  4. package/dist/es5/h3-layers/h3-cluster-layer.js +87 -149
  5. package/dist/es5/h3-layers/h3-cluster-layer.js.map +1 -1
  6. package/dist/es5/h3-layers/h3-hexagon-layer.js +226 -321
  7. package/dist/es5/h3-layers/h3-hexagon-layer.js.map +1 -1
  8. package/dist/es5/index.js +9 -9
  9. package/dist/es5/mesh-layer/mesh-layer.js +125 -151
  10. package/dist/es5/mesh-layer/mesh-layer.js.map +1 -1
  11. package/dist/es5/mvt-layer/coordinate-transform.js +19 -45
  12. package/dist/es5/mvt-layer/coordinate-transform.js.map +1 -1
  13. package/dist/es5/mvt-layer/find-index-binary.js +26 -45
  14. package/dist/es5/mvt-layer/find-index-binary.js.map +1 -1
  15. package/dist/es5/mvt-layer/mvt-layer.js +282 -374
  16. package/dist/es5/mvt-layer/mvt-layer.js.map +1 -1
  17. package/dist/es5/s2-layer/s2-geometry.js +32 -43
  18. package/dist/es5/s2-layer/s2-geometry.js.map +1 -1
  19. package/dist/es5/s2-layer/s2-layer.js +69 -104
  20. package/dist/es5/s2-layer/s2-layer.js.map +1 -1
  21. package/dist/es5/s2-layer/s2-utils.js +28 -27
  22. package/dist/es5/s2-layer/s2-utils.js.map +1 -1
  23. package/dist/es5/terrain-layer/terrain-layer.js +208 -254
  24. package/dist/es5/terrain-layer/terrain-layer.js.map +1 -1
  25. package/dist/es5/tile-3d-layer/tile-3d-layer.js +329 -382
  26. package/dist/es5/tile-3d-layer/tile-3d-layer.js.map +1 -1
  27. package/dist/es5/tile-layer/tile-2d-header.js +119 -183
  28. package/dist/es5/tile-layer/tile-2d-header.js.map +1 -1
  29. package/dist/es5/tile-layer/tile-2d-traversal.js +115 -178
  30. package/dist/es5/tile-layer/tile-2d-traversal.js.map +1 -1
  31. package/dist/es5/tile-layer/tile-layer.js +214 -258
  32. package/dist/es5/tile-layer/tile-layer.js.map +1 -1
  33. package/dist/es5/tile-layer/tileset-2d.js +290 -435
  34. package/dist/es5/tile-layer/tileset-2d.js.map +1 -1
  35. package/dist/es5/tile-layer/utils.js +61 -110
  36. package/dist/es5/tile-layer/utils.js.map +1 -1
  37. package/dist/es5/trips-layer/trips-layer.js +44 -81
  38. package/dist/es5/trips-layer/trips-layer.js.map +1 -1
  39. package/dist.min.js +1 -1
  40. package/package.json +2 -2
@@ -7,12 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = exports.STRATEGY_DEFAULT = exports.STRATEGY_REPLACE = exports.STRATEGY_NEVER = void 0;
9
9
 
10
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
-
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
-
16
10
  var _tile2dHeader = _interopRequireDefault(require("./tile-2d-header"));
17
11
 
18
12
  var _utils = require("./utils");
@@ -21,39 +15,30 @@ var _loaderUtils = require("@loaders.gl/loader-utils");
21
15
 
22
16
  var _math = require("math.gl");
23
17
 
24
- function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
25
-
26
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
27
-
28
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
29
-
30
- var TILE_STATE_UNKNOWN = 0;
31
- var TILE_STATE_VISIBLE = 1;
32
- var TILE_STATE_PLACEHOLDER = 3;
33
- var TILE_STATE_HIDDEN = 4;
34
- var TILE_STATE_SELECTED = 5;
35
- var STRATEGY_NEVER = 'never';
18
+ const TILE_STATE_UNKNOWN = 0;
19
+ const TILE_STATE_VISIBLE = 1;
20
+ const TILE_STATE_PLACEHOLDER = 3;
21
+ const TILE_STATE_HIDDEN = 4;
22
+ const TILE_STATE_SELECTED = 5;
23
+ const STRATEGY_NEVER = 'never';
36
24
  exports.STRATEGY_NEVER = STRATEGY_NEVER;
37
- var STRATEGY_REPLACE = 'no-overlap';
25
+ const STRATEGY_REPLACE = 'no-overlap';
38
26
  exports.STRATEGY_REPLACE = STRATEGY_REPLACE;
39
- var STRATEGY_DEFAULT = 'best-available';
27
+ const STRATEGY_DEFAULT = 'best-available';
40
28
  exports.STRATEGY_DEFAULT = STRATEGY_DEFAULT;
41
- var DEFAULT_CACHE_SCALE = 5;
42
-
43
- var Tileset2D = function () {
44
- function Tileset2D(opts) {
45
- var _this = this;
29
+ const DEFAULT_CACHE_SCALE = 5;
46
30
 
47
- (0, _classCallCheck2.default)(this, Tileset2D);
31
+ class Tileset2D {
32
+ constructor(opts) {
48
33
  this.opts = opts;
49
34
 
50
- this.onTileLoad = function (tile) {
51
- _this.opts.onTileLoad(tile);
35
+ this.onTileLoad = tile => {
36
+ this.opts.onTileLoad(tile);
52
37
 
53
- if (_this.opts.maxCacheByteSize) {
54
- _this._cacheByteSize += tile.byteLength;
38
+ if (this.opts.maxCacheByteSize) {
39
+ this._cacheByteSize += tile.byteLength;
55
40
 
56
- _this._resizeCache();
41
+ this._resizeCache();
57
42
  }
58
43
  };
59
44
 
@@ -71,456 +56,336 @@ var Tileset2D = function () {
71
56
  this.setOptions(opts);
72
57
  }
73
58
 
74
- (0, _createClass2.default)(Tileset2D, [{
75
- key: "setOptions",
76
- value: function setOptions(opts) {
77
- Object.assign(this.opts, opts);
59
+ get tiles() {
60
+ return this._tiles;
61
+ }
78
62
 
79
- if (Number.isFinite(opts.maxZoom)) {
80
- this._maxZoom = Math.floor(opts.maxZoom);
81
- }
63
+ get selectedTiles() {
64
+ return this._selectedTiles;
65
+ }
82
66
 
83
- if (Number.isFinite(opts.minZoom)) {
84
- this._minZoom = Math.ceil(opts.minZoom);
85
- }
86
- }
87
- }, {
88
- key: "finalize",
89
- value: function finalize() {
90
- var _iterator = _createForOfIteratorHelper(this._cache.values()),
91
- _step;
92
-
93
- try {
94
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
95
- var tile = _step.value;
96
-
97
- if (tile.isLoading) {
98
- tile.abort();
99
- }
100
- }
101
- } catch (err) {
102
- _iterator.e(err);
103
- } finally {
104
- _iterator.f();
105
- }
67
+ get isLoaded() {
68
+ return this._selectedTiles.every(tile => tile.isLoaded);
69
+ }
106
70
 
107
- this._cache.clear();
71
+ setOptions(opts) {
72
+ Object.assign(this.opts, opts);
108
73
 
109
- this._tiles = [];
110
- this._selectedTiles = null;
74
+ if (Number.isFinite(opts.maxZoom)) {
75
+ this._maxZoom = Math.floor(opts.maxZoom);
111
76
  }
112
- }, {
113
- key: "reloadAll",
114
- value: function reloadAll() {
115
- var _iterator2 = _createForOfIteratorHelper(this._cache.keys()),
116
- _step2;
117
-
118
- try {
119
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
120
- var tileId = _step2.value;
121
-
122
- var tile = this._cache.get(tileId);
123
-
124
- if (!this._selectedTiles.includes(tile)) {
125
- this._cache.delete(tileId);
126
- } else {
127
- tile.setNeedsReload();
128
- }
129
- }
130
- } catch (err) {
131
- _iterator2.e(err);
132
- } finally {
133
- _iterator2.f();
134
- }
77
+
78
+ if (Number.isFinite(opts.minZoom)) {
79
+ this._minZoom = Math.ceil(opts.minZoom);
135
80
  }
136
- }, {
137
- key: "update",
138
- value: function update(viewport) {
139
- var _this2 = this;
140
-
141
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
142
- zRange = _ref.zRange,
143
- modelMatrix = _ref.modelMatrix;
144
-
145
- var modelMatrixAsMatrix4 = new _math.Matrix4(modelMatrix);
146
- var isModelMatrixNew = !modelMatrixAsMatrix4.equals(this._modelMatrix);
147
-
148
- if (!viewport.equals(this._viewport) || isModelMatrixNew) {
149
- if (isModelMatrixNew) {
150
- this._modelMatrixInverse = modelMatrix && modelMatrixAsMatrix4.clone().invert();
151
- this._modelMatrix = modelMatrix && modelMatrixAsMatrix4;
152
- }
81
+ }
153
82
 
154
- this._viewport = viewport;
155
- var tileIndices = this.getTileIndices({
156
- viewport: viewport,
157
- maxZoom: this._maxZoom,
158
- minZoom: this._minZoom,
159
- zRange: zRange,
160
- modelMatrix: this._modelMatrix,
161
- modelMatrixInverse: this._modelMatrixInverse
162
- });
163
- this._selectedTiles = tileIndices.map(function (index) {
164
- return _this2._getTile(index, true);
165
- });
166
-
167
- if (this._dirty) {
168
- this._rebuildTree();
169
- }
83
+ finalize() {
84
+ for (const tile of this._cache.values()) {
85
+ if (tile.isLoading) {
86
+ tile.abort();
170
87
  }
88
+ }
171
89
 
172
- var changed = this.updateTileStates();
90
+ this._cache.clear();
173
91
 
174
- if (this._dirty) {
175
- this._resizeCache();
92
+ this._tiles = [];
93
+ this._selectedTiles = null;
94
+ }
95
+
96
+ reloadAll() {
97
+ for (const tileId of this._cache.keys()) {
98
+ const tile = this._cache.get(tileId);
99
+
100
+ if (!this._selectedTiles.includes(tile)) {
101
+ this._cache.delete(tileId);
102
+ } else {
103
+ tile.setNeedsReload();
176
104
  }
105
+ }
106
+ }
177
107
 
178
- if (changed) {
179
- this._frameNumber++;
108
+ update(viewport, {
109
+ zRange,
110
+ modelMatrix
111
+ } = {}) {
112
+ const modelMatrixAsMatrix4 = new _math.Matrix4(modelMatrix);
113
+ const isModelMatrixNew = !modelMatrixAsMatrix4.equals(this._modelMatrix);
114
+
115
+ if (!viewport.equals(this._viewport) || isModelMatrixNew) {
116
+ if (isModelMatrixNew) {
117
+ this._modelMatrixInverse = modelMatrix && modelMatrixAsMatrix4.clone().invert();
118
+ this._modelMatrix = modelMatrix && modelMatrixAsMatrix4;
180
119
  }
181
120
 
182
- return this._frameNumber;
183
- }
184
- }, {
185
- key: "getTileIndices",
186
- value: function getTileIndices(_ref2) {
187
- var viewport = _ref2.viewport,
188
- maxZoom = _ref2.maxZoom,
189
- minZoom = _ref2.minZoom,
190
- zRange = _ref2.zRange,
191
- modelMatrix = _ref2.modelMatrix,
192
- modelMatrixInverse = _ref2.modelMatrixInverse;
193
- var _this$opts = this.opts,
194
- tileSize = _this$opts.tileSize,
195
- extent = _this$opts.extent,
196
- zoomOffset = _this$opts.zoomOffset;
197
- return (0, _utils.getTileIndices)({
198
- viewport: viewport,
199
- maxZoom: maxZoom,
200
- minZoom: minZoom,
201
- zRange: zRange,
202
- tileSize: tileSize,
203
- extent: extent,
204
- modelMatrix: modelMatrix,
205
- modelMatrixInverse: modelMatrixInverse,
206
- zoomOffset: zoomOffset
121
+ this._viewport = viewport;
122
+ const tileIndices = this.getTileIndices({
123
+ viewport,
124
+ maxZoom: this._maxZoom,
125
+ minZoom: this._minZoom,
126
+ zRange,
127
+ modelMatrix: this._modelMatrix,
128
+ modelMatrixInverse: this._modelMatrixInverse
207
129
  });
130
+ this._selectedTiles = tileIndices.map(index => this._getTile(index, true));
131
+
132
+ if (this._dirty) {
133
+ this._rebuildTree();
134
+ }
208
135
  }
209
- }, {
210
- key: "getTileMetadata",
211
- value: function getTileMetadata(_ref3) {
212
- var x = _ref3.x,
213
- y = _ref3.y,
214
- z = _ref3.z;
215
- var tileSize = this.opts.tileSize;
216
- return {
217
- bbox: (0, _utils.tileToBoundingBox)(this._viewport, x, y, z, tileSize)
218
- };
136
+
137
+ const changed = this.updateTileStates();
138
+
139
+ if (this._dirty) {
140
+ this._resizeCache();
219
141
  }
220
- }, {
221
- key: "getParentIndex",
222
- value: function getParentIndex(tileIndex) {
223
- tileIndex.x = Math.floor(tileIndex.x / 2);
224
- tileIndex.y = Math.floor(tileIndex.y / 2);
225
- tileIndex.z -= 1;
226
- return tileIndex;
142
+
143
+ if (changed) {
144
+ this._frameNumber++;
227
145
  }
228
- }, {
229
- key: "updateTileStates",
230
- value: function updateTileStates() {
231
- this._updateTileStates(this.selectedTiles);
232
-
233
- var maxRequests = this.opts.maxRequests;
234
- var abortCandidates = [];
235
- var ongoingRequestCount = 0;
236
- var changed = false;
237
-
238
- var _iterator3 = _createForOfIteratorHelper(this._cache.values()),
239
- _step3;
240
-
241
- try {
242
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
243
- var _tile = _step3.value;
244
- var isVisible = Boolean(_tile.state & TILE_STATE_VISIBLE);
245
-
246
- if (_tile.isVisible !== isVisible) {
247
- changed = true;
248
- _tile.isVisible = isVisible;
249
- }
250
-
251
- _tile.isSelected = _tile.state === TILE_STATE_SELECTED;
252
-
253
- if (_tile.isLoading) {
254
- ongoingRequestCount++;
255
-
256
- if (!_tile.isSelected) {
257
- abortCandidates.push(_tile);
258
- }
259
- }
260
- }
261
- } catch (err) {
262
- _iterator3.e(err);
263
- } finally {
264
- _iterator3.f();
265
- }
266
146
 
267
- if (maxRequests > 0) {
268
- while (ongoingRequestCount > maxRequests && abortCandidates.length > 0) {
269
- var tile = abortCandidates.shift();
270
- tile.abort();
271
- ongoingRequestCount--;
272
- }
273
- }
147
+ return this._frameNumber;
148
+ }
274
149
 
275
- return changed;
276
- }
277
- }, {
278
- key: "_rebuildTree",
279
- value: function _rebuildTree() {
280
- var _cache = this._cache;
281
-
282
- var _iterator4 = _createForOfIteratorHelper(_cache.values()),
283
- _step4;
284
-
285
- try {
286
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
287
- var tile = _step4.value;
288
- tile.parent = null;
289
- tile.children.length = 0;
290
- }
291
- } catch (err) {
292
- _iterator4.e(err);
293
- } finally {
294
- _iterator4.f();
295
- }
150
+ getTileIndices({
151
+ viewport,
152
+ maxZoom,
153
+ minZoom,
154
+ zRange,
155
+ modelMatrix,
156
+ modelMatrixInverse
157
+ }) {
158
+ const {
159
+ tileSize,
160
+ extent,
161
+ zoomOffset
162
+ } = this.opts;
163
+ return (0, _utils.getTileIndices)({
164
+ viewport,
165
+ maxZoom,
166
+ minZoom,
167
+ zRange,
168
+ tileSize,
169
+ extent,
170
+ modelMatrix,
171
+ modelMatrixInverse,
172
+ zoomOffset
173
+ });
174
+ }
296
175
 
297
- var _iterator5 = _createForOfIteratorHelper(_cache.values()),
298
- _step5;
176
+ getTileMetadata({
177
+ x,
178
+ y,
179
+ z
180
+ }) {
181
+ const {
182
+ tileSize
183
+ } = this.opts;
184
+ return {
185
+ bbox: (0, _utils.tileToBoundingBox)(this._viewport, x, y, z, tileSize)
186
+ };
187
+ }
299
188
 
300
- try {
301
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
302
- var _tile2 = _step5.value;
189
+ getParentIndex(tileIndex) {
190
+ tileIndex.x = Math.floor(tileIndex.x / 2);
191
+ tileIndex.y = Math.floor(tileIndex.y / 2);
192
+ tileIndex.z -= 1;
193
+ return tileIndex;
194
+ }
303
195
 
304
- var parent = this._getNearestAncestor(_tile2.x, _tile2.y, _tile2.z);
196
+ updateTileStates() {
197
+ this._updateTileStates(this.selectedTiles);
305
198
 
306
- _tile2.parent = parent;
199
+ const {
200
+ maxRequests
201
+ } = this.opts;
202
+ const abortCandidates = [];
203
+ let ongoingRequestCount = 0;
204
+ let changed = false;
307
205
 
308
- if (parent) {
309
- parent.children.push(_tile2);
310
- }
311
- }
312
- } catch (err) {
313
- _iterator5.e(err);
314
- } finally {
315
- _iterator5.f();
316
- }
317
- }
318
- }, {
319
- key: "_updateTileStates",
320
- value: function _updateTileStates(selectedTiles) {
321
- var _cache = this._cache;
322
- var refinementStrategy = this.opts.refinementStrategy || STRATEGY_DEFAULT;
323
-
324
- var _iterator6 = _createForOfIteratorHelper(_cache.values()),
325
- _step6;
326
-
327
- try {
328
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
329
- var tile = _step6.value;
330
- tile.state = TILE_STATE_UNKNOWN;
331
- }
332
- } catch (err) {
333
- _iterator6.e(err);
334
- } finally {
335
- _iterator6.f();
206
+ for (const tile of this._cache.values()) {
207
+ const isVisible = Boolean(tile.state & TILE_STATE_VISIBLE);
208
+
209
+ if (tile.isVisible !== isVisible) {
210
+ changed = true;
211
+ tile.isVisible = isVisible;
336
212
  }
337
213
 
338
- var _iterator7 = _createForOfIteratorHelper(selectedTiles),
339
- _step7;
214
+ tile.isSelected = tile.state === TILE_STATE_SELECTED;
215
+
216
+ if (tile.isLoading) {
217
+ ongoingRequestCount++;
340
218
 
341
- try {
342
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
343
- var _tile3 = _step7.value;
344
- _tile3.state = TILE_STATE_SELECTED;
219
+ if (!tile.isSelected) {
220
+ abortCandidates.push(tile);
345
221
  }
346
- } catch (err) {
347
- _iterator7.e(err);
348
- } finally {
349
- _iterator7.f();
350
222
  }
223
+ }
351
224
 
352
- if (refinementStrategy === STRATEGY_NEVER) {
353
- return;
225
+ if (maxRequests > 0) {
226
+ while (ongoingRequestCount > maxRequests && abortCandidates.length > 0) {
227
+ const tile = abortCandidates.shift();
228
+ tile.abort();
229
+ ongoingRequestCount--;
354
230
  }
231
+ }
355
232
 
356
- var _iterator8 = _createForOfIteratorHelper(selectedTiles),
357
- _step8;
233
+ return changed;
234
+ }
358
235
 
359
- try {
360
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
361
- var _tile4 = _step8.value;
362
- getPlaceholderInAncestors(_tile4, refinementStrategy);
363
- }
364
- } catch (err) {
365
- _iterator8.e(err);
366
- } finally {
367
- _iterator8.f();
368
- }
236
+ _rebuildTree() {
237
+ const {
238
+ _cache
239
+ } = this;
369
240
 
370
- var _iterator9 = _createForOfIteratorHelper(selectedTiles),
371
- _step9;
241
+ for (const tile of _cache.values()) {
242
+ tile.parent = null;
243
+ tile.children.length = 0;
244
+ }
372
245
 
373
- try {
374
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
375
- var _tile5 = _step9.value;
246
+ for (const tile of _cache.values()) {
247
+ const parent = this._getNearestAncestor(tile.x, tile.y, tile.z);
376
248
 
377
- if (needsPlaceholder(_tile5)) {
378
- getPlaceholderInChildren(_tile5);
379
- }
380
- }
381
- } catch (err) {
382
- _iterator9.e(err);
383
- } finally {
384
- _iterator9.f();
249
+ tile.parent = parent;
250
+
251
+ if (parent) {
252
+ parent.children.push(tile);
385
253
  }
386
254
  }
387
- }, {
388
- key: "_resizeCache",
389
- value: function _resizeCache() {
390
- var _cache = this._cache,
391
- opts = this.opts;
392
- var maxCacheSize = opts.maxCacheSize || (opts.maxCacheByteSize ? Infinity : DEFAULT_CACHE_SCALE * this.selectedTiles.length);
393
- var maxCacheByteSize = opts.maxCacheByteSize || Infinity;
394
- var overflown = _cache.size > maxCacheSize || this._cacheByteSize > maxCacheByteSize;
395
-
396
- if (overflown) {
397
- var _iterator10 = _createForOfIteratorHelper(_cache),
398
- _step10;
399
-
400
- try {
401
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
402
- var _step10$value = (0, _slicedToArray2.default)(_step10.value, 2),
403
- tileId = _step10$value[0],
404
- tile = _step10$value[1];
405
-
406
- if (!tile.isVisible) {
407
- this._cacheByteSize -= opts.maxCacheByteSize ? tile.byteLength : 0;
408
-
409
- _cache.delete(tileId);
410
-
411
- this.opts.onTileUnload(tile);
412
- }
413
-
414
- if (_cache.size <= maxCacheSize && this._cacheByteSize <= maxCacheByteSize) {
415
- break;
416
- }
417
- }
418
- } catch (err) {
419
- _iterator10.e(err);
420
- } finally {
421
- _iterator10.f();
422
- }
255
+ }
423
256
 
424
- this._rebuildTree();
257
+ _updateTileStates(selectedTiles) {
258
+ const {
259
+ _cache
260
+ } = this;
261
+ const refinementStrategy = this.opts.refinementStrategy || STRATEGY_DEFAULT;
425
262
 
426
- this._dirty = true;
427
- }
263
+ for (const tile of _cache.values()) {
264
+ tile.state = TILE_STATE_UNKNOWN;
265
+ }
428
266
 
429
- if (this._dirty) {
430
- this._tiles = Array.from(this._cache.values()).sort(function (t1, t2) {
431
- return t1.z - t2.z;
432
- });
433
- this._dirty = false;
434
- }
267
+ for (const tile of selectedTiles) {
268
+ tile.state = TILE_STATE_SELECTED;
435
269
  }
436
- }, {
437
- key: "_getTile",
438
- value: function _getTile(_ref4, create) {
439
- var x = _ref4.x,
440
- y = _ref4.y,
441
- z = _ref4.z;
442
- var tileId = "".concat(x, ",").concat(y, ",").concat(z);
443
-
444
- var tile = this._cache.get(tileId);
445
-
446
- var needsReload = false;
447
-
448
- if (!tile && create) {
449
- tile = new _tile2dHeader.default({
450
- x: x,
451
- y: y,
452
- z: z
453
- });
454
- Object.assign(tile, this.getTileMetadata(tile));
455
- needsReload = true;
456
-
457
- this._cache.set(tileId, tile);
458
-
459
- this._dirty = true;
460
- } else if (tile && tile.needsReload) {
461
- needsReload = true;
462
- }
463
270
 
464
- if (needsReload) {
465
- tile.loadData({
466
- getData: this.opts.getTileData,
467
- requestScheduler: this._requestScheduler,
468
- onLoad: this.onTileLoad,
469
- onError: this.opts.onTileError
470
- });
471
- }
271
+ if (refinementStrategy === STRATEGY_NEVER) {
272
+ return;
273
+ }
472
274
 
473
- return tile;
275
+ for (const tile of selectedTiles) {
276
+ getPlaceholderInAncestors(tile, refinementStrategy);
474
277
  }
475
- }, {
476
- key: "_getNearestAncestor",
477
- value: function _getNearestAncestor(x, y, z) {
478
- var _this$_minZoom = this._minZoom,
479
- _minZoom = _this$_minZoom === void 0 ? 0 : _this$_minZoom;
480
278
 
481
- var index = {
482
- x: x,
483
- y: y,
484
- z: z
485
- };
279
+ for (const tile of selectedTiles) {
280
+ if (needsPlaceholder(tile)) {
281
+ getPlaceholderInChildren(tile);
282
+ }
283
+ }
284
+ }
285
+
286
+ _resizeCache() {
287
+ const {
288
+ _cache,
289
+ opts
290
+ } = this;
291
+ const maxCacheSize = opts.maxCacheSize || (opts.maxCacheByteSize ? Infinity : DEFAULT_CACHE_SCALE * this.selectedTiles.length);
292
+ const maxCacheByteSize = opts.maxCacheByteSize || Infinity;
293
+ const overflown = _cache.size > maxCacheSize || this._cacheByteSize > maxCacheByteSize;
486
294
 
487
- while (index.z > _minZoom) {
488
- index = this.getParentIndex(index);
295
+ if (overflown) {
296
+ for (const [tileId, tile] of _cache) {
297
+ if (!tile.isVisible) {
298
+ this._cacheByteSize -= opts.maxCacheByteSize ? tile.byteLength : 0;
489
299
 
490
- var parent = this._getTile(index);
300
+ _cache.delete(tileId);
491
301
 
492
- if (parent) {
493
- return parent;
302
+ this.opts.onTileUnload(tile);
303
+ }
304
+
305
+ if (_cache.size <= maxCacheSize && this._cacheByteSize <= maxCacheByteSize) {
306
+ break;
494
307
  }
495
308
  }
496
309
 
497
- return null;
310
+ this._rebuildTree();
311
+
312
+ this._dirty = true;
498
313
  }
499
- }, {
500
- key: "tiles",
501
- get: function get() {
502
- return this._tiles;
314
+
315
+ if (this._dirty) {
316
+ this._tiles = Array.from(this._cache.values()).sort((t1, t2) => t1.z - t2.z);
317
+ this._dirty = false;
503
318
  }
504
- }, {
505
- key: "selectedTiles",
506
- get: function get() {
507
- return this._selectedTiles;
319
+ }
320
+
321
+ _getTile({
322
+ x,
323
+ y,
324
+ z
325
+ }, create) {
326
+ const tileId = "".concat(x, ",").concat(y, ",").concat(z);
327
+
328
+ let tile = this._cache.get(tileId);
329
+
330
+ let needsReload = false;
331
+
332
+ if (!tile && create) {
333
+ tile = new _tile2dHeader.default({
334
+ x,
335
+ y,
336
+ z
337
+ });
338
+ Object.assign(tile, this.getTileMetadata(tile));
339
+ needsReload = true;
340
+
341
+ this._cache.set(tileId, tile);
342
+
343
+ this._dirty = true;
344
+ } else if (tile && tile.needsReload) {
345
+ needsReload = true;
508
346
  }
509
- }, {
510
- key: "isLoaded",
511
- get: function get() {
512
- return this._selectedTiles.every(function (tile) {
513
- return tile.isLoaded;
347
+
348
+ if (needsReload) {
349
+ tile.loadData({
350
+ getData: this.opts.getTileData,
351
+ requestScheduler: this._requestScheduler,
352
+ onLoad: this.onTileLoad,
353
+ onError: this.opts.onTileError
514
354
  });
515
355
  }
516
- }]);
517
- return Tileset2D;
518
- }();
356
+
357
+ return tile;
358
+ }
359
+
360
+ _getNearestAncestor(x, y, z) {
361
+ const {
362
+ _minZoom = 0
363
+ } = this;
364
+ let index = {
365
+ x,
366
+ y,
367
+ z
368
+ };
369
+
370
+ while (index.z > _minZoom) {
371
+ index = this.getParentIndex(index);
372
+
373
+ const parent = this._getTile(index);
374
+
375
+ if (parent) {
376
+ return parent;
377
+ }
378
+ }
379
+
380
+ return null;
381
+ }
382
+
383
+ }
519
384
 
520
385
  exports.default = Tileset2D;
521
386
 
522
387
  function needsPlaceholder(tile) {
523
- var t = tile;
388
+ let t = tile;
524
389
 
525
390
  while (t) {
526
391
  if (t.state & TILE_STATE_VISIBLE === 0) {
@@ -538,8 +403,8 @@ function needsPlaceholder(tile) {
538
403
  }
539
404
 
540
405
  function getPlaceholderInAncestors(tile, refinementStrategy) {
541
- var parent;
542
- var state = TILE_STATE_PLACEHOLDER;
406
+ let parent;
407
+ let state = TILE_STATE_PLACEHOLDER;
543
408
 
544
409
  while (parent = tile.parent) {
545
410
  if (tile.isLoaded) {
@@ -556,22 +421,12 @@ function getPlaceholderInAncestors(tile, refinementStrategy) {
556
421
  }
557
422
 
558
423
  function getPlaceholderInChildren(tile) {
559
- var _iterator11 = _createForOfIteratorHelper(tile.children),
560
- _step11;
561
-
562
- try {
563
- for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
564
- var child = _step11.value;
565
- child.state = Math.max(child.state, TILE_STATE_PLACEHOLDER);
424
+ for (const child of tile.children) {
425
+ child.state = Math.max(child.state, TILE_STATE_PLACEHOLDER);
566
426
 
567
- if (!child.isLoaded) {
568
- getPlaceholderInChildren(child);
569
- }
427
+ if (!child.isLoaded) {
428
+ getPlaceholderInChildren(child);
570
429
  }
571
- } catch (err) {
572
- _iterator11.e(err);
573
- } finally {
574
- _iterator11.f();
575
430
  }
576
431
  }
577
432
  //# sourceMappingURL=tileset-2d.js.map