@deck.gl/aggregation-layers 8.6.4 → 8.6.5

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 (61) hide show
  1. package/dist/es5/aggregation-layer.js +163 -109
  2. package/dist/es5/aggregation-layer.js.map +1 -1
  3. package/dist/es5/contour-layer/contour-layer.js +260 -240
  4. package/dist/es5/contour-layer/contour-layer.js.map +1 -1
  5. package/dist/es5/contour-layer/contour-utils.js +86 -65
  6. package/dist/es5/contour-layer/contour-utils.js.map +1 -1
  7. package/dist/es5/contour-layer/marching-squares-codes.js +106 -181
  8. package/dist/es5/contour-layer/marching-squares-codes.js.map +1 -1
  9. package/dist/es5/contour-layer/marching-squares.js +59 -56
  10. package/dist/es5/contour-layer/marching-squares.js.map +1 -1
  11. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +121 -85
  12. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
  13. package/dist/es5/cpu-grid-layer/grid-aggregator.js +119 -93
  14. package/dist/es5/cpu-grid-layer/grid-aggregator.js.map +1 -1
  15. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +167 -131
  16. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
  17. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +322 -319
  18. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
  19. package/dist/es5/grid-aggregation-layer.js +230 -202
  20. package/dist/es5/grid-aggregation-layer.js.map +1 -1
  21. package/dist/es5/grid-layer/grid-layer.js +91 -61
  22. package/dist/es5/grid-layer/grid-layer.js.map +1 -1
  23. package/dist/es5/heatmap-layer/heatmap-layer-utils.js +59 -24
  24. package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +1 -1
  25. package/dist/es5/heatmap-layer/heatmap-layer.js +533 -515
  26. package/dist/es5/heatmap-layer/heatmap-layer.js.map +1 -1
  27. package/dist/es5/heatmap-layer/triangle-layer.js +91 -64
  28. package/dist/es5/heatmap-layer/triangle-layer.js.map +1 -1
  29. package/dist/es5/hexagon-layer/hexagon-aggregator.js +77 -59
  30. package/dist/es5/hexagon-layer/hexagon-aggregator.js.map +1 -1
  31. package/dist/es5/hexagon-layer/hexagon-layer.js +164 -121
  32. package/dist/es5/hexagon-layer/hexagon-layer.js.map +1 -1
  33. package/dist/es5/index.js +12 -12
  34. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +193 -168
  35. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  36. package/dist/es5/screen-grid-layer/screen-grid-layer.js +250 -235
  37. package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +1 -1
  38. package/dist/es5/utils/aggregation-operation-utils.js +31 -16
  39. package/dist/es5/utils/aggregation-operation-utils.js.map +1 -1
  40. package/dist/es5/utils/bin-sorter.js +198 -118
  41. package/dist/es5/utils/bin-sorter.js.map +1 -1
  42. package/dist/es5/utils/color-utils.js +10 -8
  43. package/dist/es5/utils/color-utils.js.map +1 -1
  44. package/dist/es5/utils/cpu-aggregator.js +342 -323
  45. package/dist/es5/utils/cpu-aggregator.js.map +1 -1
  46. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +18 -20
  47. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +1 -1
  48. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +545 -545
  49. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +1 -1
  50. package/dist/es5/utils/grid-aggregation-utils.js +44 -50
  51. package/dist/es5/utils/grid-aggregation-utils.js.map +1 -1
  52. package/dist/es5/utils/prop-utils.js +2 -2
  53. package/dist/es5/utils/prop-utils.js.map +1 -1
  54. package/dist/es5/utils/resource-utils.js +39 -32
  55. package/dist/es5/utils/resource-utils.js.map +1 -1
  56. package/dist/es5/utils/scale-utils.js +66 -36
  57. package/dist/es5/utils/scale-utils.js.map +1 -1
  58. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  59. package/dist/esm/utils/cpu-aggregator.js.map +1 -1
  60. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +1 -1
  61. package/package.json +2 -2
@@ -7,6 +7,20 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+
14
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
+
16
+ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
17
+
18
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
19
+
20
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
21
+
22
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
23
+
10
24
  var _core = require("@luma.gl/core");
11
25
 
12
26
  var _core2 = require("@deck.gl/core");
@@ -25,7 +39,15 @@ var _gridAggregationLayer = _interopRequireDefault(require("../grid-aggregation-
25
39
 
26
40
  var _gridAggregationUtils = require("../utils/grid-aggregation-utils");
27
41
 
28
- const defaultProps = {
42
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
43
+
44
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
45
+
46
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
47
+
48
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
49
+
50
+ var defaultProps = {
29
51
  colorDomain: null,
30
52
  colorRange: _colorUtils.defaultColorRange,
31
53
  getColorWeight: {
@@ -59,362 +81,343 @@ const defaultProps = {
59
81
  },
60
82
  getPosition: {
61
83
  type: 'accessor',
62
- value: x => x.position
84
+ value: function value(x) {
85
+ return x.position;
86
+ }
63
87
  },
64
88
  extruded: false,
65
89
  material: true
66
90
  };
67
- const DIMENSIONS = {
91
+ var DIMENSIONS = {
68
92
  data: {
69
93
  props: ['cellSize', 'colorAggregation', 'elevationAggregation']
70
94
  }
71
95
  };
72
- const POSITION_ATTRIBUTE_NAME = 'positions';
96
+ var POSITION_ATTRIBUTE_NAME = 'positions';
73
97
 
74
- class GPUGridLayer extends _gridAggregationLayer.default {
75
- initializeState() {
76
- const {
77
- gl
78
- } = this.context;
98
+ var GPUGridLayer = function (_GridAggregationLayer) {
99
+ (0, _inherits2.default)(GPUGridLayer, _GridAggregationLayer);
79
100
 
80
- const isSupported = _gpuGridAggregator.default.isSupported(gl);
101
+ var _super = _createSuper(GPUGridLayer);
81
102
 
82
- if (!isSupported) {
83
- _core2.log.error('GPUGridLayer is not supported on this browser, use GridLayer instead')();
84
- }
103
+ function GPUGridLayer() {
104
+ (0, _classCallCheck2.default)(this, GPUGridLayer);
105
+ return _super.apply(this, arguments);
106
+ }
107
+
108
+ (0, _createClass2.default)(GPUGridLayer, [{
109
+ key: "initializeState",
110
+ value: function initializeState() {
111
+ var _attributeManager$add;
112
+
113
+ var gl = this.context.gl;
114
+
115
+ var isSupported = _gpuGridAggregator.default.isSupported(gl);
85
116
 
86
- super.initializeState({
87
- dimensions: DIMENSIONS
88
- });
89
- this.setState({
90
- gpuAggregation: true,
91
- projectPoints: false,
92
- isSupported,
93
- weights: {
94
- color: {
95
- needMin: true,
96
- needMax: true,
97
- combineMaxMin: true,
98
- maxMinBuffer: new _core.Buffer(gl, {
99
- byteLength: 4 * 4,
100
- accessor: {
101
- size: 4,
102
- type: 5126,
103
- divisor: 1
104
- }
105
- })
117
+ if (!isSupported) {
118
+ _core2.log.error('GPUGridLayer is not supported on this browser, use GridLayer instead')();
119
+ }
120
+
121
+ (0, _get2.default)((0, _getPrototypeOf2.default)(GPUGridLayer.prototype), "initializeState", this).call(this, {
122
+ dimensions: DIMENSIONS
123
+ });
124
+ this.setState({
125
+ gpuAggregation: true,
126
+ projectPoints: false,
127
+ isSupported: isSupported,
128
+ weights: {
129
+ color: {
130
+ needMin: true,
131
+ needMax: true,
132
+ combineMaxMin: true,
133
+ maxMinBuffer: new _core.Buffer(gl, {
134
+ byteLength: 4 * 4,
135
+ accessor: {
136
+ size: 4,
137
+ type: 5126,
138
+ divisor: 1
139
+ }
140
+ })
141
+ },
142
+ elevation: {
143
+ needMin: true,
144
+ needMax: true,
145
+ combineMaxMin: true,
146
+ maxMinBuffer: new _core.Buffer(gl, {
147
+ byteLength: 4 * 4,
148
+ accessor: {
149
+ size: 4,
150
+ type: 5126,
151
+ divisor: 1
152
+ }
153
+ })
154
+ }
106
155
  },
107
- elevation: {
108
- needMin: true,
109
- needMax: true,
110
- combineMaxMin: true,
111
- maxMinBuffer: new _core.Buffer(gl, {
112
- byteLength: 4 * 4,
113
- accessor: {
114
- size: 4,
115
- type: 5126,
116
- divisor: 1
117
- }
118
- })
119
- }
120
- },
121
- positionAttributeName: 'positions'
122
- });
123
- const attributeManager = this.getAttributeManager();
124
- attributeManager.add({
125
- [POSITION_ATTRIBUTE_NAME]: {
156
+ positionAttributeName: 'positions'
157
+ });
158
+ var attributeManager = this.getAttributeManager();
159
+ attributeManager.add((_attributeManager$add = {}, (0, _defineProperty2.default)(_attributeManager$add, POSITION_ATTRIBUTE_NAME, {
126
160
  size: 3,
127
161
  accessor: 'getPosition',
128
162
  type: 5130,
129
163
  fp64: this.use64bitPositions()
130
- },
131
- color: {
164
+ }), (0, _defineProperty2.default)(_attributeManager$add, "color", {
132
165
  size: 3,
133
166
  accessor: 'getColorWeight'
134
- },
135
- elevation: {
167
+ }), (0, _defineProperty2.default)(_attributeManager$add, "elevation", {
136
168
  size: 3,
137
169
  accessor: 'getElevationWeight'
138
- }
139
- });
140
- }
141
-
142
- updateState(opts) {
143
- if (this.state.isSupported === false) {
144
- return;
170
+ }), _attributeManager$add));
145
171
  }
172
+ }, {
173
+ key: "updateState",
174
+ value: function updateState(opts) {
175
+ if (this.state.isSupported === false) {
176
+ return;
177
+ }
146
178
 
147
- super.updateState(opts);
148
- const {
149
- aggregationDirty
150
- } = this.state;
151
-
152
- if (aggregationDirty) {
153
- this.setState({
154
- gridHash: null
155
- });
156
- }
157
- }
158
-
159
- getHashKeyForIndex(index) {
160
- const {
161
- numRow,
162
- numCol,
163
- boundingBox,
164
- gridOffset
165
- } = this.state;
166
- const gridSize = [numCol, numRow];
167
- const gridOrigin = [boundingBox.xMin, boundingBox.yMin];
168
- const cellSize = [gridOffset.xOffset, gridOffset.yOffset];
169
- const yIndex = Math.floor(index / gridSize[0]);
170
- const xIndex = index - yIndex * gridSize[0];
171
- const latIdx = Math.floor((yIndex * cellSize[1] + gridOrigin[1] + 90 + cellSize[1] / 2) / cellSize[1]);
172
- const lonIdx = Math.floor((xIndex * cellSize[0] + gridOrigin[0] + 180 + cellSize[0] / 2) / cellSize[0]);
173
- return "".concat(latIdx, "-").concat(lonIdx);
174
- }
175
-
176
- getPositionForIndex(index) {
177
- const {
178
- numRow,
179
- numCol,
180
- boundingBox,
181
- gridOffset
182
- } = this.state;
183
- const gridSize = [numCol, numRow];
184
- const gridOrigin = [boundingBox.xMin, boundingBox.yMin];
185
- const cellSize = [gridOffset.xOffset, gridOffset.yOffset];
186
- const yIndex = Math.floor(index / gridSize[0]);
187
- const xIndex = index - yIndex * gridSize[0];
188
- const yPos = yIndex * cellSize[1] + gridOrigin[1];
189
- const xPos = xIndex * cellSize[0] + gridOrigin[0];
190
- return [xPos, yPos];
191
- }
192
-
193
- getPickingInfo({
194
- info,
195
- mode
196
- }) {
197
- const {
198
- index
199
- } = info;
200
- let object = null;
201
-
202
- if (index >= 0) {
203
- const {
204
- gpuGridAggregator
205
- } = this.state;
206
- const position = this.getPositionForIndex(index);
207
-
208
- const colorInfo = _gpuGridAggregator.default.getAggregationData({
209
- pixelIndex: index,
210
- ...gpuGridAggregator.getData('color')
211
- });
212
-
213
- const elevationInfo = _gpuGridAggregator.default.getAggregationData({
214
- pixelIndex: index,
215
- ...gpuGridAggregator.getData('elevation')
216
- });
217
-
218
- object = {
219
- colorValue: colorInfo.cellWeight,
220
- elevationValue: elevationInfo.cellWeight,
221
- count: colorInfo.cellCount || elevationInfo.cellCount,
222
- position,
223
- totalCount: colorInfo.totalCount || elevationInfo.totalCount
224
- };
225
-
226
- if (mode !== 'hover') {
227
- const {
228
- props
229
- } = this;
230
- let {
231
- gridHash
232
- } = this.state;
233
-
234
- if (!gridHash) {
235
- const {
236
- gridOffset,
237
- translation,
238
- boundingBox
239
- } = this.state;
240
- const {
241
- viewport
242
- } = this.context;
243
- const attributes = this.getAttributes();
244
- const cpuAggregation = (0, _gridAggregator.pointToDensityGridDataCPU)(props, {
245
- gridOffset,
246
- attributes,
247
- viewport,
248
- translation,
249
- boundingBox
250
- });
251
- gridHash = cpuAggregation.gridHash;
252
- this.setState({
253
- gridHash
254
- });
255
- }
179
+ (0, _get2.default)((0, _getPrototypeOf2.default)(GPUGridLayer.prototype), "updateState", this).call(this, opts);
180
+ var aggregationDirty = this.state.aggregationDirty;
256
181
 
257
- const key = this.getHashKeyForIndex(index);
258
- const cpuAggregationData = gridHash[key];
259
- Object.assign(object, cpuAggregationData);
182
+ if (aggregationDirty) {
183
+ this.setState({
184
+ gridHash: null
185
+ });
260
186
  }
261
187
  }
262
-
263
- info.picked = Boolean(object);
264
- info.object = object;
265
- return info;
266
- }
267
-
268
- renderLayers() {
269
- if (!this.state.isSupported) {
270
- return null;
188
+ }, {
189
+ key: "getHashKeyForIndex",
190
+ value: function getHashKeyForIndex(index) {
191
+ var _this$state = this.state,
192
+ numRow = _this$state.numRow,
193
+ numCol = _this$state.numCol,
194
+ boundingBox = _this$state.boundingBox,
195
+ gridOffset = _this$state.gridOffset;
196
+ var gridSize = [numCol, numRow];
197
+ var gridOrigin = [boundingBox.xMin, boundingBox.yMin];
198
+ var cellSize = [gridOffset.xOffset, gridOffset.yOffset];
199
+ var yIndex = Math.floor(index / gridSize[0]);
200
+ var xIndex = index - yIndex * gridSize[0];
201
+ var latIdx = Math.floor((yIndex * cellSize[1] + gridOrigin[1] + 90 + cellSize[1] / 2) / cellSize[1]);
202
+ var lonIdx = Math.floor((xIndex * cellSize[0] + gridOrigin[0] + 180 + cellSize[0] / 2) / cellSize[0]);
203
+ return "".concat(latIdx, "-").concat(lonIdx);
271
204
  }
272
-
273
- const {
274
- elevationScale,
275
- extruded,
276
- cellSize: cellSizeMeters,
277
- coverage,
278
- material,
279
- elevationRange,
280
- colorDomain,
281
- elevationDomain
282
- } = this.props;
283
- const {
284
- weights,
285
- numRow,
286
- numCol,
287
- gridOrigin,
288
- gridOffset
289
- } = this.state;
290
- const {
291
- color,
292
- elevation
293
- } = weights;
294
- const colorRange = (0, _colorUtils.colorRangeToFlatArray)(this.props.colorRange);
295
- const SubLayerClass = this.getSubLayerClass('gpu-grid-cell', _gpuGridCellLayer.default);
296
- return new SubLayerClass({
297
- gridSize: [numCol, numRow],
298
- gridOrigin,
299
- gridOffset: [gridOffset.xOffset, gridOffset.yOffset],
300
- colorRange,
301
- elevationRange,
302
- colorDomain,
303
- elevationDomain,
304
- cellSize: cellSizeMeters,
305
- coverage,
306
- material,
307
- elevationScale,
308
- extruded
309
- }, this.getSubLayerProps({
310
- id: 'gpu-grid-cell'
311
- }), {
312
- data: {
313
- attributes: {
314
- colors: color.aggregationBuffer,
315
- elevations: elevation.aggregationBuffer
205
+ }, {
206
+ key: "getPositionForIndex",
207
+ value: function getPositionForIndex(index) {
208
+ var _this$state2 = this.state,
209
+ numRow = _this$state2.numRow,
210
+ numCol = _this$state2.numCol,
211
+ boundingBox = _this$state2.boundingBox,
212
+ gridOffset = _this$state2.gridOffset;
213
+ var gridSize = [numCol, numRow];
214
+ var gridOrigin = [boundingBox.xMin, boundingBox.yMin];
215
+ var cellSize = [gridOffset.xOffset, gridOffset.yOffset];
216
+ var yIndex = Math.floor(index / gridSize[0]);
217
+ var xIndex = index - yIndex * gridSize[0];
218
+ var yPos = yIndex * cellSize[1] + gridOrigin[1];
219
+ var xPos = xIndex * cellSize[0] + gridOrigin[0];
220
+ return [xPos, yPos];
221
+ }
222
+ }, {
223
+ key: "getPickingInfo",
224
+ value: function getPickingInfo(_ref) {
225
+ var info = _ref.info,
226
+ mode = _ref.mode;
227
+ var index = info.index;
228
+ var object = null;
229
+
230
+ if (index >= 0) {
231
+ var gpuGridAggregator = this.state.gpuGridAggregator;
232
+ var position = this.getPositionForIndex(index);
233
+
234
+ var colorInfo = _gpuGridAggregator.default.getAggregationData(_objectSpread({
235
+ pixelIndex: index
236
+ }, gpuGridAggregator.getData('color')));
237
+
238
+ var elevationInfo = _gpuGridAggregator.default.getAggregationData(_objectSpread({
239
+ pixelIndex: index
240
+ }, gpuGridAggregator.getData('elevation')));
241
+
242
+ object = {
243
+ colorValue: colorInfo.cellWeight,
244
+ elevationValue: elevationInfo.cellWeight,
245
+ count: colorInfo.cellCount || elevationInfo.cellCount,
246
+ position: position,
247
+ totalCount: colorInfo.totalCount || elevationInfo.totalCount
248
+ };
249
+
250
+ if (mode !== 'hover') {
251
+ var props = this.props;
252
+ var gridHash = this.state.gridHash;
253
+
254
+ if (!gridHash) {
255
+ var _this$state3 = this.state,
256
+ gridOffset = _this$state3.gridOffset,
257
+ translation = _this$state3.translation,
258
+ boundingBox = _this$state3.boundingBox;
259
+ var viewport = this.context.viewport;
260
+ var attributes = this.getAttributes();
261
+ var cpuAggregation = (0, _gridAggregator.pointToDensityGridDataCPU)(props, {
262
+ gridOffset: gridOffset,
263
+ attributes: attributes,
264
+ viewport: viewport,
265
+ translation: translation,
266
+ boundingBox: boundingBox
267
+ });
268
+ gridHash = cpuAggregation.gridHash;
269
+ this.setState({
270
+ gridHash: gridHash
271
+ });
272
+ }
273
+
274
+ var key = this.getHashKeyForIndex(index);
275
+ var cpuAggregationData = gridHash[key];
276
+ Object.assign(object, cpuAggregationData);
316
277
  }
317
- },
318
- colorMaxMinBuffer: color.maxMinBuffer,
319
- elevationMaxMinBuffer: elevation.maxMinBuffer,
320
- numInstances: numCol * numRow
321
- });
322
- }
278
+ }
323
279
 
324
- finalizeState() {
325
- const {
326
- color,
327
- elevation
328
- } = this.state.weights;
329
- [color, elevation].forEach(weight => {
330
- const {
331
- aggregationBuffer,
332
- maxMinBuffer
333
- } = weight;
334
- maxMinBuffer.delete();
335
- aggregationBuffer === null || aggregationBuffer === void 0 ? void 0 : aggregationBuffer.delete();
336
- });
337
- super.finalizeState();
338
- }
280
+ info.picked = Boolean(object);
281
+ info.object = object;
282
+ return info;
283
+ }
284
+ }, {
285
+ key: "renderLayers",
286
+ value: function renderLayers() {
287
+ if (!this.state.isSupported) {
288
+ return null;
289
+ }
339
290
 
340
- updateAggregationState(opts) {
341
- const {
342
- props,
343
- oldProps
344
- } = opts;
345
- const {
346
- cellSize,
347
- coordinateSystem
348
- } = props;
349
- const {
350
- viewport
351
- } = this.context;
352
- const cellSizeChanged = oldProps.cellSize !== cellSize;
353
- const {
354
- dimensions
355
- } = this.state;
356
- const positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME);
357
- const attributesChanged = positionsChanged || this.isAttributeChanged();
358
- let {
359
- boundingBox
360
- } = this.state;
361
-
362
- if (positionsChanged) {
363
- boundingBox = (0, _gridAggregationUtils.getBoundingBox)(this.getAttributes(), this.getNumInstances());
364
- this.setState({
365
- boundingBox
291
+ var _this$props = this.props,
292
+ elevationScale = _this$props.elevationScale,
293
+ extruded = _this$props.extruded,
294
+ cellSizeMeters = _this$props.cellSize,
295
+ coverage = _this$props.coverage,
296
+ material = _this$props.material,
297
+ elevationRange = _this$props.elevationRange,
298
+ colorDomain = _this$props.colorDomain,
299
+ elevationDomain = _this$props.elevationDomain;
300
+ var _this$state4 = this.state,
301
+ weights = _this$state4.weights,
302
+ numRow = _this$state4.numRow,
303
+ numCol = _this$state4.numCol,
304
+ gridOrigin = _this$state4.gridOrigin,
305
+ gridOffset = _this$state4.gridOffset;
306
+ var color = weights.color,
307
+ elevation = weights.elevation;
308
+ var colorRange = (0, _colorUtils.colorRangeToFlatArray)(this.props.colorRange);
309
+ var SubLayerClass = this.getSubLayerClass('gpu-grid-cell', _gpuGridCellLayer.default);
310
+ return new SubLayerClass({
311
+ gridSize: [numCol, numRow],
312
+ gridOrigin: gridOrigin,
313
+ gridOffset: [gridOffset.xOffset, gridOffset.yOffset],
314
+ colorRange: colorRange,
315
+ elevationRange: elevationRange,
316
+ colorDomain: colorDomain,
317
+ elevationDomain: elevationDomain,
318
+ cellSize: cellSizeMeters,
319
+ coverage: coverage,
320
+ material: material,
321
+ elevationScale: elevationScale,
322
+ extruded: extruded
323
+ }, this.getSubLayerProps({
324
+ id: 'gpu-grid-cell'
325
+ }), {
326
+ data: {
327
+ attributes: {
328
+ colors: color.aggregationBuffer,
329
+ elevations: elevation.aggregationBuffer
330
+ }
331
+ },
332
+ colorMaxMinBuffer: color.maxMinBuffer,
333
+ elevationMaxMinBuffer: elevation.maxMinBuffer,
334
+ numInstances: numCol * numRow
366
335
  });
367
336
  }
368
-
369
- if (positionsChanged || cellSizeChanged) {
370
- const {
371
- gridOffset,
372
- translation,
373
- width,
374
- height,
375
- numCol,
376
- numRow
377
- } = (0, _gridAggregationUtils.getGridParams)(boundingBox, cellSize, viewport, coordinateSystem);
378
- this.allocateResources(numRow, numCol);
379
- this.setState({
380
- gridOffset,
381
- translation,
382
- gridOrigin: [-1 * translation[0], -1 * translation[1]],
383
- width,
384
- height,
385
- numCol,
386
- numRow
337
+ }, {
338
+ key: "finalizeState",
339
+ value: function finalizeState() {
340
+ var _this$state$weights = this.state.weights,
341
+ color = _this$state$weights.color,
342
+ elevation = _this$state$weights.elevation;
343
+ [color, elevation].forEach(function (weight) {
344
+ var aggregationBuffer = weight.aggregationBuffer,
345
+ maxMinBuffer = weight.maxMinBuffer;
346
+ maxMinBuffer.delete();
347
+ aggregationBuffer === null || aggregationBuffer === void 0 ? void 0 : aggregationBuffer.delete();
387
348
  });
349
+ (0, _get2.default)((0, _getPrototypeOf2.default)(GPUGridLayer.prototype), "finalizeState", this).call(this);
388
350
  }
351
+ }, {
352
+ key: "updateAggregationState",
353
+ value: function updateAggregationState(opts) {
354
+ var props = opts.props,
355
+ oldProps = opts.oldProps;
356
+ var cellSize = props.cellSize,
357
+ coordinateSystem = props.coordinateSystem;
358
+ var viewport = this.context.viewport;
359
+ var cellSizeChanged = oldProps.cellSize !== cellSize;
360
+ var dimensions = this.state.dimensions;
361
+ var positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME);
362
+ var attributesChanged = positionsChanged || this.isAttributeChanged();
363
+ var boundingBox = this.state.boundingBox;
364
+
365
+ if (positionsChanged) {
366
+ boundingBox = (0, _gridAggregationUtils.getBoundingBox)(this.getAttributes(), this.getNumInstances());
367
+ this.setState({
368
+ boundingBox: boundingBox
369
+ });
370
+ }
389
371
 
390
- const aggregationDataDirty = attributesChanged || this.isAggregationDirty(opts, {
391
- dimension: dimensions.data,
392
- compareAll: true
393
- });
394
-
395
- if (aggregationDataDirty) {
396
- this._updateAccessors(opts);
397
- }
372
+ if (positionsChanged || cellSizeChanged) {
373
+ var _getGridParams = (0, _gridAggregationUtils.getGridParams)(boundingBox, cellSize, viewport, coordinateSystem),
374
+ gridOffset = _getGridParams.gridOffset,
375
+ translation = _getGridParams.translation,
376
+ width = _getGridParams.width,
377
+ height = _getGridParams.height,
378
+ numCol = _getGridParams.numCol,
379
+ numRow = _getGridParams.numRow;
380
+
381
+ this.allocateResources(numRow, numCol);
382
+ this.setState({
383
+ gridOffset: gridOffset,
384
+ translation: translation,
385
+ gridOrigin: [-1 * translation[0], -1 * translation[1]],
386
+ width: width,
387
+ height: height,
388
+ numCol: numCol,
389
+ numRow: numRow
390
+ });
391
+ }
398
392
 
399
- this.setState({
400
- aggregationDataDirty
401
- });
402
- }
393
+ var aggregationDataDirty = attributesChanged || this.isAggregationDirty(opts, {
394
+ dimension: dimensions.data,
395
+ compareAll: true
396
+ });
403
397
 
404
- _updateAccessors(opts) {
405
- const {
406
- colorAggregation,
407
- elevationAggregation
408
- } = opts.props;
409
- const {
410
- color,
411
- elevation
412
- } = this.state.weights;
413
- color.operation = _aggregationOperationUtils.AGGREGATION_OPERATION[colorAggregation];
414
- elevation.operation = _aggregationOperationUtils.AGGREGATION_OPERATION[elevationAggregation];
415
- }
398
+ if (aggregationDataDirty) {
399
+ this._updateAccessors(opts);
400
+ }
416
401
 
417
- }
402
+ this.setState({
403
+ aggregationDataDirty: aggregationDataDirty
404
+ });
405
+ }
406
+ }, {
407
+ key: "_updateAccessors",
408
+ value: function _updateAccessors(opts) {
409
+ var _opts$props = opts.props,
410
+ colorAggregation = _opts$props.colorAggregation,
411
+ elevationAggregation = _opts$props.elevationAggregation;
412
+ var _this$state$weights2 = this.state.weights,
413
+ color = _this$state$weights2.color,
414
+ elevation = _this$state$weights2.elevation;
415
+ color.operation = _aggregationOperationUtils.AGGREGATION_OPERATION[colorAggregation];
416
+ elevation.operation = _aggregationOperationUtils.AGGREGATION_OPERATION[elevationAggregation];
417
+ }
418
+ }]);
419
+ return GPUGridLayer;
420
+ }(_gridAggregationLayer.default);
418
421
 
419
422
  exports.default = GPUGridLayer;
420
423
  GPUGridLayer.layerName = 'GPUGridLayer';