@deck.gl/aggregation-layers 8.10.0-alpha.2 → 8.10.0-alpha.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 (142) hide show
  1. package/LICENSE +1 -1
  2. package/dist/dist.dev.js +58 -709
  3. package/dist/es5/aggregation-layer.js +120 -134
  4. package/dist/es5/aggregation-layer.js.map +1 -1
  5. package/dist/es5/contour-layer/contour-layer.js +225 -234
  6. package/dist/es5/contour-layer/contour-layer.js.map +1 -1
  7. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +90 -100
  8. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
  9. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +131 -140
  10. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
  11. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +285 -295
  12. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
  13. package/dist/es5/grid-aggregation-layer.js +194 -209
  14. package/dist/es5/grid-aggregation-layer.js.map +1 -1
  15. package/dist/es5/grid-layer/grid-layer.js +59 -66
  16. package/dist/es5/grid-layer/grid-layer.js.map +1 -1
  17. package/dist/es5/heatmap-layer/heatmap-layer.js +471 -497
  18. package/dist/es5/heatmap-layer/heatmap-layer.js.map +1 -1
  19. package/dist/es5/heatmap-layer/triangle-layer.js +64 -69
  20. package/dist/es5/heatmap-layer/triangle-layer.js.map +1 -1
  21. package/dist/es5/hexagon-layer/hexagon-layer.js +129 -140
  22. package/dist/es5/hexagon-layer/hexagon-layer.js.map +1 -1
  23. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +153 -166
  24. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  25. package/dist/es5/screen-grid-layer/screen-grid-layer.js +207 -220
  26. package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +1 -1
  27. package/dist/es5/utils/bin-sorter.js +163 -173
  28. package/dist/es5/utils/bin-sorter.js.map +1 -1
  29. package/dist/es5/utils/cpu-aggregator.js +300 -323
  30. package/dist/es5/utils/cpu-aggregator.js.map +1 -1
  31. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +483 -504
  32. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +1 -1
  33. package/dist/esm/aggregation-layer.js +2 -5
  34. package/dist/esm/aggregation-layer.js.map +1 -1
  35. package/dist/esm/contour-layer/contour-layer.js +2 -5
  36. package/dist/esm/contour-layer/contour-layer.js.map +1 -1
  37. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js +2 -5
  38. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
  39. package/dist/esm/cpu-grid-layer/grid-aggregator.js +1 -1
  40. package/dist/esm/cpu-grid-layer/grid-aggregator.js.map +1 -1
  41. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +15 -1
  42. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js.map +1 -1
  43. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +121 -1
  44. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js.map +1 -1
  45. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js +2 -5
  46. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
  47. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js +3 -6
  48. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
  49. package/dist/esm/grid-aggregation-layer.js +3 -6
  50. package/dist/esm/grid-aggregation-layer.js.map +1 -1
  51. package/dist/esm/grid-layer/grid-layer.js +3 -7
  52. package/dist/esm/grid-layer/grid-layer.js.map +1 -1
  53. package/dist/esm/heatmap-layer/heatmap-layer.js +7 -11
  54. package/dist/esm/heatmap-layer/heatmap-layer.js.map +1 -1
  55. package/dist/esm/heatmap-layer/max-fs.glsl.js +7 -1
  56. package/dist/esm/heatmap-layer/max-fs.glsl.js.map +1 -1
  57. package/dist/esm/heatmap-layer/max-vs.glsl.js +12 -1
  58. package/dist/esm/heatmap-layer/max-vs.glsl.js.map +1 -1
  59. package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js +39 -1
  60. package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js.map +1 -1
  61. package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js +31 -1
  62. package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js.map +1 -1
  63. package/dist/esm/heatmap-layer/triangle-layer.js +1 -3
  64. package/dist/esm/heatmap-layer/triangle-layer.js.map +1 -1
  65. package/dist/esm/heatmap-layer/weights-fs.glsl.js +19 -1
  66. package/dist/esm/heatmap-layer/weights-fs.glsl.js.map +1 -1
  67. package/dist/esm/heatmap-layer/weights-vs.glsl.js +23 -1
  68. package/dist/esm/heatmap-layer/weights-vs.glsl.js.map +1 -1
  69. package/dist/esm/hexagon-layer/hexagon-layer.js +3 -7
  70. package/dist/esm/hexagon-layer/hexagon-layer.js.map +1 -1
  71. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js +3 -7
  72. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  73. package/dist/esm/screen-grid-layer/screen-grid-layer-fragment.glsl.js +17 -1
  74. package/dist/esm/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +1 -1
  75. package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js +64 -1
  76. package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +1 -1
  77. package/dist/esm/screen-grid-layer/screen-grid-layer.js +5 -9
  78. package/dist/esm/screen-grid-layer/screen-grid-layer.js.map +1 -1
  79. package/dist/esm/utils/bin-sorter.js +7 -16
  80. package/dist/esm/utils/bin-sorter.js.map +1 -1
  81. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +20 -1
  82. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js.map +1 -1
  83. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +34 -1
  84. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js.map +1 -1
  85. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +12 -1
  86. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js.map +1 -1
  87. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +58 -1
  88. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js.map +1 -1
  89. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +14 -14
  90. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +1 -1
  91. package/dist/esm/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +17 -1
  92. package/dist/esm/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js.map +1 -1
  93. package/dist/esm/utils/scale-utils.js +2 -2
  94. package/dist/esm/utils/scale-utils.js.map +1 -1
  95. package/dist.min.js +30 -27
  96. package/package.json +2 -2
  97. package/typed/aggregation-layer.js +0 -151
  98. package/typed/contour-layer/contour-layer.js +0 -234
  99. package/typed/contour-layer/contour-utils.js +0 -64
  100. package/typed/contour-layer/marching-squares-codes.js +0 -337
  101. package/typed/contour-layer/marching-squares.js +0 -147
  102. package/typed/cpu-grid-layer/cpu-grid-layer.js +0 -129
  103. package/typed/cpu-grid-layer/grid-aggregator.js +0 -141
  104. package/typed/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -34
  105. package/typed/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +0 -141
  106. package/typed/gpu-grid-layer/gpu-grid-cell-layer.js +0 -143
  107. package/typed/gpu-grid-layer/gpu-grid-layer.js +0 -289
  108. package/typed/grid-aggregation-layer.js +0 -172
  109. package/typed/grid-layer/grid-layer.js +0 -60
  110. package/typed/heatmap-layer/heatmap-layer-utils.js +0 -78
  111. package/typed/heatmap-layer/heatmap-layer.js +0 -478
  112. package/typed/heatmap-layer/max-fs.glsl.js +0 -7
  113. package/typed/heatmap-layer/max-vs.glsl.js +0 -12
  114. package/typed/heatmap-layer/triangle-layer-fragment.glsl.js +0 -58
  115. package/typed/heatmap-layer/triangle-layer-vertex.glsl.js +0 -51
  116. package/typed/heatmap-layer/triangle-layer.js +0 -67
  117. package/typed/heatmap-layer/weights-fs.glsl.js +0 -19
  118. package/typed/heatmap-layer/weights-vs.glsl.js +0 -23
  119. package/typed/hexagon-layer/hexagon-aggregator.js +0 -112
  120. package/typed/hexagon-layer/hexagon-layer.js +0 -171
  121. package/typed/index.js +0 -33
  122. package/typed/screen-grid-layer/screen-grid-cell-layer.js +0 -159
  123. package/typed/screen-grid-layer/screen-grid-layer-fragment.glsl.js +0 -37
  124. package/typed/screen-grid-layer/screen-grid-layer-vertex.glsl.js +0 -83
  125. package/typed/screen-grid-layer/screen-grid-layer.js +0 -216
  126. package/typed/types.js +0 -1
  127. package/typed/utils/aggregation-operation-utils.js +0 -94
  128. package/typed/utils/bin-sorter.js +0 -167
  129. package/typed/utils/color-utils.js +0 -53
  130. package/typed/utils/cpu-aggregator.js +0 -417
  131. package/typed/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -39
  132. package/typed/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -53
  133. package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -31
  134. package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +0 -77
  135. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -41
  136. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -1
  137. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -562
  138. package/typed/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -36
  139. package/typed/utils/grid-aggregation-utils.js +0 -114
  140. package/typed/utils/prop-utils.js +0 -28
  141. package/typed/utils/resource-utils.js +0 -40
  142. package/typed/utils/scale-utils.js +0 -184
@@ -7,11 +7,9 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
-
12
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
11
 
14
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
13
 
16
14
  var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
17
15
 
@@ -21,8 +19,6 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
21
19
 
22
20
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
23
21
 
24
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
25
-
26
22
  var _core = require("@deck.gl/core");
27
23
 
28
24
  var _layers = require("@deck.gl/layers");
@@ -143,156 +139,149 @@ var HexagonLayer = function (_AggregationLayer) {
143
139
  }
144
140
 
145
141
  _this = _super.call.apply(_super, [this].concat(args));
146
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", void 0);
142
+ _this.state = void 0;
147
143
  return _this;
148
144
  }
149
145
 
150
- (0, _createClass2.default)(HexagonLayer, [{
151
- key: "initializeState",
152
- value: function initializeState() {
153
- var cpuAggregator = new _cpuAggregator.default({
154
- getAggregator: function getAggregator(props) {
155
- return props.hexagonAggregator;
156
- },
157
- getCellSize: function getCellSize(props) {
158
- return props.radius;
159
- }
160
- });
161
- this.state = {
162
- cpuAggregator: cpuAggregator,
163
- aggregatorState: cpuAggregator.state,
164
- vertices: null
165
- };
166
- var attributeManager = this.getAttributeManager();
167
- attributeManager.add({
168
- positions: {
169
- size: 3,
170
- type: 5130,
171
- accessor: 'getPosition'
172
- }
173
- });
174
- }
175
- }, {
176
- key: "updateState",
177
- value: function updateState(opts) {
178
- (0, _get2.default)((0, _getPrototypeOf2.default)(HexagonLayer.prototype), "updateState", this).call(this, opts);
179
-
180
- if (opts.changeFlags.propsOrDataChanged) {
181
- var aggregatorState = this.state.cpuAggregator.updateState(opts, {
182
- viewport: this.context.viewport,
183
- attributes: this.getAttributes()
184
- });
146
+ var _proto = HexagonLayer.prototype;
185
147
 
186
- if (this.state.aggregatorState.layerData !== aggregatorState.layerData) {
187
- var _ref = aggregatorState.layerData || {},
188
- hexagonVertices = _ref.hexagonVertices;
148
+ _proto.initializeState = function initializeState() {
149
+ var cpuAggregator = new _cpuAggregator.default({
150
+ getAggregator: function getAggregator(props) {
151
+ return props.hexagonAggregator;
152
+ },
153
+ getCellSize: function getCellSize(props) {
154
+ return props.radius;
155
+ }
156
+ });
157
+ this.state = {
158
+ cpuAggregator: cpuAggregator,
159
+ aggregatorState: cpuAggregator.state,
160
+ vertices: null
161
+ };
162
+ var attributeManager = this.getAttributeManager();
163
+ attributeManager.add({
164
+ positions: {
165
+ size: 3,
166
+ type: 5130,
167
+ accessor: 'getPosition'
168
+ }
169
+ });
170
+ };
171
+
172
+ _proto.updateState = function updateState(opts) {
173
+ (0, _get2.default)((0, _getPrototypeOf2.default)(HexagonLayer.prototype), "updateState", this).call(this, opts);
174
+
175
+ if (opts.changeFlags.propsOrDataChanged) {
176
+ var aggregatorState = this.state.cpuAggregator.updateState(opts, {
177
+ viewport: this.context.viewport,
178
+ attributes: this.getAttributes()
179
+ });
189
180
 
190
- this.setState({
191
- vertices: hexagonVertices && this.convertLatLngToMeterOffset(hexagonVertices)
192
- });
193
- }
181
+ if (this.state.aggregatorState.layerData !== aggregatorState.layerData) {
182
+ var _ref = aggregatorState.layerData || {},
183
+ hexagonVertices = _ref.hexagonVertices;
194
184
 
195
185
  this.setState({
196
- aggregatorState: aggregatorState
186
+ vertices: hexagonVertices && this.convertLatLngToMeterOffset(hexagonVertices)
197
187
  });
198
188
  }
199
- }
200
- }, {
201
- key: "convertLatLngToMeterOffset",
202
- value: function convertLatLngToMeterOffset(hexagonVertices) {
203
- var viewport = this.context.viewport;
204
-
205
- if (Array.isArray(hexagonVertices) && hexagonVertices.length === 6) {
206
- var vertex0 = hexagonVertices[0];
207
- var vertex3 = hexagonVertices[3];
208
- var centroid = [(vertex0[0] + vertex3[0]) / 2, (vertex0[1] + vertex3[1]) / 2];
209
- var centroidFlat = viewport.projectFlat(centroid);
210
-
211
- var _viewport$getDistance = viewport.getDistanceScales(centroid),
212
- metersPerUnit = _viewport$getDistance.metersPerUnit;
213
-
214
- var vertices = hexagonVertices.map(function (vt) {
215
- var vtFlat = viewport.projectFlat(vt);
216
- return [(vtFlat[0] - centroidFlat[0]) * metersPerUnit[0], (vtFlat[1] - centroidFlat[1]) * metersPerUnit[1]];
217
- });
218
- return vertices;
219
- }
220
-
221
- _core.log.error('HexagonLayer: hexagonVertices needs to be an array of 6 points')();
222
189
 
223
- return null;
224
- }
225
- }, {
226
- key: "getPickingInfo",
227
- value: function getPickingInfo(_ref2) {
228
- var info = _ref2.info;
229
- return this.state.cpuAggregator.getPickingInfo({
230
- info: info
190
+ this.setState({
191
+ aggregatorState: aggregatorState
231
192
  });
232
193
  }
233
- }, {
234
- key: "_onGetSublayerColor",
235
- value: function _onGetSublayerColor(cell) {
236
- return this.state.cpuAggregator.getAccessor('fillColor')(cell);
237
- }
238
- }, {
239
- key: "_onGetSublayerElevation",
240
- value: function _onGetSublayerElevation(cell) {
241
- return this.state.cpuAggregator.getAccessor('elevation')(cell);
242
- }
243
- }, {
244
- key: "_getSublayerUpdateTriggers",
245
- value: function _getSublayerUpdateTriggers() {
246
- return this.state.cpuAggregator.getUpdateTriggers(this.props);
247
- }
248
- }, {
249
- key: "renderLayers",
250
- value: function renderLayers() {
251
- var _this$props = this.props,
252
- elevationScale = _this$props.elevationScale,
253
- extruded = _this$props.extruded,
254
- coverage = _this$props.coverage,
255
- material = _this$props.material,
256
- transitions = _this$props.transitions;
257
- var _this$state = this.state,
258
- aggregatorState = _this$state.aggregatorState,
259
- vertices = _this$state.vertices;
260
- var SubLayerClass = this.getSubLayerClass('hexagon-cell', _layers.ColumnLayer);
261
-
262
- var updateTriggers = this._getSublayerUpdateTriggers();
263
-
264
- var geometry = vertices ? {
265
- vertices: vertices,
266
- radius: 1
267
- } : {
268
- radius: aggregatorState.layerData.radiusCommon || 1,
269
- radiusUnits: 'common',
270
- angle: 90
271
- };
272
- return new SubLayerClass(_objectSpread(_objectSpread({}, geometry), {}, {
273
- diskResolution: 6,
274
- elevationScale: elevationScale,
275
- extruded: extruded,
276
- coverage: coverage,
277
- material: material,
278
- getFillColor: this._onGetSublayerColor.bind(this),
279
- getElevation: this._onGetSublayerElevation.bind(this),
280
- transitions: transitions && {
281
- getFillColor: transitions.getColorValue || transitions.getColorWeight,
282
- getElevation: transitions.getElevationValue || transitions.getElevationWeight
283
- }
284
- }), this.getSubLayerProps({
285
- id: 'hexagon-cell',
286
- updateTriggers: updateTriggers
287
- }), {
288
- data: aggregatorState.layerData.data
194
+ };
195
+
196
+ _proto.convertLatLngToMeterOffset = function convertLatLngToMeterOffset(hexagonVertices) {
197
+ var viewport = this.context.viewport;
198
+
199
+ if (Array.isArray(hexagonVertices) && hexagonVertices.length === 6) {
200
+ var vertex0 = hexagonVertices[0];
201
+ var vertex3 = hexagonVertices[3];
202
+ var centroid = [(vertex0[0] + vertex3[0]) / 2, (vertex0[1] + vertex3[1]) / 2];
203
+ var centroidFlat = viewport.projectFlat(centroid);
204
+
205
+ var _viewport$getDistance = viewport.getDistanceScales(centroid),
206
+ metersPerUnit = _viewport$getDistance.metersPerUnit;
207
+
208
+ var vertices = hexagonVertices.map(function (vt) {
209
+ var vtFlat = viewport.projectFlat(vt);
210
+ return [(vtFlat[0] - centroidFlat[0]) * metersPerUnit[0], (vtFlat[1] - centroidFlat[1]) * metersPerUnit[1]];
289
211
  });
212
+ return vertices;
290
213
  }
291
- }]);
214
+
215
+ _core.log.error('HexagonLayer: hexagonVertices needs to be an array of 6 points')();
216
+
217
+ return null;
218
+ };
219
+
220
+ _proto.getPickingInfo = function getPickingInfo(_ref2) {
221
+ var info = _ref2.info;
222
+ return this.state.cpuAggregator.getPickingInfo({
223
+ info: info
224
+ });
225
+ };
226
+
227
+ _proto._onGetSublayerColor = function _onGetSublayerColor(cell) {
228
+ return this.state.cpuAggregator.getAccessor('fillColor')(cell);
229
+ };
230
+
231
+ _proto._onGetSublayerElevation = function _onGetSublayerElevation(cell) {
232
+ return this.state.cpuAggregator.getAccessor('elevation')(cell);
233
+ };
234
+
235
+ _proto._getSublayerUpdateTriggers = function _getSublayerUpdateTriggers() {
236
+ return this.state.cpuAggregator.getUpdateTriggers(this.props);
237
+ };
238
+
239
+ _proto.renderLayers = function renderLayers() {
240
+ var _this$props = this.props,
241
+ elevationScale = _this$props.elevationScale,
242
+ extruded = _this$props.extruded,
243
+ coverage = _this$props.coverage,
244
+ material = _this$props.material,
245
+ transitions = _this$props.transitions;
246
+ var _this$state = this.state,
247
+ aggregatorState = _this$state.aggregatorState,
248
+ vertices = _this$state.vertices;
249
+ var SubLayerClass = this.getSubLayerClass('hexagon-cell', _layers.ColumnLayer);
250
+
251
+ var updateTriggers = this._getSublayerUpdateTriggers();
252
+
253
+ var geometry = vertices ? {
254
+ vertices: vertices,
255
+ radius: 1
256
+ } : {
257
+ radius: aggregatorState.layerData.radiusCommon || 1,
258
+ radiusUnits: 'common',
259
+ angle: 90
260
+ };
261
+ return new SubLayerClass(_objectSpread(_objectSpread({}, geometry), {}, {
262
+ diskResolution: 6,
263
+ elevationScale: elevationScale,
264
+ extruded: extruded,
265
+ coverage: coverage,
266
+ material: material,
267
+ getFillColor: this._onGetSublayerColor.bind(this),
268
+ getElevation: this._onGetSublayerElevation.bind(this),
269
+ transitions: transitions && {
270
+ getFillColor: transitions.getColorValue || transitions.getColorWeight,
271
+ getElevation: transitions.getElevationValue || transitions.getElevationWeight
272
+ }
273
+ }), this.getSubLayerProps({
274
+ id: 'hexagon-cell',
275
+ updateTriggers: updateTriggers
276
+ }), {
277
+ data: aggregatorState.layerData.data
278
+ });
279
+ };
280
+
292
281
  return HexagonLayer;
293
282
  }(_aggregationLayer.default);
294
283
 
295
284
  exports.default = HexagonLayer;
296
- (0, _defineProperty2.default)(HexagonLayer, "layerName", 'HexagonLayer');
297
- (0, _defineProperty2.default)(HexagonLayer, "defaultProps", defaultProps);
285
+ HexagonLayer.layerName = 'HexagonLayer';
286
+ HexagonLayer.defaultProps = defaultProps;
298
287
  //# sourceMappingURL=hexagon-layer.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/hexagon-layer/hexagon-layer.ts"],"names":["nop","defaultProps","colorDomain","colorRange","defaultColorRange","getColorValue","type","value","getColorWeight","colorAggregation","lowerPercentile","min","max","upperPercentile","colorScaleType","onSetColorDomain","elevationDomain","elevationRange","getElevationValue","getElevationWeight","elevationAggregation","elevationLowerPercentile","elevationUpperPercentile","elevationScale","elevationScaleType","onSetElevationDomain","radius","coverage","extruded","hexagonAggregator","pointToHexbin","getPosition","x","position","material","_filterData","optional","HexagonLayer","cpuAggregator","CPUAggregator","getAggregator","props","getCellSize","state","aggregatorState","vertices","attributeManager","getAttributeManager","add","positions","size","accessor","opts","changeFlags","propsOrDataChanged","updateState","viewport","context","attributes","getAttributes","layerData","hexagonVertices","setState","convertLatLngToMeterOffset","Array","isArray","length","vertex0","vertex3","centroid","centroidFlat","projectFlat","getDistanceScales","metersPerUnit","map","vt","vtFlat","log","error","info","getPickingInfo","cell","getAccessor","getUpdateTriggers","transitions","SubLayerClass","getSubLayerClass","ColumnLayer","updateTriggers","_getSublayerUpdateTriggers","geometry","radiusCommon","radiusUnits","angle","diskResolution","getFillColor","_onGetSublayerCol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,QAAAA,MAAM,EAAEkB,eAAe,CAACgB,SAAhB,CAA0B+B,YAA1B,IAA0C,CAFpD;AAGEC,QAAAA,WAAW,EAAE,QAHf;AAIEC,QAAAA,KAAK,EAAE;AAJT,OAFJ;AAQA,aAAO,IAAIR,aAAJ,iCAEAK,QAFA;AAGHI,QAAAA,cAAc,EAAE,CAHb;AAIHvE,QAAAA,cAAc,EAAdA,cAJG;AAKHK,QAAAA,QAAQ,EAARA,QALG;AAMHD,QAAAA,QAAQ,EAARA,QANG;AAOHO,QAAAA,QAAQ,EAARA,QAPG;AASH6D,QAAAA,YAAY,EAAE,KAAKC,mBAAL,CAAyBC,IAAzB,CAA8B,IAA9B,CATX;AAUHC,QAAAA,YAAY,EAAE,KAAKC,uBAAL,CAA6BF,IAA7B,CAAkC,IAAlC,CAVX;AAWHb,QAAAA,WAAW,EAAEA,WAAW,IAAI;AAC1BW,UAAAA,YAAY,EAAEX,WAAW,CAAC/E,aAAZ,IAA6B+E,WAAW,CAAC5E,cAD7B;AAE1B0F,UAAAA,YAAY,EAAEd,WAAW,CAAClE,iBAAZ,IAAiCkE,WAAW,CAACjE;AAFjC;AAXzB,UAgBL,KAAKiF,gBAAL,CAAsB;AACpBC,QAAAA,EAAE,EAAE,cADgB;AAEpBb,QAAAA,cAAc,EAAdA;AAFoB,OAAtB,CAhBK,EAoBL;AACEc,QAAAA,IAAI,EAAE1D,eAAe,CAACgB,SAAhB,CAA0B0C;AADlC,OApBK,CAAP;AAwBD;;;EA5I2EC,yB;;;8BAAzDlE,Y,eAIA,c;8BAJAA,Y,kBAKGpC,Y","sourcesContent":["// Copyright (c) 2015 - 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nimport {\n Accessor,\n AccessorFunction,\n Color,\n log,\n Position,\n Material,\n UpdateParameters,\n DefaultProps\n} from '@deck.gl/core';\nimport {ColumnLayer} from '@deck.gl/layers';\n\nimport {defaultColorRange} from '../utils/color-utils';\n\nimport {pointToHexbin} from './hexagon-aggregator';\nimport CPUAggregator from '../utils/cpu-aggregator';\nimport AggregationLayer, {AggregationLayerProps} from '../aggregation-layer';\n\nimport GL from '@luma.gl/constants';\nimport {AggregateAccessor} from '../types';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nfunction nop() {}\n\nconst defaultProps: DefaultProps<HexagonLayerProps> = {\n // color\n colorDomain: null,\n colorRange: defaultColorRange,\n getColorValue: {type: 'accessor', value: null}, // default value is calcuated from `getColorWeight` and `colorAggregation`\n getColorWeight: {type: 'accessor', value: 1},\n colorAggregation: 'SUM',\n lowerPercentile: {type: 'number', value: 0, min: 0, max: 100},\n upperPercentile: {type: 'number', value: 100, min: 0, max: 100},\n colorScaleType: 'quantize',\n onSetColorDomain: nop,\n\n // elevation\n elevationDomain: null,\n elevationRange: [0, 1000],\n getElevationValue: {type: 'accessor', value: null}, // default value is calcuated from `getElevationWeight` and `elevationAggregation`\n getElevationWeight: {type: 'accessor', value: 1},\n elevationAggregation: 'SUM',\n elevationLowerPercentile: {type: 'number', value: 0, min: 0, max: 100},\n elevationUpperPercentile: {type: 'number', value: 100, min: 0, max: 100},\n elevationScale: {type: 'number', min: 0, value: 1},\n elevationScaleType: 'linear',\n onSetElevationDomain: nop,\n\n radius: {type: 'number', value: 1000, min: 1},\n coverage: {type: 'number', min: 0, max: 1, value: 1},\n extruded: false,\n hexagonAggregator: pointToHexbin,\n getPosition: {type: 'accessor', value: x => x.position},\n // Optional material for 'lighting' shader module\n material: true,\n\n // data filter\n _filterData: {type: 'function', value: null, optional: true}\n};\n\n/** All properties supported by by HexagonLayer. */\nexport type HexagonLayerProps<DataT = any> = _HexagonLayerProps<DataT> &\n AggregationLayerProps<DataT>;\n\n/** Properties added by HexagonLayer. */\ntype _HexagonLayerProps<DataT = any> = {\n /**\n * Radius of hexagon bin in meters. The hexagons are pointy-topped (rather than flat-topped).\n * @default 1000\n */\n radius?: number;\n\n /**\n * Function to aggregate data into hexagonal bins.\n * @default d3-hexbin\n */\n hexagonAggregator?: (props: any, params: any) => any;\n\n /**\n * Color scale input domain.\n * @default [min(colorWeight), max(colorWeight)]\n */\n colorDomain?: [number, number] | null;\n\n /**\n * Specified as an array of colors [color1, color2, ...].\n * @default `6-class YlOrRd` - [colorbrewer](http://colorbrewer2.org/#type=sequential&scheme=YlOrRd&n=6)\n */\n colorRange?: Color[];\n\n /**\n * Hexagon radius multiplier, clamped between 0 - 1.\n * @default 1\n */\n coverage?: number;\n\n /**\n * Elevation scale input domain. The elevation scale is a linear scale that maps number of counts to elevation.\n * @default [0, max(elevationWeight)]\n */\n elevationDomain?: [number, number] | null;\n\n /**\n * Elevation scale output range.\n * @default [0, 1000]\n */\n elevationRange?: [number, number];\n\n /**\n * Hexagon elevation multiplier.\n * @default 1\n */\n elevationScale?: number;\n\n /**\n * Whether to enable cell elevation. If set to false, all cell will be flat.\n * @default false\n */\n extruded?: boolean;\n\n /**\n * Filter bins and re-calculate color by `upperPercentile`.\n * Hexagons with color value larger than the `upperPercentile` will be hidden.\n * @default 100\n */\n upperPercentile?: number;\n\n /**\n * Filter bins and re-calculate color by `lowerPercentile`.\n * Hexagons with color value smaller than the `lowerPercentile` will be hidden.\n * @default 0\n */\n lowerPercentile?: number;\n\n /**\n * Filter bins and re-calculate elevation by `elevationUpperPercentile`.\n * Hexagons with elevation value larger than the `elevationUpperPercentile` will be hidden.\n * @default 100\n */\n elevationUpperPercentile?: number;\n\n /**\n * Filter bins and re-calculate elevation by `elevationLowerPercentile`.\n * Hexagons with elevation value larger than the `elevationLowerPercentile` will be hidden.\n * @default 0\n */\n elevationLowerPercentile?: number;\n\n /**\n * Scaling function used to determine the color of the grid cell, default value is 'quantize'.\n * Supported Values are 'quantize', 'quantile' and 'ordinal'.\n * @default 'quantize'\n */\n colorScaleType?: 'quantize' | 'quantile' | 'ordinal';\n\n /**\n * Scaling function used to determine the elevation of the grid cell, only supports 'linear'.\n */\n elevationScaleType?: 'linear';\n\n /**\n * Material settings for lighting effect. Applies if `extruded: true`.\n *\n * @default true\n * @see https://deck.gl/docs/developer-guide/using-lighting\n */\n material?: Material;\n\n /**\n * Defines the operation used to aggregate all data object weights to calculate a cell's color value.\n * @default 'SUM'\n */\n colorAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';\n\n /**\n * Defines the operation used to aggregate all data object weights to calculate a cell's elevation value.\n * @default 'SUM'\n */\n elevationAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';\n\n /**\n * Method called to retrieve the position of each object.\n * @default object => object.position\n */\n getPosition?: AccessorFunction<DataT, Position>;\n\n /**\n * The weight of a data object used to calculate the color value for a bin.\n * @default 1\n */\n getColorWeight?: Accessor<DataT, number>;\n\n /**\n * After data objects are aggregated into bins, this accessor is called on each cell to get the value that its color is based on.\n * @default null\n */\n getColorValue?: AggregateAccessor<DataT> | null;\n\n /**\n * The weight of a data object used to calculate the elevation value for a bin.\n * @default 1\n */\n getElevationWeight?: Accessor<DataT, number>;\n\n /**\n * After data objects are aggregated into bins, this accessor is called on each cell to get the value that its elevation is based on.\n * @default null\n */\n getElevationValue?: AggregateAccessor<DataT> | null;\n\n /**\n * This callback will be called when cell color domain has been calculated.\n * @default () => {}\n */\n onSetColorDomain?: (minMax: [number, number]) => void;\n\n /**\n * This callback will be called when cell elevation domain has been calculated.\n * @default () => {}\n */\n onSetElevationDomain?: (minMax: [number, number]) => void;\n\n /**\n * (Experimental) Filter data objects\n */\n _filterData: null | ((d: DataT) => boolean);\n};\n\n/** Aggregates data into a hexagon-based heatmap. The color and height of a hexagon are determined based on the objects it contains. */\nexport default class HexagonLayer<DataT, ExtraPropsT extends {} = {}> extends AggregationLayer<\n DataT,\n ExtraPropsT & Required<_HexagonLayerProps>\n> {\n static layerName = 'HexagonLayer';\n static defaultProps = defaultProps;\n\n state!: AggregationLayer<DataT>['state'] & {\n cpuAggregator: CPUAggregator;\n aggregatorState: any;\n };\n initializeState() {\n const cpuAggregator = new CPUAggregator({\n getAggregator: props => props.hexagonAggregator,\n getCellSize: props => props.radius\n });\n\n this.state = {\n cpuAggregator,\n aggregatorState: cpuAggregator.state,\n vertices: null\n };\n const attributeManager = this.getAttributeManager()!;\n attributeManager.add({\n positions: {size: 3, type: GL.DOUBLE, accessor: 'getPosition'}\n });\n // color and elevation attributes can't be added as attributes\n // they are calculated using 'getValue' accessor that takes an array of pints.\n }\n\n updateState(opts: UpdateParameters<this>) {\n super.updateState(opts);\n\n if (opts.changeFlags.propsOrDataChanged) {\n const aggregatorState = this.state.cpuAggregator.updateState(opts, {\n viewport: this.context.viewport,\n attributes: this.getAttributes()\n });\n if (this.state.aggregatorState.layerData !== aggregatorState.layerData) {\n // if user provided custom aggregator and returns hexagonVertices,\n // Need to recalculate radius and angle based on vertices\n const {hexagonVertices} = aggregatorState.layerData || {};\n this.setState({\n vertices: hexagonVertices && this.convertLatLngToMeterOffset(hexagonVertices)\n });\n }\n\n this.setState({\n // make a copy of the internal state of cpuAggregator for testing\n aggregatorState\n });\n }\n }\n\n convertLatLngToMeterOffset(hexagonVertices) {\n const {viewport} = this.context;\n if (Array.isArray(hexagonVertices) && hexagonVertices.length === 6) {\n // get centroid of hexagons\n const vertex0 = hexagonVertices[0];\n const vertex3 = hexagonVertices[3];\n\n const centroid = [(vertex0[0] + vertex3[0]) / 2, (vertex0[1] + vertex3[1]) / 2];\n const centroidFlat = viewport.projectFlat(centroid);\n\n const {metersPerUnit} = viewport.getDistanceScales(centroid);\n\n // offset all points by centroid to meter offset\n const vertices = hexagonVertices.map(vt => {\n const vtFlat = viewport.projectFlat(vt);\n\n return [\n (vtFlat[0] - centroidFlat[0]) * metersPerUnit[0],\n (vtFlat[1] - centroidFlat[1]) * metersPerUnit[1]\n ];\n });\n\n return vertices;\n }\n\n log.error('HexagonLayer: hexagonVertices needs to be an array of 6 points')();\n return null;\n }\n\n getPickingInfo({info}) {\n return this.state.cpuAggregator.getPickingInfo({info});\n }\n\n // create a method for testing\n _onGetSublayerColor(cell) {\n return this.state.cpuAggregator.getAccessor('fillColor')(cell);\n }\n\n // create a method for testing\n _onGetSublayerElevation(cell) {\n return this.state.cpuAggregator.getAccessor('elevation')(cell);\n }\n\n _getSublayerUpdateTriggers() {\n return this.state.cpuAggregator.getUpdateTriggers(this.props);\n }\n\n renderLayers() {\n const {elevationScale, extruded, coverage, material, transitions} = this.props;\n const {aggregatorState, vertices} = this.state;\n\n const SubLayerClass = this.getSubLayerClass('hexagon-cell', ColumnLayer);\n const updateTriggers = this._getSublayerUpdateTriggers();\n\n const geometry = vertices\n ? {vertices, radius: 1}\n : {\n // default geometry\n radius: aggregatorState.layerData.radiusCommon || 1,\n radiusUnits: 'common',\n angle: 90\n };\n return new SubLayerClass(\n {\n ...geometry,\n diskResolution: 6,\n elevationScale,\n extruded,\n coverage,\n material,\n\n getFillColor: this._onGetSublayerColor.bind(this),\n getElevation: this._onGetSublayerElevation.bind(this),\n transitions: transitions && {\n getFillColor: transitions.getColorValue || transitions.getColorWeight,\n getElevation: transitions.getElevationValue || transitions.getElevationWeight\n }\n },\n this.getSubLayerProps({\n id: 'hexagon-cell',\n updateTriggers\n }),\n {\n data: aggregatorState.layerData.data\n }\n );\n }\n}\n"],"file":"hexagon-layer.js"}
1
+ {"version":3,"sources":["../../../src/hexagon-layer/hexagon-layer.ts"],"names":["nop","defaultProps","colorDomain","colorRange","defaultColorRange","getColorValue","type","value","getColorWeight","colorAggregation","lowerPercentile","min","max","upperPercentile","colorScaleType","onSetColorDomain","elevationDomain","elevationRange","getElevationValue","getElevationWeight","elevationAggregation","elevationLowerPercentile","elevationUpperPercentile","elevationScale","elevationScaleType","onSetElevationDomain","radius","coverage","extruded","hexagonAggregator","pointToHexbin","getPosition","x","position","material","_filterData","optional","HexagonLayer","state","initializeState","cpuAggregator","CPUAggregator","getAggregator","props","getCellSize","aggregatorState","vertices","attributeManager","getAttributeManager","add","positions","size","accessor","updateState","opts","changeFlags","propsOrDataChanged","viewport","context","attributes","getAttributes","layerData","hexagonVertices","setState","convertLatLngToMeterOffset","Array","isArray","length","vertex0","vertex3","centroid","centroidFlat","projectFlat","getDistanceScales","metersPerUnit","map","vt","vtFlat","log","error","getPickingInfo","info","_onGetSublayerColor","cell","getAccessor","_onGetSublayerElevation","_getSublayerUpdateTriggers","getUpdateTriggers","renderLayers","transitions","SubLayerClass","getSubLayerClass","ColumnLayer","updateTriggers","geometry","radiusCommon","radiusUnits","angle","diskResolution","getFillColor","bind","getElevation","getSubLayerProps","id","data","AggregationLayer","layerName"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoBA;;AAUA;;AAEA;;AAEA;;AACA;;AACA;;;;;;;;;;AAMA,SAASA,GAAT,GAAe,CAAE;;AAEjB,IAAMC,YAA6C,GAAG;AAEpDC,EAAAA,WAAW,EAAE,IAFuC;AAGpDC,EAAAA,UAAU,EAAEC,6BAHwC;AAIpDC,EAAAA,aAAa,EAAE;AAACC,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE;AAA1B,GAJqC;AAKpDC,EAAAA,cAAc,EAAE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AAA,QAAQ,EAARA,QANG;AAOHO,MAAAA,QAAQ,EAARA,QAPG;AASHiE,MAAAA,YAAY,EAAE,KAAKjB,mBAAL,CAAyBkB,IAAzB,CAA8B,IAA9B,CATX;AAUHC,MAAAA,YAAY,EAAE,KAAKhB,uBAAL,CAA6Be,IAA7B,CAAkC,IAAlC,CAVX;AAWHX,MAAAA,WAAW,EAAEA,WAAW,IAAI;AAC1BU,QAAAA,YAAY,EAAEV,WAAW,CAACpF,aAAZ,IAA6BoF,WAAW,CAACjF,cAD7B;AAE1B6F,QAAAA,YAAY,EAAEZ,WAAW,CAACvE,iBAAZ,IAAiCuE,WAAW,CAACtE;AAFjC;AAXzB,QAgBL,KAAKmF,gBAAL,CAAsB;AACpBC,MAAAA,EAAE,EAAE,cADgB;AAEpBV,MAAAA,cAAc,EAAdA;AAFoB,KAAtB,CAhBK,EAoBL;AACEW,MAAAA,IAAI,EAAE3D,eAAe,CAACgB,SAAhB,CAA0B2C;AADlC,KApBK,CAAP;AAwBD,G;;;EA5I2EC,yB;;;AAAzDpE,Y,CAIZqE,S,GAAY,c;AAJArE,Y,CAKZpC,Y,GAAeA,Y","sourcesContent":["// Copyright (c) 2015 - 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nimport {\n Accessor,\n AccessorFunction,\n Color,\n log,\n Position,\n Material,\n UpdateParameters,\n DefaultProps\n} from '@deck.gl/core';\nimport {ColumnLayer} from '@deck.gl/layers';\n\nimport {defaultColorRange} from '../utils/color-utils';\n\nimport {pointToHexbin} from './hexagon-aggregator';\nimport CPUAggregator from '../utils/cpu-aggregator';\nimport AggregationLayer, {AggregationLayerProps} from '../aggregation-layer';\n\nimport GL from '@luma.gl/constants';\nimport {AggregateAccessor} from '../types';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nfunction nop() {}\n\nconst defaultProps: DefaultProps<HexagonLayerProps> = {\n // color\n colorDomain: null,\n colorRange: defaultColorRange,\n getColorValue: {type: 'accessor', value: null}, // default value is calcuated from `getColorWeight` and `colorAggregation`\n getColorWeight: {type: 'accessor', value: 1},\n colorAggregation: 'SUM',\n lowerPercentile: {type: 'number', value: 0, min: 0, max: 100},\n upperPercentile: {type: 'number', value: 100, min: 0, max: 100},\n colorScaleType: 'quantize',\n onSetColorDomain: nop,\n\n // elevation\n elevationDomain: null,\n elevationRange: [0, 1000],\n getElevationValue: {type: 'accessor', value: null}, // default value is calcuated from `getElevationWeight` and `elevationAggregation`\n getElevationWeight: {type: 'accessor', value: 1},\n elevationAggregation: 'SUM',\n elevationLowerPercentile: {type: 'number', value: 0, min: 0, max: 100},\n elevationUpperPercentile: {type: 'number', value: 100, min: 0, max: 100},\n elevationScale: {type: 'number', min: 0, value: 1},\n elevationScaleType: 'linear',\n onSetElevationDomain: nop,\n\n radius: {type: 'number', value: 1000, min: 1},\n coverage: {type: 'number', min: 0, max: 1, value: 1},\n extruded: false,\n hexagonAggregator: pointToHexbin,\n getPosition: {type: 'accessor', value: x => x.position},\n // Optional material for 'lighting' shader module\n material: true,\n\n // data filter\n _filterData: {type: 'function', value: null, optional: true}\n};\n\n/** All properties supported by by HexagonLayer. */\nexport type HexagonLayerProps<DataT = any> = _HexagonLayerProps<DataT> &\n AggregationLayerProps<DataT>;\n\n/** Properties added by HexagonLayer. */\ntype _HexagonLayerProps<DataT = any> = {\n /**\n * Radius of hexagon bin in meters. The hexagons are pointy-topped (rather than flat-topped).\n * @default 1000\n */\n radius?: number;\n\n /**\n * Function to aggregate data into hexagonal bins.\n * @default d3-hexbin\n */\n hexagonAggregator?: (props: any, params: any) => any;\n\n /**\n * Color scale input domain.\n * @default [min(colorWeight), max(colorWeight)]\n */\n colorDomain?: [number, number] | null;\n\n /**\n * Specified as an array of colors [color1, color2, ...].\n * @default `6-class YlOrRd` - [colorbrewer](http://colorbrewer2.org/#type=sequential&scheme=YlOrRd&n=6)\n */\n colorRange?: Color[];\n\n /**\n * Hexagon radius multiplier, clamped between 0 - 1.\n * @default 1\n */\n coverage?: number;\n\n /**\n * Elevation scale input domain. The elevation scale is a linear scale that maps number of counts to elevation.\n * @default [0, max(elevationWeight)]\n */\n elevationDomain?: [number, number] | null;\n\n /**\n * Elevation scale output range.\n * @default [0, 1000]\n */\n elevationRange?: [number, number];\n\n /**\n * Hexagon elevation multiplier.\n * @default 1\n */\n elevationScale?: number;\n\n /**\n * Whether to enable cell elevation. If set to false, all cell will be flat.\n * @default false\n */\n extruded?: boolean;\n\n /**\n * Filter bins and re-calculate color by `upperPercentile`.\n * Hexagons with color value larger than the `upperPercentile` will be hidden.\n * @default 100\n */\n upperPercentile?: number;\n\n /**\n * Filter bins and re-calculate color by `lowerPercentile`.\n * Hexagons with color value smaller than the `lowerPercentile` will be hidden.\n * @default 0\n */\n lowerPercentile?: number;\n\n /**\n * Filter bins and re-calculate elevation by `elevationUpperPercentile`.\n * Hexagons with elevation value larger than the `elevationUpperPercentile` will be hidden.\n * @default 100\n */\n elevationUpperPercentile?: number;\n\n /**\n * Filter bins and re-calculate elevation by `elevationLowerPercentile`.\n * Hexagons with elevation value larger than the `elevationLowerPercentile` will be hidden.\n * @default 0\n */\n elevationLowerPercentile?: number;\n\n /**\n * Scaling function used to determine the color of the grid cell, default value is 'quantize'.\n * Supported Values are 'quantize', 'quantile' and 'ordinal'.\n * @default 'quantize'\n */\n colorScaleType?: 'quantize' | 'quantile' | 'ordinal';\n\n /**\n * Scaling function used to determine the elevation of the grid cell, only supports 'linear'.\n */\n elevationScaleType?: 'linear';\n\n /**\n * Material settings for lighting effect. Applies if `extruded: true`.\n *\n * @default true\n * @see https://deck.gl/docs/developer-guide/using-lighting\n */\n material?: Material;\n\n /**\n * Defines the operation used to aggregate all data object weights to calculate a cell's color value.\n * @default 'SUM'\n */\n colorAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';\n\n /**\n * Defines the operation used to aggregate all data object weights to calculate a cell's elevation value.\n * @default 'SUM'\n */\n elevationAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';\n\n /**\n * Method called to retrieve the position of each object.\n * @default object => object.position\n */\n getPosition?: AccessorFunction<DataT, Position>;\n\n /**\n * The weight of a data object used to calculate the color value for a bin.\n * @default 1\n */\n getColorWeight?: Accessor<DataT, number>;\n\n /**\n * After data objects are aggregated into bins, this accessor is called on each cell to get the value that its color is based on.\n * @default null\n */\n getColorValue?: AggregateAccessor<DataT> | null;\n\n /**\n * The weight of a data object used to calculate the elevation value for a bin.\n * @default 1\n */\n getElevationWeight?: Accessor<DataT, number>;\n\n /**\n * After data objects are aggregated into bins, this accessor is called on each cell to get the value that its elevation is based on.\n * @default null\n */\n getElevationValue?: AggregateAccessor<DataT> | null;\n\n /**\n * This callback will be called when cell color domain has been calculated.\n * @default () => {}\n */\n onSetColorDomain?: (minMax: [number, number]) => void;\n\n /**\n * This callback will be called when cell elevation domain has been calculated.\n * @default () => {}\n */\n onSetElevationDomain?: (minMax: [number, number]) => void;\n\n /**\n * (Experimental) Filter data objects\n */\n _filterData: null | ((d: DataT) => boolean);\n};\n\n/** Aggregates data into a hexagon-based heatmap. The color and height of a hexagon are determined based on the objects it contains. */\nexport default class HexagonLayer<DataT, ExtraPropsT extends {} = {}> extends AggregationLayer<\n DataT,\n ExtraPropsT & Required<_HexagonLayerProps>\n> {\n static layerName = 'HexagonLayer';\n static defaultProps = defaultProps;\n\n state!: AggregationLayer<DataT>['state'] & {\n cpuAggregator: CPUAggregator;\n aggregatorState: any;\n };\n initializeState() {\n const cpuAggregator = new CPUAggregator({\n getAggregator: props => props.hexagonAggregator,\n getCellSize: props => props.radius\n });\n\n this.state = {\n cpuAggregator,\n aggregatorState: cpuAggregator.state,\n vertices: null\n };\n const attributeManager = this.getAttributeManager()!;\n attributeManager.add({\n positions: {size: 3, type: GL.DOUBLE, accessor: 'getPosition'}\n });\n // color and elevation attributes can't be added as attributes\n // they are calculated using 'getValue' accessor that takes an array of pints.\n }\n\n updateState(opts: UpdateParameters<this>) {\n super.updateState(opts);\n\n if (opts.changeFlags.propsOrDataChanged) {\n const aggregatorState = this.state.cpuAggregator.updateState(opts, {\n viewport: this.context.viewport,\n attributes: this.getAttributes()\n });\n if (this.state.aggregatorState.layerData !== aggregatorState.layerData) {\n // if user provided custom aggregator and returns hexagonVertices,\n // Need to recalculate radius and angle based on vertices\n const {hexagonVertices} = aggregatorState.layerData || {};\n this.setState({\n vertices: hexagonVertices && this.convertLatLngToMeterOffset(hexagonVertices)\n });\n }\n\n this.setState({\n // make a copy of the internal state of cpuAggregator for testing\n aggregatorState\n });\n }\n }\n\n convertLatLngToMeterOffset(hexagonVertices) {\n const {viewport} = this.context;\n if (Array.isArray(hexagonVertices) && hexagonVertices.length === 6) {\n // get centroid of hexagons\n const vertex0 = hexagonVertices[0];\n const vertex3 = hexagonVertices[3];\n\n const centroid = [(vertex0[0] + vertex3[0]) / 2, (vertex0[1] + vertex3[1]) / 2];\n const centroidFlat = viewport.projectFlat(centroid);\n\n const {metersPerUnit} = viewport.getDistanceScales(centroid);\n\n // offset all points by centroid to meter offset\n const vertices = hexagonVertices.map(vt => {\n const vtFlat = viewport.projectFlat(vt);\n\n return [\n (vtFlat[0] - centroidFlat[0]) * metersPerUnit[0],\n (vtFlat[1] - centroidFlat[1]) * metersPerUnit[1]\n ];\n });\n\n return vertices;\n }\n\n log.error('HexagonLayer: hexagonVertices needs to be an array of 6 points')();\n return null;\n }\n\n getPickingInfo({info}) {\n return this.state.cpuAggregator.getPickingInfo({info});\n }\n\n // create a method for testing\n _onGetSublayerColor(cell) {\n return this.state.cpuAggregator.getAccessor('fillColor')(cell);\n }\n\n // create a method for testing\n _onGetSublayerElevation(cell) {\n return this.state.cpuAggregator.getAccessor('elevation')(cell);\n }\n\n _getSublayerUpdateTriggers() {\n return this.state.cpuAggregator.getUpdateTriggers(this.props);\n }\n\n renderLayers() {\n const {elevationScale, extruded, coverage, material, transitions} = this.props;\n const {aggregatorState, vertices} = this.state;\n\n const SubLayerClass = this.getSubLayerClass('hexagon-cell', ColumnLayer);\n const updateTriggers = this._getSublayerUpdateTriggers();\n\n const geometry = vertices\n ? {vertices, radius: 1}\n : {\n // default geometry\n radius: aggregatorState.layerData.radiusCommon || 1,\n radiusUnits: 'common',\n angle: 90\n };\n return new SubLayerClass(\n {\n ...geometry,\n diskResolution: 6,\n elevationScale,\n extruded,\n coverage,\n material,\n\n getFillColor: this._onGetSublayerColor.bind(this),\n getElevation: this._onGetSublayerElevation.bind(this),\n transitions: transitions && {\n getFillColor: transitions.getColorValue || transitions.getColorWeight,\n getElevation: transitions.getElevationValue || transitions.getElevationWeight\n }\n },\n this.getSubLayerProps({\n id: 'hexagon-cell',\n updateTriggers\n }),\n {\n data: aggregatorState.layerData.data\n }\n );\n }\n}\n"],"file":"hexagon-layer.js"}