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