@deck.gl/aggregation-layers 8.6.2 → 8.7.0-alpha.2

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 (71) hide show
  1. package/dist/dist.dev.js +82 -50
  2. package/dist/es5/aggregation-layer.js +109 -163
  3. package/dist/es5/aggregation-layer.js.map +1 -1
  4. package/dist/es5/contour-layer/contour-layer.js +240 -260
  5. package/dist/es5/contour-layer/contour-layer.js.map +1 -1
  6. package/dist/es5/contour-layer/contour-utils.js +65 -86
  7. package/dist/es5/contour-layer/contour-utils.js.map +1 -1
  8. package/dist/es5/contour-layer/marching-squares-codes.js +181 -106
  9. package/dist/es5/contour-layer/marching-squares-codes.js.map +1 -1
  10. package/dist/es5/contour-layer/marching-squares.js +56 -59
  11. package/dist/es5/contour-layer/marching-squares.js.map +1 -1
  12. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +85 -121
  13. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
  14. package/dist/es5/cpu-grid-layer/grid-aggregator.js +93 -119
  15. package/dist/es5/cpu-grid-layer/grid-aggregator.js.map +1 -1
  16. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +131 -167
  17. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
  18. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +319 -322
  19. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
  20. package/dist/es5/grid-aggregation-layer.js +202 -230
  21. package/dist/es5/grid-aggregation-layer.js.map +1 -1
  22. package/dist/es5/grid-layer/grid-layer.js +61 -91
  23. package/dist/es5/grid-layer/grid-layer.js.map +1 -1
  24. package/dist/es5/heatmap-layer/heatmap-layer-utils.js +24 -59
  25. package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +1 -1
  26. package/dist/es5/heatmap-layer/heatmap-layer.js +515 -533
  27. package/dist/es5/heatmap-layer/heatmap-layer.js.map +1 -1
  28. package/dist/es5/heatmap-layer/triangle-layer.js +64 -91
  29. package/dist/es5/heatmap-layer/triangle-layer.js.map +1 -1
  30. package/dist/es5/hexagon-layer/hexagon-aggregator.js +59 -77
  31. package/dist/es5/hexagon-layer/hexagon-aggregator.js.map +1 -1
  32. package/dist/es5/hexagon-layer/hexagon-layer.js +121 -164
  33. package/dist/es5/hexagon-layer/hexagon-layer.js.map +1 -1
  34. package/dist/es5/index.js +12 -12
  35. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +168 -193
  36. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  37. package/dist/es5/screen-grid-layer/screen-grid-layer.js +235 -250
  38. package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +1 -1
  39. package/dist/es5/utils/aggregation-operation-utils.js +16 -31
  40. package/dist/es5/utils/aggregation-operation-utils.js.map +1 -1
  41. package/dist/es5/utils/bin-sorter.js +118 -198
  42. package/dist/es5/utils/bin-sorter.js.map +1 -1
  43. package/dist/es5/utils/color-utils.js +8 -10
  44. package/dist/es5/utils/color-utils.js.map +1 -1
  45. package/dist/es5/utils/cpu-aggregator.js +323 -342
  46. package/dist/es5/utils/cpu-aggregator.js.map +1 -1
  47. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +20 -18
  48. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +1 -1
  49. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +545 -545
  50. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +1 -1
  51. package/dist/es5/utils/grid-aggregation-utils.js +50 -44
  52. package/dist/es5/utils/grid-aggregation-utils.js.map +1 -1
  53. package/dist/es5/utils/prop-utils.js +2 -2
  54. package/dist/es5/utils/prop-utils.js.map +1 -1
  55. package/dist/es5/utils/resource-utils.js +32 -39
  56. package/dist/es5/utils/resource-utils.js.map +1 -1
  57. package/dist/es5/utils/scale-utils.js +36 -66
  58. package/dist/es5/utils/scale-utils.js.map +1 -1
  59. package/dist/esm/contour-layer/marching-squares-codes.js.map +1 -1
  60. package/dist/esm/heatmap-layer/heatmap-layer.js.map +1 -1
  61. package/dist/esm/heatmap-layer/triangle-layer.js.map +1 -1
  62. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  63. package/dist/esm/utils/aggregation-operation-utils.js.map +1 -1
  64. package/dist/esm/utils/cpu-aggregator.js.map +1 -1
  65. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +1 -1
  66. package/dist.min.js +1 -1
  67. package/package.json +2 -2
  68. package/src/contour-layer/marching-squares-codes.js +52 -10
  69. package/src/heatmap-layer/heatmap-layer.js +3 -9
  70. package/src/heatmap-layer/triangle-layer.js +2 -9
  71. package/src/utils/aggregation-operation-utils.js +4 -1
@@ -7,22 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = 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
- 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
-
24
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
25
-
26
10
  var _heatmapLayerUtils = require("./heatmap-layer-utils");
27
11
 
28
12
  var _core = require("@luma.gl/core");
@@ -43,33 +27,26 @@ var _maxVs = _interopRequireDefault(require("./max-vs.glsl"));
43
27
 
44
28
  var _maxFs = _interopRequireDefault(require("./max-fs.glsl"));
45
29
 
46
- var _parameters;
47
-
48
- 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; }
49
-
50
- 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; }
51
-
52
- 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); }; }
53
-
54
- 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; } }
55
-
56
- var RESOLUTION = 2;
57
- var TEXTURE_OPTIONS = {
30
+ const RESOLUTION = 2;
31
+ const TEXTURE_OPTIONS = {
58
32
  mipmaps: false,
59
- parameters: (_parameters = {}, (0, _defineProperty2.default)(_parameters, 10240, 9729), (0, _defineProperty2.default)(_parameters, 10241, 9729), (0, _defineProperty2.default)(_parameters, 10242, 33071), (0, _defineProperty2.default)(_parameters, 10243, 33071), _parameters),
33
+ parameters: {
34
+ [10240]: 9729,
35
+ [10241]: 9729,
36
+ [10242]: 33071,
37
+ [10243]: 33071
38
+ },
60
39
  dataFormat: 6408
61
40
  };
62
- var DEFAULT_COLOR_DOMAIN = [0, 0];
63
- var AGGREGATION_MODE = {
41
+ const DEFAULT_COLOR_DOMAIN = [0, 0];
42
+ const AGGREGATION_MODE = {
64
43
  SUM: 0,
65
44
  MEAN: 1
66
45
  };
67
- var defaultProps = {
46
+ const defaultProps = {
68
47
  getPosition: {
69
48
  type: 'accessor',
70
- value: function value(x) {
71
- return x.position;
72
- }
49
+ value: x => x.position
73
50
  },
74
51
  getWeight: {
75
52
  type: 'accessor',
@@ -112,563 +89,568 @@ var defaultProps = {
112
89
  value: 500
113
90
  }
114
91
  };
115
- var REQUIRED_FEATURES = [_core.FEATURES.BLEND_EQUATION_MINMAX, _core.FEATURES.TEXTURE_FLOAT];
116
- var DIMENSIONS = {
92
+ const REQUIRED_FEATURES = [_core.FEATURES.BLEND_EQUATION_MINMAX, _core.FEATURES.TEXTURE_FLOAT];
93
+ const DIMENSIONS = {
117
94
  data: {
118
95
  props: ['radiusPixels']
119
96
  }
120
97
  };
121
98
 
122
- var HeatmapLayer = function (_AggregationLayer) {
123
- (0, _inherits2.default)(HeatmapLayer, _AggregationLayer);
99
+ class HeatmapLayer extends _aggregationLayer.default {
100
+ initializeState() {
101
+ const {
102
+ gl
103
+ } = this.context;
124
104
 
125
- var _super = _createSuper(HeatmapLayer);
126
-
127
- function HeatmapLayer() {
128
- (0, _classCallCheck2.default)(this, HeatmapLayer);
129
- return _super.apply(this, arguments);
130
- }
105
+ if (!(0, _core.hasFeatures)(gl, REQUIRED_FEATURES)) {
106
+ this.setState({
107
+ supported: false
108
+ });
131
109
 
132
- (0, _createClass2.default)(HeatmapLayer, [{
133
- key: "initializeState",
134
- value: function initializeState() {
135
- var gl = this.context.gl;
110
+ _core2.log.error("HeatmapLayer: ".concat(this.id, " is not supported on this browser"))();
136
111
 
137
- if (!(0, _core.hasFeatures)(gl, REQUIRED_FEATURES)) {
138
- this.setState({
139
- supported: false
140
- });
112
+ return;
113
+ }
141
114
 
142
- _core2.log.error("HeatmapLayer: ".concat(this.id, " is not supported on this browser"))();
115
+ super.initializeState(DIMENSIONS);
116
+ this.setState({
117
+ supported: true,
118
+ colorDomain: DEFAULT_COLOR_DOMAIN
119
+ });
143
120
 
144
- return;
145
- }
121
+ this._setupTextureParams();
146
122
 
147
- (0, _get2.default)((0, _getPrototypeOf2.default)(HeatmapLayer.prototype), "initializeState", this).call(this, DIMENSIONS);
148
- this.setState({
149
- supported: true,
150
- colorDomain: DEFAULT_COLOR_DOMAIN
151
- });
123
+ this._setupAttributes();
152
124
 
153
- this._setupTextureParams();
154
-
155
- this._setupAttributes();
156
-
157
- this._setupResources();
158
- }
159
- }, {
160
- key: "shouldUpdateState",
161
- value: function shouldUpdateState(_ref) {
162
- var changeFlags = _ref.changeFlags;
163
- return changeFlags.somethingChanged;
164
- }
165
- }, {
166
- key: "updateState",
167
- value: function updateState(opts) {
168
- if (!this.state.supported) {
169
- return;
170
- }
125
+ this._setupResources();
126
+ }
171
127
 
172
- (0, _get2.default)((0, _getPrototypeOf2.default)(HeatmapLayer.prototype), "updateState", this).call(this, opts);
128
+ shouldUpdateState({
129
+ changeFlags
130
+ }) {
131
+ return changeFlags.somethingChanged;
132
+ }
173
133
 
174
- this._updateHeatmapState(opts);
134
+ updateState(opts) {
135
+ if (!this.state.supported) {
136
+ return;
175
137
  }
176
- }, {
177
- key: "_updateHeatmapState",
178
- value: function _updateHeatmapState(opts) {
179
- var props = opts.props,
180
- oldProps = opts.oldProps;
181
138
 
182
- var changeFlags = this._getChangeFlags(opts);
139
+ super.updateState(opts);
183
140
 
184
- if (changeFlags.dataChanged || changeFlags.viewportChanged) {
185
- changeFlags.boundsChanged = this._updateBounds(changeFlags.dataChanged);
141
+ this._updateHeatmapState(opts);
142
+ }
186
143
 
187
- this._updateTextureRenderingBounds();
188
- }
144
+ _updateHeatmapState(opts) {
145
+ const {
146
+ props,
147
+ oldProps
148
+ } = opts;
189
149
 
190
- if (changeFlags.dataChanged || changeFlags.boundsChanged) {
191
- clearTimeout(this.state.updateTimer);
192
- this.setState({
193
- isWeightMapDirty: true
194
- });
195
- } else if (changeFlags.viewportZoomChanged) {
196
- this._debouncedUpdateWeightmap();
197
- }
150
+ const changeFlags = this._getChangeFlags(opts);
198
151
 
199
- if (props.colorRange !== oldProps.colorRange) {
200
- this._updateColorTexture(opts);
201
- }
152
+ if (changeFlags.dataChanged || changeFlags.viewportChanged) {
153
+ changeFlags.boundsChanged = this._updateBounds(changeFlags.dataChanged);
202
154
 
203
- if (this.state.isWeightMapDirty) {
204
- this._updateWeightmap();
205
- }
155
+ this._updateTextureRenderingBounds();
156
+ }
206
157
 
158
+ if (changeFlags.dataChanged || changeFlags.boundsChanged) {
159
+ clearTimeout(this.state.updateTimer);
207
160
  this.setState({
208
- zoom: opts.context.viewport.zoom
161
+ isWeightMapDirty: true
209
162
  });
163
+ } else if (changeFlags.viewportZoomChanged) {
164
+ this._debouncedUpdateWeightmap();
210
165
  }
211
- }, {
212
- key: "renderLayers",
213
- value: function renderLayers() {
214
- if (!this.state.supported) {
215
- return [];
216
- }
217
166
 
218
- var _this$state = this.state,
219
- weightsTexture = _this$state.weightsTexture,
220
- triPositionBuffer = _this$state.triPositionBuffer,
221
- triTexCoordBuffer = _this$state.triTexCoordBuffer,
222
- maxWeightsTexture = _this$state.maxWeightsTexture,
223
- colorTexture = _this$state.colorTexture,
224
- colorDomain = _this$state.colorDomain;
225
- var _this$props = this.props,
226
- updateTriggers = _this$props.updateTriggers,
227
- intensity = _this$props.intensity,
228
- threshold = _this$props.threshold,
229
- aggregation = _this$props.aggregation;
230
- var TriangleLayerClass = this.getSubLayerClass('triangle', _triangleLayer.default);
231
- return new TriangleLayerClass(this.getSubLayerProps({
232
- id: 'triangle-layer',
233
- updateTriggers: updateTriggers
234
- }), {
235
- coordinateSystem: _core2.COORDINATE_SYSTEM.DEFAULT,
236
- data: {
237
- attributes: {
238
- positions: triPositionBuffer,
239
- texCoords: triTexCoordBuffer
240
- }
241
- },
242
- vertexCount: 4,
243
- maxTexture: maxWeightsTexture,
244
- colorTexture: colorTexture,
245
- aggregationMode: AGGREGATION_MODE[aggregation] || 0,
246
- texture: weightsTexture,
247
- intensity: intensity,
248
- threshold: threshold,
249
- colorDomain: colorDomain
250
- });
167
+ if (props.colorRange !== oldProps.colorRange) {
168
+ this._updateColorTexture(opts);
251
169
  }
252
- }, {
253
- key: "finalizeState",
254
- value: function finalizeState() {
255
- (0, _get2.default)((0, _getPrototypeOf2.default)(HeatmapLayer.prototype), "finalizeState", this).call(this);
256
- var _this$state2 = this.state,
257
- weightsTransform = _this$state2.weightsTransform,
258
- weightsTexture = _this$state2.weightsTexture,
259
- maxWeightTransform = _this$state2.maxWeightTransform,
260
- maxWeightsTexture = _this$state2.maxWeightsTexture,
261
- triPositionBuffer = _this$state2.triPositionBuffer,
262
- triTexCoordBuffer = _this$state2.triTexCoordBuffer,
263
- colorTexture = _this$state2.colorTexture,
264
- updateTimer = _this$state2.updateTimer;
265
- weightsTransform === null || weightsTransform === void 0 ? void 0 : weightsTransform.delete();
266
- weightsTexture === null || weightsTexture === void 0 ? void 0 : weightsTexture.delete();
267
- maxWeightTransform === null || maxWeightTransform === void 0 ? void 0 : maxWeightTransform.delete();
268
- maxWeightsTexture === null || maxWeightsTexture === void 0 ? void 0 : maxWeightsTexture.delete();
269
- triPositionBuffer === null || triPositionBuffer === void 0 ? void 0 : triPositionBuffer.delete();
270
- triTexCoordBuffer === null || triTexCoordBuffer === void 0 ? void 0 : triTexCoordBuffer.delete();
271
- colorTexture === null || colorTexture === void 0 ? void 0 : colorTexture.delete();
272
- updateTimer && clearTimeout(updateTimer);
273
- }
274
- }, {
275
- key: "_getAttributeManager",
276
- value: function _getAttributeManager() {
277
- return new _core2.AttributeManager(this.context.gl, {
278
- id: this.props.id,
279
- stats: this.context.stats
280
- });
170
+
171
+ if (this.state.isWeightMapDirty) {
172
+ this._updateWeightmap();
281
173
  }
282
- }, {
283
- key: "_getChangeFlags",
284
- value: function _getChangeFlags(opts) {
285
- var changeFlags = {};
286
- var dimensions = this.state.dimensions;
287
- changeFlags.dataChanged = this.isAttributeChanged() || this.isAggregationDirty(opts, {
288
- compareAll: true,
289
- dimension: dimensions.data
290
- });
291
- changeFlags.viewportChanged = opts.changeFlags.viewportChanged;
292
- var zoom = this.state.zoom;
293
174
 
294
- if (!opts.context.viewport || opts.context.viewport.zoom !== zoom) {
295
- changeFlags.viewportZoomChanged = true;
296
- }
175
+ this.setState({
176
+ zoom: opts.context.viewport.zoom
177
+ });
178
+ }
297
179
 
298
- return changeFlags;
299
- }
300
- }, {
301
- key: "_createTextures",
302
- value: function _createTextures() {
303
- var gl = this.context.gl;
304
- var _this$state3 = this.state,
305
- textureSize = _this$state3.textureSize,
306
- format = _this$state3.format,
307
- type = _this$state3.type;
308
- this.setState({
309
- weightsTexture: new _core.Texture2D(gl, _objectSpread({
310
- width: textureSize,
311
- height: textureSize,
312
- format: format,
313
- type: type
314
- }, TEXTURE_OPTIONS)),
315
- maxWeightsTexture: new _core.Texture2D(gl, _objectSpread({
316
- format: format,
317
- type: type
318
- }, TEXTURE_OPTIONS))
319
- });
180
+ renderLayers() {
181
+ if (!this.state.supported) {
182
+ return [];
320
183
  }
321
- }, {
322
- key: "_setupAttributes",
323
- value: function _setupAttributes() {
324
- var attributeManager = this.getAttributeManager();
325
- attributeManager.add({
326
- positions: {
327
- size: 3,
328
- type: 5130,
329
- accessor: 'getPosition'
330
- },
331
- weights: {
332
- size: 1,
333
- accessor: 'getWeight'
184
+
185
+ const {
186
+ weightsTexture,
187
+ triPositionBuffer,
188
+ triTexCoordBuffer,
189
+ maxWeightsTexture,
190
+ colorTexture,
191
+ colorDomain
192
+ } = this.state;
193
+ const {
194
+ updateTriggers,
195
+ intensity,
196
+ threshold,
197
+ aggregation
198
+ } = this.props;
199
+ const TriangleLayerClass = this.getSubLayerClass('triangle', _triangleLayer.default);
200
+ return new TriangleLayerClass(this.getSubLayerProps({
201
+ id: 'triangle-layer',
202
+ updateTriggers
203
+ }), {
204
+ coordinateSystem: _core2.COORDINATE_SYSTEM.DEFAULT,
205
+ data: {
206
+ attributes: {
207
+ positions: triPositionBuffer,
208
+ texCoords: triTexCoordBuffer
334
209
  }
335
- });
336
- this.setState({
337
- positionAttributeName: 'positions'
338
- });
210
+ },
211
+ vertexCount: 4,
212
+ maxTexture: maxWeightsTexture,
213
+ colorTexture,
214
+ aggregationMode: AGGREGATION_MODE[aggregation] || 0,
215
+ texture: weightsTexture,
216
+ intensity,
217
+ threshold,
218
+ colorDomain
219
+ });
220
+ }
221
+
222
+ finalizeState() {
223
+ super.finalizeState();
224
+ const {
225
+ weightsTransform,
226
+ weightsTexture,
227
+ maxWeightTransform,
228
+ maxWeightsTexture,
229
+ triPositionBuffer,
230
+ triTexCoordBuffer,
231
+ colorTexture,
232
+ updateTimer
233
+ } = this.state;
234
+ weightsTransform === null || weightsTransform === void 0 ? void 0 : weightsTransform.delete();
235
+ weightsTexture === null || weightsTexture === void 0 ? void 0 : weightsTexture.delete();
236
+ maxWeightTransform === null || maxWeightTransform === void 0 ? void 0 : maxWeightTransform.delete();
237
+ maxWeightsTexture === null || maxWeightsTexture === void 0 ? void 0 : maxWeightsTexture.delete();
238
+ triPositionBuffer === null || triPositionBuffer === void 0 ? void 0 : triPositionBuffer.delete();
239
+ triTexCoordBuffer === null || triTexCoordBuffer === void 0 ? void 0 : triTexCoordBuffer.delete();
240
+ colorTexture === null || colorTexture === void 0 ? void 0 : colorTexture.delete();
241
+ updateTimer && clearTimeout(updateTimer);
242
+ }
243
+
244
+ _getAttributeManager() {
245
+ return new _core2.AttributeManager(this.context.gl, {
246
+ id: this.props.id,
247
+ stats: this.context.stats
248
+ });
249
+ }
250
+
251
+ _getChangeFlags(opts) {
252
+ const changeFlags = {};
253
+ const {
254
+ dimensions
255
+ } = this.state;
256
+ changeFlags.dataChanged = this.isAttributeChanged() || this.isAggregationDirty(opts, {
257
+ compareAll: true,
258
+ dimension: dimensions.data
259
+ });
260
+ changeFlags.viewportChanged = opts.changeFlags.viewportChanged;
261
+ const {
262
+ zoom
263
+ } = this.state;
264
+
265
+ if (!opts.context.viewport || opts.context.viewport.zoom !== zoom) {
266
+ changeFlags.viewportZoomChanged = true;
339
267
  }
340
- }, {
341
- key: "_setupTextureParams",
342
- value: function _setupTextureParams() {
343
- var gl = this.context.gl;
344
- var weightsTextureSize = this.props.weightsTextureSize;
345
- var textureSize = Math.min(weightsTextureSize, (0, _core.getParameters)(gl, 3379));
346
- var floatTargetSupport = (0, _core.hasFeatures)(gl, _core.FEATURES.COLOR_ATTACHMENT_RGBA32F);
347
-
348
- var _getTextureParams = (0, _heatmapLayerUtils.getTextureParams)({
349
- gl: gl,
350
- floatTargetSupport: floatTargetSupport
351
- }),
352
- format = _getTextureParams.format,
353
- type = _getTextureParams.type;
354
268
 
355
- var weightsScale = floatTargetSupport ? 1 : 1 / 255;
356
- this.setState({
357
- textureSize: textureSize,
358
- format: format,
359
- type: type,
360
- weightsScale: weightsScale
361
- });
269
+ return changeFlags;
270
+ }
271
+
272
+ _createTextures() {
273
+ const {
274
+ gl
275
+ } = this.context;
276
+ const {
277
+ textureSize,
278
+ format,
279
+ type
280
+ } = this.state;
281
+ this.setState({
282
+ weightsTexture: new _core.Texture2D(gl, {
283
+ width: textureSize,
284
+ height: textureSize,
285
+ format,
286
+ type,
287
+ ...TEXTURE_OPTIONS
288
+ }),
289
+ maxWeightsTexture: new _core.Texture2D(gl, {
290
+ format,
291
+ type,
292
+ ...TEXTURE_OPTIONS
293
+ })
294
+ });
295
+ }
362
296
 
363
- if (!floatTargetSupport) {
364
- _core2.log.warn("HeatmapLayer: ".concat(this.id, " rendering to float texture not supported, fallingback to low precession format"))();
297
+ _setupAttributes() {
298
+ const attributeManager = this.getAttributeManager();
299
+ attributeManager.add({
300
+ positions: {
301
+ size: 3,
302
+ type: 5130,
303
+ accessor: 'getPosition'
304
+ },
305
+ weights: {
306
+ size: 1,
307
+ accessor: 'getWeight'
365
308
  }
309
+ });
310
+ this.setState({
311
+ positionAttributeName: 'positions'
312
+ });
313
+ }
314
+
315
+ _setupTextureParams() {
316
+ const {
317
+ gl
318
+ } = this.context;
319
+ const {
320
+ weightsTextureSize
321
+ } = this.props;
322
+ const textureSize = Math.min(weightsTextureSize, (0, _core.getParameters)(gl, 3379));
323
+ const floatTargetSupport = (0, _core.hasFeatures)(gl, _core.FEATURES.COLOR_ATTACHMENT_RGBA32F);
324
+ const {
325
+ format,
326
+ type
327
+ } = (0, _heatmapLayerUtils.getTextureParams)({
328
+ gl,
329
+ floatTargetSupport
330
+ });
331
+ const weightsScale = floatTargetSupport ? 1 : 1 / 255;
332
+ this.setState({
333
+ textureSize,
334
+ format,
335
+ type,
336
+ weightsScale
337
+ });
338
+
339
+ if (!floatTargetSupport) {
340
+ _core2.log.warn("HeatmapLayer: ".concat(this.id, " rendering to float texture not supported, fallingback to low precession format"))();
366
341
  }
367
- }, {
368
- key: "getShaders",
369
- value: function getShaders(type) {
370
- return (0, _get2.default)((0, _getPrototypeOf2.default)(HeatmapLayer.prototype), "getShaders", this).call(this, type === 'max-weights-transform' ? {
371
- vs: _maxVs.default,
372
- _fs: _maxFs.default
373
- } : {
374
- vs: _weightsVs.default,
375
- _fs: _weightsFs.default
376
- });
377
- }
378
- }, {
379
- key: "_createWeightsTransform",
380
- value: function _createWeightsTransform() {
381
- var _weightsTransform;
382
-
383
- var shaders = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
384
- var gl = this.context.gl;
385
- var weightsTransform = this.state.weightsTransform;
386
- var weightsTexture = this.state.weightsTexture;
387
- (_weightsTransform = weightsTransform) === null || _weightsTransform === void 0 ? void 0 : _weightsTransform.delete();
388
- weightsTransform = new _core.Transform(gl, _objectSpread({
389
- id: "".concat(this.id, "-weights-transform"),
390
- elementCount: 1,
391
- _targetTexture: weightsTexture,
392
- _targetTextureVarying: 'weightsTexture'
393
- }, shaders));
394
- this.setState({
395
- weightsTransform: weightsTransform
396
- });
397
- }
398
- }, {
399
- key: "_setupResources",
400
- value: function _setupResources() {
401
- var gl = this.context.gl;
402
-
403
- this._createTextures();
404
-
405
- var _this$state4 = this.state,
406
- textureSize = _this$state4.textureSize,
407
- weightsTexture = _this$state4.weightsTexture,
408
- maxWeightsTexture = _this$state4.maxWeightsTexture;
409
- var weightsTransformShaders = this.getShaders('weights-transform');
410
-
411
- this._createWeightsTransform(weightsTransformShaders);
412
-
413
- var maxWeightsTransformShaders = this.getShaders('max-weights-transform');
414
- var maxWeightTransform = new _core.Transform(gl, _objectSpread(_objectSpread({
415
- id: "".concat(this.id, "-max-weights-transform"),
416
- _sourceTextures: {
417
- inTexture: weightsTexture
418
- },
419
- _targetTexture: maxWeightsTexture,
420
- _targetTextureVarying: 'outTexture'
421
- }, maxWeightsTransformShaders), {}, {
422
- elementCount: textureSize * textureSize
423
- }));
424
- this.setState({
425
- weightsTexture: weightsTexture,
426
- maxWeightsTexture: maxWeightsTexture,
427
- maxWeightTransform: maxWeightTransform,
428
- zoom: null,
429
- triPositionBuffer: new _core.Buffer(gl, {
430
- byteLength: 48,
431
- accessor: {
432
- size: 3
433
- }
434
- }),
435
- triTexCoordBuffer: new _core.Buffer(gl, {
436
- byteLength: 48,
437
- accessor: {
438
- size: 2
439
- }
440
- })
441
- });
442
- }
443
- }, {
444
- key: "updateShaders",
445
- value: function updateShaders(shaderOptions) {
446
- this._createWeightsTransform(shaderOptions);
447
- }
448
- }, {
449
- key: "_updateMaxWeightValue",
450
- value: function _updateMaxWeightValue() {
451
- var maxWeightTransform = this.state.maxWeightTransform;
452
- maxWeightTransform.run({
453
- parameters: {
454
- blend: true,
455
- depthTest: false,
456
- blendFunc: [1, 1],
457
- blendEquation: 32776
342
+ }
343
+
344
+ getShaders(type) {
345
+ return super.getShaders(type === 'max-weights-transform' ? {
346
+ vs: _maxVs.default,
347
+ _fs: _maxFs.default
348
+ } : {
349
+ vs: _weightsVs.default,
350
+ _fs: _weightsFs.default
351
+ });
352
+ }
353
+
354
+ _createWeightsTransform(shaders = {}) {
355
+ var _weightsTransform;
356
+
357
+ const {
358
+ gl
359
+ } = this.context;
360
+ let {
361
+ weightsTransform
362
+ } = this.state;
363
+ const {
364
+ weightsTexture
365
+ } = this.state;
366
+ (_weightsTransform = weightsTransform) === null || _weightsTransform === void 0 ? void 0 : _weightsTransform.delete();
367
+ weightsTransform = new _core.Transform(gl, {
368
+ id: "".concat(this.id, "-weights-transform"),
369
+ elementCount: 1,
370
+ _targetTexture: weightsTexture,
371
+ _targetTextureVarying: 'weightsTexture',
372
+ ...shaders
373
+ });
374
+ this.setState({
375
+ weightsTransform
376
+ });
377
+ }
378
+
379
+ _setupResources() {
380
+ const {
381
+ gl
382
+ } = this.context;
383
+
384
+ this._createTextures();
385
+
386
+ const {
387
+ textureSize,
388
+ weightsTexture,
389
+ maxWeightsTexture
390
+ } = this.state;
391
+ const weightsTransformShaders = this.getShaders('weights-transform');
392
+
393
+ this._createWeightsTransform(weightsTransformShaders);
394
+
395
+ const maxWeightsTransformShaders = this.getShaders('max-weights-transform');
396
+ const maxWeightTransform = new _core.Transform(gl, {
397
+ id: "".concat(this.id, "-max-weights-transform"),
398
+ _sourceTextures: {
399
+ inTexture: weightsTexture
400
+ },
401
+ _targetTexture: maxWeightsTexture,
402
+ _targetTextureVarying: 'outTexture',
403
+ ...maxWeightsTransformShaders,
404
+ elementCount: textureSize * textureSize
405
+ });
406
+ this.setState({
407
+ weightsTexture,
408
+ maxWeightsTexture,
409
+ maxWeightTransform,
410
+ zoom: null,
411
+ triPositionBuffer: new _core.Buffer(gl, {
412
+ byteLength: 48,
413
+ accessor: {
414
+ size: 3
458
415
  }
459
- });
460
- }
461
- }, {
462
- key: "_updateBounds",
463
- value: function _updateBounds() {
464
- var forceUpdate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
465
- var viewport = this.context.viewport;
466
- var viewportCorners = [viewport.unproject([0, 0]), viewport.unproject([viewport.width, 0]), viewport.unproject([viewport.width, viewport.height]), viewport.unproject([0, viewport.height])].map(function (p) {
467
- return p.map(Math.fround);
468
- });
469
- var visibleWorldBounds = (0, _heatmapLayerUtils.getBounds)(viewportCorners);
470
- var newState = {
471
- visibleWorldBounds: visibleWorldBounds,
472
- viewportCorners: viewportCorners
473
- };
474
- var boundsChanged = false;
475
-
476
- if (forceUpdate || !this.state.worldBounds || !(0, _heatmapLayerUtils.boundsContain)(this.state.worldBounds, visibleWorldBounds)) {
477
- var scaledCommonBounds = this._worldToCommonBounds(visibleWorldBounds);
478
-
479
- var worldBounds = this._commonToWorldBounds(scaledCommonBounds);
480
-
481
- if (this.props.coordinateSystem === _core2.COORDINATE_SYSTEM.LNGLAT) {
482
- worldBounds[1] = Math.max(worldBounds[1], -85.051129);
483
- worldBounds[3] = Math.min(worldBounds[3], 85.051129);
484
- worldBounds[0] = Math.max(worldBounds[0], -360);
485
- worldBounds[2] = Math.min(worldBounds[2], 360);
416
+ }),
417
+ triTexCoordBuffer: new _core.Buffer(gl, {
418
+ byteLength: 48,
419
+ accessor: {
420
+ size: 2
486
421
  }
422
+ })
423
+ });
424
+ }
487
425
 
488
- var normalizedCommonBounds = this._worldToCommonBounds(worldBounds);
426
+ updateShaders(shaderOptions) {
427
+ this._createWeightsTransform(shaderOptions);
428
+ }
489
429
 
490
- newState.worldBounds = worldBounds;
491
- newState.normalizedCommonBounds = normalizedCommonBounds;
492
- boundsChanged = true;
430
+ _updateMaxWeightValue() {
431
+ const {
432
+ maxWeightTransform
433
+ } = this.state;
434
+ maxWeightTransform.run({
435
+ parameters: {
436
+ blend: true,
437
+ depthTest: false,
438
+ blendFunc: [1, 1],
439
+ blendEquation: 32776
493
440
  }
441
+ });
442
+ }
494
443
 
495
- this.setState(newState);
496
- return boundsChanged;
497
- }
498
- }, {
499
- key: "_updateTextureRenderingBounds",
500
- value: function _updateTextureRenderingBounds() {
501
- var _this$state5 = this.state,
502
- triPositionBuffer = _this$state5.triPositionBuffer,
503
- triTexCoordBuffer = _this$state5.triTexCoordBuffer,
504
- normalizedCommonBounds = _this$state5.normalizedCommonBounds,
505
- viewportCorners = _this$state5.viewportCorners;
506
- var viewport = this.context.viewport;
507
- triPositionBuffer.subData((0, _heatmapLayerUtils.packVertices)(viewportCorners, 3));
508
- var textureBounds = viewportCorners.map(function (p) {
509
- return (0, _heatmapLayerUtils.getTextureCoordinates)(viewport.projectPosition(p), normalizedCommonBounds);
510
- });
511
- triTexCoordBuffer.subData((0, _heatmapLayerUtils.packVertices)(textureBounds, 2));
512
- }
513
- }, {
514
- key: "_updateColorTexture",
515
- value: function _updateColorTexture(opts) {
516
- var colorRange = opts.props.colorRange;
517
- var colorTexture = this.state.colorTexture;
518
- var colors = (0, _colorUtils.colorRangeToFlatArray)(colorRange, false, Uint8Array);
519
-
520
- if (colorTexture) {
521
- colorTexture.setImageData({
522
- data: colors,
523
- width: colorRange.length
524
- });
525
- } else {
526
- colorTexture = new _core.Texture2D(this.context.gl, _objectSpread({
527
- data: colors,
528
- width: colorRange.length,
529
- height: 1
530
- }, TEXTURE_OPTIONS));
444
+ _updateBounds(forceUpdate = false) {
445
+ const {
446
+ viewport
447
+ } = this.context;
448
+ const viewportCorners = [viewport.unproject([0, 0]), viewport.unproject([viewport.width, 0]), viewport.unproject([viewport.width, viewport.height]), viewport.unproject([0, viewport.height])].map(p => p.map(Math.fround));
449
+ const visibleWorldBounds = (0, _heatmapLayerUtils.getBounds)(viewportCorners);
450
+ const newState = {
451
+ visibleWorldBounds,
452
+ viewportCorners
453
+ };
454
+ let boundsChanged = false;
455
+
456
+ if (forceUpdate || !this.state.worldBounds || !(0, _heatmapLayerUtils.boundsContain)(this.state.worldBounds, visibleWorldBounds)) {
457
+ const scaledCommonBounds = this._worldToCommonBounds(visibleWorldBounds);
458
+
459
+ const worldBounds = this._commonToWorldBounds(scaledCommonBounds);
460
+
461
+ if (this.props.coordinateSystem === _core2.COORDINATE_SYSTEM.LNGLAT) {
462
+ worldBounds[1] = Math.max(worldBounds[1], -85.051129);
463
+ worldBounds[3] = Math.min(worldBounds[3], 85.051129);
464
+ worldBounds[0] = Math.max(worldBounds[0], -360);
465
+ worldBounds[2] = Math.min(worldBounds[2], 360);
531
466
  }
532
467
 
533
- this.setState({
534
- colorTexture: colorTexture
535
- });
468
+ const normalizedCommonBounds = this._worldToCommonBounds(worldBounds);
469
+
470
+ newState.worldBounds = worldBounds;
471
+ newState.normalizedCommonBounds = normalizedCommonBounds;
472
+ boundsChanged = true;
536
473
  }
537
- }, {
538
- key: "_updateWeightmap",
539
- value: function _updateWeightmap() {
540
- var _weightsTexture$setPa;
541
-
542
- var _this$props2 = this.props,
543
- radiusPixels = _this$props2.radiusPixels,
544
- colorDomain = _this$props2.colorDomain,
545
- aggregation = _this$props2.aggregation;
546
- var _this$state6 = this.state,
547
- weightsTransform = _this$state6.weightsTransform,
548
- worldBounds = _this$state6.worldBounds,
549
- textureSize = _this$state6.textureSize,
550
- weightsTexture = _this$state6.weightsTexture,
551
- weightsScale = _this$state6.weightsScale;
552
- this.state.isWeightMapDirty = false;
553
-
554
- var commonBounds = this._worldToCommonBounds(worldBounds, {
555
- useLayerCoordinateSystem: true
556
- });
557
474
 
558
- if (colorDomain && aggregation === 'SUM') {
559
- var viewport = this.context.viewport;
560
- var metersPerPixel = viewport.distanceScales.metersPerUnit[2] * (commonBounds[2] - commonBounds[0]) / textureSize;
561
- this.state.colorDomain = colorDomain.map(function (x) {
562
- return x * metersPerPixel * weightsScale;
563
- });
564
- } else {
565
- this.state.colorDomain = colorDomain || DEFAULT_COLOR_DOMAIN;
566
- }
475
+ this.setState(newState);
476
+ return boundsChanged;
477
+ }
567
478
 
568
- var uniforms = {
569
- radiusPixels: radiusPixels,
570
- commonBounds: commonBounds,
571
- textureWidth: textureSize,
572
- weightsScale: weightsScale
573
- };
574
- weightsTransform.update({
575
- elementCount: this.getNumInstances()
479
+ _updateTextureRenderingBounds() {
480
+ const {
481
+ triPositionBuffer,
482
+ triTexCoordBuffer,
483
+ normalizedCommonBounds,
484
+ viewportCorners
485
+ } = this.state;
486
+ const {
487
+ viewport
488
+ } = this.context;
489
+ triPositionBuffer.subData((0, _heatmapLayerUtils.packVertices)(viewportCorners, 3));
490
+ const textureBounds = viewportCorners.map(p => (0, _heatmapLayerUtils.getTextureCoordinates)(viewport.projectPosition(p), normalizedCommonBounds));
491
+ triTexCoordBuffer.subData((0, _heatmapLayerUtils.packVertices)(textureBounds, 2));
492
+ }
493
+
494
+ _updateColorTexture(opts) {
495
+ const {
496
+ colorRange
497
+ } = opts.props;
498
+ let {
499
+ colorTexture
500
+ } = this.state;
501
+ const colors = (0, _colorUtils.colorRangeToFlatArray)(colorRange, false, Uint8Array);
502
+
503
+ if (colorTexture) {
504
+ colorTexture.setImageData({
505
+ data: colors,
506
+ width: colorRange.length
576
507
  });
577
- weightsTransform.run({
578
- uniforms: uniforms,
579
- parameters: {
580
- blend: true,
581
- depthTest: false,
582
- blendFunc: [1, 1],
583
- blendEquation: 32774
584
- },
585
- clearRenderTarget: true,
586
- attributes: this.getAttributes(),
587
- moduleSettings: this.getModuleSettings()
508
+ } else {
509
+ colorTexture = new _core.Texture2D(this.context.gl, {
510
+ data: colors,
511
+ width: colorRange.length,
512
+ height: 1,
513
+ ...TEXTURE_OPTIONS
588
514
  });
515
+ }
589
516
 
590
- this._updateMaxWeightValue();
517
+ this.setState({
518
+ colorTexture
519
+ });
520
+ }
591
521
 
592
- weightsTexture.setParameters((_weightsTexture$setPa = {}, (0, _defineProperty2.default)(_weightsTexture$setPa, 10240, 9729), (0, _defineProperty2.default)(_weightsTexture$setPa, 10241, 9729), _weightsTexture$setPa));
522
+ _updateWeightmap() {
523
+ const {
524
+ radiusPixels,
525
+ colorDomain,
526
+ aggregation
527
+ } = this.props;
528
+ const {
529
+ weightsTransform,
530
+ worldBounds,
531
+ textureSize,
532
+ weightsTexture,
533
+ weightsScale
534
+ } = this.state;
535
+ this.state.isWeightMapDirty = false;
536
+
537
+ const commonBounds = this._worldToCommonBounds(worldBounds, {
538
+ useLayerCoordinateSystem: true
539
+ });
540
+
541
+ if (colorDomain && aggregation === 'SUM') {
542
+ const {
543
+ viewport
544
+ } = this.context;
545
+ const metersPerPixel = viewport.distanceScales.metersPerUnit[2] * (commonBounds[2] - commonBounds[0]) / textureSize;
546
+ this.state.colorDomain = colorDomain.map(x => x * metersPerPixel * weightsScale);
547
+ } else {
548
+ this.state.colorDomain = colorDomain || DEFAULT_COLOR_DOMAIN;
593
549
  }
594
- }, {
595
- key: "_debouncedUpdateWeightmap",
596
- value: function _debouncedUpdateWeightmap() {
597
- var fromTimer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
598
- var updateTimer = this.state.updateTimer;
599
- var debounceTimeout = this.props.debounceTimeout;
600
-
601
- if (fromTimer) {
602
- updateTimer = null;
603
-
604
- this._updateBounds(true);
605
-
606
- this._updateTextureRenderingBounds();
607
-
608
- this.setState({
609
- isWeightMapDirty: true
610
- });
611
- } else {
612
- this.setState({
613
- isWeightMapDirty: false
614
- });
615
- clearTimeout(updateTimer);
616
- updateTimer = setTimeout(this._debouncedUpdateWeightmap.bind(this, true), debounceTimeout);
617
- }
550
+
551
+ const uniforms = {
552
+ radiusPixels,
553
+ commonBounds,
554
+ textureWidth: textureSize,
555
+ weightsScale
556
+ };
557
+ weightsTransform.update({
558
+ elementCount: this.getNumInstances()
559
+ });
560
+ weightsTransform.run({
561
+ uniforms,
562
+ parameters: {
563
+ blend: true,
564
+ depthTest: false,
565
+ blendFunc: [1, 1],
566
+ blendEquation: 32774
567
+ },
568
+ clearRenderTarget: true,
569
+ attributes: this.getAttributes(),
570
+ moduleSettings: this.getModuleSettings()
571
+ });
572
+
573
+ this._updateMaxWeightValue();
574
+
575
+ weightsTexture.setParameters({
576
+ [10240]: 9729,
577
+ [10241]: 9729
578
+ });
579
+ }
580
+
581
+ _debouncedUpdateWeightmap(fromTimer = false) {
582
+ let {
583
+ updateTimer
584
+ } = this.state;
585
+ const {
586
+ debounceTimeout
587
+ } = this.props;
588
+
589
+ if (fromTimer) {
590
+ updateTimer = null;
591
+
592
+ this._updateBounds(true);
593
+
594
+ this._updateTextureRenderingBounds();
618
595
 
619
596
  this.setState({
620
- updateTimer: updateTimer
597
+ isWeightMapDirty: true
621
598
  });
599
+ } else {
600
+ this.setState({
601
+ isWeightMapDirty: false
602
+ });
603
+ clearTimeout(updateTimer);
604
+ updateTimer = setTimeout(this._debouncedUpdateWeightmap.bind(this, true), debounceTimeout);
622
605
  }
623
- }, {
624
- key: "_worldToCommonBounds",
625
- value: function _worldToCommonBounds(worldBounds) {
626
- var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
627
- var _opts$useLayerCoordin = opts.useLayerCoordinateSystem,
628
- useLayerCoordinateSystem = _opts$useLayerCoordin === void 0 ? false : _opts$useLayerCoordin;
629
-
630
- var _worldBounds = (0, _slicedToArray2.default)(worldBounds, 4),
631
- minLong = _worldBounds[0],
632
- minLat = _worldBounds[1],
633
- maxLong = _worldBounds[2],
634
- maxLat = _worldBounds[3];
635
-
636
- var viewport = this.context.viewport;
637
- var textureSize = this.state.textureSize;
638
- var coordinateSystem = this.props.coordinateSystem;
639
- var offsetMode = useLayerCoordinateSystem && (coordinateSystem === _core2.COORDINATE_SYSTEM.LNGLAT_OFFSETS || coordinateSystem === _core2.COORDINATE_SYSTEM.METER_OFFSETS);
640
- var offsetOriginCommon = offsetMode ? viewport.projectPosition(this.props.coordinateOrigin) : [0, 0];
641
- var size = textureSize * RESOLUTION / viewport.scale;
642
- var bottomLeftCommon;
643
- var topRightCommon;
644
-
645
- if (useLayerCoordinateSystem && !offsetMode) {
646
- bottomLeftCommon = this.projectPosition([minLong, minLat, 0]);
647
- topRightCommon = this.projectPosition([maxLong, maxLat, 0]);
648
- } else {
649
- bottomLeftCommon = viewport.projectPosition([minLong, minLat, 0]);
650
- topRightCommon = viewport.projectPosition([maxLong, maxLat, 0]);
651
- }
652
606
 
653
- return (0, _heatmapLayerUtils.scaleToAspectRatio)([bottomLeftCommon[0] - offsetOriginCommon[0], bottomLeftCommon[1] - offsetOriginCommon[1], topRightCommon[0] - offsetOriginCommon[0], topRightCommon[1] - offsetOriginCommon[1]], size, size);
654
- }
655
- }, {
656
- key: "_commonToWorldBounds",
657
- value: function _commonToWorldBounds(commonBounds) {
658
- var _commonBounds = (0, _slicedToArray2.default)(commonBounds, 4),
659
- xMin = _commonBounds[0],
660
- yMin = _commonBounds[1],
661
- xMax = _commonBounds[2],
662
- yMax = _commonBounds[3];
663
-
664
- var viewport = this.context.viewport;
665
- var bottomLeftWorld = viewport.unprojectPosition([xMin, yMin]);
666
- var topRightWorld = viewport.unprojectPosition([xMax, yMax]);
667
- return bottomLeftWorld.slice(0, 2).concat(topRightWorld.slice(0, 2));
607
+ this.setState({
608
+ updateTimer
609
+ });
610
+ }
611
+
612
+ _worldToCommonBounds(worldBounds, opts = {}) {
613
+ const {
614
+ useLayerCoordinateSystem = false
615
+ } = opts;
616
+ const [minLong, minLat, maxLong, maxLat] = worldBounds;
617
+ const {
618
+ viewport
619
+ } = this.context;
620
+ const {
621
+ textureSize
622
+ } = this.state;
623
+ const {
624
+ coordinateSystem
625
+ } = this.props;
626
+ const offsetMode = useLayerCoordinateSystem && (coordinateSystem === _core2.COORDINATE_SYSTEM.LNGLAT_OFFSETS || coordinateSystem === _core2.COORDINATE_SYSTEM.METER_OFFSETS);
627
+ const offsetOriginCommon = offsetMode ? viewport.projectPosition(this.props.coordinateOrigin) : [0, 0];
628
+ const size = textureSize * RESOLUTION / viewport.scale;
629
+ let bottomLeftCommon;
630
+ let topRightCommon;
631
+
632
+ if (useLayerCoordinateSystem && !offsetMode) {
633
+ bottomLeftCommon = this.projectPosition([minLong, minLat, 0]);
634
+ topRightCommon = this.projectPosition([maxLong, maxLat, 0]);
635
+ } else {
636
+ bottomLeftCommon = viewport.projectPosition([minLong, minLat, 0]);
637
+ topRightCommon = viewport.projectPosition([maxLong, maxLat, 0]);
668
638
  }
669
- }]);
670
- return HeatmapLayer;
671
- }(_aggregationLayer.default);
639
+
640
+ return (0, _heatmapLayerUtils.scaleToAspectRatio)([bottomLeftCommon[0] - offsetOriginCommon[0], bottomLeftCommon[1] - offsetOriginCommon[1], topRightCommon[0] - offsetOriginCommon[0], topRightCommon[1] - offsetOriginCommon[1]], size, size);
641
+ }
642
+
643
+ _commonToWorldBounds(commonBounds) {
644
+ const [xMin, yMin, xMax, yMax] = commonBounds;
645
+ const {
646
+ viewport
647
+ } = this.context;
648
+ const bottomLeftWorld = viewport.unprojectPosition([xMin, yMin]);
649
+ const topRightWorld = viewport.unprojectPosition([xMax, yMax]);
650
+ return bottomLeftWorld.slice(0, 2).concat(topRightWorld.slice(0, 2));
651
+ }
652
+
653
+ }
672
654
 
673
655
  exports.default = HeatmapLayer;
674
656
  HeatmapLayer.layerName = 'HeatmapLayer';