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