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

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