@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
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.3",
|
|
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/shadertools": "^8.5.14",
|
|
35
|
+
"@math.gl/web-mercator": "^3.6.0",
|
|
35
36
|
"d3-hexbin": "^0.2.1"
|
|
36
37
|
},
|
|
37
38
|
"peerDependencies": {
|
|
38
39
|
"@deck.gl/core": "^8.0.0",
|
|
39
|
-
"@deck.gl/layers": "^8.0.0"
|
|
40
|
+
"@deck.gl/layers": "^8.0.0",
|
|
41
|
+
"@luma.gl/core": "^8.0.0"
|
|
40
42
|
},
|
|
41
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "bb459e1b4a4e3674ee9832d775d39211541d17b4"
|
|
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,18 +21,27 @@
|
|
|
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
|
+
DefaultProps
|
|
33
|
+
} from '@deck.gl/core';
|
|
25
34
|
|
|
26
35
|
import GPUGridAggregator from '../utils/gpu-grid-aggregation/gpu-grid-aggregator';
|
|
27
36
|
import {AGGREGATION_OPERATION, getValueFunc} from '../utils/aggregation-operation-utils';
|
|
28
37
|
import {getBoundingBox, getGridParams} from '../utils/grid-aggregation-utils';
|
|
29
|
-
import GridAggregationLayer from '../grid-aggregation-layer';
|
|
38
|
+
import GridAggregationLayer, {GridAggregationLayerProps} from '../grid-aggregation-layer';
|
|
30
39
|
|
|
31
40
|
const DEFAULT_COLOR = [255, 255, 255, 255];
|
|
32
41
|
const DEFAULT_STROKE_WIDTH = 1;
|
|
33
42
|
const DEFAULT_THRESHOLD = 1;
|
|
34
43
|
|
|
35
|
-
const defaultProps = {
|
|
44
|
+
const defaultProps: DefaultProps<ContourLayerProps> = {
|
|
36
45
|
// grid aggregation
|
|
37
46
|
cellSize: {type: 'number', min: 1, max: 1000, value: 1000},
|
|
38
47
|
getPosition: {type: 'accessor', value: x => x.position},
|
|
@@ -58,9 +67,84 @@ const DIMENSIONS = {
|
|
|
58
67
|
}
|
|
59
68
|
};
|
|
60
69
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
70
|
+
/** All properties supported by ContourLayer. */
|
|
71
|
+
export type ContourLayerProps<DataT = any> = _ContourLayerProps<DataT> &
|
|
72
|
+
GridAggregationLayerProps<DataT>;
|
|
73
|
+
|
|
74
|
+
/** Properties added by ContourLayer. */
|
|
75
|
+
export type _ContourLayerProps<DataT> = {
|
|
76
|
+
/**
|
|
77
|
+
* Size of each cell in meters.
|
|
78
|
+
* @default 1000
|
|
79
|
+
*/
|
|
80
|
+
cellSize?: number;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* When set to true, aggregation is performed on GPU, provided other conditions are met.
|
|
84
|
+
* @default true
|
|
85
|
+
*/
|
|
86
|
+
gpuAggregation?: boolean;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Defines the type of aggregation operation, valid values are 'SUM', 'MEAN', 'MIN' and 'MAX'.
|
|
90
|
+
* @default 'SUM'
|
|
91
|
+
*/
|
|
92
|
+
aggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Definition of contours to be drawn.
|
|
96
|
+
* @default [{threshold: 1}]
|
|
97
|
+
*/
|
|
98
|
+
contours: {
|
|
99
|
+
/**
|
|
100
|
+
* Isolines: `threshold` value must be a single `Number`, Isolines are generated based on this threshold value.
|
|
101
|
+
*
|
|
102
|
+
* 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.
|
|
103
|
+
*/
|
|
104
|
+
threshold: number | number[];
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* RGBA color array to be used to render the contour.
|
|
108
|
+
* @default [255, 255, 255, 255]
|
|
109
|
+
*/
|
|
110
|
+
color?: Color;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Applicable for `Isoline`s only, width of the Isoline in pixels.
|
|
114
|
+
* @default 1
|
|
115
|
+
*/
|
|
116
|
+
strokeWidth?: number;
|
|
117
|
+
|
|
118
|
+
/** Defines z order of the contour. */
|
|
119
|
+
zIndex?: number;
|
|
120
|
+
}[];
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* A very small z offset that is added for each vertex of a contour (Isoline or Isoband).
|
|
124
|
+
* @default 0.005
|
|
125
|
+
*/
|
|
126
|
+
zOffset?: number;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Method called to retrieve the position of each object.
|
|
130
|
+
* @default object => object.position
|
|
131
|
+
*/
|
|
132
|
+
getPosition?: AccessorFunction<DataT, Position>;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The weight of each object.
|
|
136
|
+
* @default 1
|
|
137
|
+
*/
|
|
138
|
+
getWeight?: Accessor<DataT, number>;
|
|
139
|
+
};
|
|
140
|
+
export default class ContourLayer<DataT = any, ExtraPropsT = {}> extends GridAggregationLayer<
|
|
141
|
+
ExtraPropsT & Required<_ContourLayerProps<DataT>>
|
|
142
|
+
> {
|
|
143
|
+
static layerName = 'ContourLayer';
|
|
144
|
+
static defaultProps = defaultProps;
|
|
145
|
+
|
|
146
|
+
initializeState(): void {
|
|
147
|
+
super.initializeAggregationLayer({
|
|
64
148
|
dimensions: DIMENSIONS
|
|
65
149
|
});
|
|
66
150
|
this.setState({
|
|
@@ -73,7 +157,7 @@ export default class ContourLayer extends GridAggregationLayer {
|
|
|
73
157
|
}
|
|
74
158
|
}
|
|
75
159
|
});
|
|
76
|
-
const attributeManager = this.getAttributeManager()
|
|
160
|
+
const attributeManager = this.getAttributeManager()!;
|
|
77
161
|
attributeManager.add({
|
|
78
162
|
[POSITION_ATTRIBUTE_NAME]: {
|
|
79
163
|
size: 3,
|
|
@@ -86,7 +170,7 @@ export default class ContourLayer extends GridAggregationLayer {
|
|
|
86
170
|
});
|
|
87
171
|
}
|
|
88
172
|
|
|
89
|
-
updateState(opts) {
|
|
173
|
+
updateState(opts: UpdateParameters<this>): void {
|
|
90
174
|
super.updateState(opts);
|
|
91
175
|
let contoursChanged = false;
|
|
92
176
|
const {oldProps, props} = opts;
|
|
@@ -102,7 +186,7 @@ export default class ContourLayer extends GridAggregationLayer {
|
|
|
102
186
|
}
|
|
103
187
|
}
|
|
104
188
|
|
|
105
|
-
renderLayers() {
|
|
189
|
+
renderLayers(): Layer[] {
|
|
106
190
|
const {contourSegments, contourPolygons} = this.state.contourData;
|
|
107
191
|
|
|
108
192
|
const LinesSubLayerClass = this.getSubLayerClass('lines', LineLayer);
|
|
@@ -219,7 +303,7 @@ export default class ContourLayer extends GridAggregationLayer {
|
|
|
219
303
|
|
|
220
304
|
// Private (Aggregation)
|
|
221
305
|
|
|
222
|
-
_updateAccessors(opts) {
|
|
306
|
+
private _updateAccessors(opts) {
|
|
223
307
|
const {getWeight, aggregation, data} = opts.props;
|
|
224
308
|
const {count} = this.state.weights;
|
|
225
309
|
if (count) {
|
|
@@ -229,7 +313,7 @@ export default class ContourLayer extends GridAggregationLayer {
|
|
|
229
313
|
this.setState({getValue: getValueFunc(aggregation, getWeight, {data})});
|
|
230
314
|
}
|
|
231
315
|
|
|
232
|
-
_resetResults() {
|
|
316
|
+
private _resetResults() {
|
|
233
317
|
const {count} = this.state.weights;
|
|
234
318
|
if (count) {
|
|
235
319
|
count.aggregationData = null;
|
|
@@ -238,7 +322,7 @@ export default class ContourLayer extends GridAggregationLayer {
|
|
|
238
322
|
|
|
239
323
|
// Private (Contours)
|
|
240
324
|
|
|
241
|
-
_generateContours() {
|
|
325
|
+
private _generateContours() {
|
|
242
326
|
const {numCol, numRow, gridOrigin, gridOffset, thresholdData} = this.state;
|
|
243
327
|
const {count} = this.state.weights;
|
|
244
328
|
let {aggregationData} = count;
|
|
@@ -260,7 +344,7 @@ export default class ContourLayer extends GridAggregationLayer {
|
|
|
260
344
|
this.setState({contourData});
|
|
261
345
|
}
|
|
262
346
|
|
|
263
|
-
_updateThresholdData(props) {
|
|
347
|
+
private _updateThresholdData(props) {
|
|
264
348
|
const {contours, zOffset} = props;
|
|
265
349
|
const count = contours.length;
|
|
266
350
|
const thresholdData = new Array(count);
|
|
@@ -275,6 +359,3 @@ export default class ContourLayer extends GridAggregationLayer {
|
|
|
275
359
|
this.setState({thresholdData});
|
|
276
360
|
}
|
|
277
361
|
}
|
|
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];
|