@deck.gl/geo-layers 8.6.4 → 8.6.8

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