@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.
Files changed (188) hide show
  1. package/dist/dist.dev.js +515 -407
  2. package/dist/es5/aggregation-layer.js +19 -7
  3. package/dist/es5/aggregation-layer.js.map +1 -1
  4. package/dist/es5/contour-layer/contour-layer.js +5 -5
  5. package/dist/es5/contour-layer/contour-layer.js.map +1 -1
  6. package/dist/es5/contour-layer/contour-utils.js +1 -1
  7. package/dist/es5/contour-layer/contour-utils.js.map +1 -1
  8. package/dist/es5/contour-layer/marching-squares-codes.js.map +1 -1
  9. package/dist/es5/contour-layer/marching-squares.js.map +1 -1
  10. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +5 -3
  11. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
  12. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +1 -1
  13. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +8 -12
  14. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
  15. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +12 -12
  16. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
  17. package/dist/es5/grid-aggregation-layer.js +25 -12
  18. package/dist/es5/grid-aggregation-layer.js.map +1 -1
  19. package/dist/es5/grid-layer/grid-layer.js +18 -9
  20. package/dist/es5/grid-layer/grid-layer.js.map +1 -1
  21. package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +1 -1
  22. package/dist/es5/heatmap-layer/heatmap-layer.js +17 -6
  23. package/dist/es5/heatmap-layer/heatmap-layer.js.map +1 -1
  24. package/dist/es5/heatmap-layer/max-vs.glsl.js +1 -1
  25. package/dist/es5/heatmap-layer/triangle-layer-fragment.glsl.js +1 -1
  26. package/dist/es5/heatmap-layer/triangle-layer-vertex.glsl.js +1 -1
  27. package/dist/es5/heatmap-layer/triangle-layer.js +7 -7
  28. package/dist/es5/heatmap-layer/triangle-layer.js.map +1 -1
  29. package/dist/es5/heatmap-layer/weights-fs.glsl.js +1 -1
  30. package/dist/es5/heatmap-layer/weights-vs.glsl.js +1 -1
  31. package/dist/es5/hexagon-layer/hexagon-layer.js +16 -5
  32. package/dist/es5/hexagon-layer/hexagon-layer.js.map +1 -1
  33. package/dist/es5/index.js.map +1 -1
  34. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +26 -19
  35. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  36. package/dist/es5/screen-grid-layer/screen-grid-layer-vertex.glsl.js +1 -1
  37. package/dist/es5/screen-grid-layer/screen-grid-layer.js +18 -8
  38. package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +1 -1
  39. package/dist/es5/types.js +2 -0
  40. package/dist/es5/types.js.map +1 -0
  41. package/dist/es5/utils/bin-sorter.js +9 -0
  42. package/dist/es5/utils/bin-sorter.js.map +1 -1
  43. package/dist/es5/utils/color-utils.js.map +1 -1
  44. package/dist/esm/aggregation-layer.js +12 -5
  45. package/dist/esm/aggregation-layer.js.map +1 -1
  46. package/dist/esm/contour-layer/contour-layer.js +6 -3
  47. package/dist/esm/contour-layer/contour-layer.js.map +1 -1
  48. package/dist/esm/contour-layer/contour-utils.js +1 -1
  49. package/dist/esm/contour-layer/contour-utils.js.map +1 -1
  50. package/dist/esm/contour-layer/marching-squares-codes.js.map +1 -1
  51. package/dist/esm/contour-layer/marching-squares.js.map +1 -1
  52. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js +6 -3
  53. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
  54. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js.map +1 -1
  55. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +1 -1
  56. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js.map +1 -1
  57. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js +8 -10
  58. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
  59. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js +11 -9
  60. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
  61. package/dist/esm/grid-aggregation-layer.js +13 -5
  62. package/dist/esm/grid-aggregation-layer.js.map +1 -1
  63. package/dist/esm/grid-layer/grid-layer.js +15 -8
  64. package/dist/esm/grid-layer/grid-layer.js.map +1 -1
  65. package/dist/esm/heatmap-layer/heatmap-layer-utils.js.map +1 -1
  66. package/dist/esm/heatmap-layer/heatmap-layer.js +22 -13
  67. package/dist/esm/heatmap-layer/heatmap-layer.js.map +1 -1
  68. package/dist/esm/heatmap-layer/max-fs.glsl.js.map +1 -1
  69. package/dist/esm/heatmap-layer/max-vs.glsl.js +1 -1
  70. package/dist/esm/heatmap-layer/max-vs.glsl.js.map +1 -1
  71. package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js +1 -1
  72. package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js.map +1 -1
  73. package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js +1 -1
  74. package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js.map +1 -1
  75. package/dist/esm/heatmap-layer/triangle-layer.js +6 -5
  76. package/dist/esm/heatmap-layer/triangle-layer.js.map +1 -1
  77. package/dist/esm/heatmap-layer/weights-fs.glsl.js +1 -1
  78. package/dist/esm/heatmap-layer/weights-fs.glsl.js.map +1 -1
  79. package/dist/esm/heatmap-layer/weights-vs.glsl.js +1 -1
  80. package/dist/esm/heatmap-layer/weights-vs.glsl.js.map +1 -1
  81. package/dist/esm/hexagon-layer/hexagon-layer.js +11 -2
  82. package/dist/esm/hexagon-layer/hexagon-layer.js.map +1 -1
  83. package/dist/esm/index.js.map +1 -1
  84. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js +16 -10
  85. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  86. package/dist/esm/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +1 -1
  87. package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js +1 -1
  88. package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +1 -1
  89. package/dist/esm/screen-grid-layer/screen-grid-layer.js +15 -7
  90. package/dist/esm/screen-grid-layer/screen-grid-layer.js.map +1 -1
  91. package/dist/esm/types.js +2 -0
  92. package/dist/esm/types.js.map +1 -0
  93. package/dist/esm/utils/bin-sorter.js +16 -0
  94. package/dist/esm/utils/bin-sorter.js.map +1 -1
  95. package/dist/esm/utils/color-utils.js.map +1 -1
  96. package/dist.min.js +1 -1
  97. package/package.json +7 -5
  98. package/src/{aggregation-layer.js → aggregation-layer.ts} +32 -15
  99. package/src/contour-layer/{contour-layer.js → contour-layer.ts} +97 -16
  100. package/src/contour-layer/{contour-utils.js → contour-utils.ts} +11 -5
  101. package/src/contour-layer/{marching-squares-codes.js → marching-squares-codes.ts} +0 -0
  102. package/src/contour-layer/{marching-squares.js → marching-squares.ts} +6 -6
  103. package/src/cpu-grid-layer/cpu-grid-layer.ts +324 -0
  104. package/src/gpu-grid-layer/{gpu-grid-cell-layer-fragment.glsl.js → gpu-grid-cell-layer-fragment.glsl.ts} +0 -0
  105. package/src/gpu-grid-layer/{gpu-grid-cell-layer-vertex.glsl.js → gpu-grid-cell-layer-vertex.glsl.ts} +0 -0
  106. package/src/gpu-grid-layer/{gpu-grid-cell-layer.js → gpu-grid-cell-layer.ts} +36 -19
  107. package/src/gpu-grid-layer/{gpu-grid-layer.js → gpu-grid-layer.ts} +125 -18
  108. package/src/{grid-aggregation-layer.js → grid-aggregation-layer.ts} +25 -13
  109. package/src/grid-layer/{grid-layer.js → grid-layer.ts} +45 -14
  110. package/src/heatmap-layer/{heatmap-layer-utils.js → heatmap-layer-utils.ts} +5 -5
  111. package/src/heatmap-layer/{heatmap-layer.js → heatmap-layer.ts} +141 -30
  112. package/src/heatmap-layer/{max-fs.glsl.js → max-fs.glsl.ts} +0 -0
  113. package/src/heatmap-layer/{max-vs.glsl.js → max-vs.glsl.ts} +0 -0
  114. package/src/heatmap-layer/{triangle-layer-fragment.glsl.js → triangle-layer-fragment.glsl.ts} +0 -0
  115. package/src/heatmap-layer/{triangle-layer-vertex.glsl.js → triangle-layer-vertex.glsl.ts} +0 -0
  116. package/src/heatmap-layer/{triangle-layer.js → triangle-layer.ts} +20 -10
  117. package/src/heatmap-layer/{weights-fs.glsl.js → weights-fs.glsl.ts} +0 -0
  118. package/src/heatmap-layer/{weights-vs.glsl.js → weights-vs.glsl.ts} +0 -0
  119. package/src/hexagon-layer/{hexagon-layer.js → hexagon-layer.ts} +194 -9
  120. package/src/index.ts +9 -0
  121. package/src/screen-grid-layer/{screen-grid-cell-layer.js → screen-grid-cell-layer.ts} +33 -15
  122. package/src/screen-grid-layer/{screen-grid-layer-fragment.glsl.js → screen-grid-layer-fragment.glsl.ts} +0 -0
  123. package/src/screen-grid-layer/{screen-grid-layer-vertex.glsl.js → screen-grid-layer-vertex.glsl.ts} +0 -0
  124. package/src/screen-grid-layer/{screen-grid-layer.js → screen-grid-layer.ts} +119 -16
  125. package/src/types.ts +10 -0
  126. package/src/utils/{bin-sorter.js → bin-sorter.ts} +26 -11
  127. package/src/utils/{color-utils.js → color-utils.ts} +1 -1
  128. package/typed/aggregation-layer.d.ts +16 -11
  129. package/typed/aggregation-layer.d.ts.map +1 -1
  130. package/typed/contour-layer/contour-layer.d.ts +71 -36
  131. package/typed/contour-layer/contour-layer.d.ts.map +1 -1
  132. package/typed/contour-layer/contour-utils.d.ts +8 -9
  133. package/typed/contour-layer/contour-utils.d.ts.map +1 -1
  134. package/typed/contour-layer/marching-squares-codes.d.ts +2 -2
  135. package/typed/contour-layer/marching-squares-codes.d.ts.map +1 -1
  136. package/typed/contour-layer/marching-squares.d.ts +6 -6
  137. package/typed/contour-layer/marching-squares.d.ts.map +1 -1
  138. package/typed/cpu-grid-layer/cpu-grid-layer.d.ts +147 -126
  139. package/typed/cpu-grid-layer/cpu-grid-layer.d.ts.map +1 -1
  140. package/typed/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts +1 -1
  141. package/typed/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts.map +1 -1
  142. package/typed/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts +1 -1
  143. package/typed/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts.map +1 -1
  144. package/typed/gpu-grid-layer/gpu-grid-cell-layer.d.ts +30 -81
  145. package/typed/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +1 -1
  146. package/typed/gpu-grid-layer/gpu-grid-layer.d.ts +93 -62
  147. package/typed/gpu-grid-layer/gpu-grid-layer.d.ts.map +1 -1
  148. package/typed/grid-aggregation-layer.d.ts +19 -6
  149. package/typed/grid-aggregation-layer.d.ts.map +1 -1
  150. package/typed/grid-layer/grid-layer.d.ts +29 -91
  151. package/typed/grid-layer/grid-layer.d.ts.map +1 -1
  152. package/typed/heatmap-layer/heatmap-layer-utils.d.ts +6 -6
  153. package/typed/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -1
  154. package/typed/heatmap-layer/heatmap-layer.d.ts +102 -82
  155. package/typed/heatmap-layer/heatmap-layer.d.ts.map +1 -1
  156. package/typed/heatmap-layer/max-fs.glsl.d.ts +1 -1
  157. package/typed/heatmap-layer/max-fs.glsl.d.ts.map +1 -1
  158. package/typed/heatmap-layer/max-vs.glsl.d.ts +1 -1
  159. package/typed/heatmap-layer/max-vs.glsl.d.ts.map +1 -1
  160. package/typed/heatmap-layer/triangle-layer-fragment.glsl.d.ts +1 -1
  161. package/typed/heatmap-layer/triangle-layer-fragment.glsl.d.ts.map +1 -1
  162. package/typed/heatmap-layer/triangle-layer-vertex.glsl.d.ts +1 -1
  163. package/typed/heatmap-layer/triangle-layer-vertex.glsl.d.ts.map +1 -1
  164. package/typed/heatmap-layer/triangle-layer.d.ts +25 -8
  165. package/typed/heatmap-layer/triangle-layer.d.ts.map +1 -1
  166. package/typed/heatmap-layer/weights-fs.glsl.d.ts +1 -1
  167. package/typed/heatmap-layer/weights-fs.glsl.d.ts.map +1 -1
  168. package/typed/heatmap-layer/weights-vs.glsl.d.ts +1 -1
  169. package/typed/heatmap-layer/weights-vs.glsl.d.ts.map +1 -1
  170. package/typed/hexagon-layer/hexagon-layer.d.ts +160 -125
  171. package/typed/hexagon-layer/hexagon-layer.d.ts.map +1 -1
  172. package/typed/index.d.ts +7 -0
  173. package/typed/index.d.ts.map +1 -1
  174. package/typed/screen-grid-layer/screen-grid-cell-layer.d.ts +34 -25
  175. package/typed/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -1
  176. package/typed/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts +1 -1
  177. package/typed/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts.map +1 -1
  178. package/typed/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts +1 -1
  179. package/typed/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts.map +1 -1
  180. package/typed/screen-grid-layer/screen-grid-layer.d.ts +91 -30
  181. package/typed/screen-grid-layer/screen-grid-layer.d.ts.map +1 -1
  182. package/typed/types.d.ts +11 -0
  183. package/typed/types.d.ts.map +1 -0
  184. package/typed/utils/bin-sorter.d.ts +27 -21
  185. package/typed/utils/bin-sorter.d.ts.map +1 -1
  186. package/typed/utils/color-utils.d.ts +2 -2
  187. package/typed/utils/color-utils.d.ts.map +1 -1
  188. 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-alpha.6",
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/shadertools": "^8.5.13",
34
- "@math.gl/web-mercator": "3.6.0-alpha.8",
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": "6885ccab01c91a7632385f566c9377f8ae387e7c"
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 {CompositeLayer, AttributeManager, _compareProps as compareProps} from '@deck.gl/core';
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 default class AggregationLayer extends CompositeLayer {
26
- initializeState(dimensions) {
27
- super.initializeState();
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(opts.props);
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().getShaderAttributes();
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(updateOpts, params = {}) {
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
- /* eslint-disable no-unused-vars */
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 {log} from '@deck.gl/core';
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
- export default class ContourLayer extends GridAggregationLayer {
62
- initializeState() {
63
- super.initializeState({
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],
@@ -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];