@deck.gl/aggregation-layers 9.0.35 → 9.1.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 (318) 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 +69 -0
  4. package/dist/common/aggregator/aggregator.d.ts +76 -0
  5. package/dist/common/aggregator/aggregator.d.ts.map +1 -0
  6. package/dist/common/aggregator/aggregator.js +4 -0
  7. package/dist/common/aggregator/cpu-aggregator/aggregate.d.ts +27 -0
  8. package/dist/common/aggregator/cpu-aggregator/aggregate.d.ts.map +1 -0
  9. package/dist/common/aggregator/cpu-aggregator/aggregate.js +66 -0
  10. package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.d.ts +70 -0
  11. package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.d.ts.map +1 -0
  12. package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.js +139 -0
  13. package/dist/common/aggregator/cpu-aggregator/sort-bins.d.ts +15 -0
  14. package/dist/common/aggregator/cpu-aggregator/sort-bins.d.ts.map +1 -0
  15. package/dist/common/aggregator/cpu-aggregator/sort-bins.js +43 -0
  16. package/dist/common/aggregator/cpu-aggregator/vertex-accessor.d.ts +21 -0
  17. package/dist/common/aggregator/cpu-aggregator/vertex-accessor.d.ts.map +1 -0
  18. package/dist/common/aggregator/cpu-aggregator/vertex-accessor.js +55 -0
  19. package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.d.ts +18 -0
  20. package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.d.ts.map +1 -0
  21. package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.js +20 -0
  22. package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.d.ts +14 -0
  23. package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.d.ts.map +1 -0
  24. package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.js +17 -0
  25. package/dist/common/aggregator/gpu-aggregator/utils.d.ts +6 -0
  26. package/dist/common/aggregator/gpu-aggregator/utils.d.ts.map +1 -0
  27. package/dist/common/aggregator/gpu-aggregator/utils.js +24 -0
  28. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.d.ts +24 -0
  29. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.d.ts.map +1 -0
  30. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js +215 -0
  31. package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.d.ts +81 -0
  32. package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.d.ts.map +1 -0
  33. package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.js +201 -0
  34. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.d.ts +38 -0
  35. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.d.ts.map +1 -0
  36. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.js +223 -0
  37. package/dist/common/aggregator/index.d.ts +6 -0
  38. package/dist/common/aggregator/index.d.ts.map +1 -0
  39. package/dist/common/aggregator/index.js +5 -0
  40. package/dist/common/types.d.ts +11 -0
  41. package/dist/common/types.d.ts.map +1 -0
  42. package/dist/common/types.js +4 -0
  43. package/dist/common/utils/bounds-utils.d.ts +10 -0
  44. package/dist/common/utils/bounds-utils.d.ts.map +1 -0
  45. package/dist/common/utils/bounds-utils.js +20 -0
  46. package/dist/common/utils/color-utils.d.ts +10 -0
  47. package/dist/common/utils/color-utils.d.ts.map +1 -0
  48. package/dist/common/utils/color-utils.js +65 -0
  49. package/dist/common/utils/prop-utils.d.ts.map +1 -0
  50. package/dist/common/utils/prop-utils.js +12 -0
  51. package/dist/common/utils/scale-utils.d.ts +46 -0
  52. package/dist/common/utils/scale-utils.d.ts.map +1 -0
  53. package/dist/common/utils/scale-utils.js +180 -0
  54. package/dist/contour-layer/bin-options-uniforms.d.ts +13 -0
  55. package/dist/contour-layer/bin-options-uniforms.d.ts.map +1 -0
  56. package/dist/contour-layer/bin-options-uniforms.js +17 -0
  57. package/dist/contour-layer/contour-layer.d.ts +42 -50
  58. package/dist/contour-layer/contour-layer.d.ts.map +1 -1
  59. package/dist/contour-layer/contour-layer.js +232 -192
  60. package/dist/contour-layer/contour-utils.d.ts +36 -15
  61. package/dist/contour-layer/contour-utils.d.ts.map +1 -1
  62. package/dist/contour-layer/contour-utils.js +24 -29
  63. package/dist/contour-layer/marching-squares-codes.d.ts.map +1 -1
  64. package/dist/contour-layer/marching-squares-codes.js +3 -0
  65. package/dist/contour-layer/marching-squares.d.ts +22 -6
  66. package/dist/contour-layer/marching-squares.d.ts.map +1 -1
  67. package/dist/contour-layer/marching-squares.js +71 -68
  68. package/dist/contour-layer/value-reader.d.ts +10 -0
  69. package/dist/contour-layer/value-reader.d.ts.map +1 -0
  70. package/dist/contour-layer/value-reader.js +46 -0
  71. package/dist/dist.dev.js +4842 -4081
  72. package/dist/grid-layer/bin-options-uniforms.d.ts +13 -0
  73. package/dist/grid-layer/bin-options-uniforms.d.ts.map +1 -0
  74. package/dist/grid-layer/bin-options-uniforms.js +17 -0
  75. package/dist/grid-layer/grid-cell-layer-vertex.glsl.d.ts +3 -0
  76. package/dist/grid-layer/grid-cell-layer-vertex.glsl.d.ts.map +1 -0
  77. package/dist/grid-layer/grid-cell-layer-vertex.glsl.js +51 -0
  78. package/dist/grid-layer/grid-cell-layer.d.ts +32 -0
  79. package/dist/grid-layer/grid-cell-layer.d.ts.map +1 -0
  80. package/dist/grid-layer/grid-cell-layer.js +93 -0
  81. package/dist/grid-layer/grid-layer-uniforms.d.ts +21 -0
  82. package/dist/grid-layer/grid-layer-uniforms.d.ts.map +1 -0
  83. package/dist/grid-layer/grid-layer-uniforms.js +23 -0
  84. package/dist/grid-layer/grid-layer.d.ts +175 -13
  85. package/dist/grid-layer/grid-layer.d.ts.map +1 -1
  86. package/dist/grid-layer/grid-layer.js +342 -46
  87. package/dist/{aggregation-layer.d.ts → heatmap-layer/aggregation-layer.d.ts} +1 -0
  88. package/dist/heatmap-layer/aggregation-layer.d.ts.map +1 -0
  89. package/dist/{aggregation-layer.js → heatmap-layer/aggregation-layer.js} +6 -21
  90. package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts +30 -0
  91. package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts.map +1 -0
  92. package/dist/heatmap-layer/heatmap-layer-uniforms.js +32 -0
  93. package/dist/heatmap-layer/heatmap-layer-utils.d.ts +1 -1
  94. package/dist/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -1
  95. package/dist/heatmap-layer/heatmap-layer-utils.js +3 -0
  96. package/dist/heatmap-layer/heatmap-layer.d.ts +6 -4
  97. package/dist/heatmap-layer/heatmap-layer.d.ts.map +1 -1
  98. package/dist/heatmap-layer/heatmap-layer.js +43 -33
  99. package/dist/heatmap-layer/max-fs.glsl.d.ts.map +1 -1
  100. package/dist/heatmap-layer/max-fs.glsl.js +3 -0
  101. package/dist/heatmap-layer/max-vs.glsl.d.ts +1 -1
  102. package/dist/heatmap-layer/max-vs.glsl.d.ts.map +1 -1
  103. package/dist/heatmap-layer/max-vs.glsl.js +6 -4
  104. package/dist/heatmap-layer/triangle-layer-fragment.glsl.d.ts +1 -1
  105. package/dist/heatmap-layer/triangle-layer-fragment.glsl.d.ts.map +1 -1
  106. package/dist/heatmap-layer/triangle-layer-fragment.glsl.js +5 -23
  107. package/dist/heatmap-layer/triangle-layer-uniforms.d.ts +22 -0
  108. package/dist/heatmap-layer/triangle-layer-uniforms.d.ts.map +1 -0
  109. package/dist/heatmap-layer/triangle-layer-uniforms.js +22 -0
  110. package/dist/heatmap-layer/triangle-layer-vertex.glsl.d.ts +1 -1
  111. package/dist/heatmap-layer/triangle-layer-vertex.glsl.d.ts.map +1 -1
  112. package/dist/heatmap-layer/triangle-layer-vertex.glsl.js +10 -30
  113. package/dist/heatmap-layer/triangle-layer.d.ts +4 -10
  114. package/dist/heatmap-layer/triangle-layer.d.ts.map +1 -1
  115. package/dist/heatmap-layer/triangle-layer.js +17 -30
  116. package/dist/heatmap-layer/weights-fs.glsl.d.ts.map +1 -1
  117. package/dist/heatmap-layer/weights-fs.glsl.js +3 -0
  118. package/dist/heatmap-layer/weights-vs.glsl.d.ts +1 -1
  119. package/dist/heatmap-layer/weights-vs.glsl.d.ts.map +1 -1
  120. package/dist/heatmap-layer/weights-vs.glsl.js +6 -7
  121. package/dist/hexagon-layer/bin-options-uniforms.d.ts +14 -0
  122. package/dist/hexagon-layer/bin-options-uniforms.d.ts.map +1 -0
  123. package/dist/hexagon-layer/bin-options-uniforms.js +17 -0
  124. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.d.ts +3 -0
  125. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.d.ts.map +1 -0
  126. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.js +55 -0
  127. package/dist/hexagon-layer/hexagon-cell-layer.d.ts +29 -0
  128. package/dist/hexagon-layer/hexagon-cell-layer.d.ts.map +1 -0
  129. package/dist/hexagon-layer/hexagon-cell-layer.js +94 -0
  130. package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts +19 -0
  131. package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts.map +1 -0
  132. package/dist/hexagon-layer/hexagon-layer-uniforms.js +21 -0
  133. package/dist/hexagon-layer/hexagon-layer.d.ts +84 -54
  134. package/dist/hexagon-layer/hexagon-layer.d.ts.map +1 -1
  135. package/dist/hexagon-layer/hexagon-layer.js +307 -123
  136. package/dist/hexagon-layer/hexbin.d.ts +17 -0
  137. package/dist/hexagon-layer/hexbin.d.ts.map +1 -0
  138. package/dist/hexagon-layer/hexbin.js +69 -0
  139. package/dist/index.cjs +3025 -2946
  140. package/dist/index.cjs.map +4 -4
  141. package/dist/index.d.ts +7 -13
  142. package/dist/index.d.ts.map +1 -1
  143. package/dist/index.js +5 -27
  144. package/dist/screen-grid-layer/bin-options-uniforms.d.ts +11 -0
  145. package/dist/screen-grid-layer/bin-options-uniforms.d.ts.map +1 -0
  146. package/dist/screen-grid-layer/bin-options-uniforms.js +15 -0
  147. package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts +11 -16
  148. package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -1
  149. package/dist/screen-grid-layer/screen-grid-cell-layer.js +52 -134
  150. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts +1 -1
  151. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts.map +1 -1
  152. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.js +4 -24
  153. package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts +17 -0
  154. package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts.map +1 -0
  155. package/dist/screen-grid-layer/screen-grid-layer-uniforms.js +19 -0
  156. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts +1 -1
  157. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts.map +1 -1
  158. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.js +21 -62
  159. package/dist/screen-grid-layer/screen-grid-layer.d.ts +33 -40
  160. package/dist/screen-grid-layer/screen-grid-layer.d.ts.map +1 -1
  161. package/dist/screen-grid-layer/screen-grid-layer.js +157 -174
  162. package/dist.min.js +401 -382
  163. package/package.json +10 -9
  164. package/src/common/aggregation-layer.ts +107 -0
  165. package/src/common/aggregator/aggregator.ts +88 -0
  166. package/src/common/aggregator/cpu-aggregator/aggregate.ts +101 -0
  167. package/src/common/aggregator/cpu-aggregator/cpu-aggregator.ts +203 -0
  168. package/src/common/aggregator/cpu-aggregator/sort-bins.ts +63 -0
  169. package/src/common/aggregator/cpu-aggregator/vertex-accessor.ts +86 -0
  170. package/src/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.ts +33 -0
  171. package/src/common/aggregator/gpu-aggregator/bin-sorter-uniforms.ts +27 -0
  172. package/src/common/aggregator/gpu-aggregator/utils.ts +27 -0
  173. package/src/common/aggregator/gpu-aggregator/webgl-aggregation-transform.ts +247 -0
  174. package/src/common/aggregator/gpu-aggregator/webgl-aggregator.ts +274 -0
  175. package/src/common/aggregator/gpu-aggregator/webgl-bin-sorter.ts +258 -0
  176. package/src/common/aggregator/index.ts +10 -0
  177. package/src/{types.ts → common/types.ts} +10 -4
  178. package/src/common/utils/bounds-utils.ts +34 -0
  179. package/src/common/utils/color-utils.ts +86 -0
  180. package/src/common/utils/prop-utils.ts +13 -0
  181. package/src/common/utils/scale-utils.ts +236 -0
  182. package/src/contour-layer/bin-options-uniforms.ts +26 -0
  183. package/src/contour-layer/contour-layer.ts +300 -265
  184. package/src/contour-layer/contour-utils.ts +68 -39
  185. package/src/contour-layer/marching-squares-codes.ts +4 -0
  186. package/src/contour-layer/marching-squares.ts +93 -82
  187. package/src/contour-layer/value-reader.ts +65 -0
  188. package/src/grid-layer/bin-options-uniforms.ts +26 -0
  189. package/src/grid-layer/grid-cell-layer-vertex.glsl.ts +68 -0
  190. package/src/grid-layer/grid-cell-layer.ts +141 -0
  191. package/src/grid-layer/grid-layer-uniforms.ts +37 -0
  192. package/src/grid-layer/grid-layer.ts +614 -73
  193. package/src/{aggregation-layer.ts → heatmap-layer/aggregation-layer.ts} +6 -21
  194. package/src/heatmap-layer/heatmap-layer-uniforms.ts +50 -0
  195. package/src/heatmap-layer/heatmap-layer-utils.ts +9 -1
  196. package/src/heatmap-layer/heatmap-layer.ts +59 -36
  197. package/src/heatmap-layer/max-fs.glsl.ts +4 -0
  198. package/src/heatmap-layer/max-vs.glsl.ts +7 -4
  199. package/src/heatmap-layer/triangle-layer-fragment.glsl.ts +5 -23
  200. package/src/heatmap-layer/triangle-layer-uniforms.ts +37 -0
  201. package/src/heatmap-layer/triangle-layer-vertex.glsl.ts +10 -30
  202. package/src/heatmap-layer/triangle-layer.ts +26 -31
  203. package/src/heatmap-layer/weights-fs.glsl.ts +4 -0
  204. package/src/heatmap-layer/weights-vs.glsl.ts +7 -7
  205. package/src/hexagon-layer/bin-options-uniforms.ts +27 -0
  206. package/src/hexagon-layer/hexagon-cell-layer-vertex.glsl.ts +73 -0
  207. package/src/hexagon-layer/hexagon-cell-layer.ts +141 -0
  208. package/src/hexagon-layer/hexagon-layer-uniforms.ts +34 -0
  209. package/src/hexagon-layer/hexagon-layer.ts +454 -186
  210. package/src/hexagon-layer/hexbin.ts +79 -0
  211. package/src/index.ts +21 -34
  212. package/src/screen-grid-layer/bin-options-uniforms.ts +23 -0
  213. package/src/screen-grid-layer/screen-grid-cell-layer.ts +71 -156
  214. package/src/screen-grid-layer/screen-grid-layer-fragment.glsl.ts +4 -24
  215. package/src/screen-grid-layer/screen-grid-layer-uniforms.ts +31 -0
  216. package/src/screen-grid-layer/screen-grid-layer-vertex.glsl.ts +21 -64
  217. package/src/screen-grid-layer/screen-grid-layer.ts +194 -222
  218. package/dist/aggregation-layer.d.ts.map +0 -1
  219. package/dist/cpu-grid-layer/cpu-grid-layer.d.ts +0 -158
  220. package/dist/cpu-grid-layer/cpu-grid-layer.d.ts.map +0 -1
  221. package/dist/cpu-grid-layer/cpu-grid-layer.js +0 -130
  222. package/dist/cpu-grid-layer/grid-aggregator.d.ts +0 -35
  223. package/dist/cpu-grid-layer/grid-aggregator.d.ts.map +0 -1
  224. package/dist/cpu-grid-layer/grid-aggregator.js +0 -141
  225. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts +0 -3
  226. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts.map +0 -1
  227. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -30
  228. package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts +0 -3
  229. package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts.map +0 -1
  230. package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +0 -112
  231. package/dist/gpu-grid-layer/gpu-grid-cell-layer.d.ts +0 -48
  232. package/dist/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +0 -1
  233. package/dist/gpu-grid-layer/gpu-grid-cell-layer.js +0 -146
  234. package/dist/gpu-grid-layer/gpu-grid-layer.d.ts +0 -99
  235. package/dist/gpu-grid-layer/gpu-grid-layer.d.ts.map +0 -1
  236. package/dist/gpu-grid-layer/gpu-grid-layer.js +0 -289
  237. package/dist/grid-aggregation-layer.d.ts +0 -67
  238. package/dist/grid-aggregation-layer.d.ts.map +0 -1
  239. package/dist/grid-aggregation-layer.js +0 -173
  240. package/dist/hexagon-layer/hexagon-aggregator.d.ts +0 -27
  241. package/dist/hexagon-layer/hexagon-aggregator.d.ts.map +0 -1
  242. package/dist/hexagon-layer/hexagon-aggregator.js +0 -112
  243. package/dist/types.d.ts +0 -12
  244. package/dist/types.d.ts.map +0 -1
  245. package/dist/types.js +0 -1
  246. package/dist/utils/aggregation-operation-utils.d.ts +0 -19
  247. package/dist/utils/aggregation-operation-utils.d.ts.map +0 -1
  248. package/dist/utils/aggregation-operation-utils.js +0 -94
  249. package/dist/utils/bin-sorter.d.ts +0 -52
  250. package/dist/utils/bin-sorter.d.ts.map +0 -1
  251. package/dist/utils/bin-sorter.js +0 -167
  252. package/dist/utils/color-utils.d.ts +0 -3
  253. package/dist/utils/color-utils.d.ts.map +0 -1
  254. package/dist/utils/color-utils.js +0 -53
  255. package/dist/utils/cpu-aggregator.d.ts +0 -169
  256. package/dist/utils/cpu-aggregator.d.ts.map +0 -1
  257. package/dist/utils/cpu-aggregator.js +0 -421
  258. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts +0 -3
  259. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts.map +0 -1
  260. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -36
  261. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts +0 -3
  262. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts.map +0 -1
  263. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -42
  264. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts +0 -3
  265. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts.map +0 -1
  266. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -30
  267. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts +0 -3
  268. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts.map +0 -1
  269. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +0 -61
  270. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts +0 -38
  271. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts.map +0 -1
  272. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -41
  273. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts +0 -1
  274. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts.map +0 -1
  275. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -1
  276. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts +0 -76
  277. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts.map +0 -1
  278. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -555
  279. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts +0 -3
  280. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts.map +0 -1
  281. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -32
  282. package/dist/utils/grid-aggregation-utils.d.ts +0 -30
  283. package/dist/utils/grid-aggregation-utils.d.ts.map +0 -1
  284. package/dist/utils/grid-aggregation-utils.js +0 -114
  285. package/dist/utils/prop-utils.d.ts.map +0 -1
  286. package/dist/utils/prop-utils.js +0 -28
  287. package/dist/utils/resource-utils.d.ts +0 -14
  288. package/dist/utils/resource-utils.d.ts.map +0 -1
  289. package/dist/utils/resource-utils.js +0 -38
  290. package/dist/utils/scale-utils.d.ts +0 -15
  291. package/dist/utils/scale-utils.d.ts.map +0 -1
  292. package/dist/utils/scale-utils.js +0 -184
  293. package/src/cpu-grid-layer/cpu-grid-layer.ts +0 -329
  294. package/src/cpu-grid-layer/grid-aggregator.ts +0 -184
  295. package/src/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.ts +0 -35
  296. package/src/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.ts +0 -143
  297. package/src/gpu-grid-layer/gpu-grid-cell-layer.ts +0 -201
  298. package/src/gpu-grid-layer/gpu-grid-layer.ts +0 -455
  299. package/src/grid-aggregation-layer.ts +0 -243
  300. package/src/hexagon-layer/hexagon-aggregator.ts +0 -127
  301. package/src/utils/aggregation-operation-utils.ts +0 -118
  302. package/src/utils/bin-sorter.ts +0 -218
  303. package/src/utils/color-utils.ts +0 -57
  304. package/src/utils/cpu-aggregator.ts +0 -503
  305. package/src/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.ts +0 -40
  306. package/src/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.ts +0 -54
  307. package/src/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.ts +0 -35
  308. package/src/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.ts +0 -79
  309. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.ts +0 -46
  310. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.ts +0 -0
  311. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +0 -155
  312. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.ts +0 -690
  313. package/src/utils/gpu-grid-aggregation/transform-mean-vs.glsl.ts +0 -38
  314. package/src/utils/grid-aggregation-utils.ts +0 -147
  315. package/src/utils/prop-utils.ts +0 -29
  316. package/src/utils/resource-utils.ts +0 -53
  317. package/src/utils/scale-utils.js +0 -219
  318. /package/dist/{utils → common/utils}/prop-utils.d.ts +0 -0
@@ -0,0 +1,38 @@
1
+ import { Model, ModelProps } from '@luma.gl/engine';
2
+ import type { Device, Texture } from '@luma.gl/core';
3
+ import type { WebGLAggregatorProps } from "./webgl-aggregator.js";
4
+ import type { AggregationOperation } from "../aggregator.js";
5
+ export declare const TEXTURE_WIDTH = 1024;
6
+ /**
7
+ * This class manages the resources for performing the first step of aggregation
8
+ * Sort a list of data points into a number of bins
9
+ */
10
+ export declare class WebGLBinSorter {
11
+ device: Device;
12
+ model: Model;
13
+ /**
14
+ * A packed texture in which each pixel represents a bin.
15
+ * The index of the pixel in the memory layout is the bin index.
16
+ * Alpha value is the count of data points that fall into this bin
17
+ * R,G,B values are the aggregated values of each channel:
18
+ * - Sum of all data points if operation is 'SUM', or 'MEAN'
19
+ * - Min of all data points if operation is 'MIN'
20
+ * - Max of all data points if operation is 'MAX'
21
+ */
22
+ private binsFBO;
23
+ constructor(device: Device, props: WebGLAggregatorProps);
24
+ get texture(): Texture | null;
25
+ destroy(): void;
26
+ getBinValues(index: number): Float32Array | null;
27
+ setDimensions(binCount: number, binIdRange: [number, number][]): void;
28
+ setModelProps(props: Pick<ModelProps, 'vertexCount' | 'uniforms' | 'attributes' | 'constantAttributes'> & {
29
+ shaderModuleProps?: Record<string, any>;
30
+ }): void;
31
+ /** Update aggregation */
32
+ update(
33
+ /** The aggregation operation for each channel. Use null to skip update. */
34
+ operations: (AggregationOperation | null)[]): void;
35
+ /** Recalculate aggregation on the given channels using the given operation */
36
+ private _updateBins;
37
+ }
38
+ //# sourceMappingURL=webgl-bin-sorter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webgl-bin-sorter.d.ts","sourceRoot":"","sources":["../../../../src/common/aggregator/gpu-aggregator/webgl-bin-sorter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,EAAE,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAGlD,OAAO,KAAK,EAAC,MAAM,EAAe,OAAO,EAAC,MAAM,eAAe,CAAC;AAChE,OAAO,KAAK,EAAC,oBAAoB,EAAC,8BAA2B;AAC7D,OAAO,KAAK,EAAC,oBAAoB,EAAC,yBAAsB;AAOxD,eAAO,MAAM,aAAa,OAAO,CAAC;AAElC;;;GAGG;AACH,qBAAa,cAAc;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;IAEb;;;;;;;;OAQG;IACH,OAAO,CAAC,OAAO,CAA4B;gBAE/B,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB;IAKvD,IAAI,OAAO,IAAI,OAAO,GAAG,IAAI,CAE5B;IAED,OAAO;IAMP,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAehD,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;IAuB9D,aAAa,CACX,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,aAAa,GAAG,UAAU,GAAG,YAAY,GAAG,oBAAoB,CAAC,GAAG;QAC1F,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KACzC;IAiBH,yBAAyB;IACzB,MAAM;IACJ,2EAA2E;IAC3E,UAAU,EAAE,CAAC,oBAAoB,GAAG,IAAI,CAAC,EAAE;IAW7C,8EAA8E;IAC9E,OAAO,CAAC,WAAW;CAqCpB"}
@@ -0,0 +1,223 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ import { Model } from '@luma.gl/engine';
5
+ import { createRenderTarget } from "./utils.js";
6
+ import { binSorterUniforms } from "./bin-sorter-uniforms.js";
7
+ const COLOR_CHANNELS = [0x1, 0x2, 0x4, 0x8]; // GPU color mask RED, GREEN, BLUE, ALPHA
8
+ const MAX_FLOAT32 = 3e38;
9
+ const EMPTY_MASKS = { SUM: 0, MEAN: 0, MIN: 0, MAX: 0, COUNT: 0 };
10
+ export const TEXTURE_WIDTH = 1024;
11
+ /**
12
+ * This class manages the resources for performing the first step of aggregation
13
+ * Sort a list of data points into a number of bins
14
+ */
15
+ export class WebGLBinSorter {
16
+ constructor(device, props) {
17
+ /**
18
+ * A packed texture in which each pixel represents a bin.
19
+ * The index of the pixel in the memory layout is the bin index.
20
+ * Alpha value is the count of data points that fall into this bin
21
+ * R,G,B values are the aggregated values of each channel:
22
+ * - Sum of all data points if operation is 'SUM', or 'MEAN'
23
+ * - Min of all data points if operation is 'MIN'
24
+ * - Max of all data points if operation is 'MAX'
25
+ */
26
+ this.binsFBO = null;
27
+ this.device = device;
28
+ this.model = createModel(device, props);
29
+ }
30
+ get texture() {
31
+ return this.binsFBO ? this.binsFBO.colorAttachments[0].texture : null;
32
+ }
33
+ destroy() {
34
+ this.model.destroy();
35
+ this.binsFBO?.colorAttachments[0].texture.destroy();
36
+ this.binsFBO?.destroy();
37
+ }
38
+ getBinValues(index) {
39
+ if (!this.binsFBO) {
40
+ return null;
41
+ }
42
+ const x = index % TEXTURE_WIDTH;
43
+ const y = Math.floor(index / TEXTURE_WIDTH);
44
+ const buffer = this.device.readPixelsToArrayWebGL(this.binsFBO, {
45
+ sourceX: x,
46
+ sourceY: y,
47
+ sourceWidth: 1,
48
+ sourceHeight: 1
49
+ }).buffer;
50
+ return new Float32Array(buffer);
51
+ }
52
+ setDimensions(binCount, binIdRange) {
53
+ const width = TEXTURE_WIDTH;
54
+ const height = Math.ceil(binCount / width);
55
+ // Only destroy existing texture if it is not large enough
56
+ if (!this.binsFBO) {
57
+ this.binsFBO = createRenderTarget(this.device, width, height);
58
+ }
59
+ else if (this.binsFBO.height < height) {
60
+ this.binsFBO.resize({ width, height });
61
+ }
62
+ const binSorterProps = {
63
+ binIdRange: [
64
+ binIdRange[0][0],
65
+ binIdRange[0][1],
66
+ binIdRange[1]?.[0] || 0,
67
+ binIdRange[1]?.[1] || 0
68
+ ],
69
+ targetSize: [this.binsFBO.width, this.binsFBO.height]
70
+ };
71
+ this.model.shaderInputs.setProps({ binSorter: binSorterProps });
72
+ }
73
+ setModelProps(props) {
74
+ const model = this.model;
75
+ if (props.attributes) {
76
+ model.setAttributes(props.attributes);
77
+ }
78
+ if (props.constantAttributes) {
79
+ model.setConstantAttributes(props.constantAttributes);
80
+ }
81
+ if (props.vertexCount !== undefined) {
82
+ model.setVertexCount(props.vertexCount);
83
+ }
84
+ if (props.shaderModuleProps) {
85
+ model.shaderInputs.setProps(props.shaderModuleProps);
86
+ }
87
+ }
88
+ /** Update aggregation */
89
+ update(
90
+ /** The aggregation operation for each channel. Use null to skip update. */
91
+ operations) {
92
+ if (!this.binsFBO) {
93
+ return;
94
+ }
95
+ const masks = getMaskByOperation(operations);
96
+ this._updateBins('SUM', masks.SUM + masks.MEAN);
97
+ this._updateBins('MIN', masks.MIN);
98
+ this._updateBins('MAX', masks.MAX);
99
+ }
100
+ /** Recalculate aggregation on the given channels using the given operation */
101
+ _updateBins(operation,
102
+ /** GPU bit mask of one or more channels that should be updated */
103
+ colorMask) {
104
+ if (colorMask === 0) {
105
+ return;
106
+ }
107
+ colorMask |= COLOR_CHANNELS[3]; // Also renders to the alpha channel (point count)
108
+ const model = this.model;
109
+ const target = this.binsFBO;
110
+ const initialValue = operation === 'MAX' ? -MAX_FLOAT32 : operation === 'MIN' ? MAX_FLOAT32 : 0;
111
+ const renderPass = this.device.beginRenderPass({
112
+ id: `gpu-aggregation-${operation}`,
113
+ framebuffer: target,
114
+ parameters: {
115
+ viewport: [0, 0, target.width, target.height],
116
+ colorMask
117
+ },
118
+ clearColor: [initialValue, initialValue, initialValue, 0],
119
+ clearDepth: false,
120
+ clearStencil: false
121
+ });
122
+ model.setParameters({
123
+ blend: true,
124
+ blendColorSrcFactor: 'one',
125
+ blendColorDstFactor: 'one',
126
+ blendAlphaSrcFactor: 'one',
127
+ blendAlphaDstFactor: 'one',
128
+ blendColorOperation: operation === 'MAX' ? 'max' : operation === 'MIN' ? 'min' : 'add',
129
+ blendAlphaOperation: 'add'
130
+ });
131
+ model.draw(renderPass);
132
+ renderPass.end();
133
+ }
134
+ }
135
+ /** Convert a [channel -> operation] map to a [operation -> GPU color mask] map */
136
+ function getMaskByOperation(operations) {
137
+ const result = { ...EMPTY_MASKS };
138
+ for (let channel = 0; channel < operations.length; channel++) {
139
+ const op = operations[channel];
140
+ if (op) {
141
+ result[op] += COLOR_CHANNELS[channel];
142
+ }
143
+ }
144
+ return result;
145
+ }
146
+ function createModel(device, props) {
147
+ let userVs = props.vs;
148
+ if (props.dimensions === 2) {
149
+ // If user provides 2d bin IDs, convert them to 1d indices for data packing
150
+ userVs += /* glsl */ `
151
+ void getBin(out int binId) {
152
+ ivec2 binId2;
153
+ getBin(binId2);
154
+ if (binId2.x < binSorter.binIdRange.x || binId2.x >= binSorter.binIdRange.y) {
155
+ binId = -1;
156
+ } else {
157
+ binId = (binId2.y - binSorter.binIdRange.z) * (binSorter.binIdRange.y - binSorter.binIdRange.x) + binId2.x;
158
+ }
159
+ }
160
+ `;
161
+ }
162
+ const vs = `\
163
+ #version 300 es
164
+ #define SHADER_NAME gpu-aggregation-sort-bins-vertex
165
+
166
+ ${userVs}
167
+
168
+ out vec3 v_Value;
169
+
170
+ void main() {
171
+ int binIndex;
172
+ getBin(binIndex);
173
+ binIndex = binIndex - binSorter.binIdRange.x;
174
+ if (binIndex < 0) {
175
+ gl_Position = vec4(0.);
176
+ return;
177
+ }
178
+ int row = binIndex / binSorter.targetSize.x;
179
+ int col = binIndex - row * binSorter.targetSize.x;
180
+ vec2 position = (vec2(col, row) + 0.5) / vec2(binSorter.targetSize) * 2.0 - 1.0;
181
+ gl_Position = vec4(position, 0.0, 1.0);
182
+ gl_PointSize = 1.0;
183
+
184
+ #if NUM_CHANNELS == 3
185
+ getValue(v_Value);
186
+ #elif NUM_CHANNELS == 2
187
+ getValue(v_Value.xy);
188
+ #else
189
+ getValue(v_Value.x);
190
+ #endif
191
+ }
192
+ `;
193
+ const fs = /* glsl */ `\
194
+ #version 300 es
195
+ #define SHADER_NAME gpu-aggregation-sort-bins-fragment
196
+
197
+ precision highp float;
198
+
199
+ in vec3 v_Value;
200
+ out vec4 fragColor;
201
+
202
+ void main() {
203
+ fragColor.xyz = v_Value;
204
+
205
+ #ifdef MODULE_GEOMETRY
206
+ geometry.uv = vec2(0.);
207
+ DECKGL_FILTER_COLOR(fragColor, geometry);
208
+ #endif
209
+
210
+ fragColor.w = 1.0;
211
+ }
212
+ `;
213
+ const model = new Model(device, {
214
+ bufferLayout: props.bufferLayout,
215
+ modules: [...(props.modules || []), binSorterUniforms],
216
+ defines: { ...props.defines, NON_INSTANCED_MODEL: 1, NUM_CHANNELS: props.channelCount },
217
+ isInstanced: false,
218
+ vs,
219
+ fs,
220
+ topology: 'point-list'
221
+ });
222
+ return model;
223
+ }
@@ -0,0 +1,6 @@
1
+ export { CPUAggregator } from "./cpu-aggregator/cpu-aggregator.js";
2
+ export { WebGLAggregator } from "./gpu-aggregator/webgl-aggregator.js";
3
+ export type { Aggregator, AggregatedBin, AggregationOperation, AggregationProps } from "./aggregator.js";
4
+ export type { CPUAggregatorProps } from "./cpu-aggregator/cpu-aggregator.js";
5
+ export type { WebGLAggregatorProps } from "./gpu-aggregator/webgl-aggregator.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/aggregator/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,aAAa,EAAC,2CAAwC;AAC9D,OAAO,EAAC,eAAe,EAAC,6CAA0C;AAElE,YAAY,EAAC,UAAU,EAAE,aAAa,EAAE,oBAAoB,EAAE,gBAAgB,EAAC,wBAAqB;AACpG,YAAY,EAAC,kBAAkB,EAAC,2CAAwC;AACxE,YAAY,EAAC,oBAAoB,EAAC,6CAA0C"}
@@ -0,0 +1,5 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ export { CPUAggregator } from "./cpu-aggregator/cpu-aggregator.js";
5
+ export { WebGLAggregator } from "./gpu-aggregator/webgl-aggregator.js";
@@ -0,0 +1,11 @@
1
+ /** Type assigned to e.g. getColorValue/getElevationValue props in aggregation layers (e.g. CPUGridLayer, HexagonLayer)*/
2
+ export type AggregateAccessor<DataT = any> = (
3
+ /** a list of objects whose positions fall inside this cell. */
4
+ objects: DataT[], objectInfo: {
5
+ /** the indices of `objects` in the original data. */
6
+ indices: number[];
7
+ /** the value of the `data` prop */
8
+ data: any;
9
+ }) => number;
10
+ export type ScaleType = 'linear' | 'quantize' | 'quantile' | 'ordinal';
11
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"mappings":"AAIA,yHAAyH;AACzH,MAAM,MAAM,iBAAiB,CAAC,KAAK,GAAG,GAAG,IAAI;AAC3C,+DAA+D;AAC/D,OAAO,EAAE,KAAK,EAAE,EAChB,UAAU,EAAE;IACV,qDAAqD;IACrD,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,mCAAmC;IACnC,IAAI,EAAE,GAAG,CAAC;CACX,KACE,MAAM,CAAC;AAEZ,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC"}
@@ -0,0 +1,4 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ export {};
@@ -0,0 +1,10 @@
1
+ /** Utility to estimate binIdRange as expected by AggregatorProps */
2
+ export declare function getBinIdRange({ dataBounds, getBinId, padding }: {
3
+ /** Bounds of the input data */
4
+ dataBounds: [min: number[], max: number[]];
5
+ /** Given a data point, returns the bin id that it belongs to */
6
+ getBinId: (p: number[]) => number[];
7
+ /** Add a border around the result to avoid clipping */
8
+ padding?: number;
9
+ }): [number, number][];
10
+ //# sourceMappingURL=bounds-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bounds-utils.d.ts","sourceRoot":"","sources":["../../../src/common/utils/bounds-utils.ts"],"names":[],"mappings":"AAIA,oEAAoE;AACpE,wBAAgB,aAAa,CAAC,EAC5B,UAAU,EACV,QAAQ,EACR,OAAW,EACZ,EAAE;IACD,+BAA+B;IAC/B,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;IAC3C,gEAAgE;IAChE,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,CAAC;IACpC,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAiBrB"}
@@ -0,0 +1,20 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ /** Utility to estimate binIdRange as expected by AggregatorProps */
5
+ export function getBinIdRange({ dataBounds, getBinId, padding = 0 }) {
6
+ const corners = [
7
+ dataBounds[0],
8
+ dataBounds[1],
9
+ [dataBounds[0][0], dataBounds[1][1]],
10
+ [dataBounds[1][0], dataBounds[0][1]]
11
+ ].map(p => getBinId(p));
12
+ const minX = Math.min(...corners.map(p => p[0])) - padding;
13
+ const minY = Math.min(...corners.map(p => p[1])) - padding;
14
+ const maxX = Math.max(...corners.map(p => p[0])) + padding + 1;
15
+ const maxY = Math.max(...corners.map(p => p[1])) + padding + 1;
16
+ return [
17
+ [minX, maxX],
18
+ [minY, maxY]
19
+ ];
20
+ }
@@ -0,0 +1,10 @@
1
+ import type { Color } from '@deck.gl/core';
2
+ import type { Device, Texture } from '@luma.gl/core';
3
+ import type { NumericArray, TypedArray, TypedArrayConstructor } from '@math.gl/types';
4
+ import type { ScaleType } from "../types.js";
5
+ export declare const defaultColorRange: Color[];
6
+ export declare function colorRangeToFlatArray(colorRange: Color[] | NumericArray, normalize?: boolean, ArrayType?: TypedArrayConstructor): TypedArray;
7
+ export declare const COLOR_RANGE_FILTER: Record<ScaleType, 'linear' | 'nearest'>;
8
+ export declare function updateColorRangeTexture(texture: Texture, type: ScaleType): void;
9
+ export declare function createColorRangeTexture(device: Device, colorRange: Color[] | NumericArray, type?: ScaleType): Texture;
10
+ //# sourceMappingURL=color-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color-utils.d.ts","sourceRoot":"","sources":["../../../src/common/utils/color-utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAC,MAAM,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAC,YAAY,EAAE,UAAU,EAAE,qBAAqB,EAAC,MAAM,gBAAgB,CAAC;AACpF,OAAO,KAAK,EAAC,SAAS,EAAC,oBAAiB;AAExC,eAAO,MAAM,iBAAiB,EAAE,KAAK,EAOpC,CAAC;AAGF,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,KAAK,EAAE,GAAG,YAAY,EAClC,SAAS,UAAQ,EACjB,SAAS,GAAE,qBAAoC,GAC9C,UAAU,CA0BZ;AAED,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,SAAS,EAAE,QAAQ,GAAG,SAAS,CAK7D,CAAC;AAEX,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,QAKxE;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,KAAK,EAAE,GAAG,YAAY,EAClC,IAAI,GAAE,SAAoB,GACzB,OAAO,CAgBT"}
@@ -0,0 +1,65 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ export const defaultColorRange = [
5
+ [255, 255, 178],
6
+ [254, 217, 118],
7
+ [254, 178, 76],
8
+ [253, 141, 60],
9
+ [240, 59, 32],
10
+ [189, 0, 38]
11
+ ];
12
+ // Converts a colorRange array to a flat array with 4 components per color
13
+ export function colorRangeToFlatArray(colorRange, normalize = false, ArrayType = Float32Array) {
14
+ let flatArray;
15
+ if (Number.isFinite(colorRange[0])) {
16
+ // its already a flat array.
17
+ flatArray = new ArrayType(colorRange);
18
+ }
19
+ else {
20
+ // flatten it
21
+ flatArray = new ArrayType(colorRange.length * 4);
22
+ let index = 0;
23
+ for (let i = 0; i < colorRange.length; i++) {
24
+ const color = colorRange[i];
25
+ flatArray[index++] = color[0];
26
+ flatArray[index++] = color[1];
27
+ flatArray[index++] = color[2];
28
+ flatArray[index++] = Number.isFinite(color[3]) ? color[3] : 255;
29
+ }
30
+ }
31
+ if (normalize) {
32
+ for (let i = 0; i < flatArray.length; i++) {
33
+ flatArray[i] /= 255;
34
+ }
35
+ }
36
+ return flatArray;
37
+ }
38
+ export const COLOR_RANGE_FILTER = {
39
+ linear: 'linear',
40
+ quantile: 'nearest',
41
+ quantize: 'nearest',
42
+ ordinal: 'nearest'
43
+ };
44
+ export function updateColorRangeTexture(texture, type) {
45
+ texture.setSampler({
46
+ minFilter: COLOR_RANGE_FILTER[type],
47
+ magFilter: COLOR_RANGE_FILTER[type]
48
+ });
49
+ }
50
+ export function createColorRangeTexture(device, colorRange, type = 'linear') {
51
+ const colors = colorRangeToFlatArray(colorRange, false, Uint8Array);
52
+ return device.createTexture({
53
+ format: 'rgba8unorm',
54
+ mipmaps: false,
55
+ sampler: {
56
+ minFilter: COLOR_RANGE_FILTER[type],
57
+ magFilter: COLOR_RANGE_FILTER[type],
58
+ addressModeU: 'clamp-to-edge',
59
+ addressModeV: 'clamp-to-edge'
60
+ },
61
+ data: colors,
62
+ width: colors.length / 4,
63
+ height: 1
64
+ });
65
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prop-utils.d.ts","sourceRoot":"","sources":["../../../src/common/utils/prop-utils.ts"],"names":[],"mappings":"AAIA,wBAAgB,WAAW,CAAC,KAAK,KAAA,EAAE,UAAU,KAAA,MAQ5C"}
@@ -0,0 +1,12 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ export function filterProps(props, filterKeys) {
5
+ const filteredProps = {};
6
+ for (const key in props) {
7
+ if (!filterKeys.includes(key)) {
8
+ filteredProps[key] = props[key];
9
+ }
10
+ }
11
+ return filteredProps;
12
+ }
@@ -0,0 +1,46 @@
1
+ import type { BinaryAttribute } from '@deck.gl/core';
2
+ import type { ScaleType } from "../types.js";
3
+ type ScaleProps = {
4
+ scaleType: ScaleType;
5
+ /** Trim the lower end of the domain by this percentile. Set to `0` to disable. */
6
+ lowerPercentile: number;
7
+ /** Trim the upper end of the domain by this percentile. Set to `100` to disable. */
8
+ upperPercentile: number;
9
+ };
10
+ /** Applies a scale to BinaryAttribute */
11
+ export declare class AttributeWithScale {
12
+ /** Input values accessor. Has either a `value` (CPU aggregation) or a `buffer` (GPU aggregation) */
13
+ private readonly input;
14
+ private readonly inputLength;
15
+ private props;
16
+ private _percentile?;
17
+ private _ordinal?;
18
+ /** Output values accessor */
19
+ attribute: BinaryAttribute;
20
+ /** [min, max] of attribute values, or null if unknown */
21
+ domain: [number, number] | null;
22
+ /** Valid domain if lower/upper percentile are defined */
23
+ cutoff: [number, number] | null;
24
+ constructor(input: BinaryAttribute, inputLength: number);
25
+ private getScalePercentile;
26
+ private getScaleOrdinal;
27
+ /** Returns the [lowerCutoff, upperCutoff] of scaled values, or null if not applicable */
28
+ private getCutoff;
29
+ update(props: ScaleProps): this;
30
+ }
31
+ /**
32
+ * Transform an array of values to ordinal indices
33
+ */
34
+ export declare function applyScaleOrdinal(values: Float32Array): {
35
+ attribute: BinaryAttribute;
36
+ domain: number[];
37
+ };
38
+ /**
39
+ * Transform an array of values to percentiles
40
+ */
41
+ export declare function applyScaleQuantile(values: Float32Array, rangeLength?: number): {
42
+ attribute: BinaryAttribute;
43
+ domain: number[];
44
+ };
45
+ export {};
46
+ //# sourceMappingURL=scale-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scale-utils.d.ts","sourceRoot":"","sources":["../../../src/common/utils/scale-utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAC,SAAS,EAAC,oBAAiB;AAExC,KAAK,UAAU,GAAG;IAChB,SAAS,EAAE,SAAS,CAAC;IACrB,kFAAkF;IAClF,eAAe,EAAE,MAAM,CAAC;IACxB,oFAAoF;IACpF,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,yCAAyC;AACzC,qBAAa,kBAAkB;IAC7B,oGAAoG;IACpG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAkB;IACxC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IAErC,OAAO,CAAC,KAAK,CAIX;IAGF,OAAO,CAAC,WAAW,CAAC,CAAiD;IACrE,OAAO,CAAC,QAAQ,CAAC,CAAiD;IAElE,6BAA6B;IAC7B,SAAS,EAAE,eAAe,CAAC;IAC3B,yDAAyD;IACzD,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAQ;IACvC,yDAAyD;IACzD,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAQ;gBAE3B,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM;IAOvD,OAAO,CAAC,kBAAkB;IAQ1B,OAAO,CAAC,eAAe;IAQvB,yFAAyF;IACzF,OAAO,CAAC,SAAS;IA4BjB,MAAM,CAAC,KAAK,EAAE,UAAU;CAiCzB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,YAAY,GAAG;IACvD,SAAS,EAAE,eAAe,CAAC;IAC3B,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAqBA;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EACpB,WAAW,SAAM,GAChB;IACD,SAAS,EAAE,eAAe,CAAC;IAC3B,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAgBA"}
@@ -0,0 +1,180 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ /** Applies a scale to BinaryAttribute */
5
+ export class AttributeWithScale {
6
+ constructor(input, inputLength) {
7
+ this.props = {
8
+ scaleType: 'linear',
9
+ lowerPercentile: 0,
10
+ upperPercentile: 100
11
+ };
12
+ /** [min, max] of attribute values, or null if unknown */
13
+ this.domain = null;
14
+ /** Valid domain if lower/upper percentile are defined */
15
+ this.cutoff = null;
16
+ this.input = input;
17
+ this.inputLength = inputLength;
18
+ // No processing is needed with the default scale
19
+ this.attribute = input;
20
+ }
21
+ getScalePercentile() {
22
+ if (!this._percentile) {
23
+ const value = getAttributeValue(this.input, this.inputLength);
24
+ this._percentile = applyScaleQuantile(value);
25
+ }
26
+ return this._percentile;
27
+ }
28
+ getScaleOrdinal() {
29
+ if (!this._ordinal) {
30
+ const value = getAttributeValue(this.input, this.inputLength);
31
+ this._ordinal = applyScaleOrdinal(value);
32
+ }
33
+ return this._ordinal;
34
+ }
35
+ /** Returns the [lowerCutoff, upperCutoff] of scaled values, or null if not applicable */
36
+ getCutoff({ scaleType, lowerPercentile, upperPercentile }) {
37
+ if (scaleType === 'quantile') {
38
+ return [lowerPercentile, upperPercentile - 1];
39
+ }
40
+ if (lowerPercentile > 0 || upperPercentile < 100) {
41
+ const { domain: thresholds } = this.getScalePercentile();
42
+ let lowValue = thresholds[Math.floor(lowerPercentile) - 1] ?? -Infinity;
43
+ let highValue = thresholds[Math.floor(upperPercentile) - 1] ?? Infinity;
44
+ if (scaleType === 'ordinal') {
45
+ const { domain: sortedUniqueValues } = this.getScaleOrdinal();
46
+ lowValue = sortedUniqueValues.findIndex(x => x >= lowValue);
47
+ highValue = sortedUniqueValues.findIndex(x => x > highValue) - 1;
48
+ if (highValue === -2) {
49
+ highValue = sortedUniqueValues.length - 1;
50
+ }
51
+ }
52
+ return [lowValue, highValue];
53
+ }
54
+ return null;
55
+ }
56
+ update(props) {
57
+ const oldProps = this.props;
58
+ if (props.scaleType !== oldProps.scaleType) {
59
+ switch (props.scaleType) {
60
+ case 'quantile': {
61
+ const { attribute } = this.getScalePercentile();
62
+ this.attribute = attribute;
63
+ this.domain = [0, 99];
64
+ break;
65
+ }
66
+ case 'ordinal': {
67
+ const { attribute, domain } = this.getScaleOrdinal();
68
+ this.attribute = attribute;
69
+ this.domain = [0, domain.length - 1];
70
+ break;
71
+ }
72
+ default:
73
+ this.attribute = this.input;
74
+ this.domain = null;
75
+ }
76
+ }
77
+ if (props.scaleType !== oldProps.scaleType ||
78
+ props.lowerPercentile !== oldProps.lowerPercentile ||
79
+ props.upperPercentile !== oldProps.upperPercentile) {
80
+ this.cutoff = this.getCutoff(props);
81
+ }
82
+ this.props = props;
83
+ return this;
84
+ }
85
+ }
86
+ /**
87
+ * Transform an array of values to ordinal indices
88
+ */
89
+ export function applyScaleOrdinal(values) {
90
+ const uniqueValues = new Set();
91
+ for (const x of values) {
92
+ if (Number.isFinite(x)) {
93
+ uniqueValues.add(x);
94
+ }
95
+ }
96
+ const sortedUniqueValues = Array.from(uniqueValues).sort();
97
+ const domainMap = new Map();
98
+ for (let i = 0; i < sortedUniqueValues.length; i++) {
99
+ domainMap.set(sortedUniqueValues[i], i);
100
+ }
101
+ return {
102
+ attribute: {
103
+ value: values.map(x => (Number.isFinite(x) ? domainMap.get(x) : NaN)),
104
+ type: 'float32',
105
+ size: 1
106
+ },
107
+ domain: sortedUniqueValues
108
+ };
109
+ }
110
+ /**
111
+ * Transform an array of values to percentiles
112
+ */
113
+ export function applyScaleQuantile(values, rangeLength = 100) {
114
+ const sortedValues = Array.from(values).filter(Number.isFinite).sort(ascending);
115
+ let i = 0;
116
+ const n = Math.max(1, rangeLength);
117
+ const thresholds = new Array(n - 1);
118
+ while (++i < n) {
119
+ thresholds[i - 1] = threshold(sortedValues, i / n);
120
+ }
121
+ return {
122
+ attribute: {
123
+ value: values.map(x => (Number.isFinite(x) ? bisectRight(thresholds, x) : NaN)),
124
+ type: 'float32',
125
+ size: 1
126
+ },
127
+ domain: thresholds
128
+ };
129
+ }
130
+ function getAttributeValue(attribute, length) {
131
+ const elementStride = (attribute.stride ?? 4) / 4;
132
+ const elementOffset = (attribute.offset ?? 0) / 4;
133
+ let value = attribute.value;
134
+ if (!value) {
135
+ const bytes = attribute.buffer?.readSyncWebGL(0, elementStride * 4 * length);
136
+ if (bytes) {
137
+ value = new Float32Array(bytes.buffer);
138
+ attribute.value = value;
139
+ }
140
+ }
141
+ if (elementStride === 1) {
142
+ return value.subarray(0, length);
143
+ }
144
+ const result = new Float32Array(length);
145
+ for (let i = 0; i < length; i++) {
146
+ result[i] = value[i * elementStride + elementOffset];
147
+ }
148
+ return result;
149
+ }
150
+ function ascending(a, b) {
151
+ return a - b;
152
+ }
153
+ function threshold(domain, fraction) {
154
+ const domainLength = domain.length;
155
+ if (fraction <= 0 || domainLength < 2) {
156
+ return domain[0];
157
+ }
158
+ if (fraction >= 1) {
159
+ return domain[domainLength - 1];
160
+ }
161
+ const domainFraction = (domainLength - 1) * fraction;
162
+ const lowIndex = Math.floor(domainFraction);
163
+ const low = domain[lowIndex];
164
+ const high = domain[lowIndex + 1];
165
+ return low + (high - low) * (domainFraction - lowIndex);
166
+ }
167
+ function bisectRight(a, x) {
168
+ let lo = 0;
169
+ let hi = a.length;
170
+ while (lo < hi) {
171
+ const mid = (lo + hi) >>> 1;
172
+ if (a[mid] > x) {
173
+ hi = mid;
174
+ }
175
+ else {
176
+ lo = mid + 1;
177
+ }
178
+ }
179
+ return lo;
180
+ }