@deck.gl/aggregation-layers 9.0.40 → 9.1.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 (372) hide show
  1. package/dist/common/aggregation-layer.d.ts +30 -0
  2. package/dist/common/aggregation-layer.d.ts.map +1 -0
  3. package/dist/common/aggregation-layer.js +70 -0
  4. package/dist/common/aggregation-layer.js.map +1 -0
  5. package/dist/common/aggregator/aggregator.d.ts +76 -0
  6. package/dist/common/aggregator/aggregator.d.ts.map +1 -0
  7. package/dist/common/aggregator/aggregator.js +5 -0
  8. package/dist/common/aggregator/aggregator.js.map +1 -0
  9. package/dist/common/aggregator/cpu-aggregator/aggregate.d.ts +27 -0
  10. package/dist/common/aggregator/cpu-aggregator/aggregate.d.ts.map +1 -0
  11. package/dist/common/aggregator/cpu-aggregator/aggregate.js +67 -0
  12. package/dist/common/aggregator/cpu-aggregator/aggregate.js.map +1 -0
  13. package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.d.ts +70 -0
  14. package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.d.ts.map +1 -0
  15. package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.js +140 -0
  16. package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.js.map +1 -0
  17. package/dist/common/aggregator/cpu-aggregator/sort-bins.d.ts +15 -0
  18. package/dist/common/aggregator/cpu-aggregator/sort-bins.d.ts.map +1 -0
  19. package/dist/common/aggregator/cpu-aggregator/sort-bins.js +44 -0
  20. package/dist/common/aggregator/cpu-aggregator/sort-bins.js.map +1 -0
  21. package/dist/common/aggregator/cpu-aggregator/vertex-accessor.d.ts +21 -0
  22. package/dist/common/aggregator/cpu-aggregator/vertex-accessor.d.ts.map +1 -0
  23. package/dist/common/aggregator/cpu-aggregator/vertex-accessor.js +56 -0
  24. package/dist/common/aggregator/cpu-aggregator/vertex-accessor.js.map +1 -0
  25. package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.d.ts +18 -0
  26. package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.d.ts.map +1 -0
  27. package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.js +21 -0
  28. package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.js.map +1 -0
  29. package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.d.ts +14 -0
  30. package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.d.ts.map +1 -0
  31. package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.js +18 -0
  32. package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.js.map +1 -0
  33. package/dist/common/aggregator/gpu-aggregator/utils.d.ts +6 -0
  34. package/dist/common/aggregator/gpu-aggregator/utils.d.ts.map +1 -0
  35. package/dist/common/aggregator/gpu-aggregator/utils.js +25 -0
  36. package/dist/common/aggregator/gpu-aggregator/utils.js.map +1 -0
  37. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.d.ts +24 -0
  38. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.d.ts.map +1 -0
  39. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js +216 -0
  40. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js.map +1 -0
  41. package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.d.ts +81 -0
  42. package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.d.ts.map +1 -0
  43. package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.js +202 -0
  44. package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.js.map +1 -0
  45. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.d.ts +38 -0
  46. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.d.ts.map +1 -0
  47. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.js +224 -0
  48. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.js.map +1 -0
  49. package/dist/common/aggregator/index.d.ts +6 -0
  50. package/dist/common/aggregator/index.d.ts.map +1 -0
  51. package/dist/common/aggregator/index.js +6 -0
  52. package/dist/common/aggregator/index.js.map +1 -0
  53. package/dist/common/types.d.ts +11 -0
  54. package/dist/common/types.d.ts.map +1 -0
  55. package/dist/common/types.js +5 -0
  56. package/dist/common/types.js.map +1 -0
  57. package/dist/common/utils/bounds-utils.d.ts +10 -0
  58. package/dist/common/utils/bounds-utils.d.ts.map +1 -0
  59. package/dist/common/utils/bounds-utils.js +21 -0
  60. package/dist/common/utils/bounds-utils.js.map +1 -0
  61. package/dist/common/utils/color-utils.d.ts +10 -0
  62. package/dist/common/utils/color-utils.d.ts.map +1 -0
  63. package/dist/common/utils/color-utils.js +66 -0
  64. package/dist/common/utils/color-utils.js.map +1 -0
  65. package/dist/common/utils/prop-utils.d.ts.map +1 -0
  66. package/dist/common/utils/prop-utils.js +13 -0
  67. package/dist/common/utils/prop-utils.js.map +1 -0
  68. package/dist/common/utils/scale-utils.d.ts +46 -0
  69. package/dist/common/utils/scale-utils.d.ts.map +1 -0
  70. package/dist/common/utils/scale-utils.js +181 -0
  71. package/dist/common/utils/scale-utils.js.map +1 -0
  72. package/dist/contour-layer/bin-options-uniforms.d.ts +13 -0
  73. package/dist/contour-layer/bin-options-uniforms.d.ts.map +1 -0
  74. package/dist/contour-layer/bin-options-uniforms.js +18 -0
  75. package/dist/contour-layer/bin-options-uniforms.js.map +1 -0
  76. package/dist/contour-layer/contour-layer.d.ts +42 -50
  77. package/dist/contour-layer/contour-layer.d.ts.map +1 -1
  78. package/dist/contour-layer/contour-layer.js +233 -192
  79. package/dist/contour-layer/contour-layer.js.map +1 -0
  80. package/dist/contour-layer/contour-utils.d.ts +36 -15
  81. package/dist/contour-layer/contour-utils.d.ts.map +1 -1
  82. package/dist/contour-layer/contour-utils.js +25 -29
  83. package/dist/contour-layer/contour-utils.js.map +1 -0
  84. package/dist/contour-layer/marching-squares-codes.d.ts.map +1 -1
  85. package/dist/contour-layer/marching-squares-codes.js +4 -0
  86. package/dist/contour-layer/marching-squares-codes.js.map +1 -0
  87. package/dist/contour-layer/marching-squares.d.ts +22 -6
  88. package/dist/contour-layer/marching-squares.d.ts.map +1 -1
  89. package/dist/contour-layer/marching-squares.js +72 -68
  90. package/dist/contour-layer/marching-squares.js.map +1 -0
  91. package/dist/contour-layer/value-reader.d.ts +10 -0
  92. package/dist/contour-layer/value-reader.d.ts.map +1 -0
  93. package/dist/contour-layer/value-reader.js +47 -0
  94. package/dist/contour-layer/value-reader.js.map +1 -0
  95. package/dist/dist.dev.js +4844 -4083
  96. package/dist/grid-layer/bin-options-uniforms.d.ts +13 -0
  97. package/dist/grid-layer/bin-options-uniforms.d.ts.map +1 -0
  98. package/dist/grid-layer/bin-options-uniforms.js +18 -0
  99. package/dist/grid-layer/bin-options-uniforms.js.map +1 -0
  100. package/dist/grid-layer/grid-cell-layer-vertex.glsl.d.ts +3 -0
  101. package/dist/grid-layer/grid-cell-layer-vertex.glsl.d.ts.map +1 -0
  102. package/dist/grid-layer/grid-cell-layer-vertex.glsl.js +52 -0
  103. package/dist/grid-layer/grid-cell-layer-vertex.glsl.js.map +1 -0
  104. package/dist/grid-layer/grid-cell-layer.d.ts +32 -0
  105. package/dist/grid-layer/grid-cell-layer.d.ts.map +1 -0
  106. package/dist/grid-layer/grid-cell-layer.js +94 -0
  107. package/dist/grid-layer/grid-cell-layer.js.map +1 -0
  108. package/dist/grid-layer/grid-layer-uniforms.d.ts +21 -0
  109. package/dist/grid-layer/grid-layer-uniforms.d.ts.map +1 -0
  110. package/dist/grid-layer/grid-layer-uniforms.js +24 -0
  111. package/dist/grid-layer/grid-layer-uniforms.js.map +1 -0
  112. package/dist/grid-layer/grid-layer.d.ts +176 -14
  113. package/dist/grid-layer/grid-layer.d.ts.map +1 -1
  114. package/dist/grid-layer/grid-layer.js +343 -46
  115. package/dist/grid-layer/grid-layer.js.map +1 -0
  116. package/dist/{aggregation-layer.d.ts → heatmap-layer/aggregation-layer.d.ts} +1 -0
  117. package/dist/heatmap-layer/aggregation-layer.d.ts.map +1 -0
  118. package/dist/{aggregation-layer.js → heatmap-layer/aggregation-layer.js} +7 -21
  119. package/dist/heatmap-layer/aggregation-layer.js.map +1 -0
  120. package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts +30 -0
  121. package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts.map +1 -0
  122. package/dist/heatmap-layer/heatmap-layer-uniforms.js +33 -0
  123. package/dist/heatmap-layer/heatmap-layer-uniforms.js.map +1 -0
  124. package/dist/heatmap-layer/heatmap-layer-utils.d.ts +1 -1
  125. package/dist/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -1
  126. package/dist/heatmap-layer/heatmap-layer-utils.js +4 -0
  127. package/dist/heatmap-layer/heatmap-layer-utils.js.map +1 -0
  128. package/dist/heatmap-layer/heatmap-layer.d.ts +6 -4
  129. package/dist/heatmap-layer/heatmap-layer.d.ts.map +1 -1
  130. package/dist/heatmap-layer/heatmap-layer.js +44 -33
  131. package/dist/heatmap-layer/heatmap-layer.js.map +1 -0
  132. package/dist/heatmap-layer/max-fs.glsl.d.ts.map +1 -1
  133. package/dist/heatmap-layer/max-fs.glsl.js +4 -0
  134. package/dist/heatmap-layer/max-fs.glsl.js.map +1 -0
  135. package/dist/heatmap-layer/max-vs.glsl.d.ts +1 -1
  136. package/dist/heatmap-layer/max-vs.glsl.d.ts.map +1 -1
  137. package/dist/heatmap-layer/max-vs.glsl.js +7 -4
  138. package/dist/heatmap-layer/max-vs.glsl.js.map +1 -0
  139. package/dist/heatmap-layer/triangle-layer-fragment.glsl.d.ts +1 -1
  140. package/dist/heatmap-layer/triangle-layer-fragment.glsl.d.ts.map +1 -1
  141. package/dist/heatmap-layer/triangle-layer-fragment.glsl.js +6 -23
  142. package/dist/heatmap-layer/triangle-layer-fragment.glsl.js.map +1 -0
  143. package/dist/heatmap-layer/triangle-layer-uniforms.d.ts +22 -0
  144. package/dist/heatmap-layer/triangle-layer-uniforms.d.ts.map +1 -0
  145. package/dist/heatmap-layer/triangle-layer-uniforms.js +23 -0
  146. package/dist/heatmap-layer/triangle-layer-uniforms.js.map +1 -0
  147. package/dist/heatmap-layer/triangle-layer-vertex.glsl.d.ts +1 -1
  148. package/dist/heatmap-layer/triangle-layer-vertex.glsl.d.ts.map +1 -1
  149. package/dist/heatmap-layer/triangle-layer-vertex.glsl.js +11 -30
  150. package/dist/heatmap-layer/triangle-layer-vertex.glsl.js.map +1 -0
  151. package/dist/heatmap-layer/triangle-layer.d.ts +4 -10
  152. package/dist/heatmap-layer/triangle-layer.d.ts.map +1 -1
  153. package/dist/heatmap-layer/triangle-layer.js +18 -30
  154. package/dist/heatmap-layer/triangle-layer.js.map +1 -0
  155. package/dist/heatmap-layer/weights-fs.glsl.d.ts.map +1 -1
  156. package/dist/heatmap-layer/weights-fs.glsl.js +4 -0
  157. package/dist/heatmap-layer/weights-fs.glsl.js.map +1 -0
  158. package/dist/heatmap-layer/weights-vs.glsl.d.ts +1 -1
  159. package/dist/heatmap-layer/weights-vs.glsl.d.ts.map +1 -1
  160. package/dist/heatmap-layer/weights-vs.glsl.js +7 -7
  161. package/dist/heatmap-layer/weights-vs.glsl.js.map +1 -0
  162. package/dist/hexagon-layer/bin-options-uniforms.d.ts +14 -0
  163. package/dist/hexagon-layer/bin-options-uniforms.d.ts.map +1 -0
  164. package/dist/hexagon-layer/bin-options-uniforms.js +18 -0
  165. package/dist/hexagon-layer/bin-options-uniforms.js.map +1 -0
  166. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.d.ts +3 -0
  167. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.d.ts.map +1 -0
  168. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.js +56 -0
  169. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.js.map +1 -0
  170. package/dist/hexagon-layer/hexagon-cell-layer.d.ts +29 -0
  171. package/dist/hexagon-layer/hexagon-cell-layer.d.ts.map +1 -0
  172. package/dist/hexagon-layer/hexagon-cell-layer.js +95 -0
  173. package/dist/hexagon-layer/hexagon-cell-layer.js.map +1 -0
  174. package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts +19 -0
  175. package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts.map +1 -0
  176. package/dist/hexagon-layer/hexagon-layer-uniforms.js +22 -0
  177. package/dist/hexagon-layer/hexagon-layer-uniforms.js.map +1 -0
  178. package/dist/hexagon-layer/hexagon-layer.d.ts +84 -54
  179. package/dist/hexagon-layer/hexagon-layer.d.ts.map +1 -1
  180. package/dist/hexagon-layer/hexagon-layer.js +308 -123
  181. package/dist/hexagon-layer/hexagon-layer.js.map +1 -0
  182. package/dist/hexagon-layer/hexbin.d.ts +17 -0
  183. package/dist/hexagon-layer/hexbin.d.ts.map +1 -0
  184. package/dist/hexagon-layer/hexbin.js +70 -0
  185. package/dist/hexagon-layer/hexbin.js.map +1 -0
  186. package/dist/index.cjs +3026 -2947
  187. package/dist/index.cjs.map +4 -4
  188. package/dist/index.d.ts +7 -13
  189. package/dist/index.d.ts.map +1 -1
  190. package/dist/index.js +6 -27
  191. package/dist/index.js.map +1 -0
  192. package/dist/screen-grid-layer/bin-options-uniforms.d.ts +11 -0
  193. package/dist/screen-grid-layer/bin-options-uniforms.d.ts.map +1 -0
  194. package/dist/screen-grid-layer/bin-options-uniforms.js +16 -0
  195. package/dist/screen-grid-layer/bin-options-uniforms.js.map +1 -0
  196. package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts +11 -16
  197. package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -1
  198. package/dist/screen-grid-layer/screen-grid-cell-layer.js +53 -134
  199. package/dist/screen-grid-layer/screen-grid-cell-layer.js.map +1 -0
  200. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts +1 -1
  201. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts.map +1 -1
  202. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.js +5 -24
  203. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +1 -0
  204. package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts +17 -0
  205. package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts.map +1 -0
  206. package/dist/screen-grid-layer/screen-grid-layer-uniforms.js +20 -0
  207. package/dist/screen-grid-layer/screen-grid-layer-uniforms.js.map +1 -0
  208. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts +1 -1
  209. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts.map +1 -1
  210. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.js +22 -62
  211. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +1 -0
  212. package/dist/screen-grid-layer/screen-grid-layer.d.ts +33 -40
  213. package/dist/screen-grid-layer/screen-grid-layer.d.ts.map +1 -1
  214. package/dist/screen-grid-layer/screen-grid-layer.js +158 -174
  215. package/dist/screen-grid-layer/screen-grid-layer.js.map +1 -0
  216. package/dist.min.js +401 -382
  217. package/package.json +10 -9
  218. package/src/common/aggregation-layer.ts +107 -0
  219. package/src/common/aggregator/aggregator.ts +88 -0
  220. package/src/common/aggregator/cpu-aggregator/aggregate.ts +101 -0
  221. package/src/common/aggregator/cpu-aggregator/cpu-aggregator.ts +203 -0
  222. package/src/common/aggregator/cpu-aggregator/sort-bins.ts +63 -0
  223. package/src/common/aggregator/cpu-aggregator/vertex-accessor.ts +86 -0
  224. package/src/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.ts +33 -0
  225. package/src/common/aggregator/gpu-aggregator/bin-sorter-uniforms.ts +27 -0
  226. package/src/common/aggregator/gpu-aggregator/utils.ts +27 -0
  227. package/src/common/aggregator/gpu-aggregator/webgl-aggregation-transform.ts +247 -0
  228. package/src/common/aggregator/gpu-aggregator/webgl-aggregator.ts +274 -0
  229. package/src/common/aggregator/gpu-aggregator/webgl-bin-sorter.ts +258 -0
  230. package/src/common/aggregator/index.ts +10 -0
  231. package/src/{types.ts → common/types.ts} +10 -4
  232. package/src/common/utils/bounds-utils.ts +34 -0
  233. package/src/common/utils/color-utils.ts +86 -0
  234. package/src/common/utils/prop-utils.ts +13 -0
  235. package/src/common/utils/scale-utils.ts +236 -0
  236. package/src/contour-layer/bin-options-uniforms.ts +26 -0
  237. package/src/contour-layer/contour-layer.ts +300 -265
  238. package/src/contour-layer/contour-utils.ts +68 -39
  239. package/src/contour-layer/marching-squares-codes.ts +4 -0
  240. package/src/contour-layer/marching-squares.ts +93 -82
  241. package/src/contour-layer/value-reader.ts +65 -0
  242. package/src/grid-layer/bin-options-uniforms.ts +26 -0
  243. package/src/grid-layer/grid-cell-layer-vertex.glsl.ts +68 -0
  244. package/src/grid-layer/grid-cell-layer.ts +141 -0
  245. package/src/grid-layer/grid-layer-uniforms.ts +37 -0
  246. package/src/grid-layer/grid-layer.ts +614 -73
  247. package/src/{aggregation-layer.ts → heatmap-layer/aggregation-layer.ts} +6 -21
  248. package/src/heatmap-layer/heatmap-layer-uniforms.ts +50 -0
  249. package/src/heatmap-layer/heatmap-layer-utils.ts +9 -1
  250. package/src/heatmap-layer/heatmap-layer.ts +59 -36
  251. package/src/heatmap-layer/max-fs.glsl.ts +4 -0
  252. package/src/heatmap-layer/max-vs.glsl.ts +7 -4
  253. package/src/heatmap-layer/triangle-layer-fragment.glsl.ts +5 -23
  254. package/src/heatmap-layer/triangle-layer-uniforms.ts +37 -0
  255. package/src/heatmap-layer/triangle-layer-vertex.glsl.ts +10 -30
  256. package/src/heatmap-layer/triangle-layer.ts +26 -31
  257. package/src/heatmap-layer/weights-fs.glsl.ts +4 -0
  258. package/src/heatmap-layer/weights-vs.glsl.ts +7 -7
  259. package/src/hexagon-layer/bin-options-uniforms.ts +27 -0
  260. package/src/hexagon-layer/hexagon-cell-layer-vertex.glsl.ts +73 -0
  261. package/src/hexagon-layer/hexagon-cell-layer.ts +141 -0
  262. package/src/hexagon-layer/hexagon-layer-uniforms.ts +34 -0
  263. package/src/hexagon-layer/hexagon-layer.ts +454 -186
  264. package/src/hexagon-layer/hexbin.ts +79 -0
  265. package/src/index.ts +21 -34
  266. package/src/screen-grid-layer/bin-options-uniforms.ts +23 -0
  267. package/src/screen-grid-layer/screen-grid-cell-layer.ts +71 -156
  268. package/src/screen-grid-layer/screen-grid-layer-fragment.glsl.ts +4 -24
  269. package/src/screen-grid-layer/screen-grid-layer-uniforms.ts +31 -0
  270. package/src/screen-grid-layer/screen-grid-layer-vertex.glsl.ts +21 -64
  271. package/src/screen-grid-layer/screen-grid-layer.ts +194 -222
  272. package/dist/aggregation-layer.d.ts.map +0 -1
  273. package/dist/cpu-grid-layer/cpu-grid-layer.d.ts +0 -158
  274. package/dist/cpu-grid-layer/cpu-grid-layer.d.ts.map +0 -1
  275. package/dist/cpu-grid-layer/cpu-grid-layer.js +0 -130
  276. package/dist/cpu-grid-layer/grid-aggregator.d.ts +0 -35
  277. package/dist/cpu-grid-layer/grid-aggregator.d.ts.map +0 -1
  278. package/dist/cpu-grid-layer/grid-aggregator.js +0 -141
  279. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts +0 -3
  280. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts.map +0 -1
  281. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -30
  282. package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts +0 -3
  283. package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts.map +0 -1
  284. package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +0 -112
  285. package/dist/gpu-grid-layer/gpu-grid-cell-layer.d.ts +0 -48
  286. package/dist/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +0 -1
  287. package/dist/gpu-grid-layer/gpu-grid-cell-layer.js +0 -146
  288. package/dist/gpu-grid-layer/gpu-grid-layer.d.ts +0 -99
  289. package/dist/gpu-grid-layer/gpu-grid-layer.d.ts.map +0 -1
  290. package/dist/gpu-grid-layer/gpu-grid-layer.js +0 -289
  291. package/dist/grid-aggregation-layer.d.ts +0 -67
  292. package/dist/grid-aggregation-layer.d.ts.map +0 -1
  293. package/dist/grid-aggregation-layer.js +0 -173
  294. package/dist/hexagon-layer/hexagon-aggregator.d.ts +0 -27
  295. package/dist/hexagon-layer/hexagon-aggregator.d.ts.map +0 -1
  296. package/dist/hexagon-layer/hexagon-aggregator.js +0 -112
  297. package/dist/types.d.ts +0 -12
  298. package/dist/types.d.ts.map +0 -1
  299. package/dist/types.js +0 -1
  300. package/dist/utils/aggregation-operation-utils.d.ts +0 -19
  301. package/dist/utils/aggregation-operation-utils.d.ts.map +0 -1
  302. package/dist/utils/aggregation-operation-utils.js +0 -94
  303. package/dist/utils/bin-sorter.d.ts +0 -52
  304. package/dist/utils/bin-sorter.d.ts.map +0 -1
  305. package/dist/utils/bin-sorter.js +0 -167
  306. package/dist/utils/color-utils.d.ts +0 -3
  307. package/dist/utils/color-utils.d.ts.map +0 -1
  308. package/dist/utils/color-utils.js +0 -53
  309. package/dist/utils/cpu-aggregator.d.ts +0 -169
  310. package/dist/utils/cpu-aggregator.d.ts.map +0 -1
  311. package/dist/utils/cpu-aggregator.js +0 -421
  312. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts +0 -3
  313. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts.map +0 -1
  314. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -36
  315. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts +0 -3
  316. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts.map +0 -1
  317. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -42
  318. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts +0 -3
  319. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts.map +0 -1
  320. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -30
  321. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts +0 -3
  322. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts.map +0 -1
  323. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +0 -61
  324. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts +0 -38
  325. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts.map +0 -1
  326. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -41
  327. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts +0 -1
  328. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts.map +0 -1
  329. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -1
  330. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts +0 -76
  331. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts.map +0 -1
  332. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -555
  333. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts +0 -3
  334. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts.map +0 -1
  335. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -32
  336. package/dist/utils/grid-aggregation-utils.d.ts +0 -30
  337. package/dist/utils/grid-aggregation-utils.d.ts.map +0 -1
  338. package/dist/utils/grid-aggregation-utils.js +0 -114
  339. package/dist/utils/prop-utils.d.ts.map +0 -1
  340. package/dist/utils/prop-utils.js +0 -28
  341. package/dist/utils/resource-utils.d.ts +0 -14
  342. package/dist/utils/resource-utils.d.ts.map +0 -1
  343. package/dist/utils/resource-utils.js +0 -38
  344. package/dist/utils/scale-utils.d.ts +0 -15
  345. package/dist/utils/scale-utils.d.ts.map +0 -1
  346. package/dist/utils/scale-utils.js +0 -184
  347. package/src/cpu-grid-layer/cpu-grid-layer.ts +0 -329
  348. package/src/cpu-grid-layer/grid-aggregator.ts +0 -184
  349. package/src/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.ts +0 -35
  350. package/src/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.ts +0 -143
  351. package/src/gpu-grid-layer/gpu-grid-cell-layer.ts +0 -201
  352. package/src/gpu-grid-layer/gpu-grid-layer.ts +0 -455
  353. package/src/grid-aggregation-layer.ts +0 -243
  354. package/src/hexagon-layer/hexagon-aggregator.ts +0 -127
  355. package/src/utils/aggregation-operation-utils.ts +0 -118
  356. package/src/utils/bin-sorter.ts +0 -218
  357. package/src/utils/color-utils.ts +0 -57
  358. package/src/utils/cpu-aggregator.ts +0 -503
  359. package/src/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.ts +0 -40
  360. package/src/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.ts +0 -54
  361. package/src/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.ts +0 -35
  362. package/src/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.ts +0 -79
  363. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.ts +0 -46
  364. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.ts +0 -0
  365. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +0 -155
  366. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.ts +0 -690
  367. package/src/utils/gpu-grid-aggregation/transform-mean-vs.glsl.ts +0 -38
  368. package/src/utils/grid-aggregation-utils.ts +0 -147
  369. package/src/utils/prop-utils.ts +0 -29
  370. package/src/utils/resource-utils.ts +0 -53
  371. package/src/utils/scale-utils.js +0 -219
  372. /package/dist/{utils → common/utils}/prop-utils.d.ts +0 -0
@@ -1,112 +1,653 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  import {
2
- CompositeLayer,
6
+ log,
7
+ Accessor,
8
+ Color,
9
+ GetPickingInfoParams,
3
10
  CompositeLayerProps,
11
+ createIterable,
4
12
  Layer,
13
+ Material,
14
+ project32,
15
+ LayersList,
16
+ PickingInfo,
17
+ Position,
18
+ Viewport,
5
19
  UpdateParameters,
6
20
  DefaultProps
7
21
  } from '@deck.gl/core';
8
- import GPUGridAggregator from '../utils/gpu-grid-aggregation/gpu-grid-aggregator';
9
- import GPUGridLayer, {GPUGridLayerProps} from '../gpu-grid-layer/gpu-grid-layer';
10
- import CPUGridLayer, {CPUGridLayerProps} from '../cpu-grid-layer/cpu-grid-layer';
22
+ import {WebGLAggregator, CPUAggregator, AggregationOperation} from '../common/aggregator/index';
23
+ import AggregationLayer from '../common/aggregation-layer';
24
+ import {AggregateAccessor} from '../common/types';
25
+ import {defaultColorRange} from '../common/utils/color-utils';
26
+ import {AttributeWithScale} from '../common/utils/scale-utils';
27
+ import {getBinIdRange} from '../common/utils/bounds-utils';
28
+
29
+ import {GridCellLayer} from './grid-cell-layer';
30
+ import {BinOptions, binOptionsUniforms} from './bin-options-uniforms';
31
+
32
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
33
+ function noop() {}
11
34
 
12
35
  const defaultProps: DefaultProps<GridLayerProps> = {
13
- ...GPUGridLayer.defaultProps,
14
- ...CPUGridLayer.defaultProps,
15
- gpuAggregation: false
36
+ gpuAggregation: true,
37
+
38
+ // color
39
+ colorDomain: null,
40
+ colorRange: defaultColorRange,
41
+ getColorValue: {type: 'accessor', value: null}, // default value is calculated from `getColorWeight` and `colorAggregation`
42
+ getColorWeight: {type: 'accessor', value: 1},
43
+ colorAggregation: 'SUM',
44
+ lowerPercentile: {type: 'number', min: 0, max: 100, value: 0},
45
+ upperPercentile: {type: 'number', min: 0, max: 100, value: 100},
46
+ colorScaleType: 'quantize',
47
+ onSetColorDomain: noop,
48
+
49
+ // elevation
50
+ elevationDomain: null,
51
+ elevationRange: [0, 1000],
52
+ getElevationValue: {type: 'accessor', value: null}, // default value is calculated from `getElevationWeight` and `elevationAggregation`
53
+ getElevationWeight: {type: 'accessor', value: 1},
54
+ elevationAggregation: 'SUM',
55
+ elevationScale: {type: 'number', min: 0, value: 1},
56
+ elevationLowerPercentile: {type: 'number', min: 0, max: 100, value: 0},
57
+ elevationUpperPercentile: {type: 'number', min: 0, max: 100, value: 100},
58
+ elevationScaleType: 'linear',
59
+ onSetElevationDomain: noop,
60
+
61
+ // grid
62
+ cellSize: {type: 'number', min: 0, value: 1000},
63
+ coverage: {type: 'number', min: 0, max: 1, value: 1},
64
+ getPosition: {type: 'accessor', value: (x: any) => x.position},
65
+ gridAggregator: {type: 'function', optional: true, value: null},
66
+ extruded: false,
67
+
68
+ // Optional material for 'lighting' shader module
69
+ material: true
16
70
  };
17
71
 
18
72
  /** All properties supported by GridLayer. */
19
73
  export type GridLayerProps<DataT = unknown> = _GridLayerProps<DataT> & CompositeLayerProps;
20
74
 
21
75
  /** Properties added by GridLayer. */
22
- type _GridLayerProps<DataT> = CPUGridLayerProps<DataT> &
23
- GPUGridLayerProps<DataT> & {
24
- /**
25
- * Whether the aggregation should be performed in high-precision 64-bit mode.
26
- * @default false
27
- */
28
- fp64?: boolean;
29
-
30
- /**
31
- * When set to true, aggregation is performed on GPU, provided other conditions are met.
32
- * @default false
33
- */
34
- gpuAggregation?: boolean;
35
- };
76
+ type _GridLayerProps<DataT> = {
77
+ /**
78
+ * Custom accessor to retrieve a grid bin index from each data object.
79
+ * Not supported by GPU aggregation.
80
+ */
81
+ gridAggregator?: ((position: number[], cellSize: number) => [number, number]) | null;
82
+
83
+ /**
84
+ * Size of each cell in meters.
85
+ * @default 1000
86
+ */
87
+ cellSize?: number;
88
+
89
+ /**
90
+ * Color scale domain, default is set to the extent of aggregated weights in each cell.
91
+ * @default [min(colorWeight), max(colorWeight)]
92
+ */
93
+ colorDomain?: [number, number] | null;
94
+
95
+ /**
96
+ * Default: [colorbrewer](http://colorbrewer2.org/#type=sequential&scheme=YlOrRd&n=6) `6-class YlOrRd`
97
+ */
98
+ colorRange?: Color[];
99
+
100
+ /**
101
+ * Cell size multiplier, clamped between 0 - 1.
102
+ * @default 1
103
+ */
104
+ coverage?: number;
105
+
106
+ /**
107
+ * Elevation scale input domain, default is set to between 0 and the max of aggregated weights in each cell.
108
+ * @default [0, max(elevationWeight)]
109
+ */
110
+ elevationDomain?: [number, number] | null;
111
+
112
+ /**
113
+ * Elevation scale output range.
114
+ * @default [0, 1000]
115
+ */
116
+ elevationRange?: [number, number];
117
+
118
+ /**
119
+ * Cell elevation multiplier.
120
+ * @default 1
121
+ */
122
+ elevationScale?: number;
123
+
124
+ /**
125
+ * Whether to enable cell elevation. If set to false, all cell will be flat.
126
+ * @default true
127
+ */
128
+ extruded?: boolean;
129
+
130
+ /**
131
+ * Filter cells and re-calculate color by `upperPercentile`.
132
+ * Cells with value larger than the upperPercentile will be hidden.
133
+ * @default 100
134
+ */
135
+ upperPercentile?: number;
136
+
137
+ /**
138
+ * Filter cells and re-calculate color by `lowerPercentile`.
139
+ * Cells with value smaller than the lowerPercentile will be hidden.
140
+ * @default 0
141
+ */
142
+ lowerPercentile?: number;
143
+
144
+ /**
145
+ * Filter cells and re-calculate elevation by `elevationUpperPercentile`.
146
+ * Cells with elevation value larger than the `elevationUpperPercentile` will be hidden.
147
+ * @default 100
148
+ */
149
+ elevationUpperPercentile?: number;
150
+
151
+ /**
152
+ * Filter cells and re-calculate elevation by `elevationLowerPercentile`.
153
+ * Cells with elevation value larger than the `elevationLowerPercentile` will be hidden.
154
+ * @default 0
155
+ */
156
+ elevationLowerPercentile?: number;
157
+
158
+ /**
159
+ * Scaling function used to determine the color of the grid cell.
160
+ * Supported Values are 'quantize', 'linear', 'quantile' and 'ordinal'.
161
+ * @default 'quantize'
162
+ */
163
+ colorScaleType?: 'quantize' | 'linear' | 'quantile' | 'ordinal';
164
+
165
+ /**
166
+ * Scaling function used to determine the elevation of the grid cell.
167
+ * Supported Values are 'linear' and 'quantile'.
168
+ * @default 'linear'
169
+ */
170
+ elevationScaleType?: 'linear' | 'quantile';
171
+
172
+ /**
173
+ * Material settings for lighting effect. Applies if `extruded: true`.
174
+ *
175
+ * @default true
176
+ * @see https://deck.gl/docs/developer-guide/using-lighting
177
+ */
178
+ material?: Material;
179
+
180
+ /**
181
+ * Defines the operation used to aggregate all data object weights to calculate a cell's color value.
182
+ * Valid values are 'SUM', 'MEAN', 'MIN', 'MAX', 'COUNT'.
183
+ *
184
+ * @default 'SUM'
185
+ */
186
+ colorAggregation?: AggregationOperation;
187
+
188
+ /**
189
+ * Defines the operation used to aggregate all data object weights to calculate a cell's elevation value.
190
+ * Valid values are 'SUM', 'MEAN', 'MIN', 'MAX', 'COUNT'.
191
+ *
192
+ * @default 'SUM'
193
+ */
194
+ elevationAggregation?: AggregationOperation;
195
+
196
+ /**
197
+ * Method called to retrieve the position of each object.
198
+ * @default object => object.position
199
+ */
200
+ getPosition?: Accessor<DataT, Position>;
201
+
202
+ /**
203
+ * The weight of a data object used to calculate the color value for a cell.
204
+ * @default 1
205
+ */
206
+ getColorWeight?: Accessor<DataT, number>;
207
+
208
+ /**
209
+ * After data objects are aggregated into cells, this accessor is called on each cell to get the value that its color is based on.
210
+ * Not supported by GPU aggregation.
211
+ * @default null
212
+ */
213
+ getColorValue?: AggregateAccessor<DataT> | null;
214
+
215
+ /**
216
+ * The weight of a data object used to calculate the elevation value for a cell.
217
+ * @default 1
218
+ */
219
+ getElevationWeight?: Accessor<DataT, number>;
220
+
221
+ /**
222
+ * After data objects are aggregated into cells, this accessor is called on each cell to get the value that its elevation is based on.
223
+ * Not supported by GPU aggregation.
224
+ * @default null
225
+ */
226
+ getElevationValue?: AggregateAccessor<DataT> | null;
227
+
228
+ /**
229
+ * This callback will be called when bin color domain has been calculated.
230
+ * @default () => {}
231
+ */
232
+ onSetColorDomain?: (minMax: [number, number]) => void;
233
+
234
+ /**
235
+ * This callback will be called when bin elevation domain has been calculated.
236
+ * @default () => {}
237
+ */
238
+ onSetElevationDomain?: (minMax: [number, number]) => void;
239
+
240
+ /**
241
+ * When set to true, aggregation is performed on GPU, provided other conditions are met.
242
+ * @default true
243
+ */
244
+ gpuAggregation?: boolean;
245
+ };
246
+
247
+ export type GridLayerPickingInfo<DataT> = PickingInfo<{
248
+ /** Column index of the picked cell */
249
+ col: number;
250
+ /** Row index of the picked cell */
251
+ row: number;
252
+ /** Aggregated color value, as determined by `getColorWeight` and `colorAggregation` */
253
+ colorValue: number;
254
+ /** Aggregated elevation value, as determined by `getElevationWeight` and `elevationAggregation` */
255
+ elevationValue: number;
256
+ /** Number of data points in the picked cell */
257
+ count: number;
258
+ /** Indices of the data objects in the picked cell. Only available if using CPU aggregation. */
259
+ pointIndices?: number[];
260
+ /** The data objects in the picked cell. Only available if using CPU aggregation and layer data is an array. */
261
+ points?: DataT[];
262
+ }>;
36
263
 
37
264
  /** Aggregate data into a grid-based heatmap. The color and height of a cell are determined based on the objects it contains. */
38
- export default class GridLayer<DataT = any, ExtraPropsT extends {} = {}> extends CompositeLayer<
265
+ export default class GridLayer<DataT = any, ExtraPropsT extends {} = {}> extends AggregationLayer<
266
+ DataT,
39
267
  ExtraPropsT & Required<_GridLayerProps<DataT>>
40
268
  > {
41
269
  static layerName = 'GridLayer';
42
270
  static defaultProps = defaultProps;
43
271
 
44
- state!: CompositeLayer['state'] & {
45
- useGPUAggregation: boolean;
46
- };
272
+ state!: AggregationLayer<DataT>['state'] &
273
+ BinOptions & {
274
+ // Needed if getColorValue, getElevationValue are used
275
+ dataAsArray?: DataT[];
47
276
 
48
- initializeState() {
49
- this.state = {
50
- useGPUAggregation: false // TODO(v9): Re-enable GPU aggregation.
277
+ colors?: AttributeWithScale;
278
+ elevations?: AttributeWithScale;
279
+
280
+ binIdRange: [number, number][];
281
+ aggregatorViewport: Viewport;
51
282
  };
283
+
284
+ getAggregatorType(): string {
285
+ const {gpuAggregation, gridAggregator, getColorValue, getElevationValue} = this.props;
286
+ if (gpuAggregation && (gridAggregator || getColorValue || getElevationValue)) {
287
+ // If these features are desired by the app, the user should explicitly use CPU aggregation
288
+ log.warn('Features not supported by GPU aggregation, falling back to CPU')();
289
+ return 'cpu';
290
+ }
291
+
292
+ if (
293
+ // GPU aggregation is requested
294
+ gpuAggregation &&
295
+ // GPU aggregation is supported by the device
296
+ WebGLAggregator.isSupported(this.context.device)
297
+ ) {
298
+ return 'gpu';
299
+ }
300
+ return 'cpu';
52
301
  }
53
302
 
54
- updateState({props}: UpdateParameters<this>) {
55
- this.setState({
56
- // TODO(v9): Re-enable GPU aggregation.
57
- // useGPUAggregation: this.canUseGPUAggregation(props)
58
- useGPUAggregation: false
303
+ createAggregator(type: string): WebGLAggregator | CPUAggregator {
304
+ if (type === 'cpu') {
305
+ const {gridAggregator, cellSize} = this.props;
306
+ return new CPUAggregator({
307
+ dimensions: 2,
308
+ getBin: {
309
+ sources: ['positions'],
310
+ getValue: ({positions}: {positions: number[]}, index: number, opts: BinOptions) => {
311
+ if (gridAggregator) {
312
+ return gridAggregator(positions, cellSize);
313
+ }
314
+ const viewport = this.state.aggregatorViewport;
315
+ // project to common space
316
+ const p = viewport.projectPosition(positions);
317
+ const {cellSizeCommon, cellOriginCommon} = opts;
318
+ return [
319
+ Math.floor((p[0] - cellOriginCommon[0]) / cellSizeCommon[0]),
320
+ Math.floor((p[1] - cellOriginCommon[1]) / cellSizeCommon[1])
321
+ ];
322
+ }
323
+ },
324
+ getValue: [
325
+ {sources: ['colorWeights'], getValue: ({colorWeights}) => colorWeights},
326
+ {sources: ['elevationWeights'], getValue: ({elevationWeights}) => elevationWeights}
327
+ ]
328
+ });
329
+ }
330
+ return new WebGLAggregator(this.context.device, {
331
+ dimensions: 2,
332
+ channelCount: 2,
333
+ bufferLayout: this.getAttributeManager()!.getBufferLayouts({isInstanced: false}),
334
+ ...super.getShaders({
335
+ modules: [project32, binOptionsUniforms],
336
+ vs: /* glsl */ `
337
+ in vec3 positions;
338
+ in vec3 positions64Low;
339
+ in float colorWeights;
340
+ in float elevationWeights;
341
+
342
+ void getBin(out ivec2 binId) {
343
+ vec3 positionCommon = project_position(positions, positions64Low);
344
+ vec2 gridCoords = floor(positionCommon.xy / binOptions.cellSizeCommon);
345
+ binId = ivec2(gridCoords);
346
+ }
347
+ void getValue(out vec2 value) {
348
+ value = vec2(colorWeights, elevationWeights);
349
+ }
350
+ `
351
+ })
59
352
  });
60
353
  }
61
354
 
62
- renderLayers(): Layer {
63
- const {data, updateTriggers} = this.props;
64
- const id = this.state.useGPUAggregation ? 'GPU' : 'CPU';
65
- const LayerType = this.state.useGPUAggregation
66
- ? this.getSubLayerClass('GPU', GPUGridLayer)
67
- : this.getSubLayerClass('CPU', CPUGridLayer);
68
- return new LayerType(
69
- this.props,
70
- this.getSubLayerProps({
71
- id,
72
- updateTriggers
73
- }),
74
- {
75
- data
355
+ initializeState() {
356
+ super.initializeState();
357
+
358
+ const attributeManager = this.getAttributeManager()!;
359
+ attributeManager.add({
360
+ positions: {
361
+ size: 3,
362
+ accessor: 'getPosition',
363
+ type: 'float64',
364
+ fp64: this.use64bitPositions()
365
+ },
366
+ colorWeights: {size: 1, accessor: 'getColorWeight'},
367
+ elevationWeights: {size: 1, accessor: 'getElevationWeight'}
368
+ });
369
+ }
370
+
371
+ updateState(params: UpdateParameters<this>) {
372
+ const aggregatorChanged = super.updateState(params);
373
+
374
+ const {props, oldProps, changeFlags} = params;
375
+ const {aggregator} = this.state;
376
+ if (
377
+ (changeFlags.dataChanged || !this.state.dataAsArray) &&
378
+ (props.getColorValue || props.getElevationValue)
379
+ ) {
380
+ // Convert data to array
381
+ this.state.dataAsArray = Array.from(createIterable(props.data).iterable);
382
+ }
383
+ if (
384
+ aggregatorChanged ||
385
+ changeFlags.dataChanged ||
386
+ props.cellSize !== oldProps.cellSize ||
387
+ props.getColorValue !== oldProps.getColorValue ||
388
+ props.getElevationValue !== oldProps.getElevationValue ||
389
+ props.colorAggregation !== oldProps.colorAggregation ||
390
+ props.elevationAggregation !== oldProps.elevationAggregation
391
+ ) {
392
+ this._updateBinOptions();
393
+ const {cellSizeCommon, cellOriginCommon, binIdRange, dataAsArray} = this.state;
394
+
395
+ aggregator.setProps({
396
+ // @ts-expect-error only used by GPUAggregator
397
+ binIdRange,
398
+ pointCount: this.getNumInstances(),
399
+ operations: [props.colorAggregation, props.elevationAggregation],
400
+ binOptions: {
401
+ cellSizeCommon,
402
+ cellOriginCommon
403
+ },
404
+ onUpdate: this._onAggregationUpdate.bind(this)
405
+ });
406
+
407
+ if (dataAsArray) {
408
+ const {getColorValue, getElevationValue} = this.props;
409
+ aggregator.setProps({
410
+ // @ts-expect-error only used by CPUAggregator
411
+ customOperations: [
412
+ getColorValue &&
413
+ ((indices: number[]) =>
414
+ getColorValue(
415
+ indices.map(i => dataAsArray[i]),
416
+ {indices, data: props.data}
417
+ )),
418
+ getElevationValue &&
419
+ ((indices: number[]) =>
420
+ getElevationValue(
421
+ indices.map(i => dataAsArray[i]),
422
+ {indices, data: props.data}
423
+ ))
424
+ ]
425
+ });
76
426
  }
77
- );
427
+ }
428
+ if (changeFlags.updateTriggersChanged && changeFlags.updateTriggersChanged.getColorValue) {
429
+ aggregator.setNeedsUpdate(0);
430
+ }
431
+ if (changeFlags.updateTriggersChanged && changeFlags.updateTriggersChanged.getElevationValue) {
432
+ aggregator.setNeedsUpdate(1);
433
+ }
434
+
435
+ return aggregatorChanged;
78
436
  }
79
437
 
80
- // Private methods
438
+ private _updateBinOptions() {
439
+ const bounds = this.getBounds();
440
+ const cellSizeCommon: [number, number] = [1, 1];
441
+ let cellOriginCommon: [number, number] = [0, 0];
442
+ let binIdRange: [number, number][] = [
443
+ [0, 1],
444
+ [0, 1]
445
+ ];
446
+ let viewport = this.context.viewport;
81
447
 
82
- canUseGPUAggregation(props: GridLayer['props']) {
83
- const {
84
- gpuAggregation,
85
- lowerPercentile,
86
- upperPercentile,
87
- getColorValue,
88
- getElevationValue,
89
- colorScaleType
90
- } = props;
91
- if (!gpuAggregation) {
92
- // cpu aggregation is requested
93
- return false;
448
+ if (bounds && Number.isFinite(bounds[0][0])) {
449
+ let centroid = [(bounds[0][0] + bounds[1][0]) / 2, (bounds[0][1] + bounds[1][1]) / 2];
450
+ const {cellSize} = this.props;
451
+ const {unitsPerMeter} = viewport.getDistanceScales(centroid);
452
+ cellSizeCommon[0] = unitsPerMeter[0] * cellSize;
453
+ cellSizeCommon[1] = unitsPerMeter[1] * cellSize;
454
+
455
+ // Offset common space to center at the origin of the grid cell where the data center is in
456
+ // This improves precision without affecting the cell positions
457
+ const centroidCommon = viewport.projectFlat(centroid);
458
+ cellOriginCommon = [
459
+ Math.floor(centroidCommon[0] / cellSizeCommon[0]) * cellSizeCommon[0],
460
+ Math.floor(centroidCommon[1] / cellSizeCommon[1]) * cellSizeCommon[1]
461
+ ];
462
+ centroid = viewport.unprojectFlat(cellOriginCommon);
463
+
464
+ const ViewportType = viewport.constructor as any;
465
+ // We construct a viewport for the GPU aggregator's project module
466
+ // This viewport is determined by data
467
+ // removes arbitrary precision variance that depends on initial view state
468
+ viewport = viewport.isGeospatial
469
+ ? new ViewportType({longitude: centroid[0], latitude: centroid[1], zoom: 12})
470
+ : new Viewport({position: [centroid[0], centroid[1], 0], zoom: 12});
471
+
472
+ // Round to the nearest 32-bit float to match CPU and GPU results
473
+ cellOriginCommon = [Math.fround(viewport.center[0]), Math.fround(viewport.center[1])];
474
+
475
+ binIdRange = getBinIdRange({
476
+ dataBounds: bounds,
477
+ getBinId: (p: number[]) => {
478
+ const positionCommon = viewport.projectFlat(p);
479
+ return [
480
+ Math.floor((positionCommon[0] - cellOriginCommon[0]) / cellSizeCommon[0]),
481
+ Math.floor((positionCommon[1] - cellOriginCommon[1]) / cellSizeCommon[1])
482
+ ];
483
+ }
484
+ });
485
+ }
486
+
487
+ this.setState({cellSizeCommon, cellOriginCommon, binIdRange, aggregatorViewport: viewport});
488
+ }
489
+
490
+ override draw(opts) {
491
+ // Replaces render time viewport with our own
492
+ if (opts.shaderModuleProps.project) {
493
+ opts.shaderModuleProps.project.viewport = this.state.aggregatorViewport;
94
494
  }
95
- if (!GPUGridAggregator.isSupported(this.context.device)) {
96
- return false;
495
+ super.draw(opts);
496
+ }
497
+
498
+ private _onAggregationUpdate({channel}: {channel: number}) {
499
+ const props = this.getCurrentLayer()!.props;
500
+ const {aggregator} = this.state;
501
+ if (channel === 0) {
502
+ const result = aggregator.getResult(0)!;
503
+ this.setState({
504
+ colors: new AttributeWithScale(result, aggregator.binCount)
505
+ });
506
+ props.onSetColorDomain(aggregator.getResultDomain(0));
507
+ } else if (channel === 1) {
508
+ const result = aggregator.getResult(1)!;
509
+ this.setState({
510
+ elevations: new AttributeWithScale(result, aggregator.binCount)
511
+ });
512
+ props.onSetElevationDomain(aggregator.getResultDomain(1));
97
513
  }
98
- if (lowerPercentile !== 0 || upperPercentile !== 100) {
99
- // percentile calculations requires sorting not supported on GPU
100
- return false;
514
+ }
515
+
516
+ onAttributeChange(id: string) {
517
+ const {aggregator} = this.state;
518
+ switch (id) {
519
+ case 'positions':
520
+ aggregator.setNeedsUpdate();
521
+
522
+ this._updateBinOptions();
523
+ const {cellSizeCommon, cellOriginCommon, binIdRange} = this.state;
524
+ aggregator.setProps({
525
+ // @ts-expect-error only used by GPUAggregator
526
+ binIdRange,
527
+ binOptions: {
528
+ cellSizeCommon,
529
+ cellOriginCommon
530
+ }
531
+ });
532
+ break;
533
+
534
+ case 'colorWeights':
535
+ aggregator.setNeedsUpdate(0);
536
+ break;
537
+
538
+ case 'elevationWeights':
539
+ aggregator.setNeedsUpdate(1);
540
+ break;
541
+
542
+ default:
543
+ // This should not happen
101
544
  }
102
- if (getColorValue !== null || getElevationValue !== null) {
103
- // accessor for custom color or elevation calculation is specified
104
- return false;
545
+ }
546
+
547
+ renderLayers(): LayersList | Layer | null {
548
+ const {aggregator, cellOriginCommon, cellSizeCommon} = this.state;
549
+ const {
550
+ elevationScale,
551
+ colorRange,
552
+ elevationRange,
553
+ extruded,
554
+ coverage,
555
+ material,
556
+ transitions,
557
+ colorScaleType,
558
+ lowerPercentile,
559
+ upperPercentile,
560
+ colorDomain,
561
+ elevationScaleType,
562
+ elevationLowerPercentile,
563
+ elevationUpperPercentile,
564
+ elevationDomain
565
+ } = this.props;
566
+ const CellLayerClass = this.getSubLayerClass('cells', GridCellLayer);
567
+ const binAttribute = aggregator.getBins();
568
+
569
+ const colors = this.state.colors?.update({
570
+ scaleType: colorScaleType,
571
+ lowerPercentile,
572
+ upperPercentile
573
+ });
574
+ const elevations = this.state.elevations?.update({
575
+ scaleType: elevationScaleType,
576
+ lowerPercentile: elevationLowerPercentile,
577
+ upperPercentile: elevationUpperPercentile
578
+ });
579
+
580
+ if (!colors || !elevations) {
581
+ return null;
105
582
  }
106
- if (colorScaleType === 'quantile' || colorScaleType === 'ordinal') {
107
- // quantile and ordinal scales are not supported on GPU
108
- return false;
583
+
584
+ return new CellLayerClass(
585
+ this.getSubLayerProps({
586
+ id: 'cells'
587
+ }),
588
+ {
589
+ data: {
590
+ length: aggregator.binCount,
591
+ attributes: {
592
+ getBin: binAttribute,
593
+ getColorValue: colors.attribute,
594
+ getElevationValue: elevations.attribute
595
+ }
596
+ },
597
+ // Data has changed shallowly, but we likely don't need to update the attributes
598
+ dataComparator: (data, oldData) => data.length === oldData.length,
599
+ updateTriggers: {
600
+ getBin: [binAttribute],
601
+ getColorValue: [colors.attribute],
602
+ getElevationValue: [elevations.attribute]
603
+ },
604
+ cellOriginCommon,
605
+ cellSizeCommon,
606
+ elevationScale,
607
+ colorRange,
608
+ colorScaleType,
609
+ elevationRange,
610
+ extruded,
611
+ coverage,
612
+ material,
613
+ colorDomain: colors.domain || colorDomain || aggregator.getResultDomain(0),
614
+ elevationDomain: elevations.domain || elevationDomain || aggregator.getResultDomain(1),
615
+ colorCutoff: colors.cutoff,
616
+ elevationCutoff: elevations.cutoff,
617
+ transitions: transitions && {
618
+ getFillColor: transitions.getColorValue || transitions.getColorWeight,
619
+ getElevation: transitions.getElevationValue || transitions.getElevationWeight
620
+ },
621
+ // Extensions are already handled by the GPUAggregator, do not pass it down
622
+ extensions: []
623
+ }
624
+ );
625
+ }
626
+
627
+ getPickingInfo(params: GetPickingInfoParams): GridLayerPickingInfo<DataT> {
628
+ const info: GridLayerPickingInfo<DataT> = params.info;
629
+ const {index} = info;
630
+ if (index >= 0) {
631
+ const bin = this.state.aggregator.getBin(index);
632
+ let object: GridLayerPickingInfo<DataT>['object'];
633
+ if (bin) {
634
+ object = {
635
+ col: bin.id[0],
636
+ row: bin.id[1],
637
+ colorValue: bin.value[0],
638
+ elevationValue: bin.value[1],
639
+ count: bin.count
640
+ };
641
+ if (bin.pointIndices) {
642
+ object.pointIndices = bin.pointIndices;
643
+ object.points = Array.isArray(this.props.data)
644
+ ? bin.pointIndices.map(i => (this.props.data as DataT[])[i])
645
+ : [];
646
+ }
647
+ }
648
+ info.object = object;
109
649
  }
110
- return true;
650
+
651
+ return info;
111
652
  }
112
653
  }