@deck.gl/aggregation-layers 8.8.0-alpha.6 → 8.8.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 +757 -645
- package/dist/es5/aggregation-layer.js +19 -7
- package/dist/es5/aggregation-layer.js.map +1 -1
- package/dist/es5/contour-layer/contour-layer.js +5 -5
- package/dist/es5/contour-layer/contour-layer.js.map +1 -1
- package/dist/es5/contour-layer/contour-utils.js +1 -1
- package/dist/es5/contour-layer/contour-utils.js.map +1 -1
- package/dist/es5/contour-layer/marching-squares-codes.js.map +1 -1
- package/dist/es5/contour-layer/marching-squares.js.map +1 -1
- package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +5 -3
- package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
- package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +1 -1
- package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +8 -8
- package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
- package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +12 -12
- package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
- package/dist/es5/grid-aggregation-layer.js +25 -12
- package/dist/es5/grid-aggregation-layer.js.map +1 -1
- package/dist/es5/grid-layer/grid-layer.js +18 -9
- package/dist/es5/grid-layer/grid-layer.js.map +1 -1
- package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +1 -1
- package/dist/es5/heatmap-layer/heatmap-layer.js +17 -6
- package/dist/es5/heatmap-layer/heatmap-layer.js.map +1 -1
- package/dist/es5/heatmap-layer/max-vs.glsl.js +1 -1
- package/dist/es5/heatmap-layer/triangle-layer-fragment.glsl.js +1 -1
- package/dist/es5/heatmap-layer/triangle-layer-vertex.glsl.js +1 -1
- package/dist/es5/heatmap-layer/triangle-layer.js +7 -7
- package/dist/es5/heatmap-layer/triangle-layer.js.map +1 -1
- package/dist/es5/heatmap-layer/weights-fs.glsl.js +1 -1
- package/dist/es5/heatmap-layer/weights-vs.glsl.js +1 -1
- package/dist/es5/hexagon-layer/hexagon-layer.js +16 -5
- package/dist/es5/hexagon-layer/hexagon-layer.js.map +1 -1
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +26 -19
- package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
- package/dist/es5/screen-grid-layer/screen-grid-layer-vertex.glsl.js +1 -1
- package/dist/es5/screen-grid-layer/screen-grid-layer.js +18 -8
- package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +1 -1
- package/dist/es5/types.js +2 -0
- package/dist/es5/types.js.map +1 -0
- package/dist/es5/utils/bin-sorter.js +9 -0
- package/dist/es5/utils/bin-sorter.js.map +1 -1
- package/dist/esm/aggregation-layer.js +12 -5
- package/dist/esm/aggregation-layer.js.map +1 -1
- package/dist/esm/contour-layer/contour-layer.js +6 -3
- package/dist/esm/contour-layer/contour-layer.js.map +1 -1
- package/dist/esm/contour-layer/contour-utils.js +1 -1
- package/dist/esm/contour-layer/contour-utils.js.map +1 -1
- package/dist/esm/contour-layer/marching-squares-codes.js.map +1 -1
- package/dist/esm/contour-layer/marching-squares.js.map +1 -1
- package/dist/esm/cpu-grid-layer/cpu-grid-layer.js +6 -3
- package/dist/esm/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
- package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.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/gpu-grid-layer/gpu-grid-cell-layer.js +8 -6
- package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
- package/dist/esm/gpu-grid-layer/gpu-grid-layer.js +11 -9
- package/dist/esm/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
- package/dist/esm/grid-aggregation-layer.js +13 -5
- package/dist/esm/grid-aggregation-layer.js.map +1 -1
- package/dist/esm/grid-layer/grid-layer.js +15 -8
- package/dist/esm/grid-layer/grid-layer.js.map +1 -1
- package/dist/esm/heatmap-layer/heatmap-layer-utils.js.map +1 -1
- package/dist/esm/heatmap-layer/heatmap-layer.js +22 -13
- package/dist/esm/heatmap-layer/heatmap-layer.js.map +1 -1
- package/dist/esm/heatmap-layer/max-fs.glsl.js.map +1 -1
- package/dist/esm/heatmap-layer/max-vs.glsl.js +1 -1
- package/dist/esm/heatmap-layer/max-vs.glsl.js.map +1 -1
- package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js +1 -1
- package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js.map +1 -1
- package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js +1 -1
- package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js.map +1 -1
- package/dist/esm/heatmap-layer/triangle-layer.js +6 -5
- package/dist/esm/heatmap-layer/triangle-layer.js.map +1 -1
- package/dist/esm/heatmap-layer/weights-fs.glsl.js +1 -1
- package/dist/esm/heatmap-layer/weights-fs.glsl.js.map +1 -1
- package/dist/esm/heatmap-layer/weights-vs.glsl.js +1 -1
- package/dist/esm/heatmap-layer/weights-vs.glsl.js.map +1 -1
- package/dist/esm/hexagon-layer/hexagon-layer.js +11 -2
- package/dist/esm/hexagon-layer/hexagon-layer.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js +16 -10
- package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
- package/dist/esm/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +1 -1
- package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js +1 -1
- package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +1 -1
- package/dist/esm/screen-grid-layer/screen-grid-layer.js +15 -7
- package/dist/esm/screen-grid-layer/screen-grid-layer.js.map +1 -1
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils/bin-sorter.js +16 -0
- package/dist/esm/utils/bin-sorter.js.map +1 -1
- package/dist.min.js +1 -1
- package/package.json +6 -4
- package/src/{aggregation-layer.js → aggregation-layer.ts} +32 -15
- package/src/contour-layer/{contour-layer.js → contour-layer.ts} +95 -15
- package/src/contour-layer/{contour-utils.js → contour-utils.ts} +11 -5
- package/src/contour-layer/{marching-squares-codes.js → marching-squares-codes.ts} +0 -0
- package/src/contour-layer/{marching-squares.js → marching-squares.ts} +6 -6
- package/src/cpu-grid-layer/cpu-grid-layer.ts +310 -0
- package/src/gpu-grid-layer/{gpu-grid-cell-layer-fragment.glsl.js → gpu-grid-cell-layer-fragment.glsl.ts} +0 -0
- package/src/gpu-grid-layer/{gpu-grid-cell-layer-vertex.glsl.js → gpu-grid-cell-layer-vertex.glsl.ts} +0 -0
- package/src/gpu-grid-layer/{gpu-grid-cell-layer.js → gpu-grid-cell-layer.ts} +22 -14
- package/src/gpu-grid-layer/{gpu-grid-layer.js → gpu-grid-layer.ts} +122 -17
- package/src/{grid-aggregation-layer.js → grid-aggregation-layer.ts} +25 -13
- package/src/grid-layer/{grid-layer.js → grid-layer.ts} +38 -13
- package/src/heatmap-layer/{heatmap-layer-utils.js → heatmap-layer-utils.ts} +5 -5
- package/src/heatmap-layer/{heatmap-layer.js → heatmap-layer.ts} +138 -29
- package/src/heatmap-layer/{max-fs.glsl.js → max-fs.glsl.ts} +0 -0
- package/src/heatmap-layer/{max-vs.glsl.js → max-vs.glsl.ts} +0 -0
- package/src/heatmap-layer/{triangle-layer-fragment.glsl.js → triangle-layer-fragment.glsl.ts} +0 -0
- package/src/heatmap-layer/{triangle-layer-vertex.glsl.js → triangle-layer-vertex.glsl.ts} +0 -0
- package/src/heatmap-layer/{triangle-layer.js → triangle-layer.ts} +20 -10
- package/src/heatmap-layer/{weights-fs.glsl.js → weights-fs.glsl.ts} +0 -0
- package/src/heatmap-layer/{weights-vs.glsl.js → weights-vs.glsl.ts} +0 -0
- package/src/hexagon-layer/{hexagon-layer.js → hexagon-layer.ts} +174 -9
- package/src/index.ts +9 -0
- package/src/screen-grid-layer/{screen-grid-cell-layer.js → screen-grid-cell-layer.ts} +31 -14
- package/src/screen-grid-layer/{screen-grid-layer-fragment.glsl.js → screen-grid-layer-fragment.glsl.ts} +0 -0
- package/src/screen-grid-layer/{screen-grid-layer-vertex.glsl.js → screen-grid-layer-vertex.glsl.ts} +0 -0
- package/src/screen-grid-layer/{screen-grid-layer.js → screen-grid-layer.ts} +117 -15
- package/src/types.ts +10 -0
- package/src/utils/{bin-sorter.js → bin-sorter.ts} +26 -11
- package/typed/aggregation-layer.d.ts +16 -11
- package/typed/aggregation-layer.d.ts.map +1 -1
- package/typed/aggregation-layer.js +151 -0
- package/typed/contour-layer/contour-layer.d.ts +92 -36
- package/typed/contour-layer/contour-layer.d.ts.map +1 -1
- package/typed/contour-layer/contour-layer.js +234 -0
- package/typed/contour-layer/contour-utils.d.ts +8 -9
- package/typed/contour-layer/contour-utils.d.ts.map +1 -1
- package/typed/contour-layer/contour-utils.js +64 -0
- package/typed/contour-layer/marching-squares-codes.d.ts +2 -2
- package/typed/contour-layer/marching-squares-codes.d.ts.map +1 -1
- package/typed/contour-layer/marching-squares-codes.js +337 -0
- package/typed/contour-layer/marching-squares.d.ts +6 -6
- package/typed/contour-layer/marching-squares.d.ts.map +1 -1
- package/typed/contour-layer/marching-squares.js +147 -0
- package/typed/cpu-grid-layer/cpu-grid-layer.d.ts +221 -126
- package/typed/cpu-grid-layer/cpu-grid-layer.d.ts.map +1 -1
- package/typed/cpu-grid-layer/cpu-grid-layer.js +129 -0
- package/typed/cpu-grid-layer/grid-aggregator.js +141 -0
- package/typed/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts +1 -1
- package/typed/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts.map +1 -1
- package/typed/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +34 -0
- package/typed/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts +1 -1
- package/typed/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts.map +1 -1
- package/typed/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +141 -0
- package/typed/gpu-grid-layer/gpu-grid-cell-layer.d.ts +67 -81
- package/typed/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +1 -1
- package/typed/gpu-grid-layer/gpu-grid-cell-layer.js +143 -0
- package/typed/gpu-grid-layer/gpu-grid-layer.d.ts +131 -62
- package/typed/gpu-grid-layer/gpu-grid-layer.d.ts.map +1 -1
- package/typed/gpu-grid-layer/gpu-grid-layer.js +289 -0
- package/typed/grid-aggregation-layer.d.ts +19 -6
- package/typed/grid-aggregation-layer.d.ts.map +1 -1
- package/typed/grid-aggregation-layer.js +172 -0
- package/typed/grid-layer/grid-layer.d.ts +109 -90
- package/typed/grid-layer/grid-layer.d.ts.map +1 -1
- package/typed/grid-layer/grid-layer.js +60 -0
- package/typed/heatmap-layer/heatmap-layer-utils.d.ts +6 -6
- package/typed/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -1
- package/typed/heatmap-layer/heatmap-layer-utils.js +78 -0
- package/typed/heatmap-layer/heatmap-layer.d.ts +147 -82
- package/typed/heatmap-layer/heatmap-layer.d.ts.map +1 -1
- package/typed/heatmap-layer/heatmap-layer.js +478 -0
- package/typed/heatmap-layer/max-fs.glsl.d.ts +1 -1
- package/typed/heatmap-layer/max-fs.glsl.d.ts.map +1 -1
- package/typed/heatmap-layer/max-fs.glsl.js +7 -0
- package/typed/heatmap-layer/max-vs.glsl.d.ts +1 -1
- package/typed/heatmap-layer/max-vs.glsl.d.ts.map +1 -1
- package/typed/heatmap-layer/max-vs.glsl.js +12 -0
- package/typed/heatmap-layer/triangle-layer-fragment.glsl.d.ts +1 -1
- package/typed/heatmap-layer/triangle-layer-fragment.glsl.d.ts.map +1 -1
- package/typed/heatmap-layer/triangle-layer-fragment.glsl.js +58 -0
- package/typed/heatmap-layer/triangle-layer-vertex.glsl.d.ts +1 -1
- package/typed/heatmap-layer/triangle-layer-vertex.glsl.d.ts.map +1 -1
- package/typed/heatmap-layer/triangle-layer-vertex.glsl.js +51 -0
- package/typed/heatmap-layer/triangle-layer.d.ts +25 -8
- package/typed/heatmap-layer/triangle-layer.d.ts.map +1 -1
- package/typed/heatmap-layer/triangle-layer.js +67 -0
- package/typed/heatmap-layer/weights-fs.glsl.d.ts +1 -1
- package/typed/heatmap-layer/weights-fs.glsl.d.ts.map +1 -1
- package/typed/heatmap-layer/weights-fs.glsl.js +19 -0
- package/typed/heatmap-layer/weights-vs.glsl.d.ts +1 -1
- package/typed/heatmap-layer/weights-vs.glsl.d.ts.map +1 -1
- package/typed/heatmap-layer/weights-vs.glsl.js +23 -0
- package/typed/hexagon-layer/hexagon-aggregator.js +112 -0
- package/typed/hexagon-layer/hexagon-layer.d.ts +232 -125
- package/typed/hexagon-layer/hexagon-layer.d.ts.map +1 -1
- package/typed/hexagon-layer/hexagon-layer.js +171 -0
- package/typed/index.d.ts +7 -0
- package/typed/index.d.ts.map +1 -1
- package/typed/index.js +33 -0
- package/typed/screen-grid-layer/screen-grid-cell-layer.d.ts +46 -25
- package/typed/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -1
- package/typed/screen-grid-layer/screen-grid-cell-layer.js +159 -0
- package/typed/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts +1 -1
- package/typed/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts.map +1 -1
- package/typed/screen-grid-layer/screen-grid-layer-fragment.glsl.js +37 -0
- package/typed/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts +1 -1
- package/typed/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts.map +1 -1
- package/typed/screen-grid-layer/screen-grid-layer-vertex.glsl.js +83 -0
- package/typed/screen-grid-layer/screen-grid-layer.d.ts +113 -30
- package/typed/screen-grid-layer/screen-grid-layer.d.ts.map +1 -1
- package/typed/screen-grid-layer/screen-grid-layer.js +216 -0
- package/typed/types.d.ts +11 -0
- package/typed/types.d.ts.map +1 -0
- package/typed/types.js +1 -0
- package/typed/utils/aggregation-operation-utils.js +94 -0
- package/typed/utils/bin-sorter.d.ts +27 -21
- package/typed/utils/bin-sorter.d.ts.map +1 -1
- package/typed/utils/bin-sorter.js +167 -0
- package/typed/utils/color-utils.js +53 -0
- package/typed/utils/cpu-aggregator.js +417 -0
- package/typed/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +39 -0
- package/typed/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +53 -0
- package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +31 -0
- package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +77 -0
- package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +41 -0
- package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +1 -0
- package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +562 -0
- package/typed/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +36 -0
- package/typed/utils/grid-aggregation-utils.js +114 -0
- package/typed/utils/prop-utils.js +28 -0
- package/typed/utils/resource-utils.js +40 -0
- package/typed/utils/scale-utils.js +184 -0
- package/src/cpu-grid-layer/cpu-grid-layer.js +0 -153
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
// Copyright (c) 2015 - 2017 Uber Technologies, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
// in the Software without restriction, including without limitation the rights
|
|
6
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
// furnished to do so, subject to the following conditions:
|
|
9
|
+
//
|
|
10
|
+
// The above copyright notice and this permission notice shall be included in
|
|
11
|
+
// all copies or substantial portions of the Software.
|
|
12
|
+
//
|
|
13
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
// THE SOFTWARE.
|
|
20
|
+
import { Buffer } from '@luma.gl/core';
|
|
21
|
+
import GL from '@luma.gl/constants';
|
|
22
|
+
import { log } from '@deck.gl/core';
|
|
23
|
+
import GPUGridAggregator from '../utils/gpu-grid-aggregation/gpu-grid-aggregator';
|
|
24
|
+
import { AGGREGATION_OPERATION } from '../utils/aggregation-operation-utils';
|
|
25
|
+
import { defaultColorRange, colorRangeToFlatArray } from '../utils/color-utils';
|
|
26
|
+
import GPUGridCellLayer from './gpu-grid-cell-layer';
|
|
27
|
+
import { pointToDensityGridDataCPU } from './../cpu-grid-layer/grid-aggregator';
|
|
28
|
+
import GridAggregationLayer from '../grid-aggregation-layer';
|
|
29
|
+
import { getBoundingBox, getGridParams } from '../utils/grid-aggregation-utils';
|
|
30
|
+
const defaultProps = {
|
|
31
|
+
// color
|
|
32
|
+
colorDomain: null,
|
|
33
|
+
colorRange: defaultColorRange,
|
|
34
|
+
getColorWeight: { type: 'accessor', value: 1 },
|
|
35
|
+
colorAggregation: 'SUM',
|
|
36
|
+
// elevation
|
|
37
|
+
elevationDomain: null,
|
|
38
|
+
elevationRange: [0, 1000],
|
|
39
|
+
getElevationWeight: { type: 'accessor', value: 1 },
|
|
40
|
+
elevationAggregation: 'SUM',
|
|
41
|
+
elevationScale: { type: 'number', min: 0, value: 1 },
|
|
42
|
+
// grid
|
|
43
|
+
cellSize: { type: 'number', min: 1, max: 1000, value: 1000 },
|
|
44
|
+
coverage: { type: 'number', min: 0, max: 1, value: 1 },
|
|
45
|
+
getPosition: { type: 'accessor', value: x => x.position },
|
|
46
|
+
extruded: false,
|
|
47
|
+
// Optional material for 'lighting' shader module
|
|
48
|
+
material: true
|
|
49
|
+
};
|
|
50
|
+
// This layer only perform GPU aggregation, no need to seperate data and weight props
|
|
51
|
+
// aggregation will be dirty when any of the props are changed.
|
|
52
|
+
const DIMENSIONS = {
|
|
53
|
+
data: {
|
|
54
|
+
props: ['cellSize', 'colorAggregation', 'elevationAggregation']
|
|
55
|
+
}
|
|
56
|
+
// rest of the changes are detected by `state.attributesChanged`
|
|
57
|
+
};
|
|
58
|
+
const POSITION_ATTRIBUTE_NAME = 'positions';
|
|
59
|
+
/**
|
|
60
|
+
* The `GPUGridLayer` renders a grid heatmap based on an array of inputs.
|
|
61
|
+
*/
|
|
62
|
+
export default class GPUGridLayer extends GridAggregationLayer {
|
|
63
|
+
initializeState({ gl }) {
|
|
64
|
+
const isSupported = GPUGridAggregator.isSupported(gl);
|
|
65
|
+
if (!isSupported) {
|
|
66
|
+
log.error('GPUGridLayer is not supported on this browser, use GridLayer instead')();
|
|
67
|
+
}
|
|
68
|
+
super.initializeAggregationLayer({
|
|
69
|
+
dimensions: DIMENSIONS
|
|
70
|
+
});
|
|
71
|
+
this.setState({
|
|
72
|
+
gpuAggregation: true,
|
|
73
|
+
projectPoints: false,
|
|
74
|
+
isSupported,
|
|
75
|
+
weights: {
|
|
76
|
+
color: {
|
|
77
|
+
needMin: true,
|
|
78
|
+
needMax: true,
|
|
79
|
+
combineMaxMin: true,
|
|
80
|
+
maxMinBuffer: new Buffer(gl, {
|
|
81
|
+
byteLength: 4 * 4,
|
|
82
|
+
accessor: { size: 4, type: GL.FLOAT, divisor: 1 }
|
|
83
|
+
})
|
|
84
|
+
},
|
|
85
|
+
elevation: {
|
|
86
|
+
needMin: true,
|
|
87
|
+
needMax: true,
|
|
88
|
+
combineMaxMin: true,
|
|
89
|
+
maxMinBuffer: new Buffer(gl, {
|
|
90
|
+
byteLength: 4 * 4,
|
|
91
|
+
accessor: { size: 4, type: GL.FLOAT, divisor: 1 }
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
positionAttributeName: 'positions'
|
|
96
|
+
});
|
|
97
|
+
const attributeManager = this.getAttributeManager();
|
|
98
|
+
attributeManager.add({
|
|
99
|
+
[POSITION_ATTRIBUTE_NAME]: {
|
|
100
|
+
size: 3,
|
|
101
|
+
accessor: 'getPosition',
|
|
102
|
+
type: GL.DOUBLE,
|
|
103
|
+
fp64: this.use64bitPositions()
|
|
104
|
+
},
|
|
105
|
+
color: { size: 3, accessor: 'getColorWeight' },
|
|
106
|
+
elevation: { size: 3, accessor: 'getElevationWeight' }
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
updateState(opts) {
|
|
110
|
+
if (this.state.isSupported === false) {
|
|
111
|
+
// Skip update, layer not supported
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
super.updateState(opts);
|
|
115
|
+
const { aggregationDirty } = this.state;
|
|
116
|
+
if (aggregationDirty) {
|
|
117
|
+
// reset cached CPU Aggregation results (used for picking)
|
|
118
|
+
this.setState({
|
|
119
|
+
gridHash: null
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
getHashKeyForIndex(index) {
|
|
124
|
+
const { numRow, numCol, boundingBox, gridOffset } = this.state;
|
|
125
|
+
const gridSize = [numCol, numRow];
|
|
126
|
+
const gridOrigin = [boundingBox.xMin, boundingBox.yMin];
|
|
127
|
+
const cellSize = [gridOffset.xOffset, gridOffset.yOffset];
|
|
128
|
+
const yIndex = Math.floor(index / gridSize[0]);
|
|
129
|
+
const xIndex = index - yIndex * gridSize[0];
|
|
130
|
+
// This will match the index to the hash-key to access aggregation data from CPU aggregation results.
|
|
131
|
+
const latIdx = Math.floor((yIndex * cellSize[1] + gridOrigin[1] + 90 + cellSize[1] / 2) / cellSize[1]);
|
|
132
|
+
const lonIdx = Math.floor((xIndex * cellSize[0] + gridOrigin[0] + 180 + cellSize[0] / 2) / cellSize[0]);
|
|
133
|
+
return `${latIdx}-${lonIdx}`;
|
|
134
|
+
}
|
|
135
|
+
getPositionForIndex(index) {
|
|
136
|
+
const { numRow, numCol, boundingBox, gridOffset } = this.state;
|
|
137
|
+
const gridSize = [numCol, numRow];
|
|
138
|
+
const gridOrigin = [boundingBox.xMin, boundingBox.yMin];
|
|
139
|
+
const cellSize = [gridOffset.xOffset, gridOffset.yOffset];
|
|
140
|
+
const yIndex = Math.floor(index / gridSize[0]);
|
|
141
|
+
const xIndex = index - yIndex * gridSize[0];
|
|
142
|
+
const yPos = yIndex * cellSize[1] + gridOrigin[1];
|
|
143
|
+
const xPos = xIndex * cellSize[0] + gridOrigin[0];
|
|
144
|
+
return [xPos, yPos];
|
|
145
|
+
}
|
|
146
|
+
getPickingInfo({ info, mode }) {
|
|
147
|
+
const { index } = info;
|
|
148
|
+
let object = null;
|
|
149
|
+
if (index >= 0) {
|
|
150
|
+
const { gpuGridAggregator } = this.state;
|
|
151
|
+
const position = this.getPositionForIndex(index);
|
|
152
|
+
const colorInfo = GPUGridAggregator.getAggregationData({
|
|
153
|
+
pixelIndex: index,
|
|
154
|
+
...gpuGridAggregator.getData('color')
|
|
155
|
+
});
|
|
156
|
+
const elevationInfo = GPUGridAggregator.getAggregationData({
|
|
157
|
+
pixelIndex: index,
|
|
158
|
+
...gpuGridAggregator.getData('elevation')
|
|
159
|
+
});
|
|
160
|
+
object = {
|
|
161
|
+
colorValue: colorInfo.cellWeight,
|
|
162
|
+
elevationValue: elevationInfo.cellWeight,
|
|
163
|
+
count: colorInfo.cellCount || elevationInfo.cellCount,
|
|
164
|
+
position,
|
|
165
|
+
totalCount: colorInfo.totalCount || elevationInfo.totalCount
|
|
166
|
+
};
|
|
167
|
+
if (mode !== 'hover') {
|
|
168
|
+
// perform CPU aggregation for full list of points for each cell
|
|
169
|
+
const { props } = this;
|
|
170
|
+
let { gridHash } = this.state;
|
|
171
|
+
if (!gridHash) {
|
|
172
|
+
const { gridOffset, translation, boundingBox } = this.state;
|
|
173
|
+
const { viewport } = this.context;
|
|
174
|
+
const attributes = this.getAttributes();
|
|
175
|
+
const cpuAggregation = pointToDensityGridDataCPU(props, {
|
|
176
|
+
gridOffset,
|
|
177
|
+
attributes,
|
|
178
|
+
viewport,
|
|
179
|
+
translation,
|
|
180
|
+
boundingBox
|
|
181
|
+
});
|
|
182
|
+
gridHash = cpuAggregation.gridHash;
|
|
183
|
+
this.setState({ gridHash });
|
|
184
|
+
}
|
|
185
|
+
const key = this.getHashKeyForIndex(index);
|
|
186
|
+
const cpuAggregationData = gridHash[key];
|
|
187
|
+
Object.assign(object, cpuAggregationData);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
// override object with picked cell
|
|
191
|
+
info.picked = Boolean(object);
|
|
192
|
+
info.object = object;
|
|
193
|
+
return info;
|
|
194
|
+
}
|
|
195
|
+
renderLayers() {
|
|
196
|
+
if (!this.state.isSupported) {
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
const { elevationScale, extruded, cellSize: cellSizeMeters, coverage, material, elevationRange, colorDomain, elevationDomain } = this.props;
|
|
200
|
+
const { weights, numRow, numCol, gridOrigin, gridOffset } = this.state;
|
|
201
|
+
const { color, elevation } = weights;
|
|
202
|
+
const colorRange = colorRangeToFlatArray(this.props.colorRange);
|
|
203
|
+
const SubLayerClass = this.getSubLayerClass('gpu-grid-cell', GPUGridCellLayer);
|
|
204
|
+
return new SubLayerClass({
|
|
205
|
+
gridSize: [numCol, numRow],
|
|
206
|
+
gridOrigin,
|
|
207
|
+
gridOffset: [gridOffset.xOffset, gridOffset.yOffset],
|
|
208
|
+
colorRange,
|
|
209
|
+
elevationRange,
|
|
210
|
+
colorDomain,
|
|
211
|
+
elevationDomain,
|
|
212
|
+
cellSize: cellSizeMeters,
|
|
213
|
+
coverage,
|
|
214
|
+
material,
|
|
215
|
+
elevationScale,
|
|
216
|
+
extruded
|
|
217
|
+
}, this.getSubLayerProps({
|
|
218
|
+
id: 'gpu-grid-cell'
|
|
219
|
+
}), {
|
|
220
|
+
data: {
|
|
221
|
+
attributes: {
|
|
222
|
+
colors: color.aggregationBuffer,
|
|
223
|
+
elevations: elevation.aggregationBuffer
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
colorMaxMinBuffer: color.maxMinBuffer,
|
|
227
|
+
elevationMaxMinBuffer: elevation.maxMinBuffer,
|
|
228
|
+
numInstances: numCol * numRow
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
finalizeState(context) {
|
|
232
|
+
const { color, elevation } = this.state.weights;
|
|
233
|
+
[color, elevation].forEach(weight => {
|
|
234
|
+
const { aggregationBuffer, maxMinBuffer } = weight;
|
|
235
|
+
maxMinBuffer.delete();
|
|
236
|
+
aggregationBuffer?.delete();
|
|
237
|
+
});
|
|
238
|
+
super.finalizeState(context);
|
|
239
|
+
}
|
|
240
|
+
// Aggregation Overrides
|
|
241
|
+
updateAggregationState(opts) {
|
|
242
|
+
const { props, oldProps } = opts;
|
|
243
|
+
const { cellSize, coordinateSystem } = props;
|
|
244
|
+
const { viewport } = this.context;
|
|
245
|
+
const cellSizeChanged = oldProps.cellSize !== cellSize;
|
|
246
|
+
const { dimensions } = this.state;
|
|
247
|
+
const positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME);
|
|
248
|
+
// any attribute changed
|
|
249
|
+
const attributesChanged = positionsChanged || this.isAttributeChanged();
|
|
250
|
+
let { boundingBox } = this.state;
|
|
251
|
+
if (positionsChanged) {
|
|
252
|
+
boundingBox = getBoundingBox(this.getAttributes(), this.getNumInstances());
|
|
253
|
+
this.setState({ boundingBox });
|
|
254
|
+
}
|
|
255
|
+
if (positionsChanged || cellSizeChanged) {
|
|
256
|
+
const { gridOffset, translation, width, height, numCol, numRow } = getGridParams(boundingBox, cellSize, viewport, coordinateSystem);
|
|
257
|
+
this.allocateResources(numRow, numCol);
|
|
258
|
+
this.setState({
|
|
259
|
+
gridOffset,
|
|
260
|
+
translation,
|
|
261
|
+
gridOrigin: [-1 * translation[0], -1 * translation[1]],
|
|
262
|
+
width,
|
|
263
|
+
height,
|
|
264
|
+
numCol,
|
|
265
|
+
numRow
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
const aggregationDataDirty = attributesChanged ||
|
|
269
|
+
this.isAggregationDirty(opts, {
|
|
270
|
+
dimension: dimensions.data,
|
|
271
|
+
compareAll: true
|
|
272
|
+
});
|
|
273
|
+
if (aggregationDataDirty) {
|
|
274
|
+
this._updateAccessors(opts);
|
|
275
|
+
}
|
|
276
|
+
this.setState({
|
|
277
|
+
aggregationDataDirty
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
// Private
|
|
281
|
+
_updateAccessors(opts) {
|
|
282
|
+
const { colorAggregation, elevationAggregation } = opts.props;
|
|
283
|
+
const { color, elevation } = this.state.weights;
|
|
284
|
+
color.operation = AGGREGATION_OPERATION[colorAggregation];
|
|
285
|
+
elevation.operation = AGGREGATION_OPERATION[elevationAggregation];
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
GPUGridLayer.layerName = 'GPUGridLayer';
|
|
289
|
+
GPUGridLayer.defaultProps = defaultProps;
|
|
@@ -1,4 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
import AggregationLayer, { AggregationLayerProps } from './aggregation-layer';
|
|
2
|
+
import { LayerContext, UpdateParameters } from '@deck.gl/core/typed';
|
|
3
|
+
import BinSorter from './utils/bin-sorter';
|
|
4
|
+
export declare type GridAggregationLayerProps<DataT = any> = AggregationLayerProps<DataT>;
|
|
5
|
+
export default abstract class GridAggregationLayer<ExtraPropsT = {}> extends AggregationLayer<ExtraPropsT> {
|
|
6
|
+
static layerName: string;
|
|
7
|
+
state: AggregationLayer['state'] & {
|
|
8
|
+
aggregationDataDirty?: any;
|
|
9
|
+
aggregationWeightsDirty?: any;
|
|
10
|
+
gpuAggregation?: any;
|
|
11
|
+
getValue?: () => any;
|
|
12
|
+
sortedBins?: BinSorter;
|
|
13
|
+
};
|
|
14
|
+
initializeAggregationLayer({ dimensions }: {
|
|
15
|
+
dimensions: any;
|
|
16
|
+
}): void;
|
|
17
|
+
updateState(opts: UpdateParameters<this>): void;
|
|
18
|
+
finalizeState(context: LayerContext): void;
|
|
19
|
+
updateShaders(shaders: any): void;
|
|
2
20
|
updateAggregationState(opts: any): void;
|
|
3
21
|
allocateResources(numRow: any, numCol: any): void;
|
|
4
22
|
updateResults({ aggregationData, maxMinData, maxData, minData }: {
|
|
@@ -11,9 +29,4 @@ declare class GridAggregationLayer extends AggregationLayer {
|
|
|
11
29
|
_updateWeightBins(): void;
|
|
12
30
|
_uploadAggregationResults(): void;
|
|
13
31
|
}
|
|
14
|
-
declare namespace GridAggregationLayer {
|
|
15
|
-
const layerName: string;
|
|
16
|
-
}
|
|
17
|
-
export default GridAggregationLayer;
|
|
18
|
-
import AggregationLayer from "./aggregation-layer";
|
|
19
32
|
//# sourceMappingURL=grid-aggregation-layer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid-aggregation-layer.d.ts","sourceRoot":"","sources":["../src/grid-aggregation-layer.
|
|
1
|
+
{"version":3,"file":"grid-aggregation-layer.d.ts","sourceRoot":"","sources":["../src/grid-aggregation-layer.ts"],"names":[],"mappings":"AAoBA,OAAO,gBAAgB,EAAE,EAAC,qBAAqB,EAAC,MAAM,qBAAqB,CAAC;AAG5E,OAAO,EAAC,YAAY,EAAO,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAElE,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAG3C,oBAAY,yBAAyB,CAAC,KAAK,GAAG,GAAG,IAAI,qBAAqB,CAAC,KAAK,CAAC,CAAC;AAElF,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,oBAAoB,CAChD,WAAW,GAAG,EAAE,CAChB,SAAQ,gBAAgB,CAAC,WAAW,CAAC;IACrC,MAAM,CAAC,SAAS,SAA0B;IAE1C,KAAK,EAAG,gBAAgB,CAAC,OAAO,CAAC,GAAG;QAClC,oBAAoB,CAAC,EAAE,GAAG,CAAC;QAC3B,uBAAuB,CAAC,EAAE,GAAG,CAAC;QAC9B,cAAc,CAAC,EAAE,GAAG,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC;QACrB,UAAU,CAAC,EAAE,SAAS,CAAC;KACxB,CAAC;IAEF,0BAA0B,CAAC,EAAC,UAAU,EAAC;;KAAA;IAWvC,WAAW,CAAC,IAAI,EAAE,gBAAgB,CAAC,IAAI,CAAC;IA8BxC,aAAa,CAAC,OAAO,EAAE,YAAY;IASnC,aAAa,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI;IAQjC,sBAAsB,CAAC,IAAI,KAAA;IAK3B,iBAAiB,CAAC,MAAM,KAAA,EAAE,MAAM,KAAA;IAsBhC,aAAa,CAAC,EAAC,eAAe,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAC;;;;;KAAA;IAY7D,kBAAkB,CAAC,IAAI,KAAA;IAgDvB,iBAAiB;IAOjB,yBAAyB,IAAI,IAAI;CAoBlC"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// Copyright (c) 2015 - 2017 Uber Technologies, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
// in the Software without restriction, including without limitation the rights
|
|
6
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
// furnished to do so, subject to the following conditions:
|
|
9
|
+
//
|
|
10
|
+
// The above copyright notice and this permission notice shall be included in
|
|
11
|
+
// all copies or substantial portions of the Software.
|
|
12
|
+
//
|
|
13
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
// THE SOFTWARE.
|
|
20
|
+
import AggregationLayer from './aggregation-layer';
|
|
21
|
+
import GPUGridAggregator from './utils/gpu-grid-aggregation/gpu-grid-aggregator';
|
|
22
|
+
import { Buffer } from '@luma.gl/core';
|
|
23
|
+
import { log } from '@deck.gl/core';
|
|
24
|
+
import GL from '@luma.gl/constants';
|
|
25
|
+
import BinSorter from './utils/bin-sorter';
|
|
26
|
+
import { pointToDensityGridDataCPU } from './cpu-grid-layer/grid-aggregator';
|
|
27
|
+
export default class GridAggregationLayer extends AggregationLayer {
|
|
28
|
+
initializeAggregationLayer({ dimensions }) {
|
|
29
|
+
const { gl } = this.context;
|
|
30
|
+
super.initializeAggregationLayer(dimensions);
|
|
31
|
+
this.setState({
|
|
32
|
+
// CPU aggregation results
|
|
33
|
+
layerData: {},
|
|
34
|
+
gpuGridAggregator: new GPUGridAggregator(gl, { id: `${this.id}-gpu-aggregator` }),
|
|
35
|
+
cpuGridAggregator: pointToDensityGridDataCPU
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
updateState(opts) {
|
|
39
|
+
// get current attributes
|
|
40
|
+
super.updateState(opts);
|
|
41
|
+
this.updateAggregationState(opts);
|
|
42
|
+
const { aggregationDataDirty, aggregationWeightsDirty, gpuAggregation } = this.state;
|
|
43
|
+
if (this.getNumInstances() <= 0) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
let aggregationDirty = false;
|
|
47
|
+
// CPU aggregation is two steps
|
|
48
|
+
// 1. Create bins (based on cellSize and position) 2. Aggregate weights for each bin
|
|
49
|
+
// For GPU aggregation both above steps are combined into one step
|
|
50
|
+
// step-1
|
|
51
|
+
if (aggregationDataDirty || (gpuAggregation && aggregationWeightsDirty)) {
|
|
52
|
+
this._updateAggregation(opts);
|
|
53
|
+
aggregationDirty = true;
|
|
54
|
+
}
|
|
55
|
+
// step-2 (Applicalbe for CPU aggregation only)
|
|
56
|
+
if (!gpuAggregation && (aggregationDataDirty || aggregationWeightsDirty)) {
|
|
57
|
+
this._updateWeightBins();
|
|
58
|
+
this._uploadAggregationResults();
|
|
59
|
+
aggregationDirty = true;
|
|
60
|
+
}
|
|
61
|
+
this.setState({ aggregationDirty });
|
|
62
|
+
}
|
|
63
|
+
finalizeState(context) {
|
|
64
|
+
const { count } = this.state.weights;
|
|
65
|
+
if (count && count.aggregationBuffer) {
|
|
66
|
+
count.aggregationBuffer.delete();
|
|
67
|
+
}
|
|
68
|
+
this.state.gpuGridAggregator?.delete();
|
|
69
|
+
super.finalizeState(context);
|
|
70
|
+
}
|
|
71
|
+
updateShaders(shaders) {
|
|
72
|
+
if (this.state.gpuAggregation) {
|
|
73
|
+
this.state.gpuGridAggregator.updateShaders(shaders);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Methods that can be overriden by subclasses for customizations
|
|
77
|
+
updateAggregationState(opts) {
|
|
78
|
+
// Sublayers should implement this method.
|
|
79
|
+
log.assert(false);
|
|
80
|
+
}
|
|
81
|
+
allocateResources(numRow, numCol) {
|
|
82
|
+
if (this.state.numRow !== numRow || this.state.numCol !== numCol) {
|
|
83
|
+
const dataBytes = numCol * numRow * 4 * 4;
|
|
84
|
+
const gl = this.context.gl;
|
|
85
|
+
const { weights } = this.state;
|
|
86
|
+
for (const name in weights) {
|
|
87
|
+
const weight = weights[name];
|
|
88
|
+
if (weight.aggregationBuffer) {
|
|
89
|
+
weight.aggregationBuffer.delete();
|
|
90
|
+
}
|
|
91
|
+
weight.aggregationBuffer = new Buffer(gl, {
|
|
92
|
+
byteLength: dataBytes,
|
|
93
|
+
accessor: {
|
|
94
|
+
size: 4,
|
|
95
|
+
type: GL.FLOAT,
|
|
96
|
+
divisor: 1
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
updateResults({ aggregationData, maxMinData, maxData, minData }) {
|
|
103
|
+
const { count } = this.state.weights;
|
|
104
|
+
if (count) {
|
|
105
|
+
count.aggregationData = aggregationData;
|
|
106
|
+
count.maxMinData = maxMinData;
|
|
107
|
+
count.maxData = maxData;
|
|
108
|
+
count.minData = minData;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// Private
|
|
112
|
+
_updateAggregation(opts) {
|
|
113
|
+
const { cpuGridAggregator, gpuGridAggregator, gridOffset, posOffset, translation = [0, 0], scaling = [0, 0, 0], boundingBox, projectPoints, gpuAggregation, numCol, numRow } = this.state;
|
|
114
|
+
const { props } = opts;
|
|
115
|
+
const { viewport } = this.context;
|
|
116
|
+
const attributes = this.getAttributes();
|
|
117
|
+
const vertexCount = this.getNumInstances();
|
|
118
|
+
if (!gpuAggregation) {
|
|
119
|
+
const result = cpuGridAggregator(props, {
|
|
120
|
+
gridOffset,
|
|
121
|
+
projectPoints,
|
|
122
|
+
attributes,
|
|
123
|
+
viewport,
|
|
124
|
+
posOffset,
|
|
125
|
+
boundingBox
|
|
126
|
+
});
|
|
127
|
+
this.setState({
|
|
128
|
+
layerData: result
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
const { weights } = this.state;
|
|
133
|
+
gpuGridAggregator.run({
|
|
134
|
+
weights,
|
|
135
|
+
cellSize: [gridOffset.xOffset, gridOffset.yOffset],
|
|
136
|
+
numCol,
|
|
137
|
+
numRow,
|
|
138
|
+
translation,
|
|
139
|
+
scaling,
|
|
140
|
+
vertexCount,
|
|
141
|
+
projectPoints,
|
|
142
|
+
attributes,
|
|
143
|
+
moduleSettings: this.getModuleSettings()
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
_updateWeightBins() {
|
|
148
|
+
const { getValue } = this.state;
|
|
149
|
+
const sortedBins = new BinSorter(this.state.layerData.data || [], { getValue });
|
|
150
|
+
this.setState({ sortedBins });
|
|
151
|
+
}
|
|
152
|
+
_uploadAggregationResults() {
|
|
153
|
+
const { numCol, numRow } = this.state;
|
|
154
|
+
const { data } = this.state.layerData;
|
|
155
|
+
const { aggregatedBins, minValue, maxValue, totalCount } = this.state.sortedBins;
|
|
156
|
+
const ELEMENTCOUNT = 4;
|
|
157
|
+
const aggregationSize = numCol * numRow * ELEMENTCOUNT;
|
|
158
|
+
const aggregationData = new Float32Array(aggregationSize).fill(0);
|
|
159
|
+
for (const bin of aggregatedBins) {
|
|
160
|
+
const { lonIdx, latIdx } = data[bin.i];
|
|
161
|
+
const { value, counts } = bin;
|
|
162
|
+
const cellIndex = (lonIdx + latIdx * numCol) * ELEMENTCOUNT;
|
|
163
|
+
aggregationData[cellIndex] = value;
|
|
164
|
+
aggregationData[cellIndex + ELEMENTCOUNT - 1] = counts;
|
|
165
|
+
}
|
|
166
|
+
const maxMinData = new Float32Array([maxValue, 0, 0, minValue]);
|
|
167
|
+
const maxData = new Float32Array([maxValue, 0, 0, totalCount]);
|
|
168
|
+
const minData = new Float32Array([minValue, 0, 0, totalCount]);
|
|
169
|
+
this.updateResults({ aggregationData, maxMinData, maxData, minData });
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
GridAggregationLayer.layerName = 'GridAggregationLayer';
|