@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
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@deck.gl/aggregation-layers",
|
|
3
3
|
"description": "deck.gl layers that aggregate the input data into alternative representations",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "8.8.0-
|
|
5
|
+
"version": "8.8.0-beta.1",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
@@ -30,13 +30,15 @@
|
|
|
30
30
|
"prepublishOnly": "npm run build-bundle && npm run build-bundle -- --env.dev"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@luma.gl/
|
|
34
|
-
"@
|
|
33
|
+
"@luma.gl/constants": "^8.5.14",
|
|
34
|
+
"@luma.gl/core": "^8.5.14",
|
|
35
|
+
"@luma.gl/shadertools": "^8.5.14",
|
|
36
|
+
"@math.gl/web-mercator": "^3.6.0",
|
|
35
37
|
"d3-hexbin": "^0.2.1"
|
|
36
38
|
},
|
|
37
39
|
"peerDependencies": {
|
|
38
40
|
"@deck.gl/core": "^8.0.0",
|
|
39
41
|
"@deck.gl/layers": "^8.0.0"
|
|
40
42
|
},
|
|
41
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "1e4621a4f7422a053a74dcd8a175f9b56c273a14"
|
|
42
44
|
}
|
|
@@ -18,22 +18,39 @@
|
|
|
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
|
+
CompositeLayer,
|
|
23
|
+
AttributeManager,
|
|
24
|
+
_compareProps as compareProps,
|
|
25
|
+
UpdateParameters,
|
|
26
|
+
CompositeLayerProps
|
|
27
|
+
} from '@deck.gl/core';
|
|
22
28
|
import {cssToDeviceRatio} from '@luma.gl/core';
|
|
23
29
|
import {filterProps} from './utils/prop-utils';
|
|
24
30
|
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
export type AggregationLayerProps<DataT = any> = CompositeLayerProps<DataT>;
|
|
32
|
+
|
|
33
|
+
export default abstract class AggregationLayer<
|
|
34
|
+
ExtraPropsT = {}
|
|
35
|
+
> extends CompositeLayer<ExtraPropsT> {
|
|
36
|
+
static layerName = 'AggregationLayer';
|
|
37
|
+
|
|
38
|
+
state!: CompositeLayer['state'] & {
|
|
39
|
+
ignoreProps?: Record<string, any>;
|
|
40
|
+
dimensions?: any;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
initializeAggregationLayer(dimensions: any) {
|
|
44
|
+
super.initializeState(this.context);
|
|
28
45
|
|
|
29
46
|
this.setState({
|
|
30
47
|
// Layer props , when changed doesn't require updating aggregation
|
|
31
|
-
ignoreProps: filterProps(this.constructor._propTypes, dimensions.data.props),
|
|
48
|
+
ignoreProps: filterProps((this.constructor as any)._propTypes, dimensions.data.props),
|
|
32
49
|
dimensions
|
|
33
50
|
});
|
|
34
51
|
}
|
|
35
52
|
|
|
36
|
-
updateState(opts) {
|
|
53
|
+
updateState(opts: UpdateParameters<this>) {
|
|
37
54
|
super.updateState(opts);
|
|
38
55
|
const {changeFlags} = opts;
|
|
39
56
|
if (changeFlags.extensionsChanged) {
|
|
@@ -45,7 +62,7 @@ export default class AggregationLayer extends CompositeLayer {
|
|
|
45
62
|
}
|
|
46
63
|
|
|
47
64
|
// Explictly call to update attributes as 'CompositeLayer' doesn't call this
|
|
48
|
-
this._updateAttributes(
|
|
65
|
+
this._updateAttributes();
|
|
49
66
|
}
|
|
50
67
|
|
|
51
68
|
updateAttributes(changedAttributes) {
|
|
@@ -55,7 +72,7 @@ export default class AggregationLayer extends CompositeLayer {
|
|
|
55
72
|
}
|
|
56
73
|
|
|
57
74
|
getAttributes() {
|
|
58
|
-
return this.getAttributeManager()
|
|
75
|
+
return this.getAttributeManager()!.getShaderAttributes();
|
|
59
76
|
}
|
|
60
77
|
|
|
61
78
|
getModuleSettings() {
|
|
@@ -84,7 +101,10 @@ export default class AggregationLayer extends CompositeLayer {
|
|
|
84
101
|
* @param {Boolean} params.compareAll - when `true` it will include non layer props for comparision
|
|
85
102
|
* @returns {Boolean} - returns true if dimensions' prop or accessor is changed
|
|
86
103
|
**/
|
|
87
|
-
isAggregationDirty(
|
|
104
|
+
isAggregationDirty(
|
|
105
|
+
updateOpts,
|
|
106
|
+
params: {compareAll?: boolean; dimension?: any} = {}
|
|
107
|
+
): string | boolean {
|
|
88
108
|
const {props, oldProps, changeFlags} = updateOpts;
|
|
89
109
|
const {compareAll = false, dimension} = params;
|
|
90
110
|
const {ignoreProps} = this.state;
|
|
@@ -113,7 +133,7 @@ export default class AggregationLayer extends CompositeLayer {
|
|
|
113
133
|
oldProps,
|
|
114
134
|
newProps: props,
|
|
115
135
|
ignoreProps,
|
|
116
|
-
propTypes: this.constructor._propTypes
|
|
136
|
+
propTypes: (this.constructor as any)._propTypes
|
|
117
137
|
});
|
|
118
138
|
}
|
|
119
139
|
// Compare props of the dimension
|
|
@@ -131,7 +151,7 @@ export default class AggregationLayer extends CompositeLayer {
|
|
|
131
151
|
* @returns {Boolean} - `true` if attribute `name` is changed, `false` otherwise,
|
|
132
152
|
* If `name` is not passed or `undefiend`, `true` if any attribute is changed, `false` otherwise
|
|
133
153
|
**/
|
|
134
|
-
isAttributeChanged(name) {
|
|
154
|
+
isAttributeChanged(name?: string) {
|
|
135
155
|
const {changedAttributes} = this.state;
|
|
136
156
|
if (!name) {
|
|
137
157
|
// if name not specified return true if any attribute is changed
|
|
@@ -156,13 +176,10 @@ export default class AggregationLayer extends CompositeLayer {
|
|
|
156
176
|
// Returns true if given object is empty, false otherwise.
|
|
157
177
|
function isObjectEmpty(obj) {
|
|
158
178
|
let isEmpty = true;
|
|
159
|
-
|
|
179
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
160
180
|
for (const key in obj) {
|
|
161
181
|
isEmpty = false;
|
|
162
182
|
break;
|
|
163
183
|
}
|
|
164
|
-
/* eslint-enable no-unused-vars */
|
|
165
184
|
return isEmpty;
|
|
166
185
|
}
|
|
167
|
-
|
|
168
|
-
AggregationLayer.layerName = 'AggregationLayer';
|
|
@@ -21,12 +21,20 @@
|
|
|
21
21
|
import GL from '@luma.gl/constants';
|
|
22
22
|
import {LineLayer, SolidPolygonLayer} from '@deck.gl/layers';
|
|
23
23
|
import {generateContours} from './contour-utils';
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
Accessor,
|
|
26
|
+
AccessorFunction,
|
|
27
|
+
Color,
|
|
28
|
+
Layer,
|
|
29
|
+
log,
|
|
30
|
+
Position,
|
|
31
|
+
UpdateParameters
|
|
32
|
+
} from '@deck.gl/core';
|
|
25
33
|
|
|
26
34
|
import GPUGridAggregator from '../utils/gpu-grid-aggregation/gpu-grid-aggregator';
|
|
27
35
|
import {AGGREGATION_OPERATION, getValueFunc} from '../utils/aggregation-operation-utils';
|
|
28
36
|
import {getBoundingBox, getGridParams} from '../utils/grid-aggregation-utils';
|
|
29
|
-
import GridAggregationLayer from '../grid-aggregation-layer';
|
|
37
|
+
import GridAggregationLayer, {GridAggregationLayerProps} from '../grid-aggregation-layer';
|
|
30
38
|
|
|
31
39
|
const DEFAULT_COLOR = [255, 255, 255, 255];
|
|
32
40
|
const DEFAULT_STROKE_WIDTH = 1;
|
|
@@ -58,9 +66,84 @@ const DIMENSIONS = {
|
|
|
58
66
|
}
|
|
59
67
|
};
|
|
60
68
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
69
|
+
/** All properties supported by ContourLayer. */
|
|
70
|
+
export type ContourLayerProps<DataT = any> = _ContourLayerProps<DataT> &
|
|
71
|
+
GridAggregationLayerProps<DataT>;
|
|
72
|
+
|
|
73
|
+
/** Properties added by ContourLayer. */
|
|
74
|
+
export type _ContourLayerProps<DataT> = {
|
|
75
|
+
/**
|
|
76
|
+
* Size of each cell in meters.
|
|
77
|
+
* @default 1000
|
|
78
|
+
*/
|
|
79
|
+
cellSize?: number;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* When set to true, aggregation is performed on GPU, provided other conditions are met.
|
|
83
|
+
* @default true
|
|
84
|
+
*/
|
|
85
|
+
gpuAggregation?: boolean;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Defines the type of aggregation operation, valid values are 'SUM', 'MEAN', 'MIN' and 'MAX'.
|
|
89
|
+
* @default 'SUM'
|
|
90
|
+
*/
|
|
91
|
+
aggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Definition of contours to be drawn.
|
|
95
|
+
* @default [{threshold: 1}]
|
|
96
|
+
*/
|
|
97
|
+
contours: {
|
|
98
|
+
/**
|
|
99
|
+
* Isolines: `threshold` value must be a single `Number`, Isolines are generated based on this threshold value.
|
|
100
|
+
*
|
|
101
|
+
* Isobands: `threshold` value must be an Array of two `Number`s. Isobands are generated using `[threshold[0], threshold[1])` as threshold range, i.e area that has values `>= threshold[0]` and `< threshold[1]` are rendered with corresponding color. NOTE: `threshold[0]` is inclusive and `threshold[1]` is not inclusive.
|
|
102
|
+
*/
|
|
103
|
+
threshold: number | number[];
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* RGBA color array to be used to render the contour.
|
|
107
|
+
* @default [255, 255, 255, 255]
|
|
108
|
+
*/
|
|
109
|
+
color?: Color;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Applicable for `Isoline`s only, width of the Isoline in pixels.
|
|
113
|
+
* @default 1
|
|
114
|
+
*/
|
|
115
|
+
strokeWidth?: number;
|
|
116
|
+
|
|
117
|
+
/** Defines z order of the contour. */
|
|
118
|
+
zIndex?: number;
|
|
119
|
+
}[];
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* A very small z offset that is added for each vertex of a contour (Isoline or Isoband).
|
|
123
|
+
* @default 0.005
|
|
124
|
+
*/
|
|
125
|
+
zOffset?: number;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Method called to retrieve the position of each object.
|
|
129
|
+
* @default object => object.position
|
|
130
|
+
*/
|
|
131
|
+
getPosition?: AccessorFunction<DataT, Position>;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The weight of each object.
|
|
135
|
+
* @default 1
|
|
136
|
+
*/
|
|
137
|
+
getWeight?: Accessor<DataT, number>;
|
|
138
|
+
};
|
|
139
|
+
export default class ContourLayer<DataT = any, ExtraPropsT = {}> extends GridAggregationLayer<
|
|
140
|
+
ExtraPropsT & Required<_ContourLayerProps<DataT>>
|
|
141
|
+
> {
|
|
142
|
+
static layerName = 'ContourLayer';
|
|
143
|
+
static defaultProps = defaultProps;
|
|
144
|
+
|
|
145
|
+
initializeState(): void {
|
|
146
|
+
super.initializeAggregationLayer({
|
|
64
147
|
dimensions: DIMENSIONS
|
|
65
148
|
});
|
|
66
149
|
this.setState({
|
|
@@ -73,7 +156,7 @@ export default class ContourLayer extends GridAggregationLayer {
|
|
|
73
156
|
}
|
|
74
157
|
}
|
|
75
158
|
});
|
|
76
|
-
const attributeManager = this.getAttributeManager()
|
|
159
|
+
const attributeManager = this.getAttributeManager()!;
|
|
77
160
|
attributeManager.add({
|
|
78
161
|
[POSITION_ATTRIBUTE_NAME]: {
|
|
79
162
|
size: 3,
|
|
@@ -86,7 +169,7 @@ export default class ContourLayer extends GridAggregationLayer {
|
|
|
86
169
|
});
|
|
87
170
|
}
|
|
88
171
|
|
|
89
|
-
updateState(opts) {
|
|
172
|
+
updateState(opts: UpdateParameters<this>): void {
|
|
90
173
|
super.updateState(opts);
|
|
91
174
|
let contoursChanged = false;
|
|
92
175
|
const {oldProps, props} = opts;
|
|
@@ -102,7 +185,7 @@ export default class ContourLayer extends GridAggregationLayer {
|
|
|
102
185
|
}
|
|
103
186
|
}
|
|
104
187
|
|
|
105
|
-
renderLayers() {
|
|
188
|
+
renderLayers(): Layer[] {
|
|
106
189
|
const {contourSegments, contourPolygons} = this.state.contourData;
|
|
107
190
|
|
|
108
191
|
const LinesSubLayerClass = this.getSubLayerClass('lines', LineLayer);
|
|
@@ -219,7 +302,7 @@ export default class ContourLayer extends GridAggregationLayer {
|
|
|
219
302
|
|
|
220
303
|
// Private (Aggregation)
|
|
221
304
|
|
|
222
|
-
_updateAccessors(opts) {
|
|
305
|
+
private _updateAccessors(opts) {
|
|
223
306
|
const {getWeight, aggregation, data} = opts.props;
|
|
224
307
|
const {count} = this.state.weights;
|
|
225
308
|
if (count) {
|
|
@@ -229,7 +312,7 @@ export default class ContourLayer extends GridAggregationLayer {
|
|
|
229
312
|
this.setState({getValue: getValueFunc(aggregation, getWeight, {data})});
|
|
230
313
|
}
|
|
231
314
|
|
|
232
|
-
_resetResults() {
|
|
315
|
+
private _resetResults() {
|
|
233
316
|
const {count} = this.state.weights;
|
|
234
317
|
if (count) {
|
|
235
318
|
count.aggregationData = null;
|
|
@@ -238,7 +321,7 @@ export default class ContourLayer extends GridAggregationLayer {
|
|
|
238
321
|
|
|
239
322
|
// Private (Contours)
|
|
240
323
|
|
|
241
|
-
_generateContours() {
|
|
324
|
+
private _generateContours() {
|
|
242
325
|
const {numCol, numRow, gridOrigin, gridOffset, thresholdData} = this.state;
|
|
243
326
|
const {count} = this.state.weights;
|
|
244
327
|
let {aggregationData} = count;
|
|
@@ -260,7 +343,7 @@ export default class ContourLayer extends GridAggregationLayer {
|
|
|
260
343
|
this.setState({contourData});
|
|
261
344
|
}
|
|
262
345
|
|
|
263
|
-
_updateThresholdData(props) {
|
|
346
|
+
private _updateThresholdData(props) {
|
|
264
347
|
const {contours, zOffset} = props;
|
|
265
348
|
const count = contours.length;
|
|
266
349
|
const thresholdData = new Array(count);
|
|
@@ -275,6 +358,3 @@ export default class ContourLayer extends GridAggregationLayer {
|
|
|
275
358
|
this.setState({thresholdData});
|
|
276
359
|
}
|
|
277
360
|
}
|
|
278
|
-
|
|
279
|
-
ContourLayer.layerName = 'ContourLayer';
|
|
280
|
-
ContourLayer.defaultProps = defaultProps;
|
|
@@ -4,14 +4,19 @@ import {getCode, getVertices, CONTOUR_TYPE} from './marching-squares';
|
|
|
4
4
|
/* eslint-disable max-depth */
|
|
5
5
|
export function generateContours({
|
|
6
6
|
thresholdData,
|
|
7
|
-
colors,
|
|
8
7
|
cellWeights,
|
|
9
8
|
gridSize,
|
|
10
9
|
gridOrigin,
|
|
11
10
|
cellSize
|
|
11
|
+
}: {
|
|
12
|
+
thresholdData: any;
|
|
13
|
+
cellWeights: Float32Array;
|
|
14
|
+
gridSize: number[];
|
|
15
|
+
gridOrigin: number[];
|
|
16
|
+
cellSize: number[];
|
|
12
17
|
}) {
|
|
13
|
-
const contourSegments = [];
|
|
14
|
-
const contourPolygons = [];
|
|
18
|
+
const contourSegments: {start: number[]; end: number[]; contour: any}[] = [];
|
|
19
|
+
const contourPolygons: {vertices: number[][]; contour: any}[] = [];
|
|
15
20
|
const width = gridSize[0];
|
|
16
21
|
const height = gridSize[1];
|
|
17
22
|
let segmentIndex = 0;
|
|
@@ -32,6 +37,7 @@ export function generateContours({
|
|
|
32
37
|
height
|
|
33
38
|
});
|
|
34
39
|
const opts = {
|
|
40
|
+
type: CONTOUR_TYPE.ISO_BANDS,
|
|
35
41
|
gridOrigin,
|
|
36
42
|
cellSize,
|
|
37
43
|
x,
|
|
@@ -44,7 +50,7 @@ export function generateContours({
|
|
|
44
50
|
};
|
|
45
51
|
if (Array.isArray(threshold)) {
|
|
46
52
|
opts.type = CONTOUR_TYPE.ISO_BANDS;
|
|
47
|
-
const polygons = getVertices(opts);
|
|
53
|
+
const polygons = getVertices(opts) as number[][][];
|
|
48
54
|
for (const polygon of polygons) {
|
|
49
55
|
contourPolygons[polygonIndex++] = {
|
|
50
56
|
vertices: polygon,
|
|
@@ -54,7 +60,7 @@ export function generateContours({
|
|
|
54
60
|
} else {
|
|
55
61
|
// Get the intersection vertices based on MarchingSquares code.
|
|
56
62
|
opts.type = CONTOUR_TYPE.ISO_LINES;
|
|
57
|
-
const vertices = getVertices(opts);
|
|
63
|
+
const vertices = getVertices(opts) as number[][];
|
|
58
64
|
for (let i = 0; i < vertices.length; i += 2) {
|
|
59
65
|
contourSegments[segmentIndex++] = {
|
|
60
66
|
start: vertices[i],
|
|
File without changes
|
|
@@ -16,7 +16,7 @@ const DEFAULT_THRESHOLD_DATA = {
|
|
|
16
16
|
|
|
17
17
|
// Utility methods
|
|
18
18
|
|
|
19
|
-
function getVertexCode(weight, threshold) {
|
|
19
|
+
function getVertexCode(weight: number, threshold: number | number[]): number {
|
|
20
20
|
// threshold must be a single value or a range (array of size 2)
|
|
21
21
|
|
|
22
22
|
// Iso-bands
|
|
@@ -50,8 +50,8 @@ export function getCode(opts) {
|
|
|
50
50
|
const isTopBoundary = y >= height - 1;
|
|
51
51
|
const isBoundary = isLeftBoundary || isRightBoundary || isBottomBoundary || isTopBoundary;
|
|
52
52
|
|
|
53
|
-
const weights = {};
|
|
54
|
-
const codes = {};
|
|
53
|
+
const weights: Record<string, number> = {};
|
|
54
|
+
const codes: Record<string, number> = {};
|
|
55
55
|
|
|
56
56
|
// TOP
|
|
57
57
|
if (isLeftBoundary || isTopBoundary) {
|
|
@@ -147,9 +147,9 @@ export function getVertices(opts) {
|
|
|
147
147
|
// ]
|
|
148
148
|
|
|
149
149
|
if (type === CONTOUR_TYPE.ISO_BANDS) {
|
|
150
|
-
const polygons = [];
|
|
150
|
+
const polygons: number[][][] = [];
|
|
151
151
|
offsets.forEach(polygonOffsets => {
|
|
152
|
-
const polygon = [];
|
|
152
|
+
const polygon: number[][] = [];
|
|
153
153
|
polygonOffsets.forEach(xyOffset => {
|
|
154
154
|
const vX = refVertexX + xyOffset[0] * cellSize[0];
|
|
155
155
|
const vY = refVertexY + xyOffset[1] * cellSize[1];
|
|
@@ -161,7 +161,7 @@ export function getVertices(opts) {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
// default case is ISO_LINES
|
|
164
|
-
const lines = [];
|
|
164
|
+
const lines: number[][] = [];
|
|
165
165
|
offsets.forEach(xyOffsets => {
|
|
166
166
|
xyOffsets.forEach(offset => {
|
|
167
167
|
const vX = refVertexX + offset[0] * cellSize[0];
|