@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,310 @@
|
|
|
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
|
+
|
|
21
|
+
import GL from '@luma.gl/constants';
|
|
22
|
+
import {GridCellLayer, _MaterialProps as MaterialProps} from '@deck.gl/layers';
|
|
23
|
+
import {Accessor, AccessorFunction, Color, Position} from '@deck.gl/core';
|
|
24
|
+
|
|
25
|
+
import {defaultColorRange} from '../utils/color-utils';
|
|
26
|
+
import {pointToDensityGridDataCPU} from './grid-aggregator';
|
|
27
|
+
import CPUAggregator from '../utils/cpu-aggregator';
|
|
28
|
+
import AggregationLayer, {AggregationLayerProps} from '../aggregation-layer';
|
|
29
|
+
|
|
30
|
+
import Layer, {UpdateParameters} from 'modules/core/src/lib/layer';
|
|
31
|
+
import {GetPickingInfoParams, PickingInfo} from 'modules/core/src/lib/picking/pick-info';
|
|
32
|
+
import {AggregateAccessor} from '../types';
|
|
33
|
+
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
35
|
+
function nop() {}
|
|
36
|
+
|
|
37
|
+
const defaultProps = {
|
|
38
|
+
// color
|
|
39
|
+
colorDomain: null,
|
|
40
|
+
colorRange: defaultColorRange,
|
|
41
|
+
getColorValue: {type: 'accessor', value: null}, // default value is calculated from `getColorWeight` and `colorAggregation`
|
|
42
|
+
getColorWeight: {type: 'accessor', value: 1},
|
|
43
|
+
colorAggregation: 'SUM',
|
|
44
|
+
lowerPercentile: {type: 'number', min: 0, max: 100, value: 0},
|
|
45
|
+
upperPercentile: {type: 'number', min: 0, max: 100, value: 100},
|
|
46
|
+
colorScaleType: 'quantize',
|
|
47
|
+
onSetColorDomain: nop,
|
|
48
|
+
|
|
49
|
+
// elevation
|
|
50
|
+
elevationDomain: null,
|
|
51
|
+
elevationRange: [0, 1000],
|
|
52
|
+
getElevationValue: {type: 'accessor', value: null}, // default value is calculated from `getElevationWeight` and `elevationAggregation`
|
|
53
|
+
getElevationWeight: {type: 'accessor', value: 1},
|
|
54
|
+
elevationAggregation: 'SUM',
|
|
55
|
+
elevationLowerPercentile: {type: 'number', min: 0, max: 100, value: 0},
|
|
56
|
+
elevationUpperPercentile: {type: 'number', min: 0, max: 100, value: 100},
|
|
57
|
+
elevationScale: {type: 'number', min: 0, value: 1},
|
|
58
|
+
elevationScaleType: 'linear',
|
|
59
|
+
onSetElevationDomain: nop,
|
|
60
|
+
|
|
61
|
+
gridAggregator: pointToDensityGridDataCPU,
|
|
62
|
+
|
|
63
|
+
// grid
|
|
64
|
+
cellSize: {type: 'number', min: 0, max: 1000, value: 1000},
|
|
65
|
+
coverage: {type: 'number', min: 0, max: 1, value: 1},
|
|
66
|
+
getPosition: {type: 'accessor', value: x => x.position},
|
|
67
|
+
extruded: false,
|
|
68
|
+
|
|
69
|
+
// Optional material for 'lighting' shader module
|
|
70
|
+
material: true,
|
|
71
|
+
|
|
72
|
+
// data filter
|
|
73
|
+
_filterData: {type: 'function', value: null, optional: true}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/** All properties supported by CPUGridLayer. */
|
|
77
|
+
export type CPUGridLayerProps<DataT = any> = _CPUGridLayerProps<DataT> &
|
|
78
|
+
AggregationLayerProps<DataT>;
|
|
79
|
+
|
|
80
|
+
/** Properties added by CPUGridLayer. */
|
|
81
|
+
export type _CPUGridLayerProps<DataT> = {
|
|
82
|
+
/**
|
|
83
|
+
* Size of each cell in meters.
|
|
84
|
+
* @default 1000
|
|
85
|
+
*/
|
|
86
|
+
cellSize?: number;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Color scale domain, default is set to the extent of aggregated weights in each cell.
|
|
90
|
+
* @default [min(colorWeight), max(colorWeight)]
|
|
91
|
+
*/
|
|
92
|
+
colorDomain?: [number, number] | null;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Default: [colorbrewer](http://colorbrewer2.org/#type=sequential&scheme=YlOrRd&n=6) `6-class YlOrRd`
|
|
96
|
+
*/
|
|
97
|
+
colorRange?: Color[];
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Cell size multiplier, clamped between 0 - 1.
|
|
101
|
+
* @default 1
|
|
102
|
+
*/
|
|
103
|
+
coverage?: number;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Elevation scale input domain, default is set to between 0 and the max of aggregated weights in each cell.
|
|
107
|
+
* @default [0, max(elevationWeight)]
|
|
108
|
+
*/
|
|
109
|
+
elevationDomain?: [number, number] | null;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Elevation scale output range.
|
|
113
|
+
* @default [0, 1000]
|
|
114
|
+
*/
|
|
115
|
+
elevationRange?: [number, number];
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Cell elevation multiplier.
|
|
119
|
+
* @default 1
|
|
120
|
+
*/
|
|
121
|
+
elevationScale?: number;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Whether to enable cell elevation. If set to false, all cell will be flat.
|
|
125
|
+
* @default true
|
|
126
|
+
*/
|
|
127
|
+
extruded?: boolean;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Filter cells and re-calculate color by `upperPercentile`.
|
|
131
|
+
* Cells with value arger than the upperPercentile will be hidden.
|
|
132
|
+
* @default 100
|
|
133
|
+
*/
|
|
134
|
+
upperPercentile?: number;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Filter cells and re-calculate color by `lowerPercentile`.
|
|
138
|
+
* Cells with value smaller than the lowerPercentile will be hidden.
|
|
139
|
+
* @default 0
|
|
140
|
+
*/
|
|
141
|
+
lowerPercentile?: number;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Filter cells and re-calculate elevation by `elevationUpperPercentile`.
|
|
145
|
+
* Cells with elevation value larger than the `elevationUpperPercentile` will be hidden.
|
|
146
|
+
* @default 100
|
|
147
|
+
*/
|
|
148
|
+
elevationUpperPercentile?: number;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Filter cells and re-calculate elevation by `elevationLowerPercentile`.
|
|
152
|
+
* Cells with elevation value larger than the `elevationLowerPercentile` will be hidden.
|
|
153
|
+
* @default 0
|
|
154
|
+
*/
|
|
155
|
+
elevationLowerPercentile?: number;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Scaling function used to determine the color of the grid cell, default value is 'quantize'.
|
|
159
|
+
* Supported Values are 'quantize', 'linear', 'quantile' and 'ordinal'.
|
|
160
|
+
* @default 'quantize'
|
|
161
|
+
*/
|
|
162
|
+
colorScaleType?: 'quantize' | 'linear' | 'quantile' | 'ordinal';
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* This is an object that contains material props
|
|
166
|
+
* for [lighting effect](/docs/api-reference/core/lighting-effect.md) applied on extruded polygons.
|
|
167
|
+
* @default true
|
|
168
|
+
*/
|
|
169
|
+
material?: MaterialProps | null;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Defines the operation used to aggregate all data object weights to calculate a cell's color value.
|
|
173
|
+
* @default 'SUM'
|
|
174
|
+
*/
|
|
175
|
+
colorAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Defines the operation used to aggregate all data object weights to calculate a cell's elevation value.
|
|
179
|
+
* @default 'SUM'
|
|
180
|
+
*/
|
|
181
|
+
elevationAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Method called to retrieve the position of each object.
|
|
185
|
+
* @default object => object.position
|
|
186
|
+
*/
|
|
187
|
+
getPosition?: AccessorFunction<DataT, Position>;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* The weight of a data object used to calculate the color value for a cell.
|
|
191
|
+
* @default 1
|
|
192
|
+
*/
|
|
193
|
+
getColorWeight?: Accessor<DataT, number>;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* After data objects are aggregated into cells, this accessor is called on each cell to get the value that its color is based on.
|
|
197
|
+
* @default null
|
|
198
|
+
*/
|
|
199
|
+
getColorValue?: AggregateAccessor<DataT> | null;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* The weight of a data object used to calculate the elevation value for a cell.
|
|
203
|
+
* @default 1
|
|
204
|
+
*/
|
|
205
|
+
getElevationWeight?: Accessor<DataT, number>;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* After data objects are aggregated into cells, this accessor is called on each cell to get the value that its elevation is based on.
|
|
209
|
+
* @default null
|
|
210
|
+
*/
|
|
211
|
+
getElevationValue?: AggregateAccessor<DataT> | null;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* This callback will be called when bin color domain has been calculated.
|
|
215
|
+
* @default () => {}
|
|
216
|
+
*/
|
|
217
|
+
onSetColorDomain?: (minMax: [number, number]) => void;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* This callback will be called when bin elevation domain has been calculated.
|
|
221
|
+
* @default () => {}
|
|
222
|
+
*/
|
|
223
|
+
onSetElevationDomain?: (minMax: [number, number]) => void;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
export default class CPUGridLayer<DataT = any, ExtraPropsT = {}> extends AggregationLayer<
|
|
227
|
+
ExtraPropsT & Required<_CPUGridLayerProps<DataT>>
|
|
228
|
+
> {
|
|
229
|
+
static layerName = 'CPUGridLayer';
|
|
230
|
+
static defaultProps = defaultProps;
|
|
231
|
+
|
|
232
|
+
initializeState(): void {
|
|
233
|
+
const cpuAggregator = new CPUAggregator({
|
|
234
|
+
getAggregator: props => props.gridAggregator,
|
|
235
|
+
getCellSize: props => props.cellSize
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
this.state = {
|
|
239
|
+
cpuAggregator,
|
|
240
|
+
aggregatorState: cpuAggregator.state
|
|
241
|
+
};
|
|
242
|
+
const attributeManager = this.getAttributeManager()!;
|
|
243
|
+
attributeManager.add({
|
|
244
|
+
positions: {size: 3, type: GL.DOUBLE, accessor: 'getPosition'}
|
|
245
|
+
});
|
|
246
|
+
// color and elevation attributes can't be added as attributes
|
|
247
|
+
// they are calcualted using 'getValue' accessor that takes an array of pints.
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
updateState(opts: UpdateParameters<this>) {
|
|
251
|
+
super.updateState(opts);
|
|
252
|
+
this.setState({
|
|
253
|
+
// make a copy of the internal state of cpuAggregator for testing
|
|
254
|
+
aggregatorState: this.state.cpuAggregator.updateState(opts, {
|
|
255
|
+
viewport: this.context.viewport,
|
|
256
|
+
attributes: this.getAttributes(),
|
|
257
|
+
numInstances: this.getNumInstances()
|
|
258
|
+
})
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
getPickingInfo({info}: GetPickingInfoParams): PickingInfo {
|
|
263
|
+
return this.state.cpuAggregator.getPickingInfo({info});
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// create a method for testing
|
|
267
|
+
_onGetSublayerColor(cell) {
|
|
268
|
+
return this.state.cpuAggregator.getAccessor('fillColor')(cell);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// create a method for testing
|
|
272
|
+
_onGetSublayerElevation(cell) {
|
|
273
|
+
return this.state.cpuAggregator.getAccessor('elevation')(cell);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
_getSublayerUpdateTriggers() {
|
|
277
|
+
return this.state.cpuAggregator.getUpdateTriggers(this.props);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
renderLayers(): Layer {
|
|
281
|
+
const {elevationScale, extruded, cellSize, coverage, material, transitions} = this.props;
|
|
282
|
+
const {cpuAggregator} = this.state;
|
|
283
|
+
const SubLayerClass = this.getSubLayerClass('grid-cell', GridCellLayer);
|
|
284
|
+
const updateTriggers = this._getSublayerUpdateTriggers();
|
|
285
|
+
|
|
286
|
+
return new SubLayerClass(
|
|
287
|
+
{
|
|
288
|
+
cellSize,
|
|
289
|
+
coverage,
|
|
290
|
+
material,
|
|
291
|
+
elevationScale,
|
|
292
|
+
extruded,
|
|
293
|
+
|
|
294
|
+
getFillColor: this._onGetSublayerColor.bind(this),
|
|
295
|
+
getElevation: this._onGetSublayerElevation.bind(this),
|
|
296
|
+
transitions: transitions && {
|
|
297
|
+
getFillColor: transitions.getColorValue || transitions.getColorWeight,
|
|
298
|
+
getElevation: transitions.getElevationValue || transitions.getElevationWeight
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
this.getSubLayerProps({
|
|
302
|
+
id: 'grid-cell',
|
|
303
|
+
updateTriggers
|
|
304
|
+
}),
|
|
305
|
+
{
|
|
306
|
+
data: cpuAggregator.state.layerData.data
|
|
307
|
+
}
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
File without changes
|
package/src/gpu-grid-layer/{gpu-grid-cell-layer-vertex.glsl.js → gpu-grid-cell-layer-vertex.glsl.ts}
RENAMED
|
File without changes
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
19
|
// THE SOFTWARE.
|
|
20
20
|
|
|
21
|
-
import {Layer, fp64LowPart, project32, gouraudLighting, picking} from '@deck.gl/core';
|
|
21
|
+
import {Layer, fp64LowPart, project32, gouraudLighting, picking, LayerContext} from '@deck.gl/core';
|
|
22
22
|
import GL from '@luma.gl/constants';
|
|
23
|
-
import {Model, CubeGeometry} from '@luma.gl/core';
|
|
23
|
+
import {Model, CubeGeometry, Buffer} from '@luma.gl/core';
|
|
24
24
|
import {fp64arithmetic} from '@luma.gl/shadertools';
|
|
25
25
|
import {defaultColorRange, colorRangeToFlatArray} from '../utils/color-utils';
|
|
26
|
-
|
|
26
|
+
import type {_GPUGridLayerProps} from './gpu-grid-layer';
|
|
27
27
|
import vs from './gpu-grid-cell-layer-vertex.glsl';
|
|
28
28
|
import fs from './gpu-grid-cell-layer-fragment.glsl';
|
|
29
29
|
|
|
@@ -53,7 +53,19 @@ const defaultProps = {
|
|
|
53
53
|
material: true // Use lighting module defaults
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
type _GPUGridCellLayerProps = _GPUGridLayerProps<any> & {
|
|
57
|
+
offset: number[];
|
|
58
|
+
gridSize: number[];
|
|
59
|
+
gridOrigin: number[];
|
|
60
|
+
gridOffset: number[];
|
|
61
|
+
colorMaxMinBuffer: Buffer;
|
|
62
|
+
elevationMaxMinBuffer: Buffer;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default class GPUGridCellLayer extends Layer<_GPUGridCellLayerProps> {
|
|
66
|
+
static layerName = 'GPUGridCellLayer';
|
|
67
|
+
static defaultProps = defaultProps;
|
|
68
|
+
|
|
57
69
|
getShaders() {
|
|
58
70
|
return super.getShaders({
|
|
59
71
|
vs,
|
|
@@ -62,9 +74,8 @@ export default class GPUGridCellLayer extends Layer {
|
|
|
62
74
|
});
|
|
63
75
|
}
|
|
64
76
|
|
|
65
|
-
initializeState() {
|
|
66
|
-
const
|
|
67
|
-
const attributeManager = this.getAttributeManager();
|
|
77
|
+
initializeState({gl}: LayerContext) {
|
|
78
|
+
const attributeManager = this.getAttributeManager()!;
|
|
68
79
|
attributeManager.addInstanced({
|
|
69
80
|
colors: {
|
|
70
81
|
size: 4,
|
|
@@ -80,7 +91,7 @@ export default class GPUGridCellLayer extends Layer {
|
|
|
80
91
|
this.setState({model});
|
|
81
92
|
}
|
|
82
93
|
|
|
83
|
-
_getModel(gl) {
|
|
94
|
+
_getModel(gl: WebGLRenderingContext): Model {
|
|
84
95
|
return new Model(gl, {
|
|
85
96
|
...this.getShaders(),
|
|
86
97
|
id: this.props.id,
|
|
@@ -142,7 +153,7 @@ export default class GPUGridCellLayer extends Layer {
|
|
|
142
153
|
|
|
143
154
|
getDomainUniforms() {
|
|
144
155
|
const {colorDomain, elevationDomain} = this.props;
|
|
145
|
-
const domainUniforms = {};
|
|
156
|
+
const domainUniforms: Record<string, any> = {};
|
|
146
157
|
if (colorDomain !== null) {
|
|
147
158
|
domainUniforms.colorDomainValid = true;
|
|
148
159
|
domainUniforms.colorDomain = colorDomain;
|
|
@@ -158,8 +169,8 @@ export default class GPUGridCellLayer extends Layer {
|
|
|
158
169
|
return domainUniforms;
|
|
159
170
|
}
|
|
160
171
|
|
|
161
|
-
_setupUniformBuffer(model) {
|
|
162
|
-
const gl = this.context.gl;
|
|
172
|
+
private _setupUniformBuffer(model: Model): void {
|
|
173
|
+
const gl = this.context.gl as WebGL2RenderingContext;
|
|
163
174
|
const programHandle = model.program.handle;
|
|
164
175
|
|
|
165
176
|
const colorIndex = gl.getUniformBlockIndex(programHandle, 'ColorData');
|
|
@@ -168,6 +179,3 @@ export default class GPUGridCellLayer extends Layer {
|
|
|
168
179
|
gl.uniformBlockBinding(programHandle, elevationIndex, ELEVATION_DATA_UBO_INDEX);
|
|
169
180
|
}
|
|
170
181
|
}
|
|
171
|
-
|
|
172
|
-
GPUGridCellLayer.layerName = 'GPUGridCellLayer';
|
|
173
|
-
GPUGridCellLayer.defaultProps = defaultProps;
|
|
@@ -20,14 +20,24 @@
|
|
|
20
20
|
|
|
21
21
|
import {Buffer} from '@luma.gl/core';
|
|
22
22
|
import GL from '@luma.gl/constants';
|
|
23
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
Accessor,
|
|
25
|
+
AccessorFunction,
|
|
26
|
+
Color,
|
|
27
|
+
GetPickingInfoParams,
|
|
28
|
+
LayerContext,
|
|
29
|
+
log,
|
|
30
|
+
PickingInfo,
|
|
31
|
+
Position
|
|
32
|
+
} from '@deck.gl/core';
|
|
33
|
+
import {_MaterialProps as MaterialProps} from '@deck.gl/layers';
|
|
24
34
|
|
|
25
35
|
import GPUGridAggregator from '../utils/gpu-grid-aggregation/gpu-grid-aggregator';
|
|
26
36
|
import {AGGREGATION_OPERATION} from '../utils/aggregation-operation-utils';
|
|
27
37
|
import {defaultColorRange, colorRangeToFlatArray} from '../utils/color-utils';
|
|
28
38
|
import GPUGridCellLayer from './gpu-grid-cell-layer';
|
|
29
39
|
import {pointToDensityGridDataCPU} from './../cpu-grid-layer/grid-aggregator';
|
|
30
|
-
import GridAggregationLayer from '../grid-aggregation-layer';
|
|
40
|
+
import GridAggregationLayer, {GridAggregationLayerProps} from '../grid-aggregation-layer';
|
|
31
41
|
import {getBoundingBox, getGridParams} from '../utils/grid-aggregation-utils';
|
|
32
42
|
|
|
33
43
|
const defaultProps = {
|
|
@@ -65,14 +75,112 @@ const DIMENSIONS = {
|
|
|
65
75
|
};
|
|
66
76
|
const POSITION_ATTRIBUTE_NAME = 'positions';
|
|
67
77
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
78
|
+
/** All properties supported by GPUGridLayer. */
|
|
79
|
+
export type GPUGridLayerProps<DataT = any> = _GPUGridLayerProps<DataT> &
|
|
80
|
+
GridAggregationLayerProps<DataT>;
|
|
81
|
+
|
|
82
|
+
/** Properties added by GPUGridLayer. */
|
|
83
|
+
export type _GPUGridLayerProps<DataT> = {
|
|
84
|
+
/**
|
|
85
|
+
* Size of each cell in meters.
|
|
86
|
+
* @default 1000
|
|
87
|
+
*/
|
|
88
|
+
cellSize?: number;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Color scale domain, default is set to the extent of aggregated weights in each cell.
|
|
92
|
+
* @default [min(colorWeight), max(colorWeight)]
|
|
93
|
+
*/
|
|
94
|
+
colorDomain?: [number, number] | null;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Default: [colorbrewer](http://colorbrewer2.org/#type=sequential&scheme=YlOrRd&n=6) `6-class YlOrRd`
|
|
98
|
+
*/
|
|
99
|
+
colorRange?: Color[];
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Cell size multiplier, clamped between 0 - 1.
|
|
103
|
+
* @default 1
|
|
104
|
+
*/
|
|
105
|
+
coverage?: number;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Elevation scale input domain, default is set to between 0 and the max of aggregated weights in each cell.
|
|
109
|
+
* @default [0, max(elevationWeight)]
|
|
110
|
+
*/
|
|
111
|
+
elevationDomain?: [number, number] | null;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Elevation scale output range.
|
|
115
|
+
* @default [0, 1000]
|
|
116
|
+
*/
|
|
117
|
+
elevationRange?: [number, number];
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Cell elevation multiplier.
|
|
121
|
+
* @default 1
|
|
122
|
+
*/
|
|
123
|
+
elevationScale?: number;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Whether to enable cell elevation. If set to false, all cell will be flat.
|
|
127
|
+
* @default true
|
|
128
|
+
*/
|
|
129
|
+
extruded?: boolean;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* This is an object that contains material props
|
|
133
|
+
* for [lighting effect](/docs/api-reference/core/lighting-effect.md) applied on extruded polygons.
|
|
134
|
+
* @default true
|
|
135
|
+
*/
|
|
136
|
+
material?: MaterialProps | null;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Defines the operation used to aggregate all data object weights to calculate a cell's color value.
|
|
140
|
+
* @default 'SUM'
|
|
141
|
+
*/
|
|
142
|
+
colorAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Defines the operation used to aggregate all data object weights to calculate a cell's elevation value.
|
|
146
|
+
* @default 'SUM'
|
|
147
|
+
*/
|
|
148
|
+
elevationAggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Method called to retrieve the position of each object.
|
|
152
|
+
* @default object => object.position
|
|
153
|
+
*/
|
|
154
|
+
getPosition?: AccessorFunction<DataT, Position>;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* The weight of a data object used to calculate the color value for a cell.
|
|
158
|
+
* @default 1
|
|
159
|
+
*/
|
|
160
|
+
getColorWeight?: Accessor<DataT, number>;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* The weight of a data object used to calculate the elevation value for a cell.
|
|
164
|
+
* @default 1
|
|
165
|
+
*/
|
|
166
|
+
getElevationWeight?: Accessor<DataT, number>;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The `GPUGridLayer` renders a grid heatmap based on an array of inputs.
|
|
171
|
+
*/
|
|
172
|
+
export default class GPUGridLayer<DataT = any, ExtraPropsT = {}> extends GridAggregationLayer<
|
|
173
|
+
ExtraPropsT & Required<_GPUGridLayerProps<DataT>>
|
|
174
|
+
> {
|
|
175
|
+
static layerName = 'GPUGridLayer';
|
|
176
|
+
static defaultProps = defaultProps;
|
|
177
|
+
|
|
178
|
+
initializeState({gl}: LayerContext): void {
|
|
71
179
|
const isSupported = GPUGridAggregator.isSupported(gl);
|
|
72
180
|
if (!isSupported) {
|
|
73
181
|
log.error('GPUGridLayer is not supported on this browser, use GridLayer instead')();
|
|
74
182
|
}
|
|
75
|
-
super.
|
|
183
|
+
super.initializeAggregationLayer({
|
|
76
184
|
dimensions: DIMENSIONS
|
|
77
185
|
});
|
|
78
186
|
this.setState({
|
|
@@ -101,7 +209,7 @@ export default class GPUGridLayer extends GridAggregationLayer {
|
|
|
101
209
|
},
|
|
102
210
|
positionAttributeName: 'positions'
|
|
103
211
|
});
|
|
104
|
-
const attributeManager = this.getAttributeManager()
|
|
212
|
+
const attributeManager = this.getAttributeManager()!;
|
|
105
213
|
attributeManager.add({
|
|
106
214
|
[POSITION_ATTRIBUTE_NAME]: {
|
|
107
215
|
size: 3,
|
|
@@ -129,7 +237,7 @@ export default class GPUGridLayer extends GridAggregationLayer {
|
|
|
129
237
|
}
|
|
130
238
|
}
|
|
131
239
|
|
|
132
|
-
getHashKeyForIndex(index) {
|
|
240
|
+
getHashKeyForIndex(index: number): string {
|
|
133
241
|
const {numRow, numCol, boundingBox, gridOffset} = this.state;
|
|
134
242
|
const gridSize = [numCol, numRow];
|
|
135
243
|
const gridOrigin = [boundingBox.xMin, boundingBox.yMin];
|
|
@@ -147,7 +255,7 @@ export default class GPUGridLayer extends GridAggregationLayer {
|
|
|
147
255
|
return `${latIdx}-${lonIdx}`;
|
|
148
256
|
}
|
|
149
257
|
|
|
150
|
-
getPositionForIndex(index) {
|
|
258
|
+
getPositionForIndex(index: number): Position {
|
|
151
259
|
const {numRow, numCol, boundingBox, gridOffset} = this.state;
|
|
152
260
|
const gridSize = [numCol, numRow];
|
|
153
261
|
const gridOrigin = [boundingBox.xMin, boundingBox.yMin];
|
|
@@ -160,9 +268,9 @@ export default class GPUGridLayer extends GridAggregationLayer {
|
|
|
160
268
|
return [xPos, yPos];
|
|
161
269
|
}
|
|
162
270
|
|
|
163
|
-
getPickingInfo({info, mode}) {
|
|
271
|
+
getPickingInfo({info, mode}: GetPickingInfoParams): PickingInfo {
|
|
164
272
|
const {index} = info;
|
|
165
|
-
let object = null;
|
|
273
|
+
let object: any = null;
|
|
166
274
|
if (index >= 0) {
|
|
167
275
|
const {gpuGridAggregator} = this.state;
|
|
168
276
|
const position = this.getPositionForIndex(index);
|
|
@@ -190,7 +298,7 @@ export default class GPUGridLayer extends GridAggregationLayer {
|
|
|
190
298
|
const {gridOffset, translation, boundingBox} = this.state;
|
|
191
299
|
const {viewport} = this.context;
|
|
192
300
|
const attributes = this.getAttributes();
|
|
193
|
-
const cpuAggregation = pointToDensityGridDataCPU(props, {
|
|
301
|
+
const cpuAggregation = pointToDensityGridDataCPU(props as any, {
|
|
194
302
|
gridOffset,
|
|
195
303
|
attributes,
|
|
196
304
|
viewport,
|
|
@@ -267,14 +375,14 @@ export default class GPUGridLayer extends GridAggregationLayer {
|
|
|
267
375
|
);
|
|
268
376
|
}
|
|
269
377
|
|
|
270
|
-
finalizeState() {
|
|
378
|
+
finalizeState(context: LayerContext) {
|
|
271
379
|
const {color, elevation} = this.state.weights;
|
|
272
380
|
[color, elevation].forEach(weight => {
|
|
273
381
|
const {aggregationBuffer, maxMinBuffer} = weight;
|
|
274
382
|
maxMinBuffer.delete();
|
|
275
383
|
aggregationBuffer?.delete();
|
|
276
384
|
});
|
|
277
|
-
super.finalizeState();
|
|
385
|
+
super.finalizeState(context);
|
|
278
386
|
}
|
|
279
387
|
|
|
280
388
|
// Aggregation Overrides
|
|
@@ -338,6 +446,3 @@ export default class GPUGridLayer extends GridAggregationLayer {
|
|
|
338
446
|
elevation.operation = AGGREGATION_OPERATION[elevationAggregation];
|
|
339
447
|
}
|
|
340
448
|
}
|
|
341
|
-
|
|
342
|
-
GPUGridLayer.layerName = 'GPUGridLayer';
|
|
343
|
-
GPUGridLayer.defaultProps = defaultProps;
|
|
@@ -18,18 +18,32 @@
|
|
|
18
18
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
19
|
// THE SOFTWARE.
|
|
20
20
|
|
|
21
|
-
import AggregationLayer from './aggregation-layer';
|
|
21
|
+
import AggregationLayer, {AggregationLayerProps} from './aggregation-layer';
|
|
22
22
|
import GPUGridAggregator from './utils/gpu-grid-aggregation/gpu-grid-aggregator';
|
|
23
23
|
import {Buffer} from '@luma.gl/core';
|
|
24
|
-
import {log} from '@deck.gl/core';
|
|
24
|
+
import {LayerContext, log, UpdateParameters} from '@deck.gl/core';
|
|
25
25
|
import GL from '@luma.gl/constants';
|
|
26
26
|
import BinSorter from './utils/bin-sorter';
|
|
27
27
|
import {pointToDensityGridDataCPU} from './cpu-grid-layer/grid-aggregator';
|
|
28
28
|
|
|
29
|
-
export
|
|
30
|
-
|
|
29
|
+
export type GridAggregationLayerProps<DataT = any> = AggregationLayerProps<DataT>;
|
|
30
|
+
|
|
31
|
+
export default abstract class GridAggregationLayer<
|
|
32
|
+
ExtraPropsT = {}
|
|
33
|
+
> extends AggregationLayer<ExtraPropsT> {
|
|
34
|
+
static layerName = 'GridAggregationLayer';
|
|
35
|
+
|
|
36
|
+
state!: AggregationLayer['state'] & {
|
|
37
|
+
aggregationDataDirty?: any;
|
|
38
|
+
aggregationWeightsDirty?: any;
|
|
39
|
+
gpuAggregation?: any;
|
|
40
|
+
getValue?: () => any;
|
|
41
|
+
sortedBins?: BinSorter;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
initializeAggregationLayer({dimensions}) {
|
|
31
45
|
const {gl} = this.context;
|
|
32
|
-
super.
|
|
46
|
+
super.initializeAggregationLayer(dimensions);
|
|
33
47
|
this.setState({
|
|
34
48
|
// CPU aggregation results
|
|
35
49
|
layerData: {},
|
|
@@ -38,7 +52,7 @@ export default class GridAggregationLayer extends AggregationLayer {
|
|
|
38
52
|
});
|
|
39
53
|
}
|
|
40
54
|
|
|
41
|
-
updateState(opts) {
|
|
55
|
+
updateState(opts: UpdateParameters<this>) {
|
|
42
56
|
// get current attributes
|
|
43
57
|
super.updateState(opts);
|
|
44
58
|
|
|
@@ -68,16 +82,16 @@ export default class GridAggregationLayer extends AggregationLayer {
|
|
|
68
82
|
this.setState({aggregationDirty});
|
|
69
83
|
}
|
|
70
84
|
|
|
71
|
-
finalizeState() {
|
|
85
|
+
finalizeState(context: LayerContext) {
|
|
72
86
|
const {count} = this.state.weights;
|
|
73
87
|
if (count && count.aggregationBuffer) {
|
|
74
88
|
count.aggregationBuffer.delete();
|
|
75
89
|
}
|
|
76
90
|
this.state.gpuGridAggregator?.delete();
|
|
77
|
-
super.finalizeState();
|
|
91
|
+
super.finalizeState(context);
|
|
78
92
|
}
|
|
79
93
|
|
|
80
|
-
updateShaders(shaders) {
|
|
94
|
+
updateShaders(shaders: any): void {
|
|
81
95
|
if (this.state.gpuAggregation) {
|
|
82
96
|
this.state.gpuGridAggregator.updateShaders(shaders);
|
|
83
97
|
}
|
|
@@ -179,10 +193,10 @@ export default class GridAggregationLayer extends AggregationLayer {
|
|
|
179
193
|
this.setState({sortedBins});
|
|
180
194
|
}
|
|
181
195
|
|
|
182
|
-
_uploadAggregationResults() {
|
|
196
|
+
_uploadAggregationResults(): void {
|
|
183
197
|
const {numCol, numRow} = this.state;
|
|
184
198
|
const {data} = this.state.layerData;
|
|
185
|
-
const {aggregatedBins, minValue, maxValue, totalCount} = this.state.sortedBins
|
|
199
|
+
const {aggregatedBins, minValue, maxValue, totalCount} = this.state.sortedBins!;
|
|
186
200
|
|
|
187
201
|
const ELEMENTCOUNT = 4;
|
|
188
202
|
const aggregationSize = numCol * numRow * ELEMENTCOUNT;
|
|
@@ -200,5 +214,3 @@ export default class GridAggregationLayer extends AggregationLayer {
|
|
|
200
214
|
this.updateResults({aggregationData, maxMinData, maxData, minData});
|
|
201
215
|
}
|
|
202
216
|
}
|
|
203
|
-
|
|
204
|
-
GridAggregationLayer.layerName = 'GridAggregationLayer';
|