@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.
Files changed (229) hide show
  1. package/dist/dist.dev.js +757 -645
  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 -8
  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/esm/aggregation-layer.js +12 -5
  44. package/dist/esm/aggregation-layer.js.map +1 -1
  45. package/dist/esm/contour-layer/contour-layer.js +6 -3
  46. package/dist/esm/contour-layer/contour-layer.js.map +1 -1
  47. package/dist/esm/contour-layer/contour-utils.js +1 -1
  48. package/dist/esm/contour-layer/contour-utils.js.map +1 -1
  49. package/dist/esm/contour-layer/marching-squares-codes.js.map +1 -1
  50. package/dist/esm/contour-layer/marching-squares.js.map +1 -1
  51. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js +6 -3
  52. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js.map +1 -1
  53. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js.map +1 -1
  54. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +1 -1
  55. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js.map +1 -1
  56. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js +8 -6
  57. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js.map +1 -1
  58. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js +11 -9
  59. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
  60. package/dist/esm/grid-aggregation-layer.js +13 -5
  61. package/dist/esm/grid-aggregation-layer.js.map +1 -1
  62. package/dist/esm/grid-layer/grid-layer.js +15 -8
  63. package/dist/esm/grid-layer/grid-layer.js.map +1 -1
  64. package/dist/esm/heatmap-layer/heatmap-layer-utils.js.map +1 -1
  65. package/dist/esm/heatmap-layer/heatmap-layer.js +22 -13
  66. package/dist/esm/heatmap-layer/heatmap-layer.js.map +1 -1
  67. package/dist/esm/heatmap-layer/max-fs.glsl.js.map +1 -1
  68. package/dist/esm/heatmap-layer/max-vs.glsl.js +1 -1
  69. package/dist/esm/heatmap-layer/max-vs.glsl.js.map +1 -1
  70. package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js +1 -1
  71. package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js.map +1 -1
  72. package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js +1 -1
  73. package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js.map +1 -1
  74. package/dist/esm/heatmap-layer/triangle-layer.js +6 -5
  75. package/dist/esm/heatmap-layer/triangle-layer.js.map +1 -1
  76. package/dist/esm/heatmap-layer/weights-fs.glsl.js +1 -1
  77. package/dist/esm/heatmap-layer/weights-fs.glsl.js.map +1 -1
  78. package/dist/esm/heatmap-layer/weights-vs.glsl.js +1 -1
  79. package/dist/esm/heatmap-layer/weights-vs.glsl.js.map +1 -1
  80. package/dist/esm/hexagon-layer/hexagon-layer.js +11 -2
  81. package/dist/esm/hexagon-layer/hexagon-layer.js.map +1 -1
  82. package/dist/esm/index.js.map +1 -1
  83. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js +16 -10
  84. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
  85. package/dist/esm/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +1 -1
  86. package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js +1 -1
  87. package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +1 -1
  88. package/dist/esm/screen-grid-layer/screen-grid-layer.js +15 -7
  89. package/dist/esm/screen-grid-layer/screen-grid-layer.js.map +1 -1
  90. package/dist/esm/types.js +2 -0
  91. package/dist/esm/types.js.map +1 -0
  92. package/dist/esm/utils/bin-sorter.js +16 -0
  93. package/dist/esm/utils/bin-sorter.js.map +1 -1
  94. package/dist.min.js +1 -1
  95. package/package.json +6 -4
  96. package/src/{aggregation-layer.js → aggregation-layer.ts} +32 -15
  97. package/src/contour-layer/{contour-layer.js → contour-layer.ts} +95 -15
  98. package/src/contour-layer/{contour-utils.js → contour-utils.ts} +11 -5
  99. package/src/contour-layer/{marching-squares-codes.js → marching-squares-codes.ts} +0 -0
  100. package/src/contour-layer/{marching-squares.js → marching-squares.ts} +6 -6
  101. package/src/cpu-grid-layer/cpu-grid-layer.ts +310 -0
  102. package/src/gpu-grid-layer/{gpu-grid-cell-layer-fragment.glsl.js → gpu-grid-cell-layer-fragment.glsl.ts} +0 -0
  103. package/src/gpu-grid-layer/{gpu-grid-cell-layer-vertex.glsl.js → gpu-grid-cell-layer-vertex.glsl.ts} +0 -0
  104. package/src/gpu-grid-layer/{gpu-grid-cell-layer.js → gpu-grid-cell-layer.ts} +22 -14
  105. package/src/gpu-grid-layer/{gpu-grid-layer.js → gpu-grid-layer.ts} +122 -17
  106. package/src/{grid-aggregation-layer.js → grid-aggregation-layer.ts} +25 -13
  107. package/src/grid-layer/{grid-layer.js → grid-layer.ts} +38 -13
  108. package/src/heatmap-layer/{heatmap-layer-utils.js → heatmap-layer-utils.ts} +5 -5
  109. package/src/heatmap-layer/{heatmap-layer.js → heatmap-layer.ts} +138 -29
  110. package/src/heatmap-layer/{max-fs.glsl.js → max-fs.glsl.ts} +0 -0
  111. package/src/heatmap-layer/{max-vs.glsl.js → max-vs.glsl.ts} +0 -0
  112. package/src/heatmap-layer/{triangle-layer-fragment.glsl.js → triangle-layer-fragment.glsl.ts} +0 -0
  113. package/src/heatmap-layer/{triangle-layer-vertex.glsl.js → triangle-layer-vertex.glsl.ts} +0 -0
  114. package/src/heatmap-layer/{triangle-layer.js → triangle-layer.ts} +20 -10
  115. package/src/heatmap-layer/{weights-fs.glsl.js → weights-fs.glsl.ts} +0 -0
  116. package/src/heatmap-layer/{weights-vs.glsl.js → weights-vs.glsl.ts} +0 -0
  117. package/src/hexagon-layer/{hexagon-layer.js → hexagon-layer.ts} +174 -9
  118. package/src/index.ts +9 -0
  119. package/src/screen-grid-layer/{screen-grid-cell-layer.js → screen-grid-cell-layer.ts} +31 -14
  120. package/src/screen-grid-layer/{screen-grid-layer-fragment.glsl.js → screen-grid-layer-fragment.glsl.ts} +0 -0
  121. package/src/screen-grid-layer/{screen-grid-layer-vertex.glsl.js → screen-grid-layer-vertex.glsl.ts} +0 -0
  122. package/src/screen-grid-layer/{screen-grid-layer.js → screen-grid-layer.ts} +117 -15
  123. package/src/types.ts +10 -0
  124. package/src/utils/{bin-sorter.js → bin-sorter.ts} +26 -11
  125. package/typed/aggregation-layer.d.ts +16 -11
  126. package/typed/aggregation-layer.d.ts.map +1 -1
  127. package/typed/aggregation-layer.js +151 -0
  128. package/typed/contour-layer/contour-layer.d.ts +92 -36
  129. package/typed/contour-layer/contour-layer.d.ts.map +1 -1
  130. package/typed/contour-layer/contour-layer.js +234 -0
  131. package/typed/contour-layer/contour-utils.d.ts +8 -9
  132. package/typed/contour-layer/contour-utils.d.ts.map +1 -1
  133. package/typed/contour-layer/contour-utils.js +64 -0
  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-codes.js +337 -0
  137. package/typed/contour-layer/marching-squares.d.ts +6 -6
  138. package/typed/contour-layer/marching-squares.d.ts.map +1 -1
  139. package/typed/contour-layer/marching-squares.js +147 -0
  140. package/typed/cpu-grid-layer/cpu-grid-layer.d.ts +221 -126
  141. package/typed/cpu-grid-layer/cpu-grid-layer.d.ts.map +1 -1
  142. package/typed/cpu-grid-layer/cpu-grid-layer.js +129 -0
  143. package/typed/cpu-grid-layer/grid-aggregator.js +141 -0
  144. package/typed/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts +1 -1
  145. package/typed/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts.map +1 -1
  146. package/typed/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +34 -0
  147. package/typed/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts +1 -1
  148. package/typed/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts.map +1 -1
  149. package/typed/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +141 -0
  150. package/typed/gpu-grid-layer/gpu-grid-cell-layer.d.ts +67 -81
  151. package/typed/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +1 -1
  152. package/typed/gpu-grid-layer/gpu-grid-cell-layer.js +143 -0
  153. package/typed/gpu-grid-layer/gpu-grid-layer.d.ts +131 -62
  154. package/typed/gpu-grid-layer/gpu-grid-layer.d.ts.map +1 -1
  155. package/typed/gpu-grid-layer/gpu-grid-layer.js +289 -0
  156. package/typed/grid-aggregation-layer.d.ts +19 -6
  157. package/typed/grid-aggregation-layer.d.ts.map +1 -1
  158. package/typed/grid-aggregation-layer.js +172 -0
  159. package/typed/grid-layer/grid-layer.d.ts +109 -90
  160. package/typed/grid-layer/grid-layer.d.ts.map +1 -1
  161. package/typed/grid-layer/grid-layer.js +60 -0
  162. package/typed/heatmap-layer/heatmap-layer-utils.d.ts +6 -6
  163. package/typed/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -1
  164. package/typed/heatmap-layer/heatmap-layer-utils.js +78 -0
  165. package/typed/heatmap-layer/heatmap-layer.d.ts +147 -82
  166. package/typed/heatmap-layer/heatmap-layer.d.ts.map +1 -1
  167. package/typed/heatmap-layer/heatmap-layer.js +478 -0
  168. package/typed/heatmap-layer/max-fs.glsl.d.ts +1 -1
  169. package/typed/heatmap-layer/max-fs.glsl.d.ts.map +1 -1
  170. package/typed/heatmap-layer/max-fs.glsl.js +7 -0
  171. package/typed/heatmap-layer/max-vs.glsl.d.ts +1 -1
  172. package/typed/heatmap-layer/max-vs.glsl.d.ts.map +1 -1
  173. package/typed/heatmap-layer/max-vs.glsl.js +12 -0
  174. package/typed/heatmap-layer/triangle-layer-fragment.glsl.d.ts +1 -1
  175. package/typed/heatmap-layer/triangle-layer-fragment.glsl.d.ts.map +1 -1
  176. package/typed/heatmap-layer/triangle-layer-fragment.glsl.js +58 -0
  177. package/typed/heatmap-layer/triangle-layer-vertex.glsl.d.ts +1 -1
  178. package/typed/heatmap-layer/triangle-layer-vertex.glsl.d.ts.map +1 -1
  179. package/typed/heatmap-layer/triangle-layer-vertex.glsl.js +51 -0
  180. package/typed/heatmap-layer/triangle-layer.d.ts +25 -8
  181. package/typed/heatmap-layer/triangle-layer.d.ts.map +1 -1
  182. package/typed/heatmap-layer/triangle-layer.js +67 -0
  183. package/typed/heatmap-layer/weights-fs.glsl.d.ts +1 -1
  184. package/typed/heatmap-layer/weights-fs.glsl.d.ts.map +1 -1
  185. package/typed/heatmap-layer/weights-fs.glsl.js +19 -0
  186. package/typed/heatmap-layer/weights-vs.glsl.d.ts +1 -1
  187. package/typed/heatmap-layer/weights-vs.glsl.d.ts.map +1 -1
  188. package/typed/heatmap-layer/weights-vs.glsl.js +23 -0
  189. package/typed/hexagon-layer/hexagon-aggregator.js +112 -0
  190. package/typed/hexagon-layer/hexagon-layer.d.ts +232 -125
  191. package/typed/hexagon-layer/hexagon-layer.d.ts.map +1 -1
  192. package/typed/hexagon-layer/hexagon-layer.js +171 -0
  193. package/typed/index.d.ts +7 -0
  194. package/typed/index.d.ts.map +1 -1
  195. package/typed/index.js +33 -0
  196. package/typed/screen-grid-layer/screen-grid-cell-layer.d.ts +46 -25
  197. package/typed/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -1
  198. package/typed/screen-grid-layer/screen-grid-cell-layer.js +159 -0
  199. package/typed/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts +1 -1
  200. package/typed/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts.map +1 -1
  201. package/typed/screen-grid-layer/screen-grid-layer-fragment.glsl.js +37 -0
  202. package/typed/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts +1 -1
  203. package/typed/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts.map +1 -1
  204. package/typed/screen-grid-layer/screen-grid-layer-vertex.glsl.js +83 -0
  205. package/typed/screen-grid-layer/screen-grid-layer.d.ts +113 -30
  206. package/typed/screen-grid-layer/screen-grid-layer.d.ts.map +1 -1
  207. package/typed/screen-grid-layer/screen-grid-layer.js +216 -0
  208. package/typed/types.d.ts +11 -0
  209. package/typed/types.d.ts.map +1 -0
  210. package/typed/types.js +1 -0
  211. package/typed/utils/aggregation-operation-utils.js +94 -0
  212. package/typed/utils/bin-sorter.d.ts +27 -21
  213. package/typed/utils/bin-sorter.d.ts.map +1 -1
  214. package/typed/utils/bin-sorter.js +167 -0
  215. package/typed/utils/color-utils.js +53 -0
  216. package/typed/utils/cpu-aggregator.js +417 -0
  217. package/typed/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +39 -0
  218. package/typed/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +53 -0
  219. package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +31 -0
  220. package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +77 -0
  221. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +41 -0
  222. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +1 -0
  223. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +562 -0
  224. package/typed/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +36 -0
  225. package/typed/utils/grid-aggregation-utils.js +114 -0
  226. package/typed/utils/prop-utils.js +28 -0
  227. package/typed/utils/resource-utils.js +40 -0
  228. package/typed/utils/scale-utils.js +184 -0
  229. package/src/cpu-grid-layer/cpu-grid-layer.js +0 -153
@@ -1,5 +1,14 @@
1
- declare class AggregationLayer extends CompositeLayer<any> {
2
- constructor(...propObjects: Partial<any>[]);
1
+ import { CompositeLayer, AttributeManager, UpdateParameters, CompositeLayerProps } from '@deck.gl/core/typed';
2
+ export declare type AggregationLayerProps<DataT = any> = CompositeLayerProps<DataT>;
3
+ export default abstract class AggregationLayer<ExtraPropsT = {}> extends CompositeLayer<ExtraPropsT> {
4
+ static layerName: string;
5
+ state: CompositeLayer['state'] & {
6
+ ignoreProps?: Record<string, any>;
7
+ dimensions?: any;
8
+ };
9
+ initializeAggregationLayer(dimensions: any): void;
10
+ updateState(opts: UpdateParameters<this>): void;
11
+ updateAttributes(changedAttributes: any): void;
3
12
  getAttributes(): {
4
13
  [id: string]: import("modules/core/src/lib/attribute/shader-attribute").IShaderAttribute;
5
14
  };
@@ -14,20 +23,16 @@ declare class AggregationLayer extends CompositeLayer<any> {
14
23
  * @returns {Boolean} - returns true if dimensions' prop or accessor is changed
15
24
  **/
16
25
  isAggregationDirty(updateOpts: any, params?: {
17
- dimension: any;
18
- compareAll: boolean;
19
- }): boolean;
26
+ compareAll?: boolean;
27
+ dimension?: any;
28
+ }): string | boolean;
20
29
  /**
21
30
  * Checks if an attribute is changed
22
31
  * @param {String} name - name of the attribute
23
32
  * @returns {Boolean} - `true` if attribute `name` is changed, `false` otherwise,
24
33
  * If `name` is not passed or `undefiend`, `true` if any attribute is changed, `false` otherwise
25
34
  **/
26
- isAttributeChanged(name: string): boolean;
27
- }
28
- declare namespace AggregationLayer {
29
- const layerName: string;
35
+ isAttributeChanged(name?: string): any;
36
+ _getAttributeManager(): AttributeManager;
30
37
  }
31
- export default AggregationLayer;
32
- import { CompositeLayer } from '@deck.gl/core/typed';
33
38
  //# sourceMappingURL=aggregation-layer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"aggregation-layer.d.ts","sourceRoot":"","sources":["../src/aggregation-layer.js"],"names":[],"mappings":"AAwBA;IAdoB,4CAEN;IA4CZ;;MAEC;IAED,yBAYC;IAED,kCAEC;IAED;;;;;;;QAOI;IACJ;;;gBAuCC;IAED;;;;;QAKI;IACJ,0CAOC;CAWF"}
1
+ {"version":3,"file":"aggregation-layer.d.ts","sourceRoot":"","sources":["../src/aggregation-layer.ts"],"names":[],"mappings":"AAoBA,OAAO,EACL,cAAc,EACd,gBAAgB,EAEhB,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,eAAe,CAAC;AAIvB,oBAAY,qBAAqB,CAAC,KAAK,GAAG,GAAG,IAAI,mBAAmB,CAAC,KAAK,CAAC,CAAC;AAE5E,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,gBAAgB,CAC5C,WAAW,GAAG,EAAE,CAChB,SAAQ,cAAc,CAAC,WAAW,CAAC;IACnC,MAAM,CAAC,SAAS,SAAsB;IAEtC,KAAK,EAAG,cAAc,CAAC,OAAO,CAAC,GAAG;QAChC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAClC,UAAU,CAAC,EAAE,GAAG,CAAC;KAClB,CAAC;IAEF,0BAA0B,CAAC,UAAU,EAAE,GAAG;IAU1C,WAAW,CAAC,IAAI,EAAE,gBAAgB,CAAC,IAAI,CAAC;IAexC,gBAAgB,CAAC,iBAAiB,KAAA;IAMlC,aAAa;;;IAIb,iBAAiB;IAcjB,aAAa,CAAC,OAAO,KAAA;IAIrB;;;;;;;QAOI;IACJ,kBAAkB,CAChB,UAAU,KAAA,EACV,MAAM,GAAE;QAAC,UAAU,CAAC,EAAE,OAAO,CAAC;QAAC,SAAS,CAAC,EAAE,GAAG,CAAA;KAAM,GACnD,MAAM,GAAG,OAAO;IAyCnB;;;;;QAKI;IACJ,kBAAkB,CAAC,IAAI,CAAC,EAAE,MAAM;IAYhC,oBAAoB;CAMrB"}
@@ -0,0 +1,151 @@
1
+ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ // of this software and associated documentation files (the "Software"), to deal
5
+ // in the Software without restriction, including without limitation the rights
6
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ // copies of the Software, and to permit persons to whom the Software is
8
+ // furnished to do so, subject to the following conditions:
9
+ //
10
+ // The above copyright notice and this permission notice shall be included in
11
+ // all copies or substantial portions of the Software.
12
+ //
13
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ // THE SOFTWARE.
20
+ import { CompositeLayer, AttributeManager, _compareProps as compareProps } from '@deck.gl/core';
21
+ import { cssToDeviceRatio } from '@luma.gl/core';
22
+ import { filterProps } from './utils/prop-utils';
23
+ export default class AggregationLayer extends CompositeLayer {
24
+ initializeAggregationLayer(dimensions) {
25
+ super.initializeState(this.context);
26
+ this.setState({
27
+ // Layer props , when changed doesn't require updating aggregation
28
+ ignoreProps: filterProps(this.constructor._propTypes, dimensions.data.props),
29
+ dimensions
30
+ });
31
+ }
32
+ updateState(opts) {
33
+ super.updateState(opts);
34
+ const { changeFlags } = opts;
35
+ if (changeFlags.extensionsChanged) {
36
+ const shaders = this.getShaders({});
37
+ if (shaders && shaders.defines) {
38
+ shaders.defines.NON_INSTANCED_MODEL = 1;
39
+ }
40
+ this.updateShaders(shaders);
41
+ }
42
+ // Explictly call to update attributes as 'CompositeLayer' doesn't call this
43
+ this._updateAttributes();
44
+ }
45
+ updateAttributes(changedAttributes) {
46
+ // Super classes, can refer to state.changedAttributes to determine what
47
+ // attributes changed
48
+ this.setState({ changedAttributes });
49
+ }
50
+ getAttributes() {
51
+ return this.getAttributeManager().getShaderAttributes();
52
+ }
53
+ getModuleSettings() {
54
+ // For regular layer draw this happens during draw cycle (_drawLayersInViewport) not during update cycle
55
+ // For aggregation layers this is called during updateState to update aggregation data
56
+ // NOTE: it is similar to LayerPass._getModuleParameters() but doesn't inlcude `effects` it is not needed for aggregation
57
+ const { viewport, mousePosition, gl } = this.context;
58
+ const moduleSettings = Object.assign(Object.create(this.props), {
59
+ viewport,
60
+ mousePosition,
61
+ pickingActive: 0,
62
+ devicePixelRatio: cssToDeviceRatio(gl)
63
+ });
64
+ return moduleSettings;
65
+ }
66
+ updateShaders(shaders) {
67
+ // Default implemention is empty, subclasses can update their Model objects if needed
68
+ }
69
+ /**
70
+ * Checks if aggregation is dirty
71
+ * @param {Object} updateOpts - object {props, oldProps, changeFlags}
72
+ * @param {Object} params - object {dimension, compareAll}
73
+ * @param {Object} params.dimension - {props, accessors} array of props and/or accessors
74
+ * @param {Boolean} params.compareAll - when `true` it will include non layer props for comparision
75
+ * @returns {Boolean} - returns true if dimensions' prop or accessor is changed
76
+ **/
77
+ isAggregationDirty(updateOpts, params = {}) {
78
+ const { props, oldProps, changeFlags } = updateOpts;
79
+ const { compareAll = false, dimension } = params;
80
+ const { ignoreProps } = this.state;
81
+ const { props: dataProps, accessors = [] } = dimension;
82
+ const { updateTriggersChanged } = changeFlags;
83
+ if (changeFlags.dataChanged) {
84
+ return true;
85
+ }
86
+ if (updateTriggersChanged) {
87
+ if (updateTriggersChanged.all) {
88
+ return true;
89
+ }
90
+ for (const accessor of accessors) {
91
+ if (updateTriggersChanged[accessor]) {
92
+ return true;
93
+ }
94
+ }
95
+ }
96
+ if (compareAll) {
97
+ if (changeFlags.extensionsChanged) {
98
+ return true;
99
+ }
100
+ // Compare non layer props too (like extension props)
101
+ // ignoreprops refers to all Layer props other than aggregation props that need to be comapred
102
+ return compareProps({
103
+ oldProps,
104
+ newProps: props,
105
+ ignoreProps,
106
+ propTypes: this.constructor._propTypes
107
+ });
108
+ }
109
+ // Compare props of the dimension
110
+ for (const name of dataProps) {
111
+ if (props[name] !== oldProps[name]) {
112
+ return true;
113
+ }
114
+ }
115
+ return false;
116
+ }
117
+ /**
118
+ * Checks if an attribute is changed
119
+ * @param {String} name - name of the attribute
120
+ * @returns {Boolean} - `true` if attribute `name` is changed, `false` otherwise,
121
+ * If `name` is not passed or `undefiend`, `true` if any attribute is changed, `false` otherwise
122
+ **/
123
+ isAttributeChanged(name) {
124
+ const { changedAttributes } = this.state;
125
+ if (!name) {
126
+ // if name not specified return true if any attribute is changed
127
+ return !isObjectEmpty(changedAttributes);
128
+ }
129
+ return changedAttributes && changedAttributes[name] !== undefined;
130
+ }
131
+ // Private
132
+ // override Composite layer private method to create AttributeManager instance
133
+ _getAttributeManager() {
134
+ return new AttributeManager(this.context.gl, {
135
+ id: this.props.id,
136
+ stats: this.context.stats
137
+ });
138
+ }
139
+ }
140
+ AggregationLayer.layerName = 'AggregationLayer';
141
+ // Helper methods
142
+ // Returns true if given object is empty, false otherwise.
143
+ function isObjectEmpty(obj) {
144
+ let isEmpty = true;
145
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
146
+ for (const key in obj) {
147
+ isEmpty = false;
148
+ break;
149
+ }
150
+ return isEmpty;
151
+ }
@@ -1,39 +1,95 @@
1
- declare class ContourLayer extends GridAggregationLayer {
2
- _updateAccessors(opts: any): void;
3
- _resetResults(): void;
4
- _generateContours(): void;
5
- _updateThresholdData(props: any): void;
6
- }
7
- declare namespace ContourLayer {
8
- export const layerName: string;
9
- export { defaultProps };
10
- }
11
- export default ContourLayer;
12
- import GridAggregationLayer from "../grid-aggregation-layer";
13
- declare namespace defaultProps {
14
- namespace cellSize {
15
- const type: string;
16
- const min: number;
17
- const max: number;
18
- const value: number;
19
- }
20
- namespace getPosition {
21
- const type_1: string;
22
- export { type_1 as type };
23
- export function value_1(x: any): any;
24
- export { value_1 as value };
25
- }
26
- namespace getWeight {
27
- const type_2: string;
28
- export { type_2 as type };
29
- const value_2: number;
30
- export { value_2 as value };
31
- }
32
- const gpuAggregation: boolean;
33
- const aggregation: string;
34
- const contours: {
35
- threshold: number;
1
+ import { Accessor, AccessorFunction, Color, Layer, Position, UpdateParameters } from '@deck.gl/core/typed';
2
+ import GridAggregationLayer, { GridAggregationLayerProps } from '../grid-aggregation-layer';
3
+ /** All properties supported by ContourLayer. */
4
+ export declare type ContourLayerProps<DataT = any> = _ContourLayerProps<DataT> & GridAggregationLayerProps<DataT>;
5
+ /** Properties added by ContourLayer. */
6
+ export declare type _ContourLayerProps<DataT> = {
7
+ /**
8
+ * Size of each cell in meters.
9
+ * @default 1000
10
+ */
11
+ cellSize?: number;
12
+ /**
13
+ * When set to true, aggregation is performed on GPU, provided other conditions are met.
14
+ * @default true
15
+ */
16
+ gpuAggregation?: boolean;
17
+ /**
18
+ * Defines the type of aggregation operation, valid values are 'SUM', 'MEAN', 'MIN' and 'MAX'.
19
+ * @default 'SUM'
20
+ */
21
+ aggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';
22
+ /**
23
+ * Definition of contours to be drawn.
24
+ * @default [{threshold: 1}]
25
+ */
26
+ contours: {
27
+ /**
28
+ * Isolines: `threshold` value must be a single `Number`, Isolines are generated based on this threshold value.
29
+ *
30
+ * 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.
31
+ */
32
+ threshold: number | number[];
33
+ /**
34
+ * RGBA color array to be used to render the contour.
35
+ * @default [255, 255, 255, 255]
36
+ */
37
+ color?: Color;
38
+ /**
39
+ * Applicable for `Isoline`s only, width of the Isoline in pixels.
40
+ * @default 1
41
+ */
42
+ strokeWidth?: number;
43
+ /** Defines z order of the contour. */
44
+ zIndex?: number;
36
45
  }[];
37
- const zOffset: number;
46
+ /**
47
+ * A very small z offset that is added for each vertex of a contour (Isoline or Isoband).
48
+ * @default 0.005
49
+ */
50
+ zOffset?: number;
51
+ /**
52
+ * Method called to retrieve the position of each object.
53
+ * @default object => object.position
54
+ */
55
+ getPosition?: AccessorFunction<DataT, Position>;
56
+ /**
57
+ * The weight of each object.
58
+ * @default 1
59
+ */
60
+ getWeight?: Accessor<DataT, number>;
61
+ };
62
+ export default class ContourLayer<DataT = any, ExtraPropsT = {}> extends GridAggregationLayer<ExtraPropsT & Required<_ContourLayerProps<DataT>>> {
63
+ static layerName: string;
64
+ static defaultProps: {
65
+ cellSize: {
66
+ type: string;
67
+ min: number;
68
+ max: number;
69
+ value: number;
70
+ };
71
+ getPosition: {
72
+ type: string;
73
+ value: (x: any) => any;
74
+ };
75
+ getWeight: {
76
+ type: string;
77
+ value: number;
78
+ };
79
+ gpuAggregation: boolean;
80
+ aggregation: string;
81
+ contours: {
82
+ threshold: number;
83
+ }[];
84
+ zOffset: number;
85
+ };
86
+ initializeState(): void;
87
+ updateState(opts: UpdateParameters<this>): void;
88
+ renderLayers(): Layer[];
89
+ updateAggregationState(opts: any): void;
90
+ private _updateAccessors;
91
+ private _resetResults;
92
+ private _generateContours;
93
+ private _updateThresholdData;
38
94
  }
39
95
  //# sourceMappingURL=contour-layer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contour-layer.d.ts","sourceRoot":"","sources":["../../src/contour-layer/contour-layer.js"],"names":[],"mappings":"AA4DA;IAiKE,kCAQC;IAED,sBAKC;IAID,0BAoBC;IAED,uCAaC;CACF;;;;;;;;;;;;;;;;;QA/OwC,qCAAe"}
1
+ {"version":3,"file":"contour-layer.d.ts","sourceRoot":"","sources":["../../src/contour-layer/contour-layer.ts"],"names":[],"mappings":"AAuBA,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,KAAK,EACL,KAAK,EAEL,QAAQ,EACR,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAKvB,OAAO,oBAAoB,EAAE,EAAC,yBAAyB,EAAC,MAAM,2BAA2B,CAAC;AAgC1F,gDAAgD;AAChD,oBAAY,iBAAiB,CAAC,KAAK,GAAG,GAAG,IAAI,kBAAkB,CAAC,KAAK,CAAC,GACpE,yBAAyB,CAAC,KAAK,CAAC,CAAC;AAEnC,wCAAwC;AACxC,oBAAY,kBAAkB,CAAC,KAAK,IAAI;IACtC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,WAAW,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;IAE7C;;;OAGG;IACH,QAAQ,EAAE;QACR;;;;WAIG;QACH,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAE7B;;;WAGG;QACH,KAAK,CAAC,EAAE,KAAK,CAAC;QAEd;;;WAGG;QACH,WAAW,CAAC,EAAE,MAAM,CAAC;QAErB,sCAAsC;QACtC,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,EAAE,CAAC;IAEJ;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAEhD;;;OAGG;IACH,SAAS,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;CACrC,CAAC;AACF,MAAM,CAAC,OAAO,OAAO,YAAY,CAAC,KAAK,GAAG,GAAG,EAAE,WAAW,GAAG,EAAE,CAAE,SAAQ,oBAAoB,CAC3F,WAAW,GAAG,QAAQ,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAClD;IACC,MAAM,CAAC,SAAS,SAAkB;IAClC,MAAM,CAAC,YAAY;;;;;;;;;;;;;;;;;;;;;MAAgB;IAEnC,eAAe,IAAI,IAAI;IA2BvB,WAAW,CAAC,IAAI,EAAE,gBAAgB,CAAC,IAAI,CAAC,GAAG,IAAI;IAgB/C,YAAY,IAAI,KAAK,EAAE;IA4CvB,sBAAsB,CAAC,IAAI,KAAA;IAyE3B,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,iBAAiB;IAsBzB,OAAO,CAAC,oBAAoB;CAc7B"}
@@ -0,0 +1,234 @@
1
+ // Copyright (c) 2015 - 2018 Uber Technologies, Inc.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ // of this software and associated documentation files (the "Software"), to deal
5
+ // in the Software without restriction, including without limitation the rights
6
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ // copies of the Software, and to permit persons to whom the Software is
8
+ // furnished to do so, subject to the following conditions:
9
+ //
10
+ // The above copyright notice and this permission notice shall be included in
11
+ // all copies or substantial portions of the Software.
12
+ //
13
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ // THE SOFTWARE.
20
+ import GL from '@luma.gl/constants';
21
+ import { LineLayer, SolidPolygonLayer } from '@deck.gl/layers';
22
+ import { generateContours } from './contour-utils';
23
+ import { log } from '@deck.gl/core';
24
+ import GPUGridAggregator from '../utils/gpu-grid-aggregation/gpu-grid-aggregator';
25
+ import { AGGREGATION_OPERATION, getValueFunc } from '../utils/aggregation-operation-utils';
26
+ import { getBoundingBox, getGridParams } from '../utils/grid-aggregation-utils';
27
+ import GridAggregationLayer from '../grid-aggregation-layer';
28
+ const DEFAULT_COLOR = [255, 255, 255, 255];
29
+ const DEFAULT_STROKE_WIDTH = 1;
30
+ const DEFAULT_THRESHOLD = 1;
31
+ const defaultProps = {
32
+ // grid aggregation
33
+ cellSize: { type: 'number', min: 1, max: 1000, value: 1000 },
34
+ getPosition: { type: 'accessor', value: x => x.position },
35
+ getWeight: { type: 'accessor', value: 1 },
36
+ gpuAggregation: true,
37
+ aggregation: 'SUM',
38
+ // contour lines
39
+ contours: [{ threshold: DEFAULT_THRESHOLD }],
40
+ zOffset: 0.005
41
+ };
42
+ const POSITION_ATTRIBUTE_NAME = 'positions';
43
+ const DIMENSIONS = {
44
+ data: {
45
+ props: ['cellSize']
46
+ },
47
+ weights: {
48
+ props: ['aggregation'],
49
+ accessors: ['getWeight']
50
+ }
51
+ };
52
+ export default class ContourLayer extends GridAggregationLayer {
53
+ initializeState() {
54
+ super.initializeAggregationLayer({
55
+ dimensions: DIMENSIONS
56
+ });
57
+ this.setState({
58
+ contourData: {},
59
+ projectPoints: false,
60
+ weights: {
61
+ count: {
62
+ size: 1,
63
+ operation: AGGREGATION_OPERATION.SUM
64
+ }
65
+ }
66
+ });
67
+ const attributeManager = this.getAttributeManager();
68
+ attributeManager.add({
69
+ [POSITION_ATTRIBUTE_NAME]: {
70
+ size: 3,
71
+ accessor: 'getPosition',
72
+ type: GL.DOUBLE,
73
+ fp64: this.use64bitPositions()
74
+ },
75
+ // this attribute is used in gpu aggregation path only
76
+ count: { size: 3, accessor: 'getWeight' }
77
+ });
78
+ }
79
+ updateState(opts) {
80
+ super.updateState(opts);
81
+ let contoursChanged = false;
82
+ const { oldProps, props } = opts;
83
+ const { aggregationDirty } = this.state;
84
+ if (oldProps.contours !== props.contours || oldProps.zOffset !== props.zOffset) {
85
+ contoursChanged = true;
86
+ this._updateThresholdData(opts.props);
87
+ }
88
+ if (this.getNumInstances() > 0 && (aggregationDirty || contoursChanged)) {
89
+ this._generateContours();
90
+ }
91
+ }
92
+ renderLayers() {
93
+ const { contourSegments, contourPolygons } = this.state.contourData;
94
+ const LinesSubLayerClass = this.getSubLayerClass('lines', LineLayer);
95
+ const BandsSubLayerClass = this.getSubLayerClass('bands', SolidPolygonLayer);
96
+ // Contour lines layer
97
+ const lineLayer = contourSegments &&
98
+ contourSegments.length > 0 &&
99
+ new LinesSubLayerClass(this.getSubLayerProps({
100
+ id: 'lines'
101
+ }), {
102
+ data: this.state.contourData.contourSegments,
103
+ getSourcePosition: d => d.start,
104
+ getTargetPosition: d => d.end,
105
+ getColor: d => d.contour.color || DEFAULT_COLOR,
106
+ getWidth: d => d.contour.strokeWidth || DEFAULT_STROKE_WIDTH
107
+ });
108
+ // Contour bands layer
109
+ const bandsLayer = contourPolygons &&
110
+ contourPolygons.length > 0 &&
111
+ new BandsSubLayerClass(this.getSubLayerProps({
112
+ id: 'bands'
113
+ }), {
114
+ data: this.state.contourData.contourPolygons,
115
+ getPolygon: d => d.vertices,
116
+ getFillColor: d => d.contour.color || DEFAULT_COLOR
117
+ });
118
+ return [lineLayer, bandsLayer];
119
+ }
120
+ // Aggregation Overrides
121
+ /* eslint-disable max-statements, complexity */
122
+ updateAggregationState(opts) {
123
+ const { props, oldProps } = opts;
124
+ const { cellSize, coordinateSystem } = props;
125
+ const { viewport } = this.context;
126
+ const cellSizeChanged = oldProps.cellSize !== cellSize;
127
+ let gpuAggregation = props.gpuAggregation;
128
+ if (this.state.gpuAggregation !== props.gpuAggregation) {
129
+ if (gpuAggregation && !GPUGridAggregator.isSupported(this.context.gl)) {
130
+ log.warn('GPU Grid Aggregation not supported, falling back to CPU')();
131
+ gpuAggregation = false;
132
+ }
133
+ }
134
+ const gpuAggregationChanged = gpuAggregation !== this.state.gpuAggregation;
135
+ this.setState({
136
+ gpuAggregation
137
+ });
138
+ const { dimensions } = this.state;
139
+ const positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME);
140
+ const { data, weights } = dimensions;
141
+ let { boundingBox } = this.state;
142
+ if (positionsChanged) {
143
+ boundingBox = getBoundingBox(this.getAttributes(), this.getNumInstances());
144
+ this.setState({ boundingBox });
145
+ }
146
+ if (positionsChanged || cellSizeChanged) {
147
+ const { gridOffset, translation, width, height, numCol, numRow } = getGridParams(boundingBox, cellSize, viewport, coordinateSystem);
148
+ this.allocateResources(numRow, numCol);
149
+ this.setState({
150
+ gridOffset,
151
+ boundingBox,
152
+ translation,
153
+ posOffset: translation.slice(),
154
+ gridOrigin: [-1 * translation[0], -1 * translation[1]],
155
+ width,
156
+ height,
157
+ numCol,
158
+ numRow
159
+ });
160
+ }
161
+ const aggregationDataDirty = positionsChanged ||
162
+ gpuAggregationChanged ||
163
+ this.isAggregationDirty(opts, {
164
+ dimension: data,
165
+ compareAll: gpuAggregation // check for all (including extentions props) when using gpu aggregation
166
+ });
167
+ const aggregationWeightsDirty = this.isAggregationDirty(opts, {
168
+ dimension: weights
169
+ });
170
+ if (aggregationWeightsDirty) {
171
+ this._updateAccessors(opts);
172
+ }
173
+ if (aggregationDataDirty || aggregationWeightsDirty) {
174
+ this._resetResults();
175
+ }
176
+ this.setState({
177
+ aggregationDataDirty,
178
+ aggregationWeightsDirty
179
+ });
180
+ }
181
+ /* eslint-enable max-statements, complexity */
182
+ // Private (Aggregation)
183
+ _updateAccessors(opts) {
184
+ const { getWeight, aggregation, data } = opts.props;
185
+ const { count } = this.state.weights;
186
+ if (count) {
187
+ count.getWeight = getWeight;
188
+ count.operation = AGGREGATION_OPERATION[aggregation];
189
+ }
190
+ this.setState({ getValue: getValueFunc(aggregation, getWeight, { data }) });
191
+ }
192
+ _resetResults() {
193
+ const { count } = this.state.weights;
194
+ if (count) {
195
+ count.aggregationData = null;
196
+ }
197
+ }
198
+ // Private (Contours)
199
+ _generateContours() {
200
+ const { numCol, numRow, gridOrigin, gridOffset, thresholdData } = this.state;
201
+ const { count } = this.state.weights;
202
+ let { aggregationData } = count;
203
+ if (!aggregationData) {
204
+ aggregationData = count.aggregationBuffer.getData();
205
+ count.aggregationData = aggregationData;
206
+ }
207
+ const { cellWeights } = GPUGridAggregator.getCellData({ countsData: aggregationData });
208
+ const contourData = generateContours({
209
+ thresholdData,
210
+ cellWeights,
211
+ gridSize: [numCol, numRow],
212
+ gridOrigin,
213
+ cellSize: [gridOffset.xOffset, gridOffset.yOffset]
214
+ });
215
+ // contourData contains both iso-lines and iso-bands if requested.
216
+ this.setState({ contourData });
217
+ }
218
+ _updateThresholdData(props) {
219
+ const { contours, zOffset } = props;
220
+ const count = contours.length;
221
+ const thresholdData = new Array(count);
222
+ for (let i = 0; i < count; i++) {
223
+ const contour = contours[i];
224
+ thresholdData[i] = {
225
+ contour,
226
+ zIndex: contour.zIndex || i,
227
+ zOffset
228
+ };
229
+ }
230
+ this.setState({ thresholdData });
231
+ }
232
+ }
233
+ ContourLayer.layerName = 'ContourLayer';
234
+ ContourLayer.defaultProps = defaultProps;
@@ -1,18 +1,17 @@
1
- export function generateContours({ thresholdData, colors, cellWeights, gridSize, gridOrigin, cellSize }: {
1
+ export declare function generateContours({ thresholdData, cellWeights, gridSize, gridOrigin, cellSize }: {
2
2
  thresholdData: any;
3
- colors: any;
4
- cellWeights: any;
5
- gridSize: any;
6
- gridOrigin: any;
7
- cellSize: any;
3
+ cellWeights: Float32Array;
4
+ gridSize: number[];
5
+ gridOrigin: number[];
6
+ cellSize: number[];
8
7
  }): {
9
8
  contourSegments: {
10
- start: any;
11
- end: any;
9
+ start: number[];
10
+ end: number[];
12
11
  contour: any;
13
12
  }[];
14
13
  contourPolygons: {
15
- vertices: any;
14
+ vertices: number[][];
16
15
  contour: any;
17
16
  }[];
18
17
  };
@@ -1 +1 @@
1
- {"version":3,"file":"contour-utils.d.ts","sourceRoot":"","sources":["../../src/contour-layer/contour-utils.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;EAiEC"}
1
+ {"version":3,"file":"contour-utils.d.ts","sourceRoot":"","sources":["../../src/contour-layer/contour-utils.ts"],"names":[],"mappings":"AAIA,wBAAgB,gBAAgB,CAAC,EAC/B,aAAa,EACb,WAAW,EACX,QAAQ,EACR,UAAU,EACV,QAAQ,EACT,EAAE;IACD,aAAa,EAAE,GAAG,CAAC;IACnB,WAAW,EAAE,YAAY,CAAC;IAC1B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;;eACgC,MAAM,EAAE;aAAO,MAAM,EAAE;iBAAW,GAAG;;;kBAClC,MAAM,EAAE,EAAE;iBAAW,GAAG;;EAyD3D"}
@@ -0,0 +1,64 @@
1
+ import { getCode, getVertices, CONTOUR_TYPE } from './marching-squares';
2
+ // Given all the cell weights, generates contours for each threshold.
3
+ /* eslint-disable max-depth */
4
+ export function generateContours({ thresholdData, cellWeights, gridSize, gridOrigin, cellSize }) {
5
+ const contourSegments = [];
6
+ const contourPolygons = [];
7
+ const width = gridSize[0];
8
+ const height = gridSize[1];
9
+ let segmentIndex = 0;
10
+ let polygonIndex = 0;
11
+ for (const data of thresholdData) {
12
+ const { contour } = data;
13
+ const { threshold } = contour;
14
+ for (let x = -1; x < width; x++) {
15
+ for (let y = -1; y < height; y++) {
16
+ // Get the MarchingSquares code based on neighbor cell weights.
17
+ const { code, meanCode } = getCode({
18
+ cellWeights,
19
+ threshold,
20
+ x,
21
+ y,
22
+ width,
23
+ height
24
+ });
25
+ const opts = {
26
+ type: CONTOUR_TYPE.ISO_BANDS,
27
+ gridOrigin,
28
+ cellSize,
29
+ x,
30
+ y,
31
+ width,
32
+ height,
33
+ code,
34
+ meanCode,
35
+ thresholdData: data
36
+ };
37
+ if (Array.isArray(threshold)) {
38
+ opts.type = CONTOUR_TYPE.ISO_BANDS;
39
+ const polygons = getVertices(opts);
40
+ for (const polygon of polygons) {
41
+ contourPolygons[polygonIndex++] = {
42
+ vertices: polygon,
43
+ contour
44
+ };
45
+ }
46
+ }
47
+ else {
48
+ // Get the intersection vertices based on MarchingSquares code.
49
+ opts.type = CONTOUR_TYPE.ISO_LINES;
50
+ const vertices = getVertices(opts);
51
+ for (let i = 0; i < vertices.length; i += 2) {
52
+ contourSegments[segmentIndex++] = {
53
+ start: vertices[i],
54
+ end: vertices[i + 1],
55
+ contour
56
+ };
57
+ }
58
+ }
59
+ }
60
+ }
61
+ }
62
+ return { contourSegments, contourPolygons };
63
+ }
64
+ /* eslint-enable max-depth */