@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
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {CompositeLayer} from '@deck.gl/core';
|
|
1
|
+
import {CompositeLayer, CompositeLayerProps, Layer, UpdateParameters} from '@deck.gl/core';
|
|
2
2
|
import GPUGridAggregator from '../utils/gpu-grid-aggregation/gpu-grid-aggregator';
|
|
3
|
-
import GPUGridLayer from '../gpu-grid-layer/gpu-grid-layer';
|
|
4
|
-
import CPUGridLayer from '../cpu-grid-layer/cpu-grid-layer';
|
|
3
|
+
import GPUGridLayer, {_GPUGridLayerProps} from '../gpu-grid-layer/gpu-grid-layer';
|
|
4
|
+
import CPUGridLayer, {_CPUGridLayerProps} from '../cpu-grid-layer/cpu-grid-layer';
|
|
5
5
|
|
|
6
6
|
const defaultProps = {
|
|
7
7
|
...GPUGridLayer.defaultProps,
|
|
@@ -9,20 +9,48 @@ const defaultProps = {
|
|
|
9
9
|
gpuAggregation: false
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
/** All properties supported by GridLayer. */
|
|
13
|
+
export type GridLayerProps<DataT = any> = _GridLayerProps<DataT> & CompositeLayerProps<DataT>;
|
|
14
|
+
|
|
15
|
+
/** Properties added by GridLayer. */
|
|
16
|
+
type _GridLayerProps<DataT = any> = _CPUGridLayerProps<DataT> &
|
|
17
|
+
_GPUGridLayerProps<DataT> & {
|
|
18
|
+
/**
|
|
19
|
+
* Whether the aggregation should be performed in high-precision 64-bit mode.
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
fp64?: boolean;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* When set to true, aggregation is performed on GPU, provided other conditions are met.
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
gpuAggregation?: boolean;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default class GridLayer<DataT = any, ExtraPropsT = {}> extends CompositeLayer<
|
|
32
|
+
ExtraPropsT & Required<_GridLayerProps<DataT>>
|
|
33
|
+
> {
|
|
34
|
+
static layerName = 'GridLayer';
|
|
35
|
+
static defaultProps = defaultProps;
|
|
36
|
+
|
|
37
|
+
state!: CompositeLayer['state'] & {
|
|
38
|
+
useGPUAggregation: boolean;
|
|
39
|
+
};
|
|
40
|
+
|
|
13
41
|
initializeState() {
|
|
14
42
|
this.state = {
|
|
15
43
|
useGPUAggregation: true
|
|
16
44
|
};
|
|
17
45
|
}
|
|
18
46
|
|
|
19
|
-
updateState({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
47
|
+
updateState({props}: UpdateParameters<this>) {
|
|
48
|
+
this.setState({
|
|
49
|
+
useGPUAggregation: this.canUseGPUAggregation(props)
|
|
50
|
+
});
|
|
23
51
|
}
|
|
24
52
|
|
|
25
|
-
renderLayers() {
|
|
53
|
+
renderLayers(): Layer {
|
|
26
54
|
const {data, updateTriggers} = this.props;
|
|
27
55
|
const id = this.state.useGPUAggregation ? 'GPU' : 'CPU';
|
|
28
56
|
const LayerType = this.state.useGPUAggregation
|
|
@@ -42,7 +70,7 @@ export default class GridLayer extends CompositeLayer {
|
|
|
42
70
|
|
|
43
71
|
// Private methods
|
|
44
72
|
|
|
45
|
-
canUseGPUAggregation(props) {
|
|
73
|
+
canUseGPUAggregation(props: GridLayer['props']) {
|
|
46
74
|
const {
|
|
47
75
|
gpuAggregation,
|
|
48
76
|
lowerPercentile,
|
|
@@ -73,6 +101,3 @@ export default class GridLayer extends CompositeLayer {
|
|
|
73
101
|
return true;
|
|
74
102
|
}
|
|
75
103
|
}
|
|
76
|
-
|
|
77
|
-
GridLayer.layerName = 'GridLayer';
|
|
78
|
-
GridLayer.defaultProps = defaultProps;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import GL from '@luma.gl/constants';
|
|
2
2
|
import {isWebGL2} from '@luma.gl/core';
|
|
3
3
|
|
|
4
|
-
export function getBounds(points) {
|
|
4
|
+
export function getBounds(points: number[][]): number[] {
|
|
5
5
|
// Now build bounding box in world space (aligned to world coordiante system)
|
|
6
6
|
const x = points.map(p => p[0]);
|
|
7
7
|
const y = points.map(p => p[1]);
|
|
@@ -15,7 +15,7 @@ export function getBounds(points) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
// true if currentBounds contains targetBounds, false otherwise
|
|
18
|
-
export function boundsContain(currentBounds, targetBounds) {
|
|
18
|
+
export function boundsContain(currentBounds: number[], targetBounds: number[]): boolean {
|
|
19
19
|
if (
|
|
20
20
|
targetBounds[0] >= currentBounds[0] &&
|
|
21
21
|
targetBounds[2] <= currentBounds[2] &&
|
|
@@ -30,7 +30,7 @@ export function boundsContain(currentBounds, targetBounds) {
|
|
|
30
30
|
const scratchArray = new Float32Array(12);
|
|
31
31
|
|
|
32
32
|
// For given rectangle bounds generates two triangles vertices that coverit completely
|
|
33
|
-
export function packVertices(points, dimensions = 2) {
|
|
33
|
+
export function packVertices(points: number[][], dimensions: number = 2): Float32Array {
|
|
34
34
|
let index = 0;
|
|
35
35
|
for (const point of points) {
|
|
36
36
|
for (let i = 0; i < dimensions; i++) {
|
|
@@ -41,7 +41,7 @@ export function packVertices(points, dimensions = 2) {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
// Expands boundingBox:[xMin, yMin, xMax, yMax] to match aspect ratio of given width and height
|
|
44
|
-
export function scaleToAspectRatio(boundingBox, width, height) {
|
|
44
|
+
export function scaleToAspectRatio(boundingBox: number[], width: number, height: number): number[] {
|
|
45
45
|
const [xMin, yMin, xMax, yMax] = boundingBox;
|
|
46
46
|
|
|
47
47
|
const currentWidth = xMax - xMin;
|
|
@@ -73,7 +73,7 @@ export function scaleToAspectRatio(boundingBox, width, height) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
// Get texture coordiante of point inside a bounding box
|
|
76
|
-
export function getTextureCoordinates(point, bounds) {
|
|
76
|
+
export function getTextureCoordinates(point: number[], bounds: number[]) {
|
|
77
77
|
const [xMin, yMin, xMax, yMax] = bounds;
|
|
78
78
|
return [(point[0] - xMin) / (xMax - xMin), (point[1] - yMin) / (yMax - yMin)];
|
|
79
79
|
}
|
|
@@ -29,14 +29,27 @@ import {
|
|
|
29
29
|
getTextureParams
|
|
30
30
|
} from './heatmap-layer-utils';
|
|
31
31
|
import {Buffer, Texture2D, Transform, getParameters, FEATURES, hasFeatures} from '@luma.gl/core';
|
|
32
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
Accessor,
|
|
34
|
+
AccessorFunction,
|
|
35
|
+
AttributeManager,
|
|
36
|
+
ChangeFlags,
|
|
37
|
+
Color,
|
|
38
|
+
COORDINATE_SYSTEM,
|
|
39
|
+
Layer,
|
|
40
|
+
LayerContext,
|
|
41
|
+
LayersList,
|
|
42
|
+
log,
|
|
43
|
+
Position,
|
|
44
|
+
UpdateParameters
|
|
45
|
+
} from '@deck.gl/core';
|
|
33
46
|
import TriangleLayer from './triangle-layer';
|
|
34
|
-
import AggregationLayer from '../aggregation-layer';
|
|
47
|
+
import AggregationLayer, {AggregationLayerProps} from '../aggregation-layer';
|
|
35
48
|
import {defaultColorRange, colorRangeToFlatArray} from '../utils/color-utils';
|
|
36
|
-
import
|
|
37
|
-
import
|
|
38
|
-
import
|
|
39
|
-
import
|
|
49
|
+
import weightsVs from './weights-vs.glsl';
|
|
50
|
+
import weightsFs from './weights-fs.glsl';
|
|
51
|
+
import vsMax from './max-vs.glsl';
|
|
52
|
+
import fsMax from './max-fs.glsl';
|
|
40
53
|
|
|
41
54
|
const RESOLUTION = 2; // (number of common space pixels) / (number texels)
|
|
42
55
|
const TEXTURE_OPTIONS = {
|
|
@@ -85,7 +98,103 @@ const DIMENSIONS = {
|
|
|
85
98
|
}
|
|
86
99
|
};
|
|
87
100
|
|
|
88
|
-
export
|
|
101
|
+
export type HeatmapLayerProps<DataT> = _HeatmapLayerProps<DataT> & AggregationLayerProps<DataT>;
|
|
102
|
+
|
|
103
|
+
type _HeatmapLayerProps<DataT = any> = {
|
|
104
|
+
/**
|
|
105
|
+
* Radius of the circle in pixels, to which the weight of an object is distributed.
|
|
106
|
+
*
|
|
107
|
+
* @default 30
|
|
108
|
+
*/
|
|
109
|
+
radiusPixels?: number;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Specified as an array of colors [color1, color2, ...].
|
|
113
|
+
*
|
|
114
|
+
* @default `6-class YlOrRd` - [colorbrewer](http://colorbrewer2.org/#type=sequential&scheme=YlOrRd&n=6)
|
|
115
|
+
*/
|
|
116
|
+
colorRange?: Color[];
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Value that is multiplied with the total weight at a pixel to obtain the final weight.
|
|
120
|
+
*
|
|
121
|
+
* @default 1
|
|
122
|
+
*/
|
|
123
|
+
intensity?: number;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Ratio of the fading weight to the max weight, between `0` and `1`.
|
|
127
|
+
*
|
|
128
|
+
* For example, `0.1` affects all pixels with weight under 10% of the max.
|
|
129
|
+
*
|
|
130
|
+
* Ignored when `colorDomain` is specified.
|
|
131
|
+
* @default 0.05
|
|
132
|
+
*/
|
|
133
|
+
threshold?: number;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Controls how weight values are mapped to the `colorRange`, as an array of two numbers [`minValue`, `maxValue`].
|
|
137
|
+
*
|
|
138
|
+
* @default null
|
|
139
|
+
*/
|
|
140
|
+
colorDomain?: [number, number] | null;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Defines the type of aggregation operation
|
|
144
|
+
*
|
|
145
|
+
* V valid values are 'SUM', 'MEAN'.
|
|
146
|
+
*
|
|
147
|
+
* @default 'SUM'
|
|
148
|
+
*/
|
|
149
|
+
aggregation?: 'SUM' | 'MEAN';
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Specifies the size of weight texture.
|
|
153
|
+
* @default 2048
|
|
154
|
+
*/
|
|
155
|
+
weightsTextureSize?: number;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Interval in milliseconds during which changes to the viewport don't trigger aggregation.
|
|
159
|
+
*
|
|
160
|
+
* @default 500
|
|
161
|
+
*/
|
|
162
|
+
debounceTimeout?: number;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Method called to retrieve the position of each object.
|
|
166
|
+
*
|
|
167
|
+
* @default d => d.position
|
|
168
|
+
*/
|
|
169
|
+
getPosition?: AccessorFunction<DataT, Position>;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* The weight of each object.
|
|
173
|
+
*
|
|
174
|
+
* @default 1
|
|
175
|
+
*/
|
|
176
|
+
getWeight?: Accessor<DataT, number>;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export default class HeatmapLayer<DataT = any, ExtraPropsT = {}> extends AggregationLayer<
|
|
180
|
+
ExtraPropsT & Required<_HeatmapLayerProps<DataT>>
|
|
181
|
+
> {
|
|
182
|
+
static layerName = 'HeatmapLayer';
|
|
183
|
+
static defaultProps = defaultProps;
|
|
184
|
+
|
|
185
|
+
state!: AggregationLayer['state'] & {
|
|
186
|
+
supported: boolean;
|
|
187
|
+
colorDomain?: number[];
|
|
188
|
+
isWeightMapDirty?: boolean;
|
|
189
|
+
weightsTexture?: Texture2D;
|
|
190
|
+
zoom?: number;
|
|
191
|
+
worldBounds?: number[];
|
|
192
|
+
normalizedCommonBounds?: number[];
|
|
193
|
+
updateTimer?: any;
|
|
194
|
+
triPositionBuffer?: Buffer;
|
|
195
|
+
triTexCoordBuffer?: Buffer;
|
|
196
|
+
};
|
|
197
|
+
|
|
89
198
|
initializeState() {
|
|
90
199
|
const {gl} = this.context;
|
|
91
200
|
if (!hasFeatures(gl, REQUIRED_FEATURES)) {
|
|
@@ -93,20 +202,20 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
93
202
|
log.error(`HeatmapLayer: ${this.id} is not supported on this browser`)();
|
|
94
203
|
return;
|
|
95
204
|
}
|
|
96
|
-
super.
|
|
205
|
+
super.initializeAggregationLayer(DIMENSIONS);
|
|
97
206
|
this.setState({supported: true, colorDomain: DEFAULT_COLOR_DOMAIN});
|
|
98
207
|
this._setupTextureParams();
|
|
99
208
|
this._setupAttributes();
|
|
100
209
|
this._setupResources();
|
|
101
210
|
}
|
|
102
211
|
|
|
103
|
-
shouldUpdateState({changeFlags}) {
|
|
212
|
+
shouldUpdateState({changeFlags}: UpdateParameters<this>) {
|
|
104
213
|
// Need to be updated when viewport changes
|
|
105
214
|
return changeFlags.somethingChanged;
|
|
106
215
|
}
|
|
107
216
|
|
|
108
217
|
/* eslint-disable max-statements,complexity */
|
|
109
|
-
updateState(opts) {
|
|
218
|
+
updateState(opts: UpdateParameters<this>) {
|
|
110
219
|
if (!this.state.supported) {
|
|
111
220
|
return;
|
|
112
221
|
}
|
|
@@ -114,7 +223,7 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
114
223
|
this._updateHeatmapState(opts);
|
|
115
224
|
}
|
|
116
225
|
|
|
117
|
-
_updateHeatmapState(opts) {
|
|
226
|
+
_updateHeatmapState(opts: UpdateParameters<this>) {
|
|
118
227
|
const {props, oldProps} = opts;
|
|
119
228
|
const changeFlags = this._getChangeFlags(opts);
|
|
120
229
|
|
|
@@ -144,7 +253,7 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
144
253
|
this.setState({zoom: opts.context.viewport.zoom});
|
|
145
254
|
}
|
|
146
255
|
|
|
147
|
-
renderLayers() {
|
|
256
|
+
renderLayers(): LayersList | Layer {
|
|
148
257
|
if (!this.state.supported) {
|
|
149
258
|
return [];
|
|
150
259
|
}
|
|
@@ -187,8 +296,8 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
187
296
|
);
|
|
188
297
|
}
|
|
189
298
|
|
|
190
|
-
finalizeState() {
|
|
191
|
-
super.finalizeState();
|
|
299
|
+
finalizeState(context: LayerContext) {
|
|
300
|
+
super.finalizeState(context);
|
|
192
301
|
const {
|
|
193
302
|
weightsTransform,
|
|
194
303
|
weightsTexture,
|
|
@@ -221,8 +330,11 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
221
330
|
});
|
|
222
331
|
}
|
|
223
332
|
|
|
224
|
-
_getChangeFlags(opts) {
|
|
225
|
-
const changeFlags
|
|
333
|
+
_getChangeFlags(opts: UpdateParameters<this>) {
|
|
334
|
+
const changeFlags: Partial<ChangeFlags> & {
|
|
335
|
+
boundsChanged?: boolean;
|
|
336
|
+
viewportZoomChanged?: boolean;
|
|
337
|
+
} = {};
|
|
226
338
|
const {dimensions} = this.state;
|
|
227
339
|
changeFlags.dataChanged =
|
|
228
340
|
this.isAttributeChanged() || // if any attribute is changed
|
|
@@ -257,7 +369,7 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
257
369
|
}
|
|
258
370
|
|
|
259
371
|
_setupAttributes() {
|
|
260
|
-
const attributeManager = this.getAttributeManager()
|
|
372
|
+
const attributeManager = this.getAttributeManager()!;
|
|
261
373
|
attributeManager.add({
|
|
262
374
|
positions: {size: 3, type: GL.DOUBLE, accessor: 'getPosition'},
|
|
263
375
|
weights: {size: 1, accessor: 'getWeight'}
|
|
@@ -285,12 +397,12 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
285
397
|
return super.getShaders(
|
|
286
398
|
type === 'max-weights-transform'
|
|
287
399
|
? {
|
|
288
|
-
vs:
|
|
289
|
-
_fs:
|
|
400
|
+
vs: vsMax,
|
|
401
|
+
_fs: fsMax
|
|
290
402
|
}
|
|
291
403
|
: {
|
|
292
|
-
vs:
|
|
293
|
-
_fs:
|
|
404
|
+
vs: weightsVs,
|
|
405
|
+
_fs: weightsFs
|
|
294
406
|
}
|
|
295
407
|
);
|
|
296
408
|
}
|
|
@@ -366,7 +478,7 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
366
478
|
}
|
|
367
479
|
|
|
368
480
|
// Computes world bounds area that needs to be processed for generate heatmap
|
|
369
|
-
_updateBounds(forceUpdate = false) {
|
|
481
|
+
_updateBounds(forceUpdate: any = false): boolean {
|
|
370
482
|
const {viewport} = this.context;
|
|
371
483
|
|
|
372
484
|
// Unproject all 4 corners of the current screen coordinates into world coordinates (lng/lat)
|
|
@@ -381,7 +493,7 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
381
493
|
// #1: get world bounds for current viewport extends
|
|
382
494
|
const visibleWorldBounds = getBounds(viewportCorners); // TODO: Change to visible bounds
|
|
383
495
|
|
|
384
|
-
const newState = {visibleWorldBounds, viewportCorners};
|
|
496
|
+
const newState: Partial<HeatmapLayer['state']> = {visibleWorldBounds, viewportCorners};
|
|
385
497
|
let boundsChanged = false;
|
|
386
498
|
|
|
387
499
|
if (
|
|
@@ -426,7 +538,7 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
426
538
|
triPositionBuffer.subData(packVertices(viewportCorners, 3));
|
|
427
539
|
|
|
428
540
|
const textureBounds = viewportCorners.map(p =>
|
|
429
|
-
getTextureCoordinates(viewport.projectPosition(p), normalizedCommonBounds)
|
|
541
|
+
getTextureCoordinates(viewport.projectPosition(p), normalizedCommonBounds!)
|
|
430
542
|
);
|
|
431
543
|
triTexCoordBuffer.subData(packVertices(textureBounds, 2));
|
|
432
544
|
}
|
|
@@ -434,7 +546,7 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
434
546
|
_updateColorTexture(opts) {
|
|
435
547
|
const {colorRange} = opts.props;
|
|
436
548
|
let {colorTexture} = this.state;
|
|
437
|
-
const colors = colorRangeToFlatArray(colorRange, false, Uint8Array);
|
|
549
|
+
const colors = colorRangeToFlatArray(colorRange, false, Uint8Array as any);
|
|
438
550
|
|
|
439
551
|
if (colorTexture) {
|
|
440
552
|
colorTexture.setImageData({
|
|
@@ -527,7 +639,7 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
527
639
|
// input: worldBounds: [minLong, minLat, maxLong, maxLat]
|
|
528
640
|
// input: opts.useLayerCoordinateSystem : layers coordiante system is used
|
|
529
641
|
// optput: commonBounds: [minX, minY, maxX, maxY] scaled to fit the current texture
|
|
530
|
-
_worldToCommonBounds(worldBounds, opts = {}) {
|
|
642
|
+
_worldToCommonBounds(worldBounds, opts: {useLayerCoordinateSystem?: boolean} = {}) {
|
|
531
643
|
const {useLayerCoordinateSystem = false} = opts;
|
|
532
644
|
const [minLong, minLat, maxLong, maxLat] = worldBounds;
|
|
533
645
|
const {viewport} = this.context;
|
|
@@ -578,6 +690,3 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
578
690
|
return bottomLeftWorld.slice(0, 2).concat(topRightWorld.slice(0, 2));
|
|
579
691
|
}
|
|
580
692
|
}
|
|
581
|
-
|
|
582
|
-
HeatmapLayer.layerName = 'HeatmapLayer';
|
|
583
|
-
HeatmapLayer.defaultProps = defaultProps;
|
|
File without changes
|
|
File without changes
|
package/src/heatmap-layer/{triangle-layer-fragment.glsl.js → triangle-layer-fragment.glsl.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
@@ -19,19 +19,31 @@
|
|
|
19
19
|
// THE SOFTWARE.
|
|
20
20
|
|
|
21
21
|
import GL from '@luma.gl/constants';
|
|
22
|
-
import {Model, Geometry} from '@luma.gl/core';
|
|
23
|
-
import {Layer, project32} from '@deck.gl/core';
|
|
22
|
+
import {Model, Geometry, Texture2D} from '@luma.gl/core';
|
|
23
|
+
import {Layer, LayerContext, project32} from '@deck.gl/core';
|
|
24
24
|
import vs from './triangle-layer-vertex.glsl';
|
|
25
25
|
import fs from './triangle-layer-fragment.glsl';
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
type _TriangleLayerProps = {
|
|
28
|
+
colorDomain: number[];
|
|
29
|
+
aggregationMode: string;
|
|
30
|
+
threshold: number;
|
|
31
|
+
intensity: number;
|
|
32
|
+
vertexCount: number;
|
|
33
|
+
colorTexture: Texture2D;
|
|
34
|
+
maxTexture: Texture2D;
|
|
35
|
+
texture: Texture2D;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default class TriangleLayer extends Layer<_TriangleLayerProps> {
|
|
39
|
+
static layerName = 'TriangleLayer';
|
|
40
|
+
|
|
28
41
|
getShaders() {
|
|
29
42
|
return {vs, fs, modules: [project32]};
|
|
30
43
|
}
|
|
31
44
|
|
|
32
|
-
initializeState() {
|
|
33
|
-
const
|
|
34
|
-
const attributeManager = this.getAttributeManager();
|
|
45
|
+
initializeState({gl}: LayerContext): void {
|
|
46
|
+
const attributeManager = this.getAttributeManager()!;
|
|
35
47
|
attributeManager.add({
|
|
36
48
|
positions: {size: 3, noAlloc: true},
|
|
37
49
|
texCoords: {size: 2, noAlloc: true}
|
|
@@ -41,7 +53,7 @@ export default class TriangleLayer extends Layer {
|
|
|
41
53
|
});
|
|
42
54
|
}
|
|
43
55
|
|
|
44
|
-
_getModel(gl) {
|
|
56
|
+
_getModel(gl: WebGLRenderingContext): Model {
|
|
45
57
|
const {vertexCount} = this.props;
|
|
46
58
|
|
|
47
59
|
return new Model(gl, {
|
|
@@ -54,7 +66,7 @@ export default class TriangleLayer extends Layer {
|
|
|
54
66
|
});
|
|
55
67
|
}
|
|
56
68
|
|
|
57
|
-
draw({uniforms}) {
|
|
69
|
+
draw({uniforms}): void {
|
|
58
70
|
const {model} = this.state;
|
|
59
71
|
|
|
60
72
|
const {texture, maxTexture, colorTexture, intensity, threshold, aggregationMode, colorDomain} =
|
|
@@ -74,5 +86,3 @@ export default class TriangleLayer extends Layer {
|
|
|
74
86
|
.draw();
|
|
75
87
|
}
|
|
76
88
|
}
|
|
77
|
-
|
|
78
|
-
TriangleLayer.layerName = 'TriangleLayer';
|
|
File without changes
|
|
File without changes
|