@deck.gl/aggregation-layers 8.10.0-alpha.4 → 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 (95) hide show
  1. package/dist/dist.dev.js +58 -709
  2. package/dist/es5/aggregation-layer.js +120 -134
  3. package/dist/es5/aggregation-layer.js.map +1 -1
  4. package/dist/es5/contour-layer/contour-layer.js +225 -234
  5. package/dist/es5/contour-layer/contour-layer.js.map +1 -1
  6. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +90 -100
  7. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
  8. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +131 -140
  9. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
  10. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +285 -295
  11. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
  12. package/dist/es5/grid-aggregation-layer.js +194 -209
  13. package/dist/es5/grid-aggregation-layer.js.map +1 -1
  14. package/dist/es5/grid-layer/grid-layer.js +59 -66
  15. package/dist/es5/grid-layer/grid-layer.js.map +1 -1
  16. package/dist/es5/heatmap-layer/heatmap-layer.js +471 -497
  17. package/dist/es5/heatmap-layer/heatmap-layer.js.map +1 -1
  18. package/dist/es5/heatmap-layer/triangle-layer.js +64 -69
  19. package/dist/es5/heatmap-layer/triangle-layer.js.map +1 -1
  20. package/dist/es5/hexagon-layer/hexagon-layer.js +129 -140
  21. package/dist/es5/hexagon-layer/hexagon-layer.js.map +1 -1
  22. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +153 -166
  23. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  24. package/dist/es5/screen-grid-layer/screen-grid-layer.js +207 -220
  25. package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +1 -1
  26. package/dist/es5/utils/bin-sorter.js +163 -173
  27. package/dist/es5/utils/bin-sorter.js.map +1 -1
  28. package/dist/es5/utils/cpu-aggregator.js +300 -323
  29. package/dist/es5/utils/cpu-aggregator.js.map +1 -1
  30. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +483 -504
  31. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +1 -1
  32. package/dist/esm/aggregation-layer.js +2 -5
  33. package/dist/esm/aggregation-layer.js.map +1 -1
  34. package/dist/esm/contour-layer/contour-layer.js +2 -5
  35. package/dist/esm/contour-layer/contour-layer.js.map +1 -1
  36. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js +2 -5
  37. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
  38. package/dist/esm/cpu-grid-layer/grid-aggregator.js +1 -1
  39. package/dist/esm/cpu-grid-layer/grid-aggregator.js.map +1 -1
  40. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +15 -1
  41. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js.map +1 -1
  42. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +121 -1
  43. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js.map +1 -1
  44. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js +2 -5
  45. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
  46. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js +3 -6
  47. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
  48. package/dist/esm/grid-aggregation-layer.js +3 -6
  49. package/dist/esm/grid-aggregation-layer.js.map +1 -1
  50. package/dist/esm/grid-layer/grid-layer.js +3 -7
  51. package/dist/esm/grid-layer/grid-layer.js.map +1 -1
  52. package/dist/esm/heatmap-layer/heatmap-layer.js +7 -11
  53. package/dist/esm/heatmap-layer/heatmap-layer.js.map +1 -1
  54. package/dist/esm/heatmap-layer/max-fs.glsl.js +7 -1
  55. package/dist/esm/heatmap-layer/max-fs.glsl.js.map +1 -1
  56. package/dist/esm/heatmap-layer/max-vs.glsl.js +12 -1
  57. package/dist/esm/heatmap-layer/max-vs.glsl.js.map +1 -1
  58. package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js +39 -1
  59. package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js.map +1 -1
  60. package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js +31 -1
  61. package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js.map +1 -1
  62. package/dist/esm/heatmap-layer/triangle-layer.js +1 -3
  63. package/dist/esm/heatmap-layer/triangle-layer.js.map +1 -1
  64. package/dist/esm/heatmap-layer/weights-fs.glsl.js +19 -1
  65. package/dist/esm/heatmap-layer/weights-fs.glsl.js.map +1 -1
  66. package/dist/esm/heatmap-layer/weights-vs.glsl.js +23 -1
  67. package/dist/esm/heatmap-layer/weights-vs.glsl.js.map +1 -1
  68. package/dist/esm/hexagon-layer/hexagon-layer.js +3 -7
  69. package/dist/esm/hexagon-layer/hexagon-layer.js.map +1 -1
  70. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js +3 -7
  71. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  72. package/dist/esm/screen-grid-layer/screen-grid-layer-fragment.glsl.js +17 -1
  73. package/dist/esm/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +1 -1
  74. package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js +64 -1
  75. package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +1 -1
  76. package/dist/esm/screen-grid-layer/screen-grid-layer.js +5 -9
  77. package/dist/esm/screen-grid-layer/screen-grid-layer.js.map +1 -1
  78. package/dist/esm/utils/bin-sorter.js +7 -16
  79. package/dist/esm/utils/bin-sorter.js.map +1 -1
  80. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +20 -1
  81. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js.map +1 -1
  82. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +34 -1
  83. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js.map +1 -1
  84. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +12 -1
  85. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js.map +1 -1
  86. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +58 -1
  87. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js.map +1 -1
  88. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +14 -14
  89. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +1 -1
  90. package/dist/esm/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +17 -1
  91. package/dist/esm/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js.map +1 -1
  92. package/dist/esm/utils/scale-utils.js +2 -2
  93. package/dist/esm/utils/scale-utils.js.map +1 -1
  94. package/dist.min.js +30 -27
  95. package/package.json +2 -2
@@ -7,9 +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"));
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
 
12
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
13
 
14
14
  var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
15
15
 
@@ -19,8 +19,6 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
19
19
 
20
20
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
21
 
22
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
-
24
22
  var _layers = require("@deck.gl/layers");
25
23
 
26
24
  var _contourUtils = require("./contour-utils");
@@ -92,260 +90,253 @@ var ContourLayer = function (_GridAggregationLayer) {
92
90
  return _super.apply(this, arguments);
93
91
  }
94
92
 
95
- (0, _createClass2.default)(ContourLayer, [{
96
- key: "initializeState",
97
- value: function initializeState() {
98
- var _attributeManager$add;
99
-
100
- (0, _get2.default)((0, _getPrototypeOf2.default)(ContourLayer.prototype), "initializeAggregationLayer", this).call(this, {
101
- dimensions: DIMENSIONS
102
- });
103
- this.setState({
104
- contourData: {},
105
- projectPoints: false,
106
- weights: {
107
- count: {
108
- size: 1,
109
- operation: _aggregationOperationUtils.AGGREGATION_OPERATION.SUM
110
- }
93
+ var _proto = ContourLayer.prototype;
94
+
95
+ _proto.initializeState = function initializeState() {
96
+ var _attributeManager$add;
97
+
98
+ (0, _get2.default)((0, _getPrototypeOf2.default)(ContourLayer.prototype), "initializeAggregationLayer", this).call(this, {
99
+ dimensions: DIMENSIONS
100
+ });
101
+ this.setState({
102
+ contourData: {},
103
+ projectPoints: false,
104
+ weights: {
105
+ count: {
106
+ size: 1,
107
+ operation: _aggregationOperationUtils.AGGREGATION_OPERATION.SUM
111
108
  }
112
- });
113
- var attributeManager = this.getAttributeManager();
114
- attributeManager.add((_attributeManager$add = {}, (0, _defineProperty2.default)(_attributeManager$add, POSITION_ATTRIBUTE_NAME, {
115
- size: 3,
116
- accessor: 'getPosition',
117
- type: 5130,
118
- fp64: this.use64bitPositions()
119
- }), (0, _defineProperty2.default)(_attributeManager$add, "count", {
120
- size: 3,
121
- accessor: 'getWeight'
122
- }), _attributeManager$add));
123
- }
124
- }, {
125
- key: "updateState",
126
- value: function updateState(opts) {
127
- (0, _get2.default)((0, _getPrototypeOf2.default)(ContourLayer.prototype), "updateState", this).call(this, opts);
128
- var contoursChanged = false;
129
- var oldProps = opts.oldProps,
130
- props = opts.props;
131
- var aggregationDirty = this.state.aggregationDirty;
132
-
133
- if (oldProps.contours !== props.contours || oldProps.zOffset !== props.zOffset) {
134
- contoursChanged = true;
135
-
136
- this._updateThresholdData(opts.props);
137
- }
138
-
139
- if (this.getNumInstances() > 0 && (aggregationDirty || contoursChanged)) {
140
- this._generateContours();
141
109
  }
110
+ });
111
+ var attributeManager = this.getAttributeManager();
112
+ attributeManager.add((_attributeManager$add = {}, (0, _defineProperty2.default)(_attributeManager$add, POSITION_ATTRIBUTE_NAME, {
113
+ size: 3,
114
+ accessor: 'getPosition',
115
+ type: 5130,
116
+ fp64: this.use64bitPositions()
117
+ }), (0, _defineProperty2.default)(_attributeManager$add, "count", {
118
+ size: 3,
119
+ accessor: 'getWeight'
120
+ }), _attributeManager$add));
121
+ };
122
+
123
+ _proto.updateState = function updateState(opts) {
124
+ (0, _get2.default)((0, _getPrototypeOf2.default)(ContourLayer.prototype), "updateState", this).call(this, opts);
125
+ var contoursChanged = false;
126
+ var oldProps = opts.oldProps,
127
+ props = opts.props;
128
+ var aggregationDirty = this.state.aggregationDirty;
129
+
130
+ if (oldProps.contours !== props.contours || oldProps.zOffset !== props.zOffset) {
131
+ contoursChanged = true;
132
+
133
+ this._updateThresholdData(opts.props);
142
134
  }
143
- }, {
144
- key: "renderLayers",
145
- value: function renderLayers() {
146
- var _this$state$contourDa = this.state.contourData,
147
- contourSegments = _this$state$contourDa.contourSegments,
148
- contourPolygons = _this$state$contourDa.contourPolygons;
149
- var LinesSubLayerClass = this.getSubLayerClass('lines', _layers.LineLayer);
150
- var BandsSubLayerClass = this.getSubLayerClass('bands', _layers.SolidPolygonLayer);
151
- var lineLayer = contourSegments && contourSegments.length > 0 && new LinesSubLayerClass(this.getSubLayerProps({
152
- id: 'lines'
153
- }), {
154
- data: this.state.contourData.contourSegments,
155
- getSourcePosition: function getSourcePosition(d) {
156
- return d.start;
157
- },
158
- getTargetPosition: function getTargetPosition(d) {
159
- return d.end;
160
- },
161
- getColor: function getColor(d) {
162
- return d.contour.color || DEFAULT_COLOR;
163
- },
164
- getWidth: function getWidth(d) {
165
- return d.contour.strokeWidth || DEFAULT_STROKE_WIDTH;
166
- }
167
- });
168
- var bandsLayer = contourPolygons && contourPolygons.length > 0 && new BandsSubLayerClass(this.getSubLayerProps({
169
- id: 'bands'
170
- }), {
171
- data: this.state.contourData.contourPolygons,
172
- getPolygon: function getPolygon(d) {
173
- return d.vertices;
174
- },
175
- getFillColor: function getFillColor(d) {
176
- return d.contour.color || DEFAULT_COLOR;
177
- }
178
- });
179
- return [lineLayer, bandsLayer];
135
+
136
+ if (this.getNumInstances() > 0 && (aggregationDirty || contoursChanged)) {
137
+ this._generateContours();
180
138
  }
181
- }, {
182
- key: "updateAggregationState",
183
- value: function updateAggregationState(opts) {
184
- var props = opts.props,
185
- oldProps = opts.oldProps;
186
- var cellSize = props.cellSize,
187
- coordinateSystem = props.coordinateSystem;
188
- var viewport = this.context.viewport;
189
- var cellSizeChanged = oldProps.cellSize !== cellSize;
190
- var gpuAggregation = props.gpuAggregation;
191
-
192
- if (this.state.gpuAggregation !== props.gpuAggregation) {
193
- if (gpuAggregation && !_gpuGridAggregator.default.isSupported(this.context.gl)) {
194
- _core.log.warn('GPU Grid Aggregation not supported, falling back to CPU')();
195
-
196
- gpuAggregation = false;
197
- }
139
+ };
140
+
141
+ _proto.renderLayers = function renderLayers() {
142
+ var _this$state$contourDa = this.state.contourData,
143
+ contourSegments = _this$state$contourDa.contourSegments,
144
+ contourPolygons = _this$state$contourDa.contourPolygons;
145
+ var LinesSubLayerClass = this.getSubLayerClass('lines', _layers.LineLayer);
146
+ var BandsSubLayerClass = this.getSubLayerClass('bands', _layers.SolidPolygonLayer);
147
+ var lineLayer = contourSegments && contourSegments.length > 0 && new LinesSubLayerClass(this.getSubLayerProps({
148
+ id: 'lines'
149
+ }), {
150
+ data: this.state.contourData.contourSegments,
151
+ getSourcePosition: function getSourcePosition(d) {
152
+ return d.start;
153
+ },
154
+ getTargetPosition: function getTargetPosition(d) {
155
+ return d.end;
156
+ },
157
+ getColor: function getColor(d) {
158
+ return d.contour.color || DEFAULT_COLOR;
159
+ },
160
+ getWidth: function getWidth(d) {
161
+ return d.contour.strokeWidth || DEFAULT_STROKE_WIDTH;
198
162
  }
199
-
200
- var gpuAggregationChanged = gpuAggregation !== this.state.gpuAggregation;
201
- this.setState({
202
- gpuAggregation: gpuAggregation
203
- });
204
- var dimensions = this.state.dimensions;
205
- var positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME);
206
- var data = dimensions.data,
207
- weights = dimensions.weights;
208
- var boundingBox = this.state.boundingBox;
209
-
210
- if (positionsChanged) {
211
- boundingBox = (0, _gridAggregationUtils.getBoundingBox)(this.getAttributes(), this.getNumInstances());
212
- this.setState({
213
- boundingBox: boundingBox
214
- });
163
+ });
164
+ var bandsLayer = contourPolygons && contourPolygons.length > 0 && new BandsSubLayerClass(this.getSubLayerProps({
165
+ id: 'bands'
166
+ }), {
167
+ data: this.state.contourData.contourPolygons,
168
+ getPolygon: function getPolygon(d) {
169
+ return d.vertices;
170
+ },
171
+ getFillColor: function getFillColor(d) {
172
+ return d.contour.color || DEFAULT_COLOR;
215
173
  }
216
-
217
- if (positionsChanged || cellSizeChanged) {
218
- var _getGridParams = (0, _gridAggregationUtils.getGridParams)(boundingBox, cellSize, viewport, coordinateSystem),
219
- gridOffset = _getGridParams.gridOffset,
220
- translation = _getGridParams.translation,
221
- width = _getGridParams.width,
222
- height = _getGridParams.height,
223
- numCol = _getGridParams.numCol,
224
- numRow = _getGridParams.numRow;
225
-
226
- this.allocateResources(numRow, numCol);
227
- this.setState({
228
- gridOffset: gridOffset,
229
- boundingBox: boundingBox,
230
- translation: translation,
231
- posOffset: translation.slice(),
232
- gridOrigin: [-1 * translation[0], -1 * translation[1]],
233
- width: width,
234
- height: height,
235
- numCol: numCol,
236
- numRow: numRow
237
- });
174
+ });
175
+ return [lineLayer, bandsLayer];
176
+ };
177
+
178
+ _proto.updateAggregationState = function updateAggregationState(opts) {
179
+ var props = opts.props,
180
+ oldProps = opts.oldProps;
181
+ var cellSize = props.cellSize,
182
+ coordinateSystem = props.coordinateSystem;
183
+ var viewport = this.context.viewport;
184
+ var cellSizeChanged = oldProps.cellSize !== cellSize;
185
+ var gpuAggregation = props.gpuAggregation;
186
+
187
+ if (this.state.gpuAggregation !== props.gpuAggregation) {
188
+ if (gpuAggregation && !_gpuGridAggregator.default.isSupported(this.context.gl)) {
189
+ _core.log.warn('GPU Grid Aggregation not supported, falling back to CPU')();
190
+
191
+ gpuAggregation = false;
238
192
  }
193
+ }
239
194
 
240
- var aggregationDataDirty = positionsChanged || gpuAggregationChanged || this.isAggregationDirty(opts, {
241
- dimension: data,
242
- compareAll: gpuAggregation
243
- });
244
- var aggregationWeightsDirty = this.isAggregationDirty(opts, {
245
- dimension: weights
195
+ var gpuAggregationChanged = gpuAggregation !== this.state.gpuAggregation;
196
+ this.setState({
197
+ gpuAggregation: gpuAggregation
198
+ });
199
+ var dimensions = this.state.dimensions;
200
+ var positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME);
201
+ var data = dimensions.data,
202
+ weights = dimensions.weights;
203
+ var boundingBox = this.state.boundingBox;
204
+
205
+ if (positionsChanged) {
206
+ boundingBox = (0, _gridAggregationUtils.getBoundingBox)(this.getAttributes(), this.getNumInstances());
207
+ this.setState({
208
+ boundingBox: boundingBox
246
209
  });
210
+ }
247
211
 
248
- if (aggregationWeightsDirty) {
249
- this._updateAccessors(opts);
250
- }
251
-
252
- if (aggregationDataDirty || aggregationWeightsDirty) {
253
- this._resetResults();
254
- }
212
+ if (positionsChanged || cellSizeChanged) {
213
+ var _getGridParams = (0, _gridAggregationUtils.getGridParams)(boundingBox, cellSize, viewport, coordinateSystem),
214
+ gridOffset = _getGridParams.gridOffset,
215
+ translation = _getGridParams.translation,
216
+ width = _getGridParams.width,
217
+ height = _getGridParams.height,
218
+ numCol = _getGridParams.numCol,
219
+ numRow = _getGridParams.numRow;
255
220
 
221
+ this.allocateResources(numRow, numCol);
256
222
  this.setState({
257
- aggregationDataDirty: aggregationDataDirty,
258
- aggregationWeightsDirty: aggregationWeightsDirty
223
+ gridOffset: gridOffset,
224
+ boundingBox: boundingBox,
225
+ translation: translation,
226
+ posOffset: translation.slice(),
227
+ gridOrigin: [-1 * translation[0], -1 * translation[1]],
228
+ width: width,
229
+ height: height,
230
+ numCol: numCol,
231
+ numRow: numRow
259
232
  });
260
233
  }
261
- }, {
262
- key: "_updateAccessors",
263
- value: function _updateAccessors(opts) {
264
- var _opts$props = opts.props,
265
- getWeight = _opts$props.getWeight,
266
- aggregation = _opts$props.aggregation,
267
- data = _opts$props.data;
268
- var count = this.state.weights.count;
269
-
270
- if (count) {
271
- count.getWeight = getWeight;
272
- count.operation = _aggregationOperationUtils.AGGREGATION_OPERATION[aggregation];
273
- }
274
234
 
275
- this.setState({
276
- getValue: (0, _aggregationOperationUtils.getValueFunc)(aggregation, getWeight, {
277
- data: data
278
- })
279
- });
235
+ var aggregationDataDirty = positionsChanged || gpuAggregationChanged || this.isAggregationDirty(opts, {
236
+ dimension: data,
237
+ compareAll: gpuAggregation
238
+ });
239
+ var aggregationWeightsDirty = this.isAggregationDirty(opts, {
240
+ dimension: weights
241
+ });
242
+
243
+ if (aggregationWeightsDirty) {
244
+ this._updateAccessors(opts);
280
245
  }
281
- }, {
282
- key: "_resetResults",
283
- value: function _resetResults() {
284
- var count = this.state.weights.count;
285
246
 
286
- if (count) {
287
- count.aggregationData = null;
288
- }
247
+ if (aggregationDataDirty || aggregationWeightsDirty) {
248
+ this._resetResults();
289
249
  }
290
- }, {
291
- key: "_generateContours",
292
- value: function _generateContours() {
293
- var _this$state = this.state,
294
- numCol = _this$state.numCol,
295
- numRow = _this$state.numRow,
296
- gridOrigin = _this$state.gridOrigin,
297
- gridOffset = _this$state.gridOffset,
298
- thresholdData = _this$state.thresholdData;
299
- var count = this.state.weights.count;
300
- var aggregationData = count.aggregationData;
301
-
302
- if (!aggregationData) {
303
- aggregationData = count.aggregationBuffer.getData();
304
- count.aggregationData = aggregationData;
305
- }
306
250
 
307
- var _GPUGridAggregator$ge = _gpuGridAggregator.default.getCellData({
308
- countsData: aggregationData
309
- }),
310
- cellWeights = _GPUGridAggregator$ge.cellWeights;
311
-
312
- var contourData = (0, _contourUtils.generateContours)({
313
- thresholdData: thresholdData,
314
- cellWeights: cellWeights,
315
- gridSize: [numCol, numRow],
316
- gridOrigin: gridOrigin,
317
- cellSize: [gridOffset.xOffset, gridOffset.yOffset]
318
- });
319
- this.setState({
320
- contourData: contourData
321
- });
251
+ this.setState({
252
+ aggregationDataDirty: aggregationDataDirty,
253
+ aggregationWeightsDirty: aggregationWeightsDirty
254
+ });
255
+ };
256
+
257
+ _proto._updateAccessors = function _updateAccessors(opts) {
258
+ var _opts$props = opts.props,
259
+ getWeight = _opts$props.getWeight,
260
+ aggregation = _opts$props.aggregation,
261
+ data = _opts$props.data;
262
+ var count = this.state.weights.count;
263
+
264
+ if (count) {
265
+ count.getWeight = getWeight;
266
+ count.operation = _aggregationOperationUtils.AGGREGATION_OPERATION[aggregation];
322
267
  }
323
- }, {
324
- key: "_updateThresholdData",
325
- value: function _updateThresholdData(props) {
326
- var contours = props.contours,
327
- zOffset = props.zOffset;
328
- var count = contours.length;
329
- var thresholdData = new Array(count);
330
-
331
- for (var i = 0; i < count; i++) {
332
- var contour = contours[i];
333
- thresholdData[i] = {
334
- contour: contour,
335
- zIndex: contour.zIndex || i,
336
- zOffset: zOffset
337
- };
338
- }
339
268
 
340
- this.setState({
341
- thresholdData: thresholdData
342
- });
269
+ this.setState({
270
+ getValue: (0, _aggregationOperationUtils.getValueFunc)(aggregation, getWeight, {
271
+ data: data
272
+ })
273
+ });
274
+ };
275
+
276
+ _proto._resetResults = function _resetResults() {
277
+ var count = this.state.weights.count;
278
+
279
+ if (count) {
280
+ count.aggregationData = null;
281
+ }
282
+ };
283
+
284
+ _proto._generateContours = function _generateContours() {
285
+ var _this$state = this.state,
286
+ numCol = _this$state.numCol,
287
+ numRow = _this$state.numRow,
288
+ gridOrigin = _this$state.gridOrigin,
289
+ gridOffset = _this$state.gridOffset,
290
+ thresholdData = _this$state.thresholdData;
291
+ var count = this.state.weights.count;
292
+ var aggregationData = count.aggregationData;
293
+
294
+ if (!aggregationData) {
295
+ aggregationData = count.aggregationBuffer.getData();
296
+ count.aggregationData = aggregationData;
297
+ }
298
+
299
+ var _GPUGridAggregator$ge = _gpuGridAggregator.default.getCellData({
300
+ countsData: aggregationData
301
+ }),
302
+ cellWeights = _GPUGridAggregator$ge.cellWeights;
303
+
304
+ var contourData = (0, _contourUtils.generateContours)({
305
+ thresholdData: thresholdData,
306
+ cellWeights: cellWeights,
307
+ gridSize: [numCol, numRow],
308
+ gridOrigin: gridOrigin,
309
+ cellSize: [gridOffset.xOffset, gridOffset.yOffset]
310
+ });
311
+ this.setState({
312
+ contourData: contourData
313
+ });
314
+ };
315
+
316
+ _proto._updateThresholdData = function _updateThresholdData(props) {
317
+ var contours = props.contours,
318
+ zOffset = props.zOffset;
319
+ var count = contours.length;
320
+ var thresholdData = new Array(count);
321
+
322
+ for (var i = 0; i < count; i++) {
323
+ var contour = contours[i];
324
+ thresholdData[i] = {
325
+ contour: contour,
326
+ zIndex: contour.zIndex || i,
327
+ zOffset: zOffset
328
+ };
343
329
  }
344
- }]);
330
+
331
+ this.setState({
332
+ thresholdData: thresholdData
333
+ });
334
+ };
335
+
345
336
  return ContourLayer;
346
337
  }(_gridAggregationLayer.default);
347
338
 
348
339
  exports.default = ContourLayer;
349
- (0, _defineProperty2.default)(ContourLayer, "layerName", 'ContourLayer');
350
- (0, _defineProperty2.default)(ContourLayer, "defaultProps", defaultProps);
340
+ ContourLayer.layerName = 'ContourLayer';
341
+ ContourLayer.defaultProps = defaultProps;
351
342
  //# sourceMappingURL=contour-layer.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/contour-layer/contour-layer.ts"],"names":["DEFAULT_COLOR","DEFAULT_STROKE_WIDTH","DEFAULT_THRESHOLD","defaultProps","cellSize","type","min","max","value","getPosition","x","position","getWeight","gpuAggregation","aggregation","contours","threshold","optional","compare","zOffset","POSITION_ATTRIBUTE_NAME","DIMENSIONS","data","props","weights","accessors","ContourLayer","dimensions","setState","contourData","projectPoints","count","size","operation","AGGREGATION_OPERATION","SUM","attributeManager","getAttributeManager","add","accessor","fp64","use64bitPositions","opts","contoursChanged","oldProps","aggregationDirty","state","_updateThresholdData","getNumInstances","_generateContours","contourSegments","contourPolygons","LinesSubLayerClass","getSubLayerClass","LineLayer","BandsSubLayerClass","SolidPolygonLayer","lineLayer","length","getSubLayerProps","id","getSourcePosition","d","start","getTargetPosition","end","getColor","contour","color","getWidth","strokeWidth","bandsLayer","getPolygon","vertices","getFillColor","coordinateSystem","viewport","context","cellSizeChanged","GPUGridAggregator","isSupported","gl","log","warn","gpuAggregationChanged","positionsChanged","isAttributeChanged","boundingBox","getAttributes","gridOffset","translation","width","height","numCol","numRow","allocateResources","posOffset","slice","gridOrigin","aggregationDataDirty","isAggregationDirty","dimension","compareAll","aggregationWeightsDirty","_updateAccessors","_resetResults","getValue","aggregationData","thresholdData","aggregationBuffer","getData","getCellData","countsData","cellWeights","gridSize","xOffset","yOffset","Array","i","zIndex","GridAggregationLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAqBA;;AACA;;AACA;;AAWA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,aAAa,GAAG,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,EAAgB,GAAhB,CAAtB;AACA,IAAMC,oBAAoB,GAAG,CAA7B;AACA,IAAMC,iBAAiB,GAAG,CAA1B;AAEA,IAAMC,YAA6C,GAAG;AAEpDC,EAAAA,QAAQ,EAAE;AAACC,IAAAA,IAAI,EAAE,QAAP;AAAiBC,IAAAA,GAAG,EAAE,CAAtB;AAAyBC,IAAAA,GAAG,EAAE,IAA9B;AAAoCC,IAAAA,KAAK,EAAE;AAA3C,GAF0C;AAGpDC,E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A1NOY,6B;;;8BAHW9F,Y,eAIA,c;8BAJAA,Y,kBAKGvB,Y","sourcesContent":["// Copyright (c) 2015 - 2018 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 GL from '@luma.gl/constants';\nimport {LineLayer, SolidPolygonLayer} from '@deck.gl/layers';\nimport {generateContours} from './contour-utils';\nimport {\n Accessor,\n AccessorFunction,\n Color,\n Layer,\n log,\n Position,\n UpdateParameters,\n DefaultProps\n} from '@deck.gl/core';\n\nimport GPUGridAggregator from '../utils/gpu-grid-aggregation/gpu-grid-aggregator';\nimport {AGGREGATION_OPERATION, getValueFunc} from '../utils/aggregation-operation-utils';\nimport {getBoundingBox, getGridParams} from '../utils/grid-aggregation-utils';\nimport GridAggregationLayer, {GridAggregationLayerProps} from '../grid-aggregation-layer';\n\nconst DEFAULT_COLOR = [255, 255, 255, 255];\nconst DEFAULT_STROKE_WIDTH = 1;\nconst DEFAULT_THRESHOLD = 1;\n\nconst defaultProps: DefaultProps<ContourLayerProps> = {\n // grid aggregation\n cellSize: {type: 'number', min: 1, max: 1000, value: 1000},\n getPosition: {type: 'accessor', value: x => x.position},\n getWeight: {type: 'accessor', value: 1},\n gpuAggregation: true,\n aggregation: 'SUM',\n\n // contour lines\n contours: {\n type: 'object',\n value: [{threshold: DEFAULT_THRESHOLD}],\n optional: true,\n compare: 3\n },\n\n zOffset: 0.005\n};\n\nconst POSITION_ATTRIBUTE_NAME = 'positions';\n\nconst DIMENSIONS = {\n data: {\n props: ['cellSize']\n },\n weights: {\n props: ['aggregation'],\n accessors: ['getWeight']\n }\n};\n\n/** All properties supported by ContourLayer. */\nexport type ContourLayerProps<DataT = any> = _ContourLayerProps<DataT> &\n GridAggregationLayerProps<DataT>;\n\n/** Properties added by ContourLayer. */\nexport type _ContourLayerProps<DataT> = {\n /**\n * Size of each cell in meters.\n * @default 1000\n */\n cellSize?: number;\n\n /**\n * When set to true, aggregation is performed on GPU, provided other conditions are met.\n * @default true\n */\n gpuAggregation?: boolean;\n\n /**\n * Defines the type of aggregation operation, valid values are 'SUM', 'MEAN', 'MIN' and 'MAX'.\n * @default 'SUM'\n */\n aggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';\n\n /**\n * Definition of contours to be drawn.\n * @default [{threshold: 1}]\n */\n contours: {\n /**\n * Isolines: `threshold` value must be a single `Number`, Isolines are generated based on this threshold value.\n *\n * Isobands: `threshold` value must be an Array of two `Number`s. Isobands are generated using `[threshold[0], threshold[1])` as threshold range, i.e area that has values `>= threshold[0]` and `< threshold[1]` are rendered with corresponding color. NOTE: `threshold[0]` is inclusive and `threshold[1]` is not inclusive.\n */\n threshold: number | number[];\n\n /**\n * RGBA color array to be used to render the contour.\n * @default [255, 255, 255, 255]\n */\n color?: Color;\n\n /**\n * Applicable for `Isoline`s only, width of the Isoline in pixels.\n * @default 1\n */\n strokeWidth?: number;\n\n /** Defines z order of the contour. */\n zIndex?: number;\n }[];\n\n /**\n * A very small z offset that is added for each vertex of a contour (Isoline or Isoband).\n * @default 0.005\n */\n zOffset?: number;\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 each object.\n * @default 1\n */\n getWeight?: Accessor<DataT, number>;\n};\n\n/** Aggregate data into iso-lines or iso-bands for a given threshold and cell size. */\nexport default class ContourLayer<\n DataT = any,\n ExtraPropsT extends {} = {}\n> extends GridAggregationLayer<DataT, ExtraPropsT & Required<_ContourLayerProps<DataT>>> {\n static layerName = 'ContourLayer';\n static defaultProps = defaultProps;\n\n initializeState(): void {\n super.initializeAggregationLayer({\n dimensions: DIMENSIONS\n });\n this.setState({\n contourData: {},\n projectPoints: false,\n weights: {\n count: {\n size: 1,\n operation: AGGREGATION_OPERATION.SUM\n }\n }\n });\n const attributeManager = this.getAttributeManager()!;\n attributeManager.add({\n [POSITION_ATTRIBUTE_NAME]: {\n size: 3,\n accessor: 'getPosition',\n type: GL.DOUBLE,\n fp64: this.use64bitPositions()\n },\n // this attribute is used in gpu aggregation path only\n count: {size: 3, accessor: 'getWeight'}\n });\n }\n\n updateState(opts: UpdateParameters<this>): void {\n super.updateState(opts);\n let contoursChanged = false;\n const {oldProps, props} = opts;\n const {aggregationDirty} = this.state;\n\n if (oldProps.contours !== props.contours || oldProps.zOffset !== props.zOffset) {\n contoursChanged = true;\n this._updateThresholdData(opts.props);\n }\n\n if (this.getNumInstances() > 0 && (aggregationDirty || contoursChanged)) {\n this._generateContours();\n }\n }\n\n renderLayers(): Layer[] {\n const {contourSegments, contourPolygons} = this.state.contourData;\n\n const LinesSubLayerClass = this.getSubLayerClass('lines', LineLayer);\n const BandsSubLayerClass = this.getSubLayerClass('bands', SolidPolygonLayer);\n\n // Contour lines layer\n const lineLayer =\n contourSegments &&\n contourSegments.length > 0 &&\n new LinesSubLayerClass(\n this.getSubLayerProps({\n id: 'lines'\n }),\n {\n data: this.state.contourData.contourSegments,\n getSourcePosition: d => d.start,\n getTargetPosition: d => d.end,\n getColor: d => d.contour.color || DEFAULT_COLOR,\n getWidth: d => d.contour.strokeWidth || DEFAULT_STROKE_WIDTH\n }\n );\n\n // Contour bands layer\n const bandsLayer =\n contourPolygons &&\n contourPolygons.length > 0 &&\n new BandsSubLayerClass(\n this.getSubLayerProps({\n id: 'bands'\n }),\n {\n data: this.state.contourData.contourPolygons,\n getPolygon: d => d.vertices,\n getFillColor: d => d.contour.color || DEFAULT_COLOR\n }\n );\n\n return [lineLayer, bandsLayer];\n }\n\n // Aggregation Overrides\n\n /* eslint-disable max-statements, complexity */\n updateAggregationState(opts) {\n const {props, oldProps} = opts;\n const {cellSize, coordinateSystem} = props;\n const {viewport} = this.context;\n const cellSizeChanged = oldProps.cellSize !== cellSize;\n let gpuAggregation = props.gpuAggregation;\n if (this.state.gpuAggregation !== props.gpuAggregation) {\n if (gpuAggregation && !GPUGridAggregator.isSupported(this.context.gl)) {\n log.warn('GPU Grid Aggregation not supported, falling back to CPU')();\n gpuAggregation = false;\n }\n }\n const gpuAggregationChanged = gpuAggregation !== this.state.gpuAggregation;\n this.setState({\n gpuAggregation\n });\n\n const {dimensions} = this.state;\n const positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME);\n const {data, weights} = dimensions;\n\n let {boundingBox} = this.state;\n if (positionsChanged) {\n boundingBox = getBoundingBox(this.getAttributes(), this.getNumInstances());\n this.setState({boundingBox});\n }\n if (positionsChanged || cellSizeChanged) {\n const {gridOffset, translation, width, height, numCol, numRow} = getGridParams(\n boundingBox,\n cellSize,\n viewport,\n coordinateSystem\n );\n this.allocateResources(numRow, numCol);\n this.setState({\n gridOffset,\n boundingBox,\n translation,\n posOffset: translation.slice(), // Used for CPU aggregation, to offset points\n gridOrigin: [-1 * translation[0], -1 * translation[1]],\n width,\n height,\n numCol,\n numRow\n });\n }\n\n const aggregationDataDirty =\n positionsChanged ||\n gpuAggregationChanged ||\n this.isAggregationDirty(opts, {\n dimension: data,\n compareAll: gpuAggregation // check for all (including extentions props) when using gpu aggregation\n });\n const aggregationWeightsDirty = this.isAggregationDirty(opts, {\n dimension: weights\n });\n\n if (aggregationWeightsDirty) {\n this._updateAccessors(opts);\n }\n if (aggregationDataDirty || aggregationWeightsDirty) {\n this._resetResults();\n }\n this.setState({\n aggregationDataDirty,\n aggregationWeightsDirty\n });\n }\n /* eslint-enable max-statements, complexity */\n\n // Private (Aggregation)\n\n private _updateAccessors(opts) {\n const {getWeight, aggregation, data} = opts.props;\n const {count} = this.state.weights;\n if (count) {\n count.getWeight = getWeight;\n count.operation = AGGREGATION_OPERATION[aggregation];\n }\n this.setState({getValue: getValueFunc(aggregation, getWeight, {data})});\n }\n\n private _resetResults() {\n const {count} = this.state.weights;\n if (count) {\n count.aggregationData = null;\n }\n }\n\n // Private (Contours)\n\n private _generateContours() {\n const {numCol, numRow, gridOrigin, gridOffset, thresholdData} = this.state;\n const {count} = this.state.weights;\n let {aggregationData} = count;\n if (!aggregationData) {\n aggregationData = count.aggregationBuffer.getData();\n count.aggregationData = aggregationData;\n }\n\n const {cellWeights} = GPUGridAggregator.getCellData({countsData: aggregationData});\n const contourData = generateContours({\n thresholdData,\n cellWeights,\n gridSize: [numCol, numRow],\n gridOrigin,\n cellSize: [gridOffset.xOffset, gridOffset.yOffset]\n });\n\n // contourData contains both iso-lines and iso-bands if requested.\n this.setState({contourData});\n }\n\n private _updateThresholdData(props) {\n const {contours, zOffset} = props;\n const count = contours.length;\n const thresholdData = new Array(count);\n for (let i = 0; i < count; i++) {\n const contour = contours[i];\n thresholdData[i] = {\n contour,\n zIndex: contour.zIndex || i,\n zOffset\n };\n }\n this.setState({thresholdData});\n }\n}\n"],"file":"contour-layer.js"}
1
+ {"version":3,"sources":["../../../src/contour-layer/contour-layer.ts"],"names":["DEFAULT_COLOR","DEFAULT_STROKE_WIDTH","DEFAULT_THRESHOLD","defaultProps","cellSize","type","min","max","value","getPosition","x","position","getWeight","gpuAggregation","aggregation","contours","threshold","optional","compare","zOffset","POSITION_ATTRIBUTE_NAME","DIMENSIONS","data","props","weights","accessors","ContourLayer","initializeState","dimensions","setState","contourData","projectPoints","count","size","operation","AGGREGATION_OPERATION","SUM","attributeManager","getAttributeManager","add","accessor","fp64","use64bitPositions","updateState","opts","contoursChanged","oldProps","aggregationDirty","state","_updateThresholdData","getNumInstances","_generateContours","renderLayers","contourSegments","contourPolygons","LinesSubLayerClass","getSubLayerClass","LineLayer","BandsSubLayerClass","SolidPolygonLayer","lineLayer","length","getSubLayerProps","id","getSourcePosition","d","start","getTargetPosition","end","getColor","contour","color","getWidth","strokeWidth","bandsLayer","getPolygon","vertices","getFillColor","updateAggregationState","coordinateSystem","viewport","context","cellSizeChanged","GPUGridAggregator","isSupported","gl","log","warn","gpuAggregationChanged","positionsChanged","isAttributeChanged","boundingBox","getAttributes","gridOffset","translation","width","height","numCol","numRow","allocateResources","posOffset","slice","gridOrigin","aggregationDataDirty","isAggregationDirty","dimension","compareAll","aggregationWeightsDirty","_updateAccessors","_resetResults","getValue","aggregationData","thresholdData","aggregationBuffer","getData","getCellData","countsData","cellWeights","gridSize","xOffset","yOffset","Array","i","zIndex","GridAggregationLayer","layerName"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA;;AACA;;AACA;;AAWA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,aAAa,GAAG,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,EAAgB,GAAhB,CAAtB;AACA,IAAMC,oBAAoB,GAAG,CAA7B;AACA,IAAMC,iBAAiB,GAAG,CAA1B;AAEA,IAAMC,YAA6C,GAAG;AAEpDC,EAAAA,QAAQ,EAAE;AAACC,IAAAA,IAAI,EAAE,QAAP;AAAiBC,IAAAA,GAAG,EAAE,CAAtB;AAAyBC,IAAAA,GAAG,EAAE,IAA9B;AAAoCC,IAAAA,KAAK,EAAE;AAA3C,GAF0C;AAGpDC,EAAAA,WAAW,EAAE;AAACJ,IAAAA,IAAI,EAAE,UAAP;AAAmBG,IAAAA,KAAK,EAAE,eAAAE,CAAC;A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AAd;AACD,G;;;EA1NOY,6B;;;AAHWlG,Y,CAIZmG,S,GAAY,c;AAJAnG,Y,CAKZvB,Y,GAAeA,Y","sourcesContent":["// Copyright (c) 2015 - 2018 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 GL from '@luma.gl/constants';\nimport {LineLayer, SolidPolygonLayer} from '@deck.gl/layers';\nimport {generateContours} from './contour-utils';\nimport {\n Accessor,\n AccessorFunction,\n Color,\n Layer,\n log,\n Position,\n UpdateParameters,\n DefaultProps\n} from '@deck.gl/core';\n\nimport GPUGridAggregator from '../utils/gpu-grid-aggregation/gpu-grid-aggregator';\nimport {AGGREGATION_OPERATION, getValueFunc} from '../utils/aggregation-operation-utils';\nimport {getBoundingBox, getGridParams} from '../utils/grid-aggregation-utils';\nimport GridAggregationLayer, {GridAggregationLayerProps} from '../grid-aggregation-layer';\n\nconst DEFAULT_COLOR = [255, 255, 255, 255];\nconst DEFAULT_STROKE_WIDTH = 1;\nconst DEFAULT_THRESHOLD = 1;\n\nconst defaultProps: DefaultProps<ContourLayerProps> = {\n // grid aggregation\n cellSize: {type: 'number', min: 1, max: 1000, value: 1000},\n getPosition: {type: 'accessor', value: x => x.position},\n getWeight: {type: 'accessor', value: 1},\n gpuAggregation: true,\n aggregation: 'SUM',\n\n // contour lines\n contours: {\n type: 'object',\n value: [{threshold: DEFAULT_THRESHOLD}],\n optional: true,\n compare: 3\n },\n\n zOffset: 0.005\n};\n\nconst POSITION_ATTRIBUTE_NAME = 'positions';\n\nconst DIMENSIONS = {\n data: {\n props: ['cellSize']\n },\n weights: {\n props: ['aggregation'],\n accessors: ['getWeight']\n }\n};\n\n/** All properties supported by ContourLayer. */\nexport type ContourLayerProps<DataT = any> = _ContourLayerProps<DataT> &\n GridAggregationLayerProps<DataT>;\n\n/** Properties added by ContourLayer. */\nexport type _ContourLayerProps<DataT> = {\n /**\n * Size of each cell in meters.\n * @default 1000\n */\n cellSize?: number;\n\n /**\n * When set to true, aggregation is performed on GPU, provided other conditions are met.\n * @default true\n */\n gpuAggregation?: boolean;\n\n /**\n * Defines the type of aggregation operation, valid values are 'SUM', 'MEAN', 'MIN' and 'MAX'.\n * @default 'SUM'\n */\n aggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';\n\n /**\n * Definition of contours to be drawn.\n * @default [{threshold: 1}]\n */\n contours: {\n /**\n * Isolines: `threshold` value must be a single `Number`, Isolines are generated based on this threshold value.\n *\n * Isobands: `threshold` value must be an Array of two `Number`s. Isobands are generated using `[threshold[0], threshold[1])` as threshold range, i.e area that has values `>= threshold[0]` and `< threshold[1]` are rendered with corresponding color. NOTE: `threshold[0]` is inclusive and `threshold[1]` is not inclusive.\n */\n threshold: number | number[];\n\n /**\n * RGBA color array to be used to render the contour.\n * @default [255, 255, 255, 255]\n */\n color?: Color;\n\n /**\n * Applicable for `Isoline`s only, width of the Isoline in pixels.\n * @default 1\n */\n strokeWidth?: number;\n\n /** Defines z order of the contour. */\n zIndex?: number;\n }[];\n\n /**\n * A very small z offset that is added for each vertex of a contour (Isoline or Isoband).\n * @default 0.005\n */\n zOffset?: number;\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 each object.\n * @default 1\n */\n getWeight?: Accessor<DataT, number>;\n};\n\n/** Aggregate data into iso-lines or iso-bands for a given threshold and cell size. */\nexport default class ContourLayer<\n DataT = any,\n ExtraPropsT extends {} = {}\n> extends GridAggregationLayer<DataT, ExtraPropsT & Required<_ContourLayerProps<DataT>>> {\n static layerName = 'ContourLayer';\n static defaultProps = defaultProps;\n\n initializeState(): void {\n super.initializeAggregationLayer({\n dimensions: DIMENSIONS\n });\n this.setState({\n contourData: {},\n projectPoints: false,\n weights: {\n count: {\n size: 1,\n operation: AGGREGATION_OPERATION.SUM\n }\n }\n });\n const attributeManager = this.getAttributeManager()!;\n attributeManager.add({\n [POSITION_ATTRIBUTE_NAME]: {\n size: 3,\n accessor: 'getPosition',\n type: GL.DOUBLE,\n fp64: this.use64bitPositions()\n },\n // this attribute is used in gpu aggregation path only\n count: {size: 3, accessor: 'getWeight'}\n });\n }\n\n updateState(opts: UpdateParameters<this>): void {\n super.updateState(opts);\n let contoursChanged = false;\n const {oldProps, props} = opts;\n const {aggregationDirty} = this.state;\n\n if (oldProps.contours !== props.contours || oldProps.zOffset !== props.zOffset) {\n contoursChanged = true;\n this._updateThresholdData(opts.props);\n }\n\n if (this.getNumInstances() > 0 && (aggregationDirty || contoursChanged)) {\n this._generateContours();\n }\n }\n\n renderLayers(): Layer[] {\n const {contourSegments, contourPolygons} = this.state.contourData;\n\n const LinesSubLayerClass = this.getSubLayerClass('lines', LineLayer);\n const BandsSubLayerClass = this.getSubLayerClass('bands', SolidPolygonLayer);\n\n // Contour lines layer\n const lineLayer =\n contourSegments &&\n contourSegments.length > 0 &&\n new LinesSubLayerClass(\n this.getSubLayerProps({\n id: 'lines'\n }),\n {\n data: this.state.contourData.contourSegments,\n getSourcePosition: d => d.start,\n getTargetPosition: d => d.end,\n getColor: d => d.contour.color || DEFAULT_COLOR,\n getWidth: d => d.contour.strokeWidth || DEFAULT_STROKE_WIDTH\n }\n );\n\n // Contour bands layer\n const bandsLayer =\n contourPolygons &&\n contourPolygons.length > 0 &&\n new BandsSubLayerClass(\n this.getSubLayerProps({\n id: 'bands'\n }),\n {\n data: this.state.contourData.contourPolygons,\n getPolygon: d => d.vertices,\n getFillColor: d => d.contour.color || DEFAULT_COLOR\n }\n );\n\n return [lineLayer, bandsLayer];\n }\n\n // Aggregation Overrides\n\n /* eslint-disable max-statements, complexity */\n updateAggregationState(opts) {\n const {props, oldProps} = opts;\n const {cellSize, coordinateSystem} = props;\n const {viewport} = this.context;\n const cellSizeChanged = oldProps.cellSize !== cellSize;\n let gpuAggregation = props.gpuAggregation;\n if (this.state.gpuAggregation !== props.gpuAggregation) {\n if (gpuAggregation && !GPUGridAggregator.isSupported(this.context.gl)) {\n log.warn('GPU Grid Aggregation not supported, falling back to CPU')();\n gpuAggregation = false;\n }\n }\n const gpuAggregationChanged = gpuAggregation !== this.state.gpuAggregation;\n this.setState({\n gpuAggregation\n });\n\n const {dimensions} = this.state;\n const positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME);\n const {data, weights} = dimensions;\n\n let {boundingBox} = this.state;\n if (positionsChanged) {\n boundingBox = getBoundingBox(this.getAttributes(), this.getNumInstances());\n this.setState({boundingBox});\n }\n if (positionsChanged || cellSizeChanged) {\n const {gridOffset, translation, width, height, numCol, numRow} = getGridParams(\n boundingBox,\n cellSize,\n viewport,\n coordinateSystem\n );\n this.allocateResources(numRow, numCol);\n this.setState({\n gridOffset,\n boundingBox,\n translation,\n posOffset: translation.slice(), // Used for CPU aggregation, to offset points\n gridOrigin: [-1 * translation[0], -1 * translation[1]],\n width,\n height,\n numCol,\n numRow\n });\n }\n\n const aggregationDataDirty =\n positionsChanged ||\n gpuAggregationChanged ||\n this.isAggregationDirty(opts, {\n dimension: data,\n compareAll: gpuAggregation // check for all (including extentions props) when using gpu aggregation\n });\n const aggregationWeightsDirty = this.isAggregationDirty(opts, {\n dimension: weights\n });\n\n if (aggregationWeightsDirty) {\n this._updateAccessors(opts);\n }\n if (aggregationDataDirty || aggregationWeightsDirty) {\n this._resetResults();\n }\n this.setState({\n aggregationDataDirty,\n aggregationWeightsDirty\n });\n }\n /* eslint-enable max-statements, complexity */\n\n // Private (Aggregation)\n\n private _updateAccessors(opts) {\n const {getWeight, aggregation, data} = opts.props;\n const {count} = this.state.weights;\n if (count) {\n count.getWeight = getWeight;\n count.operation = AGGREGATION_OPERATION[aggregation];\n }\n this.setState({getValue: getValueFunc(aggregation, getWeight, {data})});\n }\n\n private _resetResults() {\n const {count} = this.state.weights;\n if (count) {\n count.aggregationData = null;\n }\n }\n\n // Private (Contours)\n\n private _generateContours() {\n const {numCol, numRow, gridOrigin, gridOffset, thresholdData} = this.state;\n const {count} = this.state.weights;\n let {aggregationData} = count;\n if (!aggregationData) {\n aggregationData = count.aggregationBuffer.getData();\n count.aggregationData = aggregationData;\n }\n\n const {cellWeights} = GPUGridAggregator.getCellData({countsData: aggregationData});\n const contourData = generateContours({\n thresholdData,\n cellWeights,\n gridSize: [numCol, numRow],\n gridOrigin,\n cellSize: [gridOffset.xOffset, gridOffset.yOffset]\n });\n\n // contourData contains both iso-lines and iso-bands if requested.\n this.setState({contourData});\n }\n\n private _updateThresholdData(props) {\n const {contours, zOffset} = props;\n const count = contours.length;\n const thresholdData = new Array(count);\n for (let i = 0; i < count; i++) {\n const contour = contours[i];\n thresholdData[i] = {\n contour,\n zIndex: contour.zIndex || i,\n zOffset\n };\n }\n this.setState({thresholdData});\n }\n}\n"],"file":"contour-layer.js"}