@deck.gl/geo-layers 8.6.3 → 8.7.0-alpha.1

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 +26 -1
  3. package/dist/es5/great-circle-layer/great-circle-layer.js.map +1 -1
  4. package/dist/es5/h3-layers/h3-cluster-layer.js +149 -87
  5. package/dist/es5/h3-layers/h3-cluster-layer.js.map +1 -1
  6. package/dist/es5/h3-layers/h3-hexagon-layer.js +321 -226
  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 +151 -125
  10. package/dist/es5/mesh-layer/mesh-layer.js.map +1 -1
  11. package/dist/es5/mvt-layer/coordinate-transform.js +45 -19
  12. package/dist/es5/mvt-layer/coordinate-transform.js.map +1 -1
  13. package/dist/es5/mvt-layer/find-index-binary.js +45 -26
  14. package/dist/es5/mvt-layer/find-index-binary.js.map +1 -1
  15. package/dist/es5/mvt-layer/mvt-layer.js +374 -282
  16. package/dist/es5/mvt-layer/mvt-layer.js.map +1 -1
  17. package/dist/es5/s2-layer/s2-geometry.js +43 -32
  18. package/dist/es5/s2-layer/s2-geometry.js.map +1 -1
  19. package/dist/es5/s2-layer/s2-layer.js +104 -69
  20. package/dist/es5/s2-layer/s2-layer.js.map +1 -1
  21. package/dist/es5/s2-layer/s2-utils.js +27 -28
  22. package/dist/es5/s2-layer/s2-utils.js.map +1 -1
  23. package/dist/es5/terrain-layer/terrain-layer.js +254 -208
  24. package/dist/es5/terrain-layer/terrain-layer.js.map +1 -1
  25. package/dist/es5/tile-3d-layer/tile-3d-layer.js +382 -329
  26. package/dist/es5/tile-3d-layer/tile-3d-layer.js.map +1 -1
  27. package/dist/es5/tile-layer/tile-2d-header.js +183 -119
  28. package/dist/es5/tile-layer/tile-2d-header.js.map +1 -1
  29. package/dist/es5/tile-layer/tile-2d-traversal.js +178 -115
  30. package/dist/es5/tile-layer/tile-2d-traversal.js.map +1 -1
  31. package/dist/es5/tile-layer/tile-layer.js +258 -214
  32. package/dist/es5/tile-layer/tile-layer.js.map +1 -1
  33. package/dist/es5/tile-layer/tileset-2d.js +435 -290
  34. package/dist/es5/tile-layer/tileset-2d.js.map +1 -1
  35. package/dist/es5/tile-layer/utils.js +110 -61
  36. package/dist/es5/tile-layer/utils.js.map +1 -1
  37. package/dist/es5/trips-layer/trips-layer.js +81 -44
  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,6 +7,12 @@ 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
+
10
16
  var _tile2dHeader = _interopRequireDefault(require("./tile-2d-header"));
11
17
 
12
18
  var _utils = require("./utils");
@@ -15,30 +21,39 @@ var _loaderUtils = require("@loaders.gl/loader-utils");
15
21
 
16
22
  var _math = require("math.gl");
17
23
 
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';
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';
24
36
  exports.STRATEGY_NEVER = STRATEGY_NEVER;
25
- const STRATEGY_REPLACE = 'no-overlap';
37
+ var STRATEGY_REPLACE = 'no-overlap';
26
38
  exports.STRATEGY_REPLACE = STRATEGY_REPLACE;
27
- const STRATEGY_DEFAULT = 'best-available';
39
+ var STRATEGY_DEFAULT = 'best-available';
28
40
  exports.STRATEGY_DEFAULT = STRATEGY_DEFAULT;
29
- const DEFAULT_CACHE_SCALE = 5;
41
+ var DEFAULT_CACHE_SCALE = 5;
42
+
43
+ var Tileset2D = function () {
44
+ function Tileset2D(opts) {
45
+ var _this = this;
30
46
 
31
- class Tileset2D {
32
- constructor(opts) {
47
+ (0, _classCallCheck2.default)(this, Tileset2D);
33
48
  this.opts = opts;
34
49
 
35
- this.onTileLoad = tile => {
36
- this.opts.onTileLoad(tile);
50
+ this.onTileLoad = function (tile) {
51
+ _this.opts.onTileLoad(tile);
37
52
 
38
- if (this.opts.maxCacheByteSize) {
39
- this._cacheByteSize += tile.byteLength;
53
+ if (_this.opts.maxCacheByteSize) {
54
+ _this._cacheByteSize += tile.byteLength;
40
55
 
41
- this._resizeCache();
56
+ _this._resizeCache();
42
57
  }
43
58
  };
44
59
 
@@ -56,336 +71,456 @@ class Tileset2D {
56
71
  this.setOptions(opts);
57
72
  }
58
73
 
59
- get tiles() {
60
- return this._tiles;
61
- }
62
-
63
- get selectedTiles() {
64
- return this._selectedTiles;
65
- }
66
-
67
- get isLoaded() {
68
- return this._selectedTiles.every(tile => tile.isLoaded);
69
- }
70
-
71
- setOptions(opts) {
72
- Object.assign(this.opts, opts);
74
+ (0, _createClass2.default)(Tileset2D, [{
75
+ key: "setOptions",
76
+ value: function setOptions(opts) {
77
+ Object.assign(this.opts, opts);
73
78
 
74
- if (Number.isFinite(opts.maxZoom)) {
75
- this._maxZoom = Math.floor(opts.maxZoom);
76
- }
77
-
78
- if (Number.isFinite(opts.minZoom)) {
79
- this._minZoom = Math.ceil(opts.minZoom);
80
- }
81
- }
79
+ if (Number.isFinite(opts.maxZoom)) {
80
+ this._maxZoom = Math.floor(opts.maxZoom);
81
+ }
82
82
 
83
- finalize() {
84
- for (const tile of this._cache.values()) {
85
- if (tile.isLoading) {
86
- tile.abort();
83
+ if (Number.isFinite(opts.minZoom)) {
84
+ this._minZoom = Math.ceil(opts.minZoom);
87
85
  }
88
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
+ }
89
106
 
90
- this._cache.clear();
91
-
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);
107
+ this._cache.clear();
99
108
 
100
- if (!this._selectedTiles.includes(tile)) {
101
- this._cache.delete(tileId);
102
- } else {
103
- tile.setNeedsReload();
109
+ this._tiles = [];
110
+ this._selectedTiles = null;
111
+ }
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();
104
134
  }
105
135
  }
106
- }
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
+ }
107
153
 
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;
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
+ }
119
170
  }
120
171
 
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
129
- });
130
- this._selectedTiles = tileIndices.map(index => this._getTile(index, true));
172
+ var changed = this.updateTileStates();
131
173
 
132
174
  if (this._dirty) {
133
- this._rebuildTree();
175
+ this._resizeCache();
134
176
  }
135
- }
136
177
 
137
- const changed = this.updateTileStates();
178
+ if (changed) {
179
+ this._frameNumber++;
180
+ }
138
181
 
139
- if (this._dirty) {
140
- this._resizeCache();
182
+ return this._frameNumber;
141
183
  }
142
-
143
- if (changed) {
144
- this._frameNumber++;
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
207
+ });
145
208
  }
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
+ };
219
+ }
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;
227
+ }
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
+ }
146
266
 
147
- return this._frameNumber;
148
- }
149
-
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
- }
267
+ if (maxRequests > 0) {
268
+ while (ongoingRequestCount > maxRequests && abortCandidates.length > 0) {
269
+ var tile = abortCandidates.shift();
270
+ tile.abort();
271
+ ongoingRequestCount--;
272
+ }
273
+ }
175
274
 
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
- }
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
+ }
188
296
 
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
- }
297
+ var _iterator5 = _createForOfIteratorHelper(_cache.values()),
298
+ _step5;
195
299
 
196
- updateTileStates() {
197
- this._updateTileStates(this.selectedTiles);
300
+ try {
301
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
302
+ var _tile2 = _step5.value;
198
303
 
199
- const {
200
- maxRequests
201
- } = this.opts;
202
- const abortCandidates = [];
203
- let ongoingRequestCount = 0;
204
- let changed = false;
304
+ var parent = this._getNearestAncestor(_tile2.x, _tile2.y, _tile2.z);
205
305
 
206
- for (const tile of this._cache.values()) {
207
- const isVisible = Boolean(tile.state & TILE_STATE_VISIBLE);
306
+ _tile2.parent = parent;
208
307
 
209
- if (tile.isVisible !== isVisible) {
210
- changed = true;
211
- tile.isVisible = isVisible;
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();
212
336
  }
213
337
 
214
- tile.isSelected = tile.state === TILE_STATE_SELECTED;
215
-
216
- if (tile.isLoading) {
217
- ongoingRequestCount++;
338
+ var _iterator7 = _createForOfIteratorHelper(selectedTiles),
339
+ _step7;
218
340
 
219
- if (!tile.isSelected) {
220
- abortCandidates.push(tile);
341
+ try {
342
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
343
+ var _tile3 = _step7.value;
344
+ _tile3.state = TILE_STATE_SELECTED;
221
345
  }
346
+ } catch (err) {
347
+ _iterator7.e(err);
348
+ } finally {
349
+ _iterator7.f();
222
350
  }
223
- }
224
351
 
225
- if (maxRequests > 0) {
226
- while (ongoingRequestCount > maxRequests && abortCandidates.length > 0) {
227
- const tile = abortCandidates.shift();
228
- tile.abort();
229
- ongoingRequestCount--;
352
+ if (refinementStrategy === STRATEGY_NEVER) {
353
+ return;
230
354
  }
231
- }
232
355
 
233
- return changed;
234
- }
235
-
236
- _rebuildTree() {
237
- const {
238
- _cache
239
- } = this;
356
+ var _iterator8 = _createForOfIteratorHelper(selectedTiles),
357
+ _step8;
240
358
 
241
- for (const tile of _cache.values()) {
242
- tile.parent = null;
243
- tile.children.length = 0;
244
- }
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
+ }
245
369
 
246
- for (const tile of _cache.values()) {
247
- const parent = this._getNearestAncestor(tile.x, tile.y, tile.z);
370
+ var _iterator9 = _createForOfIteratorHelper(selectedTiles),
371
+ _step9;
248
372
 
249
- tile.parent = parent;
373
+ try {
374
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
375
+ var _tile5 = _step9.value;
250
376
 
251
- if (parent) {
252
- parent.children.push(tile);
377
+ if (needsPlaceholder(_tile5)) {
378
+ getPlaceholderInChildren(_tile5);
379
+ }
380
+ }
381
+ } catch (err) {
382
+ _iterator9.e(err);
383
+ } finally {
384
+ _iterator9.f();
253
385
  }
254
386
  }
255
- }
256
-
257
- _updateTileStates(selectedTiles) {
258
- const {
259
- _cache
260
- } = this;
261
- const refinementStrategy = this.opts.refinementStrategy || STRATEGY_DEFAULT;
262
-
263
- for (const tile of _cache.values()) {
264
- tile.state = TILE_STATE_UNKNOWN;
265
- }
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
+ }
266
423
 
267
- for (const tile of selectedTiles) {
268
- tile.state = TILE_STATE_SELECTED;
269
- }
424
+ this._rebuildTree();
270
425
 
271
- if (refinementStrategy === STRATEGY_NEVER) {
272
- return;
273
- }
426
+ this._dirty = true;
427
+ }
274
428
 
275
- for (const tile of selectedTiles) {
276
- getPlaceholderInAncestors(tile, refinementStrategy);
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
+ }
277
435
  }
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
+ }
278
463
 
279
- for (const tile of selectedTiles) {
280
- if (needsPlaceholder(tile)) {
281
- getPlaceholderInChildren(tile);
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
+ });
282
471
  }
472
+
473
+ return tile;
283
474
  }
284
- }
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;
285
480
 
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;
481
+ var index = {
482
+ x: x,
483
+ y: y,
484
+ z: z
485
+ };
294
486
 
295
- if (overflown) {
296
- for (const [tileId, tile] of _cache) {
297
- if (!tile.isVisible) {
298
- this._cacheByteSize -= opts.maxCacheByteSize ? tile.byteLength : 0;
487
+ while (index.z > _minZoom) {
488
+ index = this.getParentIndex(index);
299
489
 
300
- _cache.delete(tileId);
490
+ var parent = this._getTile(index);
301
491
 
302
- this.opts.onTileUnload(tile);
303
- }
304
-
305
- if (_cache.size <= maxCacheSize && this._cacheByteSize <= maxCacheByteSize) {
306
- break;
492
+ if (parent) {
493
+ return parent;
307
494
  }
308
495
  }
309
496
 
310
- this._rebuildTree();
311
-
312
- this._dirty = true;
497
+ return null;
313
498
  }
314
-
315
- if (this._dirty) {
316
- this._tiles = Array.from(this._cache.values()).sort((t1, t2) => t1.z - t2.z);
317
- this._dirty = false;
499
+ }, {
500
+ key: "tiles",
501
+ get: function get() {
502
+ return this._tiles;
318
503
  }
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;
504
+ }, {
505
+ key: "selectedTiles",
506
+ get: function get() {
507
+ return this._selectedTiles;
346
508
  }
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
509
+ }, {
510
+ key: "isLoaded",
511
+ get: function get() {
512
+ return this._selectedTiles.every(function (tile) {
513
+ return tile.isLoaded;
354
514
  });
355
515
  }
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
- }
516
+ }]);
517
+ return Tileset2D;
518
+ }();
384
519
 
385
520
  exports.default = Tileset2D;
386
521
 
387
522
  function needsPlaceholder(tile) {
388
- let t = tile;
523
+ var t = tile;
389
524
 
390
525
  while (t) {
391
526
  if (t.state & TILE_STATE_VISIBLE === 0) {
@@ -403,8 +538,8 @@ function needsPlaceholder(tile) {
403
538
  }
404
539
 
405
540
  function getPlaceholderInAncestors(tile, refinementStrategy) {
406
- let parent;
407
- let state = TILE_STATE_PLACEHOLDER;
541
+ var parent;
542
+ var state = TILE_STATE_PLACEHOLDER;
408
543
 
409
544
  while (parent = tile.parent) {
410
545
  if (tile.isLoaded) {
@@ -421,12 +556,22 @@ function getPlaceholderInAncestors(tile, refinementStrategy) {
421
556
  }
422
557
 
423
558
  function getPlaceholderInChildren(tile) {
424
- for (const child of tile.children) {
425
- child.state = Math.max(child.state, TILE_STATE_PLACEHOLDER);
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);
426
566
 
427
- if (!child.isLoaded) {
428
- getPlaceholderInChildren(child);
567
+ if (!child.isLoaded) {
568
+ getPlaceholderInChildren(child);
569
+ }
429
570
  }
571
+ } catch (err) {
572
+ _iterator11.e(err);
573
+ } finally {
574
+ _iterator11.f();
430
575
  }
431
576
  }
432
577
  //# sourceMappingURL=tileset-2d.js.map