@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.
- package/dist/dist.dev.js +1449 -1449
- package/dist/es5/great-circle-layer/great-circle-layer.js +1 -26
- package/dist/es5/great-circle-layer/great-circle-layer.js.map +1 -1
- package/dist/es5/h3-layers/h3-cluster-layer.js +87 -149
- package/dist/es5/h3-layers/h3-cluster-layer.js.map +1 -1
- package/dist/es5/h3-layers/h3-hexagon-layer.js +226 -321
- package/dist/es5/h3-layers/h3-hexagon-layer.js.map +1 -1
- package/dist/es5/index.js +9 -9
- package/dist/es5/mesh-layer/mesh-layer.js +125 -151
- package/dist/es5/mesh-layer/mesh-layer.js.map +1 -1
- package/dist/es5/mvt-layer/coordinate-transform.js +19 -45
- package/dist/es5/mvt-layer/coordinate-transform.js.map +1 -1
- package/dist/es5/mvt-layer/find-index-binary.js +26 -45
- package/dist/es5/mvt-layer/find-index-binary.js.map +1 -1
- package/dist/es5/mvt-layer/mvt-layer.js +282 -374
- package/dist/es5/mvt-layer/mvt-layer.js.map +1 -1
- package/dist/es5/s2-layer/s2-geometry.js +32 -43
- package/dist/es5/s2-layer/s2-geometry.js.map +1 -1
- package/dist/es5/s2-layer/s2-layer.js +69 -104
- package/dist/es5/s2-layer/s2-layer.js.map +1 -1
- package/dist/es5/s2-layer/s2-utils.js +28 -27
- package/dist/es5/s2-layer/s2-utils.js.map +1 -1
- package/dist/es5/terrain-layer/terrain-layer.js +208 -254
- package/dist/es5/terrain-layer/terrain-layer.js.map +1 -1
- package/dist/es5/tile-3d-layer/tile-3d-layer.js +329 -382
- package/dist/es5/tile-3d-layer/tile-3d-layer.js.map +1 -1
- package/dist/es5/tile-layer/tile-2d-header.js +119 -183
- package/dist/es5/tile-layer/tile-2d-header.js.map +1 -1
- package/dist/es5/tile-layer/tile-2d-traversal.js +115 -178
- package/dist/es5/tile-layer/tile-2d-traversal.js.map +1 -1
- package/dist/es5/tile-layer/tile-layer.js +214 -258
- package/dist/es5/tile-layer/tile-layer.js.map +1 -1
- package/dist/es5/tile-layer/tileset-2d.js +290 -435
- package/dist/es5/tile-layer/tileset-2d.js.map +1 -1
- package/dist/es5/tile-layer/utils.js +61 -110
- package/dist/es5/tile-layer/utils.js.map +1 -1
- package/dist/es5/trips-layer/trips-layer.js +44 -81
- package/dist/es5/trips-layer/trips-layer.js.map +1 -1
- package/dist.min.js +1 -1
- 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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
25
|
+
const STRATEGY_REPLACE = 'no-overlap';
|
|
38
26
|
exports.STRATEGY_REPLACE = STRATEGY_REPLACE;
|
|
39
|
-
|
|
27
|
+
const STRATEGY_DEFAULT = 'best-available';
|
|
40
28
|
exports.STRATEGY_DEFAULT = STRATEGY_DEFAULT;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
var Tileset2D = function () {
|
|
44
|
-
function Tileset2D(opts) {
|
|
45
|
-
var _this = this;
|
|
29
|
+
const DEFAULT_CACHE_SCALE = 5;
|
|
46
30
|
|
|
47
|
-
|
|
31
|
+
class Tileset2D {
|
|
32
|
+
constructor(opts) {
|
|
48
33
|
this.opts = opts;
|
|
49
34
|
|
|
50
|
-
this.onTileLoad =
|
|
51
|
-
|
|
35
|
+
this.onTileLoad = tile => {
|
|
36
|
+
this.opts.onTileLoad(tile);
|
|
52
37
|
|
|
53
|
-
if (
|
|
54
|
-
|
|
38
|
+
if (this.opts.maxCacheByteSize) {
|
|
39
|
+
this._cacheByteSize += tile.byteLength;
|
|
55
40
|
|
|
56
|
-
|
|
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
|
-
(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
Object.assign(this.opts, opts);
|
|
59
|
+
get tiles() {
|
|
60
|
+
return this._tiles;
|
|
61
|
+
}
|
|
78
62
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
63
|
+
get selectedTiles() {
|
|
64
|
+
return this._selectedTiles;
|
|
65
|
+
}
|
|
82
66
|
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
71
|
+
setOptions(opts) {
|
|
72
|
+
Object.assign(this.opts, opts);
|
|
108
73
|
|
|
109
|
-
|
|
110
|
-
this.
|
|
74
|
+
if (Number.isFinite(opts.maxZoom)) {
|
|
75
|
+
this._maxZoom = Math.floor(opts.maxZoom);
|
|
111
76
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
90
|
+
this._cache.clear();
|
|
173
91
|
|
|
174
|
-
|
|
175
|
-
|
|
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
|
-
|
|
179
|
-
|
|
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
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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
|
-
|
|
222
|
-
|
|
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
|
-
|
|
268
|
-
|
|
269
|
-
var tile = abortCandidates.shift();
|
|
270
|
-
tile.abort();
|
|
271
|
-
ongoingRequestCount--;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
147
|
+
return this._frameNumber;
|
|
148
|
+
}
|
|
274
149
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
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
|
-
|
|
298
|
-
|
|
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
|
-
|
|
301
|
-
|
|
302
|
-
|
|
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
|
-
|
|
196
|
+
updateTileStates() {
|
|
197
|
+
this._updateTileStates(this.selectedTiles);
|
|
305
198
|
|
|
306
|
-
|
|
199
|
+
const {
|
|
200
|
+
maxRequests
|
|
201
|
+
} = this.opts;
|
|
202
|
+
const abortCandidates = [];
|
|
203
|
+
let ongoingRequestCount = 0;
|
|
204
|
+
let changed = false;
|
|
307
205
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
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
|
-
|
|
339
|
-
|
|
214
|
+
tile.isSelected = tile.state === TILE_STATE_SELECTED;
|
|
215
|
+
|
|
216
|
+
if (tile.isLoading) {
|
|
217
|
+
ongoingRequestCount++;
|
|
340
218
|
|
|
341
|
-
|
|
342
|
-
|
|
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
|
-
|
|
353
|
-
|
|
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
|
-
|
|
357
|
-
|
|
233
|
+
return changed;
|
|
234
|
+
}
|
|
358
235
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
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
|
-
|
|
371
|
-
|
|
241
|
+
for (const tile of _cache.values()) {
|
|
242
|
+
tile.parent = null;
|
|
243
|
+
tile.children.length = 0;
|
|
244
|
+
}
|
|
372
245
|
|
|
373
|
-
|
|
374
|
-
|
|
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
|
-
|
|
378
|
-
|
|
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
|
-
|
|
257
|
+
_updateTileStates(selectedTiles) {
|
|
258
|
+
const {
|
|
259
|
+
_cache
|
|
260
|
+
} = this;
|
|
261
|
+
const refinementStrategy = this.opts.refinementStrategy || STRATEGY_DEFAULT;
|
|
425
262
|
|
|
426
|
-
|
|
427
|
-
|
|
263
|
+
for (const tile of _cache.values()) {
|
|
264
|
+
tile.state = TILE_STATE_UNKNOWN;
|
|
265
|
+
}
|
|
428
266
|
|
|
429
|
-
|
|
430
|
-
|
|
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
|
-
|
|
465
|
-
|
|
466
|
-
|
|
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
|
-
|
|
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
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
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
|
-
|
|
488
|
-
|
|
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
|
-
|
|
300
|
+
_cache.delete(tileId);
|
|
491
301
|
|
|
492
|
-
|
|
493
|
-
|
|
302
|
+
this.opts.onTileUnload(tile);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (_cache.size <= maxCacheSize && this._cacheByteSize <= maxCacheByteSize) {
|
|
306
|
+
break;
|
|
494
307
|
}
|
|
495
308
|
}
|
|
496
309
|
|
|
497
|
-
|
|
310
|
+
this._rebuildTree();
|
|
311
|
+
|
|
312
|
+
this._dirty = true;
|
|
498
313
|
}
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
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
|
-
|
|
506
|
-
|
|
507
|
-
|
|
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
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
542
|
-
|
|
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
|
-
|
|
560
|
-
|
|
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
|
-
|
|
568
|
-
|
|
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
|