@deck.gl/aggregation-layers 8.6.0-alpha.1 → 8.6.0-beta.1
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/dist.dev.js +3240 -527
- package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +1 -1
- package/dist/es5/heatmap-layer/heatmap-layer.js +44 -18
- package/dist/es5/heatmap-layer/heatmap-layer.js.map +1 -1
- package/dist/es5/hexagon-layer/hexagon-layer.js +21 -55
- package/dist/es5/hexagon-layer/hexagon-layer.js.map +1 -1
- package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +1 -1
- package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js.map +1 -1
- package/dist/esm/heatmap-layer/heatmap-layer.js +44 -16
- package/dist/esm/heatmap-layer/heatmap-layer.js.map +1 -1
- package/dist/esm/hexagon-layer/hexagon-layer.js +16 -56
- package/dist/esm/hexagon-layer/hexagon-layer.js.map +1 -1
- package/dist.min.js +1 -1
- package/package.json +4 -4
- package/src/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +1 -1
- package/src/heatmap-layer/heatmap-layer.js +37 -25
- package/src/hexagon-layer/hexagon-layer.js +23 -41
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@deck.gl/aggregation-layers",
|
|
3
3
|
"description": "deck.gl layers that aggregate the input data into alternative representations",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "8.6.0-
|
|
5
|
+
"version": "8.6.0-beta.1",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"prepublishOnly": "npm run build-bundle && npm run build-bundle -- --env.dev"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@luma.gl/shadertools": "^8.5.
|
|
33
|
-
"@math.gl/web-mercator": "^3.5.
|
|
32
|
+
"@luma.gl/shadertools": "^8.5.10",
|
|
33
|
+
"@math.gl/web-mercator": "^3.5.4",
|
|
34
34
|
"d3-hexbin": "^0.2.1"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@deck.gl/core": "^8.0.0",
|
|
38
38
|
"@deck.gl/layers": "^8.0.0"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "ce689d7ceb9a732d8b83d959581147b36f416d38"
|
|
41
41
|
}
|
|
@@ -95,7 +95,6 @@ float linearScale(vec2 domain, vec2 range, float value) {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
void main(void) {
|
|
98
|
-
|
|
99
98
|
vec2 clrDomain = colorDomainValid ? colorDomain : vec2(colorData.maxMinCount.a, colorData.maxMinCount.r);
|
|
100
99
|
vec4 color = quantizeScale(clrDomain, colorRange, colors.r);
|
|
101
100
|
|
|
@@ -121,6 +120,7 @@ void main(void) {
|
|
|
121
120
|
|
|
122
121
|
vec3 centroidPosition = vec3(instancePositionXFP64[0], instancePositionYFP64[0], elevation);
|
|
123
122
|
vec3 centroidPosition64Low = vec3(instancePositionXFP64[1], instancePositionYFP64[1], 0.0);
|
|
123
|
+
geometry.worldPosition = centroidPosition;
|
|
124
124
|
vec3 pos = vec3(project_size(positions.xy + offset) * dotRadius, 0.);
|
|
125
125
|
|
|
126
126
|
// Set color to be rendered to picking fbo (also used to check for selection highlight).
|
|
@@ -29,12 +29,7 @@ import {
|
|
|
29
29
|
getTextureParams
|
|
30
30
|
} from './heatmap-layer-utils';
|
|
31
31
|
import {Buffer, Texture2D, Transform, getParameters, FEATURES, hasFeatures} from '@luma.gl/core';
|
|
32
|
-
import {
|
|
33
|
-
AttributeManager,
|
|
34
|
-
COORDINATE_SYSTEM,
|
|
35
|
-
log,
|
|
36
|
-
_mergeShaders as mergeShaders
|
|
37
|
-
} from '@deck.gl/core';
|
|
32
|
+
import {AttributeManager, COORDINATE_SYSTEM, log} from '@deck.gl/core';
|
|
38
33
|
import TriangleLayer from './triangle-layer';
|
|
39
34
|
import AggregationLayer from '../aggregation-layer';
|
|
40
35
|
import {defaultColorRange, colorRangeToFlatArray} from '../utils/color-utils';
|
|
@@ -44,8 +39,6 @@ import vs_max from './max-vs.glsl';
|
|
|
44
39
|
import fs_max from './max-fs.glsl';
|
|
45
40
|
|
|
46
41
|
const RESOLUTION = 2; // (number of common space pixels) / (number texels)
|
|
47
|
-
const SIZE_2K = 2048;
|
|
48
|
-
const ZOOM_DEBOUNCE = 500; // milliseconds
|
|
49
42
|
const TEXTURE_OPTIONS = {
|
|
50
43
|
mipmaps: false,
|
|
51
44
|
parameters: {
|
|
@@ -71,7 +64,9 @@ const defaultProps = {
|
|
|
71
64
|
threshold: {type: 'number', min: 0, max: 1, value: 0.05},
|
|
72
65
|
colorDomain: {type: 'array', value: null, optional: true},
|
|
73
66
|
// 'SUM' or 'MEAN'
|
|
74
|
-
aggregation: 'SUM'
|
|
67
|
+
aggregation: 'SUM',
|
|
68
|
+
weightsTextureSize: {type: 'number', min: 128, max: 2048, value: 2048},
|
|
69
|
+
debounceTimeout: {type: 'number', min: 0, max: 1000, value: 500}
|
|
75
70
|
};
|
|
76
71
|
|
|
77
72
|
const REQUIRED_FEATURES = [
|
|
@@ -112,11 +107,16 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
112
107
|
return;
|
|
113
108
|
}
|
|
114
109
|
super.updateState(opts);
|
|
110
|
+
this._updateHeatmapState(opts);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
_updateHeatmapState(opts) {
|
|
115
114
|
const {props, oldProps} = opts;
|
|
116
115
|
const changeFlags = this._getChangeFlags(opts);
|
|
117
116
|
|
|
118
|
-
if (changeFlags.viewportChanged) {
|
|
119
|
-
|
|
117
|
+
if (changeFlags.dataChanged || changeFlags.viewportChanged) {
|
|
118
|
+
// if data is changed, do not debounce and immediately update the weight map
|
|
119
|
+
changeFlags.boundsChanged = this._updateBounds(changeFlags.dataChanged);
|
|
120
120
|
this._updateTextureRenderingBounds();
|
|
121
121
|
}
|
|
122
122
|
|
|
@@ -139,7 +139,6 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
139
139
|
|
|
140
140
|
this.setState({zoom: opts.context.viewport.zoom});
|
|
141
141
|
}
|
|
142
|
-
/* eslint-enable max-statements,complexity */
|
|
143
142
|
|
|
144
143
|
renderLayers() {
|
|
145
144
|
if (!this.state.supported) {
|
|
@@ -262,7 +261,9 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
262
261
|
|
|
263
262
|
_setupTextureParams() {
|
|
264
263
|
const {gl} = this.context;
|
|
265
|
-
const
|
|
264
|
+
const {weightsTextureSize} = this.props;
|
|
265
|
+
|
|
266
|
+
const textureSize = Math.min(weightsTextureSize, getParameters(gl, gl.MAX_TEXTURE_SIZE));
|
|
266
267
|
const floatTargetSupport = hasFeatures(gl, FEATURES.COLOR_ATTACHMENT_RGBA32F);
|
|
267
268
|
const {format, type} = getTextureParams({gl, floatTargetSupport});
|
|
268
269
|
const weightsScale = floatTargetSupport ? 1 : 1 / 255;
|
|
@@ -276,18 +277,25 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
276
277
|
}
|
|
277
278
|
}
|
|
278
279
|
|
|
279
|
-
|
|
280
|
+
getShaders(type) {
|
|
281
|
+
return super.getShaders(
|
|
282
|
+
type === 'max-weights-transform'
|
|
283
|
+
? {
|
|
284
|
+
vs: vs_max,
|
|
285
|
+
_fs: fs_max
|
|
286
|
+
}
|
|
287
|
+
: {
|
|
288
|
+
vs: weights_vs,
|
|
289
|
+
_fs: weights_fs
|
|
290
|
+
}
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
_createWeightsTransform(shaders = {}) {
|
|
280
295
|
const {gl} = this.context;
|
|
281
296
|
let {weightsTransform} = this.state;
|
|
282
297
|
const {weightsTexture} = this.state;
|
|
283
298
|
weightsTransform?.delete();
|
|
284
|
-
const shaders = mergeShaders(
|
|
285
|
-
{
|
|
286
|
-
vs: weights_vs,
|
|
287
|
-
_fs: weights_fs
|
|
288
|
-
},
|
|
289
|
-
shaderOptions
|
|
290
|
-
);
|
|
291
299
|
|
|
292
300
|
weightsTransform = new Transform(gl, {
|
|
293
301
|
id: `${this.id}-weights-transform`,
|
|
@@ -303,7 +311,11 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
303
311
|
const {gl} = this.context;
|
|
304
312
|
this._createTextures();
|
|
305
313
|
const {textureSize, weightsTexture, maxWeightsTexture} = this.state;
|
|
306
|
-
|
|
314
|
+
|
|
315
|
+
const weightsTransformShaders = this.getShaders('weights-transform');
|
|
316
|
+
this._createWeightsTransform(weightsTransformShaders);
|
|
317
|
+
|
|
318
|
+
const maxWeightsTransformShaders = this.getShaders('max-weights-transform');
|
|
307
319
|
const maxWeightTransform = new Transform(gl, {
|
|
308
320
|
id: `${this.id}-max-weights-transform`,
|
|
309
321
|
_sourceTextures: {
|
|
@@ -311,8 +323,7 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
311
323
|
},
|
|
312
324
|
_targetTexture: maxWeightsTexture,
|
|
313
325
|
_targetTextureVarying: 'outTexture',
|
|
314
|
-
|
|
315
|
-
_fs: fs_max,
|
|
326
|
+
...maxWeightsTransformShaders,
|
|
316
327
|
elementCount: textureSize * textureSize
|
|
317
328
|
});
|
|
318
329
|
|
|
@@ -496,6 +507,7 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
496
507
|
|
|
497
508
|
_debouncedUpdateWeightmap(fromTimer = false) {
|
|
498
509
|
let {updateTimer} = this.state;
|
|
510
|
+
const {debounceTimeout} = this.props;
|
|
499
511
|
|
|
500
512
|
if (fromTimer) {
|
|
501
513
|
updateTimer = null;
|
|
@@ -506,7 +518,7 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
506
518
|
} else {
|
|
507
519
|
this.setState({isWeightMapDirty: false});
|
|
508
520
|
clearTimeout(updateTimer);
|
|
509
|
-
updateTimer = setTimeout(this._debouncedUpdateWeightmap.bind(this, true),
|
|
521
|
+
updateTimer = setTimeout(this._debouncedUpdateWeightmap.bind(this, true), debounceTimeout);
|
|
510
522
|
}
|
|
511
523
|
|
|
512
524
|
this.setState({updateTimer});
|
|
@@ -66,9 +66,6 @@ const defaultProps = {
|
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
export default class HexagonLayer extends AggregationLayer {
|
|
69
|
-
shouldUpdateState({changeFlags}) {
|
|
70
|
-
return changeFlags.somethingChanged;
|
|
71
|
-
}
|
|
72
69
|
initializeState() {
|
|
73
70
|
const cpuAggregator = new CPUAggregator({
|
|
74
71
|
getAggregator: props => props.hexagonAggregator,
|
|
@@ -78,7 +75,7 @@ export default class HexagonLayer extends AggregationLayer {
|
|
|
78
75
|
this.state = {
|
|
79
76
|
cpuAggregator,
|
|
80
77
|
aggregatorState: cpuAggregator.state,
|
|
81
|
-
|
|
78
|
+
vertices: null
|
|
82
79
|
};
|
|
83
80
|
const attributeManager = this.getAttributeManager();
|
|
84
81
|
attributeManager.add({
|
|
@@ -90,47 +87,25 @@ export default class HexagonLayer extends AggregationLayer {
|
|
|
90
87
|
|
|
91
88
|
updateState(opts) {
|
|
92
89
|
super.updateState(opts);
|
|
93
|
-
const {cpuAggregator, hexagonVertices: oldVertices} = this.state;
|
|
94
90
|
|
|
95
91
|
if (opts.changeFlags.propsOrDataChanged) {
|
|
96
|
-
this.
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
viewport: this.context.viewport,
|
|
100
|
-
attributes: this.getAttributes()
|
|
101
|
-
})
|
|
92
|
+
const aggregatorState = this.state.cpuAggregator.updateState(opts, {
|
|
93
|
+
viewport: this.context.viewport,
|
|
94
|
+
attributes: this.getAttributes()
|
|
102
95
|
});
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const {hexagonVertices} = cpuAggregator.state.layerData || {};
|
|
108
|
-
|
|
109
|
-
if (hexagonVertices && oldVertices !== hexagonVertices) {
|
|
110
|
-
const vertices = this.convertLatLngToMeterOffset(hexagonVertices);
|
|
111
|
-
if (vertices) {
|
|
96
|
+
if (this.state.aggregatorState.layerData !== aggregatorState.layerData) {
|
|
97
|
+
// if user provided custom aggregator and returns hexagonVertices,
|
|
98
|
+
// Need to recalculate radius and angle based on vertices
|
|
99
|
+
const {hexagonVertices} = aggregatorState.layerData || {};
|
|
112
100
|
this.setState({
|
|
113
|
-
hexagonVertices
|
|
114
|
-
vertices
|
|
101
|
+
vertices: hexagonVertices && this.convertLatLngToMeterOffset(hexagonVertices)
|
|
115
102
|
});
|
|
116
103
|
}
|
|
117
|
-
} else {
|
|
118
|
-
// update radius angle by viewport
|
|
119
|
-
this.updateRadiusAngle();
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
updateRadiusAngle(vertices) {
|
|
124
|
-
const {viewport} = this.context;
|
|
125
|
-
const {unitsPerMeter} = viewport.getDistanceScales();
|
|
126
|
-
const {cpuAggregator} = this.state;
|
|
127
|
-
|
|
128
|
-
if (cpuAggregator.state.layerData && cpuAggregator.state.layerData.radiusCommon) {
|
|
129
|
-
const {radiusCommon} = cpuAggregator.state.layerData;
|
|
130
|
-
const radius = radiusCommon / unitsPerMeter[0];
|
|
131
104
|
|
|
132
|
-
|
|
133
|
-
|
|
105
|
+
this.setState({
|
|
106
|
+
// make a copy of the internal state of cpuAggregator for testing
|
|
107
|
+
aggregatorState
|
|
108
|
+
});
|
|
134
109
|
}
|
|
135
110
|
}
|
|
136
111
|
|
|
@@ -183,12 +158,19 @@ export default class HexagonLayer extends AggregationLayer {
|
|
|
183
158
|
|
|
184
159
|
renderLayers() {
|
|
185
160
|
const {elevationScale, extruded, coverage, material, transitions} = this.props;
|
|
186
|
-
const {
|
|
161
|
+
const {aggregatorState, vertices} = this.state;
|
|
187
162
|
|
|
188
163
|
const SubLayerClass = this.getSubLayerClass('hexagon-cell', ColumnLayer);
|
|
189
164
|
const updateTriggers = this._getSublayerUpdateTriggers();
|
|
190
165
|
|
|
191
|
-
const geometry = vertices
|
|
166
|
+
const geometry = vertices
|
|
167
|
+
? {vertices, radius: 1}
|
|
168
|
+
: {
|
|
169
|
+
// default geometry
|
|
170
|
+
radius: aggregatorState.layerData.radiusCommon || 1,
|
|
171
|
+
radiusUnits: 'common',
|
|
172
|
+
angle: 90
|
|
173
|
+
};
|
|
192
174
|
return new SubLayerClass(
|
|
193
175
|
{
|
|
194
176
|
...geometry,
|
|
@@ -210,7 +192,7 @@ export default class HexagonLayer extends AggregationLayer {
|
|
|
210
192
|
updateTriggers
|
|
211
193
|
}),
|
|
212
194
|
{
|
|
213
|
-
data:
|
|
195
|
+
data: aggregatorState.layerData.data
|
|
214
196
|
}
|
|
215
197
|
);
|
|
216
198
|
}
|