@deck.gl/aggregation-layers 9.0.0-beta.1 → 9.0.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 (336) hide show
  1. package/dist/aggregation-layer.js +153 -0
  2. package/dist/contour-layer/contour-layer.js +241 -0
  3. package/dist/contour-layer/contour-utils.js +64 -0
  4. package/dist/contour-layer/marching-squares-codes.js +337 -0
  5. package/dist/contour-layer/marching-squares.js +147 -0
  6. package/dist/cpu-grid-layer/cpu-grid-layer.js +130 -0
  7. package/dist/cpu-grid-layer/grid-aggregator.js +141 -0
  8. package/dist/dist.dev.js +1187 -10528
  9. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +34 -0
  10. package/dist/{esm/gpu-grid-layer → gpu-grid-layer}/gpu-grid-cell-layer-vertex.glsl.js +20 -1
  11. package/dist/gpu-grid-layer/gpu-grid-cell-layer.js +145 -0
  12. package/dist/gpu-grid-layer/gpu-grid-layer.js +288 -0
  13. package/dist/grid-aggregation-layer.js +172 -0
  14. package/dist/grid-layer/grid-layer.js +63 -0
  15. package/{typed → dist}/heatmap-layer/heatmap-layer-utils.d.ts +0 -9
  16. package/dist/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -0
  17. package/dist/heatmap-layer/heatmap-layer-utils.js +63 -0
  18. package/{typed → dist}/heatmap-layer/heatmap-layer.d.ts +4 -4
  19. package/dist/heatmap-layer/heatmap-layer.d.ts.map +1 -0
  20. package/dist/heatmap-layer/heatmap-layer.js +471 -0
  21. package/dist/{esm/heatmap-layer → heatmap-layer}/max-fs.glsl.js +0 -1
  22. package/dist/heatmap-layer/max-vs.glsl.d.ts +3 -0
  23. package/{typed → dist}/heatmap-layer/max-vs.glsl.d.ts.map +1 -1
  24. package/dist/heatmap-layer/max-vs.glsl.js +19 -0
  25. package/dist/heatmap-layer/triangle-layer-fragment.glsl.d.ts +3 -0
  26. package/dist/heatmap-layer/triangle-layer-fragment.glsl.js +61 -0
  27. package/dist/heatmap-layer/triangle-layer-vertex.glsl.js +52 -0
  28. package/{typed → dist}/heatmap-layer/triangle-layer.d.ts +10 -2
  29. package/dist/heatmap-layer/triangle-layer.d.ts.map +1 -0
  30. package/dist/heatmap-layer/triangle-layer.js +59 -0
  31. package/dist/{esm/heatmap-layer → heatmap-layer}/weights-fs.glsl.js +0 -1
  32. package/dist/heatmap-layer/weights-vs.glsl.d.ts +3 -0
  33. package/{typed → dist}/heatmap-layer/weights-vs.glsl.d.ts.map +1 -1
  34. package/dist/{esm/heatmap-layer → heatmap-layer}/weights-vs.glsl.js +4 -3
  35. package/dist/hexagon-layer/hexagon-aggregator.js +112 -0
  36. package/dist/hexagon-layer/hexagon-layer.js +174 -0
  37. package/dist/index.cjs +4494 -0
  38. package/dist/index.cjs.map +7 -0
  39. package/dist/index.js +32 -0
  40. package/dist/screen-grid-layer/screen-grid-cell-layer.js +166 -0
  41. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.js +40 -0
  42. package/dist/{esm/screen-grid-layer → screen-grid-layer}/screen-grid-layer-vertex.glsl.js +19 -1
  43. package/dist/screen-grid-layer/screen-grid-layer.js +216 -0
  44. package/dist/types.js +1 -0
  45. package/dist/utils/aggregation-operation-utils.js +94 -0
  46. package/dist/utils/bin-sorter.js +167 -0
  47. package/dist/utils/color-utils.js +53 -0
  48. package/dist/utils/cpu-aggregator.js +421 -0
  49. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +39 -0
  50. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +53 -0
  51. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +34 -0
  52. package/dist/{esm/utils → utils}/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +19 -1
  53. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +41 -0
  54. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +1 -0
  55. package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts.map +1 -1
  56. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +566 -0
  57. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +37 -0
  58. package/dist/utils/grid-aggregation-utils.js +114 -0
  59. package/dist/utils/prop-utils.js +28 -0
  60. package/dist/utils/resource-utils.js +38 -0
  61. package/dist/utils/scale-utils.js +184 -0
  62. package/dist.min.js +74 -178
  63. package/package.json +18 -11
  64. package/src/heatmap-layer/heatmap-layer-utils.ts +0 -23
  65. package/src/heatmap-layer/heatmap-layer.ts +87 -105
  66. package/src/heatmap-layer/max-vs.glsl.ts +11 -5
  67. package/src/heatmap-layer/triangle-layer-fragment.glsl.ts +2 -2
  68. package/src/heatmap-layer/triangle-layer.ts +17 -23
  69. package/src/heatmap-layer/weights-vs.glsl.ts +4 -2
  70. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.ts +10 -13
  71. package/dist/es5/aggregation-layer.js +0 -215
  72. package/dist/es5/aggregation-layer.js.map +0 -1
  73. package/dist/es5/contour-layer/contour-layer.js +0 -353
  74. package/dist/es5/contour-layer/contour-layer.js.map +0 -1
  75. package/dist/es5/contour-layer/contour-utils.js +0 -110
  76. package/dist/es5/contour-layer/contour-utils.js.map +0 -1
  77. package/dist/es5/contour-layer/marching-squares-codes.js +0 -152
  78. package/dist/es5/contour-layer/marching-squares-codes.js.map +0 -1
  79. package/dist/es5/contour-layer/marching-squares.js +0 -168
  80. package/dist/es5/contour-layer/marching-squares.js.map +0 -1
  81. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +0 -235
  82. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +0 -1
  83. package/dist/es5/cpu-grid-layer/grid-aggregator.js +0 -180
  84. package/dist/es5/cpu-grid-layer/grid-aggregator.js.map +0 -1
  85. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -9
  86. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js.map +0 -1
  87. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +0 -9
  88. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js.map +0 -1
  89. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +0 -247
  90. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +0 -1
  91. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +0 -424
  92. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +0 -1
  93. package/dist/es5/grid-aggregation-layer.js +0 -280
  94. package/dist/es5/grid-aggregation-layer.js.map +0 -1
  95. package/dist/es5/grid-layer/grid-layer.js +0 -125
  96. package/dist/es5/grid-layer/grid-layer.js.map +0 -1
  97. package/dist/es5/heatmap-layer/heatmap-layer-utils.js +0 -122
  98. package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +0 -1
  99. package/dist/es5/heatmap-layer/heatmap-layer.js +0 -672
  100. package/dist/es5/heatmap-layer/heatmap-layer.js.map +0 -1
  101. package/dist/es5/heatmap-layer/max-fs.glsl.js +0 -9
  102. package/dist/es5/heatmap-layer/max-fs.glsl.js.map +0 -1
  103. package/dist/es5/heatmap-layer/max-vs.glsl.js +0 -9
  104. package/dist/es5/heatmap-layer/max-vs.glsl.js.map +0 -1
  105. package/dist/es5/heatmap-layer/triangle-layer-fragment.glsl.js +0 -9
  106. package/dist/es5/heatmap-layer/triangle-layer-fragment.glsl.js.map +0 -1
  107. package/dist/es5/heatmap-layer/triangle-layer-vertex.glsl.js +0 -9
  108. package/dist/es5/heatmap-layer/triangle-layer-vertex.glsl.js.map +0 -1
  109. package/dist/es5/heatmap-layer/triangle-layer.js +0 -122
  110. package/dist/es5/heatmap-layer/triangle-layer.js.map +0 -1
  111. package/dist/es5/heatmap-layer/weights-fs.glsl.js +0 -9
  112. package/dist/es5/heatmap-layer/weights-fs.glsl.js.map +0 -1
  113. package/dist/es5/heatmap-layer/weights-vs.glsl.js +0 -9
  114. package/dist/es5/heatmap-layer/weights-vs.glsl.js.map +0 -1
  115. package/dist/es5/hexagon-layer/hexagon-aggregator.js +0 -118
  116. package/dist/es5/hexagon-layer/hexagon-aggregator.js.map +0 -1
  117. package/dist/es5/hexagon-layer/hexagon-layer.js +0 -289
  118. package/dist/es5/hexagon-layer/hexagon-layer.js.map +0 -1
  119. package/dist/es5/index.js +0 -104
  120. package/dist/es5/index.js.map +0 -1
  121. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +0 -244
  122. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +0 -1
  123. package/dist/es5/screen-grid-layer/screen-grid-layer-fragment.glsl.js +0 -9
  124. package/dist/es5/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +0 -1
  125. package/dist/es5/screen-grid-layer/screen-grid-layer-vertex.glsl.js +0 -9
  126. package/dist/es5/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +0 -1
  127. package/dist/es5/screen-grid-layer/screen-grid-layer.js +0 -317
  128. package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +0 -1
  129. package/dist/es5/types.js +0 -2
  130. package/dist/es5/types.js.map +0 -1
  131. package/dist/es5/utils/aggregation-operation-utils.js +0 -123
  132. package/dist/es5/utils/aggregation-operation-utils.js.map +0 -1
  133. package/dist/es5/utils/bin-sorter.js +0 -248
  134. package/dist/es5/utils/bin-sorter.js.map +0 -1
  135. package/dist/es5/utils/color-utils.js +0 -39
  136. package/dist/es5/utils/color-utils.js.map +0 -1
  137. package/dist/es5/utils/cpu-aggregator.js +0 -496
  138. package/dist/es5/utils/cpu-aggregator.js.map +0 -1
  139. package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -9
  140. package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js.map +0 -1
  141. package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -9
  142. package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js.map +0 -1
  143. package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -9
  144. package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js.map +0 -1
  145. package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +0 -9
  146. package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js.map +0 -1
  147. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -63
  148. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +0 -1
  149. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -2
  150. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js.map +0 -1
  151. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -732
  152. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +0 -1
  153. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +0 -155
  154. package/dist/es5/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -9
  155. package/dist/es5/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js.map +0 -1
  156. package/dist/es5/utils/grid-aggregation-utils.js +0 -118
  157. package/dist/es5/utils/grid-aggregation-utils.js.map +0 -1
  158. package/dist/es5/utils/prop-utils.js +0 -19
  159. package/dist/es5/utils/prop-utils.js.map +0 -1
  160. package/dist/es5/utils/resource-utils.js +0 -59
  161. package/dist/es5/utils/resource-utils.js.map +0 -1
  162. package/dist/es5/utils/scale-utils.js +0 -254
  163. package/dist/es5/utils/scale-utils.js.map +0 -1
  164. package/dist/esm/aggregation-layer.js +0 -156
  165. package/dist/esm/aggregation-layer.js.map +0 -1
  166. package/dist/esm/contour-layer/contour-layer.js +0 -316
  167. package/dist/esm/contour-layer/contour-layer.js.map +0 -1
  168. package/dist/esm/contour-layer/contour-utils.js +0 -81
  169. package/dist/esm/contour-layer/contour-utils.js.map +0 -1
  170. package/dist/esm/contour-layer/marching-squares-codes.js +0 -219
  171. package/dist/esm/contour-layer/marching-squares-codes.js.map +0 -1
  172. package/dist/esm/contour-layer/marching-squares.js +0 -151
  173. package/dist/esm/contour-layer/marching-squares.js.map +0 -1
  174. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js +0 -186
  175. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js.map +0 -1
  176. package/dist/esm/cpu-grid-layer/grid-aggregator.js +0 -142
  177. package/dist/esm/cpu-grid-layer/grid-aggregator.js.map +0 -1
  178. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -16
  179. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js.map +0 -1
  180. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js.map +0 -1
  181. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js +0 -196
  182. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js.map +0 -1
  183. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js +0 -399
  184. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js.map +0 -1
  185. package/dist/esm/grid-aggregation-layer.js +0 -240
  186. package/dist/esm/grid-aggregation-layer.js.map +0 -1
  187. package/dist/esm/grid-layer/grid-layer.js +0 -80
  188. package/dist/esm/grid-layer/grid-layer.js.map +0 -1
  189. package/dist/esm/heatmap-layer/heatmap-layer-utils.js +0 -68
  190. package/dist/esm/heatmap-layer/heatmap-layer-utils.js.map +0 -1
  191. package/dist/esm/heatmap-layer/heatmap-layer.js +0 -626
  192. package/dist/esm/heatmap-layer/heatmap-layer.js.map +0 -1
  193. package/dist/esm/heatmap-layer/max-fs.glsl.js.map +0 -1
  194. package/dist/esm/heatmap-layer/max-vs.glsl.js +0 -14
  195. package/dist/esm/heatmap-layer/max-vs.glsl.js.map +0 -1
  196. package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js +0 -43
  197. package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js.map +0 -1
  198. package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js +0 -33
  199. package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js.map +0 -1
  200. package/dist/esm/heatmap-layer/triangle-layer.js +0 -80
  201. package/dist/esm/heatmap-layer/triangle-layer.js.map +0 -1
  202. package/dist/esm/heatmap-layer/weights-fs.glsl.js.map +0 -1
  203. package/dist/esm/heatmap-layer/weights-vs.glsl.js.map +0 -1
  204. package/dist/esm/hexagon-layer/hexagon-aggregator.js +0 -87
  205. package/dist/esm/hexagon-layer/hexagon-aggregator.js.map +0 -1
  206. package/dist/esm/hexagon-layer/hexagon-layer.js +0 -232
  207. package/dist/esm/hexagon-layer/hexagon-layer.js.map +0 -1
  208. package/dist/esm/index.js +0 -13
  209. package/dist/esm/index.js.map +0 -1
  210. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js +0 -203
  211. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js.map +0 -1
  212. package/dist/esm/screen-grid-layer/screen-grid-layer-fragment.glsl.js +0 -21
  213. package/dist/esm/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +0 -1
  214. package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +0 -1
  215. package/dist/esm/screen-grid-layer/screen-grid-layer.js +0 -285
  216. package/dist/esm/screen-grid-layer/screen-grid-layer.js.map +0 -1
  217. package/dist/esm/types.js +0 -2
  218. package/dist/esm/types.js.map +0 -1
  219. package/dist/esm/utils/aggregation-operation-utils.js +0 -91
  220. package/dist/esm/utils/aggregation-operation-utils.js.map +0 -1
  221. package/dist/esm/utils/bin-sorter.js +0 -165
  222. package/dist/esm/utils/bin-sorter.js.map +0 -1
  223. package/dist/esm/utils/color-utils.js +0 -28
  224. package/dist/esm/utils/color-utils.js.map +0 -1
  225. package/dist/esm/utils/cpu-aggregator.js +0 -487
  226. package/dist/esm/utils/cpu-aggregator.js.map +0 -1
  227. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -21
  228. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js.map +0 -1
  229. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -35
  230. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js.map +0 -1
  231. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -16
  232. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js.map +0 -1
  233. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js.map +0 -1
  234. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -42
  235. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +0 -1
  236. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -2
  237. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js.map +0 -1
  238. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -720
  239. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +0 -1
  240. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +0 -155
  241. package/dist/esm/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -19
  242. package/dist/esm/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js.map +0 -1
  243. package/dist/esm/utils/grid-aggregation-utils.js +0 -109
  244. package/dist/esm/utils/grid-aggregation-utils.js.map +0 -1
  245. package/dist/esm/utils/prop-utils.js +0 -12
  246. package/dist/esm/utils/prop-utils.js.map +0 -1
  247. package/dist/esm/utils/resource-utils.js +0 -44
  248. package/dist/esm/utils/resource-utils.js.map +0 -1
  249. package/dist/esm/utils/scale-utils.js +0 -192
  250. package/dist/esm/utils/scale-utils.js.map +0 -1
  251. package/typed/heatmap-layer/heatmap-layer-utils.d.ts.map +0 -1
  252. package/typed/heatmap-layer/heatmap-layer.d.ts.map +0 -1
  253. package/typed/heatmap-layer/max-vs.glsl.d.ts +0 -3
  254. package/typed/heatmap-layer/triangle-layer-fragment.glsl.d.ts +0 -3
  255. package/typed/heatmap-layer/triangle-layer.d.ts.map +0 -1
  256. package/typed/heatmap-layer/weights-vs.glsl.d.ts +0 -3
  257. /package/{typed → dist}/aggregation-layer.d.ts +0 -0
  258. /package/{typed → dist}/aggregation-layer.d.ts.map +0 -0
  259. /package/{typed → dist}/contour-layer/contour-layer.d.ts +0 -0
  260. /package/{typed → dist}/contour-layer/contour-layer.d.ts.map +0 -0
  261. /package/{typed → dist}/contour-layer/contour-utils.d.ts +0 -0
  262. /package/{typed → dist}/contour-layer/contour-utils.d.ts.map +0 -0
  263. /package/{typed → dist}/contour-layer/marching-squares-codes.d.ts +0 -0
  264. /package/{typed → dist}/contour-layer/marching-squares-codes.d.ts.map +0 -0
  265. /package/{typed → dist}/contour-layer/marching-squares.d.ts +0 -0
  266. /package/{typed → dist}/contour-layer/marching-squares.d.ts.map +0 -0
  267. /package/{typed → dist}/cpu-grid-layer/cpu-grid-layer.d.ts +0 -0
  268. /package/{typed → dist}/cpu-grid-layer/cpu-grid-layer.d.ts.map +0 -0
  269. /package/{typed → dist}/cpu-grid-layer/grid-aggregator.d.ts +0 -0
  270. /package/{typed → dist}/cpu-grid-layer/grid-aggregator.d.ts.map +0 -0
  271. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts +0 -0
  272. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts.map +0 -0
  273. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts +0 -0
  274. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts.map +0 -0
  275. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer.d.ts +0 -0
  276. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +0 -0
  277. /package/{typed → dist}/gpu-grid-layer/gpu-grid-layer.d.ts +0 -0
  278. /package/{typed → dist}/gpu-grid-layer/gpu-grid-layer.d.ts.map +0 -0
  279. /package/{typed → dist}/grid-aggregation-layer.d.ts +0 -0
  280. /package/{typed → dist}/grid-aggregation-layer.d.ts.map +0 -0
  281. /package/{typed → dist}/grid-layer/grid-layer.d.ts +0 -0
  282. /package/{typed → dist}/grid-layer/grid-layer.d.ts.map +0 -0
  283. /package/{typed → dist}/heatmap-layer/max-fs.glsl.d.ts +0 -0
  284. /package/{typed → dist}/heatmap-layer/max-fs.glsl.d.ts.map +0 -0
  285. /package/{typed → dist}/heatmap-layer/triangle-layer-fragment.glsl.d.ts.map +0 -0
  286. /package/{typed → dist}/heatmap-layer/triangle-layer-vertex.glsl.d.ts +0 -0
  287. /package/{typed → dist}/heatmap-layer/triangle-layer-vertex.glsl.d.ts.map +0 -0
  288. /package/{typed → dist}/heatmap-layer/weights-fs.glsl.d.ts +0 -0
  289. /package/{typed → dist}/heatmap-layer/weights-fs.glsl.d.ts.map +0 -0
  290. /package/{typed → dist}/hexagon-layer/hexagon-aggregator.d.ts +0 -0
  291. /package/{typed → dist}/hexagon-layer/hexagon-aggregator.d.ts.map +0 -0
  292. /package/{typed → dist}/hexagon-layer/hexagon-layer.d.ts +0 -0
  293. /package/{typed → dist}/hexagon-layer/hexagon-layer.d.ts.map +0 -0
  294. /package/{typed → dist}/index.d.ts +0 -0
  295. /package/{typed → dist}/index.d.ts.map +0 -0
  296. /package/{typed → dist}/screen-grid-layer/screen-grid-cell-layer.d.ts +0 -0
  297. /package/{typed → dist}/screen-grid-layer/screen-grid-cell-layer.d.ts.map +0 -0
  298. /package/{typed → dist}/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts +0 -0
  299. /package/{typed → dist}/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts.map +0 -0
  300. /package/{typed → dist}/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts +0 -0
  301. /package/{typed → dist}/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts.map +0 -0
  302. /package/{typed → dist}/screen-grid-layer/screen-grid-layer.d.ts +0 -0
  303. /package/{typed → dist}/screen-grid-layer/screen-grid-layer.d.ts.map +0 -0
  304. /package/{typed → dist}/types.d.ts +0 -0
  305. /package/{typed → dist}/types.d.ts.map +0 -0
  306. /package/{typed → dist}/utils/aggregation-operation-utils.d.ts +0 -0
  307. /package/{typed → dist}/utils/aggregation-operation-utils.d.ts.map +0 -0
  308. /package/{typed → dist}/utils/bin-sorter.d.ts +0 -0
  309. /package/{typed → dist}/utils/bin-sorter.d.ts.map +0 -0
  310. /package/{typed → dist}/utils/color-utils.d.ts +0 -0
  311. /package/{typed → dist}/utils/color-utils.d.ts.map +0 -0
  312. /package/{typed → dist}/utils/cpu-aggregator.d.ts +0 -0
  313. /package/{typed → dist}/utils/cpu-aggregator.d.ts.map +0 -0
  314. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts +0 -0
  315. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts.map +0 -0
  316. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts +0 -0
  317. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts.map +0 -0
  318. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts +0 -0
  319. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts.map +0 -0
  320. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts +0 -0
  321. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts.map +0 -0
  322. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts +0 -0
  323. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts.map +0 -0
  324. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts +0 -0
  325. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts.map +0 -0
  326. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts +0 -0
  327. /package/{typed → dist}/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts +0 -0
  328. /package/{typed → dist}/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts.map +0 -0
  329. /package/{typed → dist}/utils/grid-aggregation-utils.d.ts +0 -0
  330. /package/{typed → dist}/utils/grid-aggregation-utils.d.ts.map +0 -0
  331. /package/{typed → dist}/utils/prop-utils.d.ts +0 -0
  332. /package/{typed → dist}/utils/prop-utils.d.ts.map +0 -0
  333. /package/{typed → dist}/utils/resource-utils.d.ts +0 -0
  334. /package/{typed → dist}/utils/resource-utils.d.ts.map +0 -0
  335. /package/{typed → dist}/utils/scale-utils.d.ts +0 -0
  336. /package/{typed → dist}/utils/scale-utils.d.ts.map +0 -0
@@ -0,0 +1,63 @@
1
+ import { CompositeLayer } from '@deck.gl/core';
2
+ import GPUGridAggregator from "../utils/gpu-grid-aggregation/gpu-grid-aggregator.js";
3
+ import GPUGridLayer from "../gpu-grid-layer/gpu-grid-layer.js";
4
+ import CPUGridLayer from "../cpu-grid-layer/cpu-grid-layer.js";
5
+ const defaultProps = {
6
+ ...GPUGridLayer.defaultProps,
7
+ ...CPUGridLayer.defaultProps,
8
+ gpuAggregation: false
9
+ };
10
+ /** Aggregate data into a grid-based heatmap. The color and height of a cell are determined based on the objects it contains. */
11
+ export default class GridLayer extends CompositeLayer {
12
+ static { this.layerName = 'GridLayer'; }
13
+ static { this.defaultProps = defaultProps; }
14
+ initializeState() {
15
+ this.state = {
16
+ useGPUAggregation: false // TODO(v9): Re-enable GPU aggregation.
17
+ };
18
+ }
19
+ updateState({ props }) {
20
+ this.setState({
21
+ // TODO(v9): Re-enable GPU aggregation.
22
+ // useGPUAggregation: this.canUseGPUAggregation(props)
23
+ useGPUAggregation: false
24
+ });
25
+ }
26
+ renderLayers() {
27
+ const { data, updateTriggers } = this.props;
28
+ const id = this.state.useGPUAggregation ? 'GPU' : 'CPU';
29
+ const LayerType = this.state.useGPUAggregation
30
+ ? this.getSubLayerClass('GPU', GPUGridLayer)
31
+ : this.getSubLayerClass('CPU', CPUGridLayer);
32
+ return new LayerType(this.props, this.getSubLayerProps({
33
+ id,
34
+ updateTriggers
35
+ }), {
36
+ data
37
+ });
38
+ }
39
+ // Private methods
40
+ canUseGPUAggregation(props) {
41
+ const { gpuAggregation, lowerPercentile, upperPercentile, getColorValue, getElevationValue, colorScaleType } = props;
42
+ if (!gpuAggregation) {
43
+ // cpu aggregation is requested
44
+ return false;
45
+ }
46
+ if (!GPUGridAggregator.isSupported(this.context.device)) {
47
+ return false;
48
+ }
49
+ if (lowerPercentile !== 0 || upperPercentile !== 100) {
50
+ // percentile calculations requires sorting not supported on GPU
51
+ return false;
52
+ }
53
+ if (getColorValue !== null || getElevationValue !== null) {
54
+ // accessor for custom color or elevation calculation is specified
55
+ return false;
56
+ }
57
+ if (colorScaleType === 'quantile' || colorScaleType === 'ordinal') {
58
+ // quantile and ordinal scales are not supported on GPU
59
+ return false;
60
+ }
61
+ return true;
62
+ }
63
+ }
@@ -1,15 +1,6 @@
1
- import { Device } from '@luma.gl/core';
2
- import { GL } from '@luma.gl/constants';
3
1
  export declare function getBounds(points: number[][]): number[];
4
2
  export declare function boundsContain(currentBounds: number[], targetBounds: number[]): boolean;
5
3
  export declare function packVertices(points: number[][], dimensions?: number): Float32Array;
6
4
  export declare function scaleToAspectRatio(boundingBox: number[], width: number, height: number): number[];
7
5
  export declare function getTextureCoordinates(point: number[], bounds: number[]): number[];
8
- export declare function getTextureParams({ device, floatTargetSupport }: {
9
- device: Device;
10
- floatTargetSupport?: boolean;
11
- }): {
12
- format: GL;
13
- type: GL;
14
- };
15
6
  //# sourceMappingURL=heatmap-layer-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heatmap-layer-utils.d.ts","sourceRoot":"","sources":["../../src/heatmap-layer/heatmap-layer-utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,CAWtD;AAGD,wBAAgB,aAAa,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,OAAO,CAUtF;AAKD,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,GAAE,MAAU,GAAG,YAAY,CAQrF;AAGD,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CA6BjG;AAGD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,YAGtE"}
@@ -0,0 +1,63 @@
1
+ export function getBounds(points) {
2
+ // Now build bounding box in world space (aligned to world coordiante system)
3
+ const x = points.map(p => p[0]);
4
+ const y = points.map(p => p[1]);
5
+ const xMin = Math.min.apply(null, x);
6
+ const xMax = Math.max.apply(null, x);
7
+ const yMin = Math.min.apply(null, y);
8
+ const yMax = Math.max.apply(null, y);
9
+ return [xMin, yMin, xMax, yMax];
10
+ }
11
+ // true if currentBounds contains targetBounds, false otherwise
12
+ export function boundsContain(currentBounds, targetBounds) {
13
+ if (targetBounds[0] >= currentBounds[0] &&
14
+ targetBounds[2] <= currentBounds[2] &&
15
+ targetBounds[1] >= currentBounds[1] &&
16
+ targetBounds[3] <= currentBounds[3]) {
17
+ return true;
18
+ }
19
+ return false;
20
+ }
21
+ const scratchArray = new Float32Array(12);
22
+ // For given rectangle bounds generates two triangles vertices that coverit completely
23
+ export function packVertices(points, dimensions = 2) {
24
+ let index = 0;
25
+ for (const point of points) {
26
+ for (let i = 0; i < dimensions; i++) {
27
+ scratchArray[index++] = point[i] || 0;
28
+ }
29
+ }
30
+ return scratchArray;
31
+ }
32
+ // Expands boundingBox:[xMin, yMin, xMax, yMax] to match aspect ratio of given width and height
33
+ export function scaleToAspectRatio(boundingBox, width, height) {
34
+ const [xMin, yMin, xMax, yMax] = boundingBox;
35
+ const currentWidth = xMax - xMin;
36
+ const currentHeight = yMax - yMin;
37
+ let newWidth = currentWidth;
38
+ let newHeight = currentHeight;
39
+ if (currentWidth / currentHeight < width / height) {
40
+ // expand bounding box width
41
+ newWidth = (width / height) * currentHeight;
42
+ }
43
+ else {
44
+ newHeight = (height / width) * currentWidth;
45
+ }
46
+ if (newWidth < width) {
47
+ newWidth = width;
48
+ newHeight = height;
49
+ }
50
+ const xCenter = (xMax + xMin) / 2;
51
+ const yCenter = (yMax + yMin) / 2;
52
+ return [
53
+ xCenter - newWidth / 2,
54
+ yCenter - newHeight / 2,
55
+ xCenter + newWidth / 2,
56
+ yCenter + newHeight / 2
57
+ ];
58
+ }
59
+ // Get texture coordiante of point inside a bounding box
60
+ export function getTextureCoordinates(point, bounds) {
61
+ const [xMin, yMin, xMax, yMax] = bounds;
62
+ return [(point[0] - xMin) / (xMax - xMin), (point[1] - yMin) / (yMax - yMin)];
63
+ }
@@ -1,5 +1,4 @@
1
1
  import { Buffer, Texture, TextureFormat } from '@luma.gl/core';
2
- import { GL } from '@luma.gl/constants';
3
2
  import { TextureTransform } from '@luma.gl/engine';
4
3
  import { Accessor, AccessorFunction, AttributeManager, ChangeFlags, Color, Layer, LayerContext, LayersList, Position, UpdateParameters, DefaultProps } from '@deck.gl/core';
5
4
  import AggregationLayer, { AggregationLayerProps } from '../aggregation-layer';
@@ -91,7 +90,6 @@ export default class HeatmapLayer<DataT = any, ExtraPropsT extends {} = {}> exte
91
90
  maxWeightTransform?: TextureTransform;
92
91
  textureSize: number;
93
92
  format: TextureFormat;
94
- type: GL;
95
93
  weightsScale: number;
96
94
  visibleWorldBounds: number[];
97
95
  viewportCorners: number[][];
@@ -110,8 +108,10 @@ export default class HeatmapLayer<DataT = any, ExtraPropsT extends {} = {}> exte
110
108
  _createTextures(): void;
111
109
  _setupAttributes(): void;
112
110
  _setupTextureParams(): void;
113
- getShaders(type: any): any;
114
- _createWeightsTransform(shaders?: {}): void;
111
+ _createWeightsTransform(shaders: {
112
+ vs: string;
113
+ fs?: string;
114
+ }): void;
115
115
  _setupResources(): void;
116
116
  updateShaders(shaderOptions: any): void;
117
117
  _updateMaxWeightValue(): void;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heatmap-layer.d.ts","sourceRoot":"","sources":["../../src/heatmap-layer/heatmap-layer.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,471 @@
1
+ // Copyright (c) 2015 - 2019 Uber Technologies, Inc.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ // of this software and associated documentation files (the "Software"), to deal
5
+ // in the Software without restriction, including without limitation the rights
6
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ // copies of the Software, and to permit persons to whom the Software is
8
+ // furnished to do so, subject to the following conditions:
9
+ //
10
+ // The above copyright notice and this permission notice shall be included in
11
+ // all copies or substantial portions of the Software.
12
+ //
13
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ // THE SOFTWARE.
20
+ /* global setTimeout clearTimeout */
21
+ import { getBounds, boundsContain, packVertices, scaleToAspectRatio, getTextureCoordinates } from "./heatmap-layer-utils.js";
22
+ import { GL } from '@luma.gl/constants';
23
+ import { TextureTransform } from '@luma.gl/engine';
24
+ import { AttributeManager, COORDINATE_SYSTEM, log } from '@deck.gl/core';
25
+ import TriangleLayer from "./triangle-layer.js";
26
+ import AggregationLayer from "../aggregation-layer.js";
27
+ import { defaultColorRange, colorRangeToFlatArray } from "../utils/color-utils.js";
28
+ import weightsVs from "./weights-vs.glsl.js";
29
+ import weightsFs from "./weights-fs.glsl.js";
30
+ import maxVs from "./max-vs.glsl.js";
31
+ import maxFs from "./max-fs.glsl.js";
32
+ const RESOLUTION = 2; // (number of common space pixels) / (number texels)
33
+ const TEXTURE_PROPS = {
34
+ format: 'rgba8unorm',
35
+ mipmaps: false,
36
+ sampler: {
37
+ minFilter: 'linear',
38
+ magFilter: 'linear',
39
+ addressModeU: 'clamp-to-edge',
40
+ addressModeV: 'clamp-to-edge'
41
+ }
42
+ };
43
+ const DEFAULT_COLOR_DOMAIN = [0, 0];
44
+ const AGGREGATION_MODE = {
45
+ SUM: 0,
46
+ MEAN: 1
47
+ };
48
+ const defaultProps = {
49
+ getPosition: { type: 'accessor', value: (x) => x.position },
50
+ getWeight: { type: 'accessor', value: 1 },
51
+ intensity: { type: 'number', min: 0, value: 1 },
52
+ radiusPixels: { type: 'number', min: 1, max: 100, value: 50 },
53
+ colorRange: defaultColorRange,
54
+ threshold: { type: 'number', min: 0, max: 1, value: 0.05 },
55
+ colorDomain: { type: 'array', value: null, optional: true },
56
+ // 'SUM' or 'MEAN'
57
+ aggregation: 'SUM',
58
+ weightsTextureSize: { type: 'number', min: 128, max: 2048, value: 2048 },
59
+ debounceTimeout: { type: 'number', min: 0, max: 1000, value: 500 }
60
+ };
61
+ const REQUIRED_FEATURES = [
62
+ 'blend-minmax-webgl1', // max weight calculation
63
+ 'texture-formats-float32-webgl1' // weight-map as texture
64
+ ];
65
+ const FLOAT_TARGET_FEATURES = [
66
+ 'texture-renderable-float32-webgl', // ability to render to float texture
67
+ 'texture-blend-float-webgl1' // ability to blend when rendering to float texture
68
+ ];
69
+ const DIMENSIONS = {
70
+ data: {
71
+ props: ['radiusPixels']
72
+ }
73
+ };
74
+ /** Visualizes the spatial distribution of data. */
75
+ export default class HeatmapLayer extends AggregationLayer {
76
+ static { this.layerName = 'HeatmapLayer'; }
77
+ static { this.defaultProps = defaultProps; }
78
+ initializeState() {
79
+ if (!REQUIRED_FEATURES.every(feature => this.context.device.features.has(feature))) {
80
+ this.setState({ supported: false });
81
+ log.error(`HeatmapLayer: ${this.id} is not supported on this browser`)();
82
+ return;
83
+ }
84
+ super.initializeAggregationLayer(DIMENSIONS);
85
+ this.setState({ supported: true, colorDomain: DEFAULT_COLOR_DOMAIN });
86
+ this._setupTextureParams();
87
+ this._setupAttributes();
88
+ this._setupResources();
89
+ }
90
+ shouldUpdateState({ changeFlags }) {
91
+ // Need to be updated when viewport changes
92
+ return changeFlags.somethingChanged;
93
+ }
94
+ /* eslint-disable max-statements,complexity */
95
+ updateState(opts) {
96
+ if (!this.state.supported) {
97
+ return;
98
+ }
99
+ super.updateState(opts);
100
+ this._updateHeatmapState(opts);
101
+ }
102
+ _updateHeatmapState(opts) {
103
+ const { props, oldProps } = opts;
104
+ const changeFlags = this._getChangeFlags(opts);
105
+ if (changeFlags.dataChanged || changeFlags.viewportChanged) {
106
+ // if data is changed, do not debounce and immediately update the weight map
107
+ changeFlags.boundsChanged = this._updateBounds(changeFlags.dataChanged);
108
+ this._updateTextureRenderingBounds();
109
+ }
110
+ if (changeFlags.dataChanged || changeFlags.boundsChanged) {
111
+ // Update weight map immediately
112
+ clearTimeout(this.state.updateTimer);
113
+ this.setState({ isWeightMapDirty: true });
114
+ }
115
+ else if (changeFlags.viewportZoomChanged) {
116
+ // Update weight map when zoom stops
117
+ this._debouncedUpdateWeightmap();
118
+ }
119
+ if (props.colorRange !== oldProps.colorRange) {
120
+ this._updateColorTexture(opts);
121
+ }
122
+ if (this.state.isWeightMapDirty) {
123
+ this._updateWeightmap();
124
+ }
125
+ this.setState({ zoom: opts.context.viewport.zoom });
126
+ }
127
+ renderLayers() {
128
+ if (!this.state.supported) {
129
+ return [];
130
+ }
131
+ const { weightsTexture, triPositionBuffer, triTexCoordBuffer, maxWeightsTexture, colorTexture, colorDomain } = this.state;
132
+ const { updateTriggers, intensity, threshold, aggregation } = this.props;
133
+ const TriangleLayerClass = this.getSubLayerClass('triangle', TriangleLayer);
134
+ return new TriangleLayerClass(this.getSubLayerProps({
135
+ id: 'triangle-layer',
136
+ updateTriggers
137
+ }), {
138
+ // position buffer is filled with world coordinates generated from viewport.unproject
139
+ // i.e. LNGLAT if geospatial, CARTESIAN otherwise
140
+ coordinateSystem: COORDINATE_SYSTEM.DEFAULT,
141
+ data: {
142
+ attributes: {
143
+ positions: triPositionBuffer,
144
+ texCoords: triTexCoordBuffer
145
+ }
146
+ },
147
+ vertexCount: 4,
148
+ maxTexture: maxWeightsTexture,
149
+ colorTexture,
150
+ aggregationMode: AGGREGATION_MODE[aggregation] || 0,
151
+ weightsTexture,
152
+ intensity,
153
+ threshold,
154
+ colorDomain
155
+ });
156
+ }
157
+ finalizeState(context) {
158
+ super.finalizeState(context);
159
+ const { weightsTransform, weightsTexture, maxWeightTransform, maxWeightsTexture, triPositionBuffer, triTexCoordBuffer, colorTexture, updateTimer } = this.state;
160
+ weightsTransform?.destroy();
161
+ weightsTexture?.destroy();
162
+ maxWeightTransform?.destroy();
163
+ maxWeightsTexture?.destroy();
164
+ triPositionBuffer?.destroy();
165
+ triTexCoordBuffer?.destroy();
166
+ colorTexture?.destroy();
167
+ if (updateTimer) {
168
+ clearTimeout(updateTimer);
169
+ }
170
+ }
171
+ // PRIVATE
172
+ // override Composite layer private method to create AttributeManager instance
173
+ _getAttributeManager() {
174
+ return new AttributeManager(this.context.device, {
175
+ id: this.props.id,
176
+ stats: this.context.stats
177
+ });
178
+ }
179
+ _getChangeFlags(opts) {
180
+ const changeFlags = {};
181
+ const { dimensions } = this.state;
182
+ changeFlags.dataChanged =
183
+ (this.isAttributeChanged() && 'attribute changed') || // if any attribute is changed
184
+ (this.isAggregationDirty(opts, {
185
+ compareAll: true,
186
+ dimension: dimensions.data
187
+ }) &&
188
+ 'aggregation is dirty');
189
+ changeFlags.viewportChanged = opts.changeFlags.viewportChanged;
190
+ const { zoom } = this.state;
191
+ if (!opts.context.viewport || opts.context.viewport.zoom !== zoom) {
192
+ changeFlags.viewportZoomChanged = true;
193
+ }
194
+ return changeFlags;
195
+ }
196
+ _createTextures() {
197
+ const { textureSize, format } = this.state;
198
+ this.setState({
199
+ weightsTexture: this.context.device.createTexture({
200
+ ...TEXTURE_PROPS,
201
+ width: textureSize,
202
+ height: textureSize,
203
+ format
204
+ }),
205
+ maxWeightsTexture: this.context.device.createTexture({
206
+ ...TEXTURE_PROPS,
207
+ width: 1,
208
+ height: 1,
209
+ format
210
+ })
211
+ });
212
+ }
213
+ _setupAttributes() {
214
+ const attributeManager = this.getAttributeManager();
215
+ attributeManager.add({
216
+ positions: { size: 3, type: GL.DOUBLE, accessor: 'getPosition' },
217
+ weights: { size: 1, accessor: 'getWeight' }
218
+ });
219
+ this.setState({ positionAttributeName: 'positions' });
220
+ }
221
+ _setupTextureParams() {
222
+ const { device } = this.context;
223
+ const { weightsTextureSize } = this.props;
224
+ const textureSize = Math.min(weightsTextureSize, device.limits.maxTextureDimension2D);
225
+ const floatTargetSupport = FLOAT_TARGET_FEATURES.every(feature => device.features.has(feature));
226
+ const format = floatTargetSupport ? 'rgba32float' : 'rgba8unorm';
227
+ const weightsScale = floatTargetSupport ? 1 : 1 / 255;
228
+ this.setState({ textureSize, format, weightsScale });
229
+ if (!floatTargetSupport) {
230
+ log.warn(`HeatmapLayer: ${this.id} rendering to float texture not supported, falling back to low precision format`)();
231
+ }
232
+ }
233
+ _createWeightsTransform(shaders) {
234
+ let { weightsTransform } = this.state;
235
+ const { weightsTexture } = this.state;
236
+ const attributeManager = this.getAttributeManager();
237
+ weightsTransform?.destroy();
238
+ weightsTransform = new TextureTransform(this.context.device, {
239
+ id: `${this.id}-weights-transform`,
240
+ bufferLayout: attributeManager.getBufferLayouts(),
241
+ vertexCount: 1,
242
+ targetTexture: weightsTexture,
243
+ parameters: {
244
+ depthWriteEnabled: false,
245
+ blendColorOperation: 'add',
246
+ blendColorSrcFactor: 'one',
247
+ blendColorDstFactor: 'one',
248
+ blendAlphaSrcFactor: 'one',
249
+ blendAlphaDstFactor: 'one'
250
+ },
251
+ topology: 'point-list',
252
+ ...shaders
253
+ });
254
+ this.setState({ weightsTransform });
255
+ }
256
+ _setupResources() {
257
+ this._createTextures();
258
+ const { device } = this.context;
259
+ const { textureSize, weightsTexture, maxWeightsTexture } = this.state;
260
+ const weightsTransformShaders = this.getShaders({
261
+ vs: weightsVs,
262
+ fs: weightsFs
263
+ });
264
+ this._createWeightsTransform(weightsTransformShaders);
265
+ const maxWeightsTransformShaders = this.getShaders({ vs: maxVs, fs: maxFs });
266
+ const maxWeightTransform = new TextureTransform(device, {
267
+ id: `${this.id}-max-weights-transform`,
268
+ bindings: { inTexture: weightsTexture },
269
+ uniforms: { textureSize },
270
+ targetTexture: maxWeightsTexture,
271
+ ...maxWeightsTransformShaders,
272
+ vertexCount: textureSize * textureSize,
273
+ topology: 'point-list',
274
+ parameters: {
275
+ depthWriteEnabled: false,
276
+ blendColorOperation: 'max',
277
+ blendAlphaOperation: 'max',
278
+ blendColorSrcFactor: 'one',
279
+ blendColorDstFactor: 'one',
280
+ blendAlphaSrcFactor: 'one',
281
+ blendAlphaDstFactor: 'one'
282
+ }
283
+ });
284
+ this.setState({
285
+ weightsTexture,
286
+ maxWeightsTexture,
287
+ maxWeightTransform,
288
+ zoom: null,
289
+ triPositionBuffer: device.createBuffer({ byteLength: 48 }),
290
+ triTexCoordBuffer: device.createBuffer({ byteLength: 48 })
291
+ });
292
+ }
293
+ // overwrite super class method to update transform model
294
+ updateShaders(shaderOptions) {
295
+ // shader params (modules, injects) changed, update model object
296
+ this._createWeightsTransform({
297
+ vs: weightsVs,
298
+ fs: weightsFs,
299
+ ...shaderOptions
300
+ });
301
+ }
302
+ _updateMaxWeightValue() {
303
+ const { maxWeightTransform, textureSize } = this.state;
304
+ maxWeightTransform.run({
305
+ parameters: { viewport: [0, 0, 1, 1] },
306
+ clearColor: [0, 0, 0, 0]
307
+ });
308
+ }
309
+ // Computes world bounds area that needs to be processed for generate heatmap
310
+ _updateBounds(forceUpdate = false) {
311
+ const { viewport } = this.context;
312
+ // Unproject all 4 corners of the current screen coordinates into world coordinates (lng/lat)
313
+ // Takes care of viewport has non zero bearing/pitch (i.e axis not aligned with world coordiante system)
314
+ const viewportCorners = [
315
+ viewport.unproject([0, 0]),
316
+ viewport.unproject([viewport.width, 0]),
317
+ viewport.unproject([viewport.width, viewport.height]),
318
+ viewport.unproject([0, viewport.height])
319
+ ].map(p => p.map(Math.fround));
320
+ // #1: get world bounds for current viewport extends
321
+ const visibleWorldBounds = getBounds(viewportCorners); // TODO: Change to visible bounds
322
+ const newState = { visibleWorldBounds, viewportCorners };
323
+ let boundsChanged = false;
324
+ if (forceUpdate ||
325
+ !this.state.worldBounds ||
326
+ !boundsContain(this.state.worldBounds, visibleWorldBounds)) {
327
+ // #2 : convert world bounds to common (Flat) bounds
328
+ // #3 : extend common bounds to match aspect ratio with viewport
329
+ const scaledCommonBounds = this._worldToCommonBounds(visibleWorldBounds);
330
+ // #4 :convert aligned common bounds to world bounds
331
+ const worldBounds = this._commonToWorldBounds(scaledCommonBounds);
332
+ // Clip webmercator projection limits
333
+ if (this.props.coordinateSystem === COORDINATE_SYSTEM.LNGLAT) {
334
+ worldBounds[1] = Math.max(worldBounds[1], -85.051129);
335
+ worldBounds[3] = Math.min(worldBounds[3], 85.051129);
336
+ worldBounds[0] = Math.max(worldBounds[0], -360);
337
+ worldBounds[2] = Math.min(worldBounds[2], 360);
338
+ }
339
+ // #5: now convert world bounds to common using Layer's coordiante system and origin
340
+ const normalizedCommonBounds = this._worldToCommonBounds(worldBounds);
341
+ newState.worldBounds = worldBounds;
342
+ newState.normalizedCommonBounds = normalizedCommonBounds;
343
+ boundsChanged = true;
344
+ }
345
+ this.setState(newState);
346
+ return boundsChanged;
347
+ }
348
+ _updateTextureRenderingBounds() {
349
+ // Just render visible portion of the texture
350
+ const { triPositionBuffer, triTexCoordBuffer, normalizedCommonBounds, viewportCorners } = this.state;
351
+ const { viewport } = this.context;
352
+ triPositionBuffer.write(packVertices(viewportCorners, 3));
353
+ const textureBounds = viewportCorners.map(p => getTextureCoordinates(viewport.projectPosition(p), normalizedCommonBounds));
354
+ triTexCoordBuffer.write(packVertices(textureBounds, 2));
355
+ }
356
+ _updateColorTexture(opts) {
357
+ const { colorRange } = opts.props;
358
+ let { colorTexture } = this.state;
359
+ const colors = colorRangeToFlatArray(colorRange, false, Uint8Array);
360
+ if (colorTexture && colorTexture?.width === colorRange.length) {
361
+ // TODO(v9): Unclear whether `setSubImageData` is a public API, or what to use if not.
362
+ colorTexture.setSubImageData({ data: colors });
363
+ }
364
+ else {
365
+ colorTexture?.destroy();
366
+ colorTexture = this.context.device.createTexture({
367
+ ...TEXTURE_PROPS,
368
+ data: colors,
369
+ width: colorRange.length,
370
+ height: 1
371
+ });
372
+ }
373
+ this.setState({ colorTexture });
374
+ }
375
+ _updateWeightmap() {
376
+ const { radiusPixels, colorDomain, aggregation } = this.props;
377
+ const { worldBounds, textureSize, weightsScale } = this.state;
378
+ const weightsTransform = this.state.weightsTransform;
379
+ this.state.isWeightMapDirty = false;
380
+ // convert world bounds to common using Layer's coordiante system and origin
381
+ const commonBounds = this._worldToCommonBounds(worldBounds, {
382
+ useLayerCoordinateSystem: true
383
+ });
384
+ if (colorDomain && aggregation === 'SUM') {
385
+ // scale color domain to weight per pixel
386
+ const { viewport } = this.context;
387
+ const metersPerPixel = (viewport.distanceScales.metersPerUnit[2] * (commonBounds[2] - commonBounds[0])) /
388
+ textureSize;
389
+ this.state.colorDomain = colorDomain.map(x => x * metersPerPixel * weightsScale);
390
+ }
391
+ else {
392
+ this.state.colorDomain = colorDomain || DEFAULT_COLOR_DOMAIN;
393
+ }
394
+ const attributeManager = this.getAttributeManager();
395
+ const attributes = attributeManager.getAttributes();
396
+ const moduleSettings = this.getModuleSettings();
397
+ const positions = attributes.positions.buffer;
398
+ const uniforms = { radiusPixels, commonBounds, textureWidth: textureSize, weightsScale };
399
+ const weights = attributes.weights.buffer;
400
+ weightsTransform.model.setAttributes({ positions, weights });
401
+ weightsTransform.model.setVertexCount(this.getNumInstances());
402
+ weightsTransform.model.setUniforms(uniforms);
403
+ weightsTransform.model.updateModuleSettings(moduleSettings);
404
+ weightsTransform.run({
405
+ parameters: { viewport: [0, 0, textureSize, textureSize] },
406
+ clearColor: [0, 0, 0, 0]
407
+ });
408
+ this._updateMaxWeightValue();
409
+ }
410
+ _debouncedUpdateWeightmap(fromTimer = false) {
411
+ let { updateTimer } = this.state;
412
+ const { debounceTimeout } = this.props;
413
+ if (fromTimer) {
414
+ updateTimer = null;
415
+ // update
416
+ this._updateBounds(true);
417
+ this._updateTextureRenderingBounds();
418
+ this.setState({ isWeightMapDirty: true });
419
+ }
420
+ else {
421
+ this.setState({ isWeightMapDirty: false });
422
+ clearTimeout(updateTimer);
423
+ updateTimer = setTimeout(this._debouncedUpdateWeightmap.bind(this, true), debounceTimeout);
424
+ }
425
+ this.setState({ updateTimer });
426
+ }
427
+ // input: worldBounds: [minLong, minLat, maxLong, maxLat]
428
+ // input: opts.useLayerCoordinateSystem : layers coordiante system is used
429
+ // optput: commonBounds: [minX, minY, maxX, maxY] scaled to fit the current texture
430
+ _worldToCommonBounds(worldBounds, opts = {}) {
431
+ const { useLayerCoordinateSystem = false } = opts;
432
+ const [minLong, minLat, maxLong, maxLat] = worldBounds;
433
+ const { viewport } = this.context;
434
+ const { textureSize } = this.state;
435
+ const { coordinateSystem } = this.props;
436
+ const offsetMode = useLayerCoordinateSystem &&
437
+ (coordinateSystem === COORDINATE_SYSTEM.LNGLAT_OFFSETS ||
438
+ coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS);
439
+ const offsetOriginCommon = offsetMode
440
+ ? viewport.projectPosition(this.props.coordinateOrigin)
441
+ : [0, 0];
442
+ const size = (textureSize * RESOLUTION) / viewport.scale;
443
+ let bottomLeftCommon;
444
+ let topRightCommon;
445
+ // Y-axis is flipped between World and Common bounds
446
+ if (useLayerCoordinateSystem && !offsetMode) {
447
+ bottomLeftCommon = this.projectPosition([minLong, minLat, 0]);
448
+ topRightCommon = this.projectPosition([maxLong, maxLat, 0]);
449
+ }
450
+ else {
451
+ bottomLeftCommon = viewport.projectPosition([minLong, minLat, 0]);
452
+ topRightCommon = viewport.projectPosition([maxLong, maxLat, 0]);
453
+ }
454
+ // Ignore z component
455
+ return scaleToAspectRatio([
456
+ bottomLeftCommon[0] - offsetOriginCommon[0],
457
+ bottomLeftCommon[1] - offsetOriginCommon[1],
458
+ topRightCommon[0] - offsetOriginCommon[0],
459
+ topRightCommon[1] - offsetOriginCommon[1]
460
+ ], size, size);
461
+ }
462
+ // input commonBounds: [xMin, yMin, xMax, yMax]
463
+ // output worldBounds: [minLong, minLat, maxLong, maxLat]
464
+ _commonToWorldBounds(commonBounds) {
465
+ const [xMin, yMin, xMax, yMax] = commonBounds;
466
+ const { viewport } = this.context;
467
+ const bottomLeftWorld = viewport.unprojectPosition([xMin, yMin]);
468
+ const topRightWorld = viewport.unprojectPosition([xMax, yMax]);
469
+ return bottomLeftWorld.slice(0, 2).concat(topRightWorld.slice(0, 2));
470
+ }
471
+ }
@@ -7,4 +7,3 @@ void main() {
7
7
  fragColor.g = outTexture.r / max(1.0, outTexture.a);
8
8
  }
9
9
  `;
10
- //# sourceMappingURL=max-fs.glsl.js.map
@@ -0,0 +1,3 @@
1
+ declare const _default: "#version 300 es\nuniform sampler2D inTexture;\nuniform float textureSize;\nout vec4 outTexture;\n\nvoid main()\n{\n // Sample every pixel in texture\n int yIndex = gl_VertexID / int(textureSize);\n int xIndex = gl_VertexID - (yIndex * int(textureSize));\n vec2 uv = (0.5 + vec2(float(xIndex), float(yIndex))) / textureSize;\n outTexture = texture(inTexture, uv);\n\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n // Enforce default value for ANGLE issue (https://bugs.chromium.org/p/angleproject/issues/detail?id=3941)\n gl_PointSize = 1.0;\n}\n";
2
+ export default _default;
3
+ //# sourceMappingURL=max-vs.glsl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"max-vs.glsl.d.ts","sourceRoot":"","sources":["../../src/heatmap-layer/max-vs.glsl.ts"],"names":[],"mappings":";AAAA,wBAYE"}
1
+ {"version":3,"file":"max-vs.glsl.d.ts","sourceRoot":"","sources":["../../src/heatmap-layer/max-vs.glsl.ts"],"names":[],"mappings":";AAAA,wBAkBE"}