@deck.gl/aggregation-layers 9.0.0-beta.1 → 9.0.0-beta.10

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 (360) hide show
  1. package/dist/aggregation-layer.js +153 -0
  2. package/{typed → dist}/contour-layer/contour-layer.d.ts +1 -1
  3. package/dist/contour-layer/contour-layer.d.ts.map +1 -0
  4. package/dist/contour-layer/contour-layer.js +240 -0
  5. package/dist/contour-layer/contour-utils.js +64 -0
  6. package/dist/contour-layer/marching-squares-codes.js +337 -0
  7. package/dist/contour-layer/marching-squares.js +147 -0
  8. package/{typed → dist}/cpu-grid-layer/cpu-grid-layer.d.ts +3 -3
  9. package/dist/cpu-grid-layer/cpu-grid-layer.d.ts.map +1 -0
  10. package/dist/cpu-grid-layer/cpu-grid-layer.js +129 -0
  11. package/dist/cpu-grid-layer/grid-aggregator.js +141 -0
  12. package/dist/dist.dev.js +1439 -10866
  13. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +30 -0
  14. package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +112 -0
  15. package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer.d.ts +1 -1
  16. package/dist/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +1 -0
  17. package/dist/gpu-grid-layer/gpu-grid-cell-layer.js +145 -0
  18. package/{typed → dist}/gpu-grid-layer/gpu-grid-layer.d.ts +4 -4
  19. package/dist/gpu-grid-layer/gpu-grid-layer.d.ts.map +1 -0
  20. package/dist/gpu-grid-layer/gpu-grid-layer.js +288 -0
  21. package/{typed → dist}/grid-aggregation-layer.d.ts +3 -3
  22. package/dist/grid-aggregation-layer.d.ts.map +1 -0
  23. package/dist/grid-aggregation-layer.js +172 -0
  24. package/{typed → dist}/grid-layer/grid-layer.d.ts +2 -2
  25. package/dist/grid-layer/grid-layer.d.ts.map +1 -0
  26. package/dist/grid-layer/grid-layer.js +63 -0
  27. package/{typed → dist}/heatmap-layer/heatmap-layer-utils.d.ts +0 -9
  28. package/dist/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -0
  29. package/dist/heatmap-layer/heatmap-layer-utils.js +63 -0
  30. package/{typed → dist}/heatmap-layer/heatmap-layer.d.ts +5 -6
  31. package/dist/heatmap-layer/heatmap-layer.d.ts.map +1 -0
  32. package/dist/heatmap-layer/heatmap-layer.js +455 -0
  33. package/dist/heatmap-layer/max-fs.glsl.js +9 -0
  34. package/dist/heatmap-layer/max-vs.glsl.d.ts +3 -0
  35. package/{typed → dist}/heatmap-layer/max-vs.glsl.d.ts.map +1 -1
  36. package/dist/heatmap-layer/max-vs.glsl.js +15 -0
  37. package/dist/heatmap-layer/triangle-layer-fragment.glsl.d.ts +3 -0
  38. package/dist/heatmap-layer/triangle-layer-fragment.glsl.js +51 -0
  39. package/dist/heatmap-layer/triangle-layer-vertex.glsl.js +47 -0
  40. package/{typed → dist}/heatmap-layer/triangle-layer.d.ts +10 -2
  41. package/dist/heatmap-layer/triangle-layer.d.ts.map +1 -0
  42. package/dist/heatmap-layer/triangle-layer.js +59 -0
  43. package/dist/heatmap-layer/weights-fs.glsl.js +17 -0
  44. package/dist/heatmap-layer/weights-vs.glsl.d.ts +3 -0
  45. package/{typed → dist}/heatmap-layer/weights-vs.glsl.d.ts.map +1 -1
  46. package/dist/heatmap-layer/weights-vs.glsl.js +21 -0
  47. package/dist/hexagon-layer/hexagon-aggregator.js +112 -0
  48. package/{typed → dist}/hexagon-layer/hexagon-layer.d.ts +4 -4
  49. package/dist/hexagon-layer/hexagon-layer.d.ts.map +1 -0
  50. package/dist/hexagon-layer/hexagon-layer.js +173 -0
  51. package/dist/index.cjs +4327 -0
  52. package/dist/index.cjs.map +7 -0
  53. package/dist/index.d.ts +20 -0
  54. package/dist/index.d.ts.map +1 -0
  55. package/dist/index.js +32 -0
  56. package/{typed → dist}/screen-grid-layer/screen-grid-cell-layer.d.ts +2 -3
  57. package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -0
  58. package/dist/screen-grid-layer/screen-grid-cell-layer.js +163 -0
  59. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.js +35 -0
  60. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.js +72 -0
  61. package/{typed → dist}/screen-grid-layer/screen-grid-layer.d.ts +1 -4
  62. package/dist/screen-grid-layer/screen-grid-layer.d.ts.map +1 -0
  63. package/dist/screen-grid-layer/screen-grid-layer.js +209 -0
  64. package/dist/types.js +1 -0
  65. package/dist/utils/aggregation-operation-utils.js +94 -0
  66. package/{typed → dist}/utils/bin-sorter.d.ts +1 -1
  67. package/dist/utils/bin-sorter.js +167 -0
  68. package/dist/utils/color-utils.js +53 -0
  69. package/dist/utils/cpu-aggregator.js +421 -0
  70. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +36 -0
  71. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +42 -0
  72. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +30 -0
  73. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +61 -0
  74. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +41 -0
  75. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +1 -0
  76. package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts.map +1 -1
  77. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +555 -0
  78. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +32 -0
  79. package/dist/utils/grid-aggregation-utils.js +114 -0
  80. package/dist/utils/prop-utils.js +28 -0
  81. package/dist/utils/resource-utils.js +38 -0
  82. package/dist/utils/scale-utils.js +184 -0
  83. package/dist.min.js +299 -555
  84. package/package.json +19 -14
  85. package/src/contour-layer/contour-layer.ts +2 -3
  86. package/src/cpu-grid-layer/cpu-grid-layer.ts +1 -2
  87. package/src/gpu-grid-layer/gpu-grid-cell-layer.ts +1 -1
  88. package/src/gpu-grid-layer/gpu-grid-layer.ts +2 -2
  89. package/src/heatmap-layer/heatmap-layer-utils.ts +0 -23
  90. package/src/heatmap-layer/heatmap-layer.ts +92 -128
  91. package/src/heatmap-layer/max-vs.glsl.ts +11 -5
  92. package/src/heatmap-layer/triangle-layer-fragment.glsl.ts +2 -2
  93. package/src/heatmap-layer/triangle-layer.ts +17 -23
  94. package/src/heatmap-layer/weights-vs.glsl.ts +4 -2
  95. package/src/hexagon-layer/hexagon-layer.ts +2 -3
  96. package/src/screen-grid-layer/screen-grid-cell-layer.ts +0 -4
  97. package/src/screen-grid-layer/screen-grid-layer.ts +1 -11
  98. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.ts +14 -28
  99. package/dist/es5/aggregation-layer.js +0 -215
  100. package/dist/es5/aggregation-layer.js.map +0 -1
  101. package/dist/es5/contour-layer/contour-layer.js +0 -353
  102. package/dist/es5/contour-layer/contour-layer.js.map +0 -1
  103. package/dist/es5/contour-layer/contour-utils.js +0 -110
  104. package/dist/es5/contour-layer/contour-utils.js.map +0 -1
  105. package/dist/es5/contour-layer/marching-squares-codes.js +0 -152
  106. package/dist/es5/contour-layer/marching-squares-codes.js.map +0 -1
  107. package/dist/es5/contour-layer/marching-squares.js +0 -168
  108. package/dist/es5/contour-layer/marching-squares.js.map +0 -1
  109. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +0 -235
  110. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +0 -1
  111. package/dist/es5/cpu-grid-layer/grid-aggregator.js +0 -180
  112. package/dist/es5/cpu-grid-layer/grid-aggregator.js.map +0 -1
  113. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -9
  114. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js.map +0 -1
  115. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +0 -9
  116. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js.map +0 -1
  117. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +0 -247
  118. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +0 -1
  119. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +0 -424
  120. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +0 -1
  121. package/dist/es5/grid-aggregation-layer.js +0 -280
  122. package/dist/es5/grid-aggregation-layer.js.map +0 -1
  123. package/dist/es5/grid-layer/grid-layer.js +0 -125
  124. package/dist/es5/grid-layer/grid-layer.js.map +0 -1
  125. package/dist/es5/heatmap-layer/heatmap-layer-utils.js +0 -122
  126. package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +0 -1
  127. package/dist/es5/heatmap-layer/heatmap-layer.js +0 -672
  128. package/dist/es5/heatmap-layer/heatmap-layer.js.map +0 -1
  129. package/dist/es5/heatmap-layer/max-fs.glsl.js +0 -9
  130. package/dist/es5/heatmap-layer/max-fs.glsl.js.map +0 -1
  131. package/dist/es5/heatmap-layer/max-vs.glsl.js +0 -9
  132. package/dist/es5/heatmap-layer/max-vs.glsl.js.map +0 -1
  133. package/dist/es5/heatmap-layer/triangle-layer-fragment.glsl.js +0 -9
  134. package/dist/es5/heatmap-layer/triangle-layer-fragment.glsl.js.map +0 -1
  135. package/dist/es5/heatmap-layer/triangle-layer-vertex.glsl.js +0 -9
  136. package/dist/es5/heatmap-layer/triangle-layer-vertex.glsl.js.map +0 -1
  137. package/dist/es5/heatmap-layer/triangle-layer.js +0 -122
  138. package/dist/es5/heatmap-layer/triangle-layer.js.map +0 -1
  139. package/dist/es5/heatmap-layer/weights-fs.glsl.js +0 -9
  140. package/dist/es5/heatmap-layer/weights-fs.glsl.js.map +0 -1
  141. package/dist/es5/heatmap-layer/weights-vs.glsl.js +0 -9
  142. package/dist/es5/heatmap-layer/weights-vs.glsl.js.map +0 -1
  143. package/dist/es5/hexagon-layer/hexagon-aggregator.js +0 -118
  144. package/dist/es5/hexagon-layer/hexagon-aggregator.js.map +0 -1
  145. package/dist/es5/hexagon-layer/hexagon-layer.js +0 -289
  146. package/dist/es5/hexagon-layer/hexagon-layer.js.map +0 -1
  147. package/dist/es5/index.js +0 -104
  148. package/dist/es5/index.js.map +0 -1
  149. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +0 -244
  150. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +0 -1
  151. package/dist/es5/screen-grid-layer/screen-grid-layer-fragment.glsl.js +0 -9
  152. package/dist/es5/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +0 -1
  153. package/dist/es5/screen-grid-layer/screen-grid-layer-vertex.glsl.js +0 -9
  154. package/dist/es5/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +0 -1
  155. package/dist/es5/screen-grid-layer/screen-grid-layer.js +0 -317
  156. package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +0 -1
  157. package/dist/es5/types.js +0 -2
  158. package/dist/es5/types.js.map +0 -1
  159. package/dist/es5/utils/aggregation-operation-utils.js +0 -123
  160. package/dist/es5/utils/aggregation-operation-utils.js.map +0 -1
  161. package/dist/es5/utils/bin-sorter.js +0 -248
  162. package/dist/es5/utils/bin-sorter.js.map +0 -1
  163. package/dist/es5/utils/color-utils.js +0 -39
  164. package/dist/es5/utils/color-utils.js.map +0 -1
  165. package/dist/es5/utils/cpu-aggregator.js +0 -496
  166. package/dist/es5/utils/cpu-aggregator.js.map +0 -1
  167. package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -9
  168. package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js.map +0 -1
  169. package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -9
  170. package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js.map +0 -1
  171. package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -9
  172. package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js.map +0 -1
  173. package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +0 -9
  174. package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js.map +0 -1
  175. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -63
  176. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +0 -1
  177. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -2
  178. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js.map +0 -1
  179. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -732
  180. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +0 -1
  181. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +0 -155
  182. package/dist/es5/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -9
  183. package/dist/es5/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js.map +0 -1
  184. package/dist/es5/utils/grid-aggregation-utils.js +0 -118
  185. package/dist/es5/utils/grid-aggregation-utils.js.map +0 -1
  186. package/dist/es5/utils/prop-utils.js +0 -19
  187. package/dist/es5/utils/prop-utils.js.map +0 -1
  188. package/dist/es5/utils/resource-utils.js +0 -59
  189. package/dist/es5/utils/resource-utils.js.map +0 -1
  190. package/dist/es5/utils/scale-utils.js +0 -254
  191. package/dist/es5/utils/scale-utils.js.map +0 -1
  192. package/dist/esm/aggregation-layer.js +0 -156
  193. package/dist/esm/aggregation-layer.js.map +0 -1
  194. package/dist/esm/contour-layer/contour-layer.js +0 -316
  195. package/dist/esm/contour-layer/contour-layer.js.map +0 -1
  196. package/dist/esm/contour-layer/contour-utils.js +0 -81
  197. package/dist/esm/contour-layer/contour-utils.js.map +0 -1
  198. package/dist/esm/contour-layer/marching-squares-codes.js +0 -219
  199. package/dist/esm/contour-layer/marching-squares-codes.js.map +0 -1
  200. package/dist/esm/contour-layer/marching-squares.js +0 -151
  201. package/dist/esm/contour-layer/marching-squares.js.map +0 -1
  202. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js +0 -186
  203. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js.map +0 -1
  204. package/dist/esm/cpu-grid-layer/grid-aggregator.js +0 -142
  205. package/dist/esm/cpu-grid-layer/grid-aggregator.js.map +0 -1
  206. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -16
  207. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js.map +0 -1
  208. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +0 -122
  209. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js.map +0 -1
  210. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js +0 -196
  211. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js.map +0 -1
  212. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js +0 -399
  213. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js.map +0 -1
  214. package/dist/esm/grid-aggregation-layer.js +0 -240
  215. package/dist/esm/grid-aggregation-layer.js.map +0 -1
  216. package/dist/esm/grid-layer/grid-layer.js +0 -80
  217. package/dist/esm/grid-layer/grid-layer.js.map +0 -1
  218. package/dist/esm/heatmap-layer/heatmap-layer-utils.js +0 -68
  219. package/dist/esm/heatmap-layer/heatmap-layer-utils.js.map +0 -1
  220. package/dist/esm/heatmap-layer/heatmap-layer.js +0 -626
  221. package/dist/esm/heatmap-layer/heatmap-layer.js.map +0 -1
  222. package/dist/esm/heatmap-layer/max-fs.glsl.js +0 -10
  223. package/dist/esm/heatmap-layer/max-fs.glsl.js.map +0 -1
  224. package/dist/esm/heatmap-layer/max-vs.glsl.js +0 -14
  225. package/dist/esm/heatmap-layer/max-vs.glsl.js.map +0 -1
  226. package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js +0 -43
  227. package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js.map +0 -1
  228. package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js +0 -33
  229. package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js.map +0 -1
  230. package/dist/esm/heatmap-layer/triangle-layer.js +0 -80
  231. package/dist/esm/heatmap-layer/triangle-layer.js.map +0 -1
  232. package/dist/esm/heatmap-layer/weights-fs.glsl.js +0 -22
  233. package/dist/esm/heatmap-layer/weights-fs.glsl.js.map +0 -1
  234. package/dist/esm/heatmap-layer/weights-vs.glsl.js +0 -25
  235. package/dist/esm/heatmap-layer/weights-vs.glsl.js.map +0 -1
  236. package/dist/esm/hexagon-layer/hexagon-aggregator.js +0 -87
  237. package/dist/esm/hexagon-layer/hexagon-aggregator.js.map +0 -1
  238. package/dist/esm/hexagon-layer/hexagon-layer.js +0 -232
  239. package/dist/esm/hexagon-layer/hexagon-layer.js.map +0 -1
  240. package/dist/esm/index.js +0 -13
  241. package/dist/esm/index.js.map +0 -1
  242. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js +0 -203
  243. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js.map +0 -1
  244. package/dist/esm/screen-grid-layer/screen-grid-layer-fragment.glsl.js +0 -21
  245. package/dist/esm/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +0 -1
  246. package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js +0 -66
  247. package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +0 -1
  248. package/dist/esm/screen-grid-layer/screen-grid-layer.js +0 -285
  249. package/dist/esm/screen-grid-layer/screen-grid-layer.js.map +0 -1
  250. package/dist/esm/types.js +0 -2
  251. package/dist/esm/types.js.map +0 -1
  252. package/dist/esm/utils/aggregation-operation-utils.js +0 -91
  253. package/dist/esm/utils/aggregation-operation-utils.js.map +0 -1
  254. package/dist/esm/utils/bin-sorter.js +0 -165
  255. package/dist/esm/utils/bin-sorter.js.map +0 -1
  256. package/dist/esm/utils/color-utils.js +0 -28
  257. package/dist/esm/utils/color-utils.js.map +0 -1
  258. package/dist/esm/utils/cpu-aggregator.js +0 -487
  259. package/dist/esm/utils/cpu-aggregator.js.map +0 -1
  260. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -21
  261. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js.map +0 -1
  262. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -35
  263. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js.map +0 -1
  264. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -16
  265. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js.map +0 -1
  266. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +0 -60
  267. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js.map +0 -1
  268. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -42
  269. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +0 -1
  270. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -2
  271. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js.map +0 -1
  272. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -720
  273. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +0 -1
  274. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +0 -155
  275. package/dist/esm/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -19
  276. package/dist/esm/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js.map +0 -1
  277. package/dist/esm/utils/grid-aggregation-utils.js +0 -109
  278. package/dist/esm/utils/grid-aggregation-utils.js.map +0 -1
  279. package/dist/esm/utils/prop-utils.js +0 -12
  280. package/dist/esm/utils/prop-utils.js.map +0 -1
  281. package/dist/esm/utils/resource-utils.js +0 -44
  282. package/dist/esm/utils/resource-utils.js.map +0 -1
  283. package/dist/esm/utils/scale-utils.js +0 -192
  284. package/dist/esm/utils/scale-utils.js.map +0 -1
  285. package/typed/contour-layer/contour-layer.d.ts.map +0 -1
  286. package/typed/cpu-grid-layer/cpu-grid-layer.d.ts.map +0 -1
  287. package/typed/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +0 -1
  288. package/typed/gpu-grid-layer/gpu-grid-layer.d.ts.map +0 -1
  289. package/typed/grid-aggregation-layer.d.ts.map +0 -1
  290. package/typed/grid-layer/grid-layer.d.ts.map +0 -1
  291. package/typed/heatmap-layer/heatmap-layer-utils.d.ts.map +0 -1
  292. package/typed/heatmap-layer/heatmap-layer.d.ts.map +0 -1
  293. package/typed/heatmap-layer/max-vs.glsl.d.ts +0 -3
  294. package/typed/heatmap-layer/triangle-layer-fragment.glsl.d.ts +0 -3
  295. package/typed/heatmap-layer/triangle-layer.d.ts.map +0 -1
  296. package/typed/heatmap-layer/weights-vs.glsl.d.ts +0 -3
  297. package/typed/hexagon-layer/hexagon-layer.d.ts.map +0 -1
  298. package/typed/index.d.ts +0 -20
  299. package/typed/index.d.ts.map +0 -1
  300. package/typed/screen-grid-layer/screen-grid-cell-layer.d.ts.map +0 -1
  301. package/typed/screen-grid-layer/screen-grid-layer.d.ts.map +0 -1
  302. /package/{typed → dist}/aggregation-layer.d.ts +0 -0
  303. /package/{typed → dist}/aggregation-layer.d.ts.map +0 -0
  304. /package/{typed → dist}/contour-layer/contour-utils.d.ts +0 -0
  305. /package/{typed → dist}/contour-layer/contour-utils.d.ts.map +0 -0
  306. /package/{typed → dist}/contour-layer/marching-squares-codes.d.ts +0 -0
  307. /package/{typed → dist}/contour-layer/marching-squares-codes.d.ts.map +0 -0
  308. /package/{typed → dist}/contour-layer/marching-squares.d.ts +0 -0
  309. /package/{typed → dist}/contour-layer/marching-squares.d.ts.map +0 -0
  310. /package/{typed → dist}/cpu-grid-layer/grid-aggregator.d.ts +0 -0
  311. /package/{typed → dist}/cpu-grid-layer/grid-aggregator.d.ts.map +0 -0
  312. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts +0 -0
  313. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts.map +0 -0
  314. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts +0 -0
  315. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts.map +0 -0
  316. /package/{typed → dist}/heatmap-layer/max-fs.glsl.d.ts +0 -0
  317. /package/{typed → dist}/heatmap-layer/max-fs.glsl.d.ts.map +0 -0
  318. /package/{typed → dist}/heatmap-layer/triangle-layer-fragment.glsl.d.ts.map +0 -0
  319. /package/{typed → dist}/heatmap-layer/triangle-layer-vertex.glsl.d.ts +0 -0
  320. /package/{typed → dist}/heatmap-layer/triangle-layer-vertex.glsl.d.ts.map +0 -0
  321. /package/{typed → dist}/heatmap-layer/weights-fs.glsl.d.ts +0 -0
  322. /package/{typed → dist}/heatmap-layer/weights-fs.glsl.d.ts.map +0 -0
  323. /package/{typed → dist}/hexagon-layer/hexagon-aggregator.d.ts +0 -0
  324. /package/{typed → dist}/hexagon-layer/hexagon-aggregator.d.ts.map +0 -0
  325. /package/{typed → dist}/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts +0 -0
  326. /package/{typed → dist}/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts.map +0 -0
  327. /package/{typed → dist}/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts +0 -0
  328. /package/{typed → dist}/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts.map +0 -0
  329. /package/{typed → dist}/types.d.ts +0 -0
  330. /package/{typed → dist}/types.d.ts.map +0 -0
  331. /package/{typed → dist}/utils/aggregation-operation-utils.d.ts +0 -0
  332. /package/{typed → dist}/utils/aggregation-operation-utils.d.ts.map +0 -0
  333. /package/{typed → dist}/utils/bin-sorter.d.ts.map +0 -0
  334. /package/{typed → dist}/utils/color-utils.d.ts +0 -0
  335. /package/{typed → dist}/utils/color-utils.d.ts.map +0 -0
  336. /package/{typed → dist}/utils/cpu-aggregator.d.ts +0 -0
  337. /package/{typed → dist}/utils/cpu-aggregator.d.ts.map +0 -0
  338. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts +0 -0
  339. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts.map +0 -0
  340. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts +0 -0
  341. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts.map +0 -0
  342. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts +0 -0
  343. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts.map +0 -0
  344. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts +0 -0
  345. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts.map +0 -0
  346. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts +0 -0
  347. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts.map +0 -0
  348. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts +0 -0
  349. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts.map +0 -0
  350. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts +0 -0
  351. /package/{typed → dist}/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts +0 -0
  352. /package/{typed → dist}/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts.map +0 -0
  353. /package/{typed → dist}/utils/grid-aggregation-utils.d.ts +0 -0
  354. /package/{typed → dist}/utils/grid-aggregation-utils.d.ts.map +0 -0
  355. /package/{typed → dist}/utils/prop-utils.d.ts +0 -0
  356. /package/{typed → dist}/utils/prop-utils.d.ts.map +0 -0
  357. /package/{typed → dist}/utils/resource-utils.d.ts +0 -0
  358. /package/{typed → dist}/utils/resource-utils.d.ts.map +0 -0
  359. /package/{typed → dist}/utils/scale-utils.d.ts +0 -0
  360. /package/{typed → dist}/utils/scale-utils.d.ts.map +0 -0
package/dist/index.cjs ADDED
@@ -0,0 +1,4327 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // dist/index.js
21
+ var dist_exports = {};
22
+ __export(dist_exports, {
23
+ AGGREGATION_OPERATION: () => AGGREGATION_OPERATION,
24
+ CPUGridLayer: () => CPUGridLayer,
25
+ ContourLayer: () => ContourLayer,
26
+ GPUGridLayer: () => GPUGridLayer,
27
+ GridLayer: () => GridLayer,
28
+ HeatmapLayer: () => HeatmapLayer,
29
+ HexagonLayer: () => HexagonLayer,
30
+ ScreenGridLayer: () => ScreenGridLayer,
31
+ _AggregationLayer: () => AggregationLayer,
32
+ _BinSorter: () => BinSorter,
33
+ _CPUAggregator: () => CPUAggregator,
34
+ _GPUGridAggregator: () => GPUGridAggregator
35
+ });
36
+ module.exports = __toCommonJS(dist_exports);
37
+
38
+ // dist/screen-grid-layer/screen-grid-layer.js
39
+ var import_core8 = require("@deck.gl/core");
40
+
41
+ // dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.js
42
+ var import_engine = require("@luma.gl/engine");
43
+ var import_shadertools = require("@luma.gl/shadertools");
44
+ var import_constants2 = require("@luma.gl/constants");
45
+ var import_core = require("@deck.gl/core");
46
+
47
+ // dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js
48
+ var import_constants = require("@luma.gl/constants");
49
+
50
+ // dist/utils/aggregation-operation-utils.js
51
+ var AGGREGATION_OPERATION = {
52
+ SUM: 1,
53
+ MEAN: 2,
54
+ MIN: 3,
55
+ MAX: 4
56
+ };
57
+ function sumReducer(accu, cur) {
58
+ return accu + cur;
59
+ }
60
+ function maxReducer(accu, cur) {
61
+ return cur > accu ? cur : accu;
62
+ }
63
+ function minReducer(accu, cur) {
64
+ return cur < accu ? cur : accu;
65
+ }
66
+ function getMean(pts, accessor) {
67
+ if (Number.isFinite(accessor)) {
68
+ return pts.length ? accessor : null;
69
+ }
70
+ const filtered = pts.map(accessor).filter(Number.isFinite);
71
+ return filtered.length ? filtered.reduce(sumReducer, 0) / filtered.length : null;
72
+ }
73
+ function getSum(pts, accessor) {
74
+ if (Number.isFinite(accessor)) {
75
+ return pts.length ? pts.length * accessor : null;
76
+ }
77
+ const filtered = pts.map(accessor).filter(Number.isFinite);
78
+ return filtered.length ? filtered.reduce(sumReducer, 0) : null;
79
+ }
80
+ function getMax(pts, accessor) {
81
+ if (Number.isFinite(accessor)) {
82
+ return pts.length ? accessor : null;
83
+ }
84
+ const filtered = pts.map(accessor).filter(Number.isFinite);
85
+ return filtered.length ? filtered.reduce(maxReducer, -Infinity) : null;
86
+ }
87
+ function getMin(pts, accessor) {
88
+ if (Number.isFinite(accessor)) {
89
+ return pts.length ? accessor : null;
90
+ }
91
+ const filtered = pts.map(accessor).filter(Number.isFinite);
92
+ return filtered.length ? filtered.reduce(minReducer, Infinity) : null;
93
+ }
94
+ function getValueFunc(aggregation, accessor, context) {
95
+ const op = AGGREGATION_OPERATION[aggregation] || AGGREGATION_OPERATION.SUM;
96
+ accessor = wrapAccessor(accessor, context);
97
+ switch (op) {
98
+ case AGGREGATION_OPERATION.MIN:
99
+ return (pts) => getMin(pts, accessor);
100
+ case AGGREGATION_OPERATION.SUM:
101
+ return (pts) => getSum(pts, accessor);
102
+ case AGGREGATION_OPERATION.MEAN:
103
+ return (pts) => getMean(pts, accessor);
104
+ case AGGREGATION_OPERATION.MAX:
105
+ return (pts) => getMax(pts, accessor);
106
+ default:
107
+ return null;
108
+ }
109
+ }
110
+ function wrapAccessor(accessor, context = {}) {
111
+ if (Number.isFinite(accessor)) {
112
+ return accessor;
113
+ }
114
+ return (pt) => {
115
+ context.index = pt.index;
116
+ return accessor(pt.source, context);
117
+ };
118
+ }
119
+ function wrapGetValueFunc(getValue, context = {}) {
120
+ return (pts) => {
121
+ context.indices = pts.map((pt) => pt.index);
122
+ return getValue(pts.map((pt) => pt.source), context);
123
+ };
124
+ }
125
+
126
+ // dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js
127
+ var DEFAULT_RUN_PARAMS = {
128
+ projectPoints: false,
129
+ viewport: null,
130
+ createBufferObjects: true,
131
+ moduleSettings: {}
132
+ };
133
+ var MAX_32_BIT_FLOAT = 3402823466e29;
134
+ var MIN_BLEND_EQUATION = [32775, 32774];
135
+ var MAX_BLEND_EQUATION = [32776, 32774];
136
+ var MAX_MIN_BLEND_EQUATION = [32776, 32775];
137
+ var EQUATION_MAP = {
138
+ [AGGREGATION_OPERATION.SUM]: 32774,
139
+ [AGGREGATION_OPERATION.MEAN]: 32774,
140
+ [AGGREGATION_OPERATION.MIN]: MIN_BLEND_EQUATION,
141
+ [AGGREGATION_OPERATION.MAX]: MAX_BLEND_EQUATION
142
+ };
143
+ var DEFAULT_WEIGHT_PARAMS = {
144
+ size: 1,
145
+ operation: AGGREGATION_OPERATION.SUM,
146
+ needMin: false,
147
+ needMax: false,
148
+ combineMaxMin: false
149
+ };
150
+ var PIXEL_SIZE = 4;
151
+
152
+ // dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js
153
+ var aggregate_to_grid_vs_glsl_default = `#version 300 es
154
+ #define SHADER_NAME gpu-aggregation-to-grid-vs
155
+ in vec3 positions;
156
+ in vec3 positions64Low;
157
+ in vec3 weights;
158
+ uniform vec2 cellSize;
159
+ uniform vec2 gridSize;
160
+ uniform bool projectPoints;
161
+ uniform vec2 translation;
162
+ uniform vec3 scaling;
163
+ out vec3 vWeights;
164
+ vec2 project_to_pixel(vec4 pos) {
165
+ vec4 result;
166
+ pos.xy = pos.xy/pos.w;
167
+ result = pos + vec4(translation, 0., 0.);
168
+ result.xy = scaling.z > 0. ? result.xy * scaling.xy : result.xy;
169
+ return result.xy;
170
+ }
171
+ void main(void) {
172
+ vWeights = weights;
173
+ vec4 windowPos = vec4(positions, 1.);
174
+ if (projectPoints) {
175
+ windowPos = project_position_to_clipspace(positions, positions64Low, vec3(0));
176
+ }
177
+ vec2 pos = project_to_pixel(windowPos);
178
+ vec2 pixelXY64[2];
179
+ pixelXY64[0] = vec2(pos.x, 0.);
180
+ pixelXY64[1] = vec2(pos.y, 0.);
181
+ vec2 gridXY64[2];
182
+ gridXY64[0] = div_fp64(pixelXY64[0], vec2(cellSize.x, 0));
183
+ gridXY64[1] = div_fp64(pixelXY64[1], vec2(cellSize.y, 0));
184
+ float x = floor(gridXY64[0].x);
185
+ float y = floor(gridXY64[1].x);
186
+ pos = vec2(x, y);
187
+ pos = (pos * (2., 2.) / (gridSize)) - (1., 1.);
188
+ vec2 offset = 1.0 / gridSize;
189
+ pos = pos + offset;
190
+ gl_Position = vec4(pos, 0.0, 1.0);
191
+ gl_PointSize = 1.0;
192
+ }
193
+ `;
194
+
195
+ // dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js
196
+ var aggregate_to_grid_fs_glsl_default = `#version 300 es
197
+ #define SHADER_NAME gpu-aggregation-to-grid-fs
198
+ precision highp float;
199
+ in vec3 vWeights;
200
+ out vec4 fragColor;
201
+ void main(void) {
202
+ fragColor = vec4(vWeights, 1.0);
203
+ DECKGL_FILTER_COLOR(fragColor, geometry);
204
+ }
205
+ `;
206
+
207
+ // dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js
208
+ var aggregate_all_vs_glsl_default = `#version 300 es
209
+ #define SHADER_NAME gpu-aggregation-all-vs-64
210
+ in vec2 position;
211
+ uniform ivec2 gridSize;
212
+ out vec2 vTextureCoord;
213
+ void main(void) {
214
+ vec2 pos = vec2(-1.0, -1.0);
215
+ vec2 offset = 1.0 / vec2(gridSize);
216
+ pos = pos + offset;
217
+ gl_Position = vec4(pos, 0.0, 1.0);
218
+ int yIndex = gl_InstanceID / gridSize[0];
219
+ int xIndex = gl_InstanceID - (yIndex * gridSize[0]);
220
+ vec2 yIndexFP64 = vec2(float(yIndex), 0.);
221
+ vec2 xIndexFP64 = vec2(float(xIndex), 0.);
222
+ vec2 gridSizeYFP64 = vec2(gridSize[1], 0.);
223
+ vec2 gridSizeXFP64 = vec2(gridSize[0], 0.);
224
+ vec2 texCoordXFP64 = div_fp64(yIndexFP64, gridSizeYFP64);
225
+ vec2 texCoordYFP64 = div_fp64(xIndexFP64, gridSizeXFP64);
226
+ vTextureCoord = vec2(texCoordYFP64.x, texCoordXFP64.x);
227
+ gl_PointSize = 1.0;
228
+ }
229
+ `;
230
+
231
+ // dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js
232
+ var aggregate_all_fs_glsl_default = `#version 300 es
233
+ #define SHADER_NAME gpu-aggregation-all-fs
234
+ precision highp float;
235
+ in vec2 vTextureCoord;
236
+ uniform sampler2D uSampler;
237
+ uniform bool combineMaxMin;
238
+ out vec4 fragColor;
239
+ void main(void) {
240
+ vec4 textureColor = texture(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));
241
+ if (textureColor.a == 0.) {
242
+ discard;
243
+ }
244
+ fragColor.rgb = textureColor.rgb;
245
+ fragColor.a = combineMaxMin ? textureColor.r : textureColor.a;
246
+ }
247
+ `;
248
+
249
+ // dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js
250
+ var transform_mean_vs_glsl_default = `#version 300 es
251
+ #define SHADER_NAME gpu-aggregation-transform-mean-vs
252
+ in vec4 aggregationValues;
253
+ out vec4 meanValues;
254
+ void main()
255
+ {
256
+ bool isCellValid = bool(aggregationValues.w > 0.);
257
+ meanValues.xyz = isCellValid ? aggregationValues.xyz/aggregationValues.w : vec3(0, 0, 0);
258
+ meanValues.w = aggregationValues.w;
259
+ gl_PointSize = 1.0;
260
+ }
261
+ `;
262
+
263
+ // dist/utils/resource-utils.js
264
+ var DEFAULT_PARAMETERS = {
265
+ minFilter: "nearest",
266
+ magFilter: "nearest"
267
+ };
268
+ function getFloatTexture(device, opts) {
269
+ const { width = 1, height = 1, data = null, parameters = DEFAULT_PARAMETERS } = opts;
270
+ const texture = device.createTexture({
271
+ data,
272
+ format: "rgba32float",
273
+ mipmaps: false,
274
+ sampler: parameters,
275
+ width,
276
+ height
277
+ });
278
+ return texture;
279
+ }
280
+ function getFramebuffer(device, opts) {
281
+ const { id, width = 1, height = 1, texture } = opts;
282
+ const fb = device.createFramebuffer({
283
+ id,
284
+ width,
285
+ height,
286
+ colorAttachments: [texture]
287
+ });
288
+ return fb;
289
+ }
290
+
291
+ // dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.js
292
+ var BUFFER_NAMES = ["aggregationBuffer", "maxMinBuffer", "minBuffer", "maxBuffer"];
293
+ var ARRAY_BUFFER_MAP = {
294
+ maxData: "maxBuffer",
295
+ minData: "minBuffer",
296
+ maxMinData: "maxMinBuffer"
297
+ };
298
+ var REQUIRED_FEATURES = [
299
+ "float32-renderable-webgl",
300
+ "texture-blend-float-webgl"
301
+ ];
302
+ var GPUGridAggregator = class {
303
+ static getAggregationData({ aggregationData, maxData, minData, maxMinData, pixelIndex }) {
304
+ const index = pixelIndex * PIXEL_SIZE;
305
+ const results = {};
306
+ if (aggregationData) {
307
+ results.cellCount = aggregationData[index + 3];
308
+ results.cellWeight = aggregationData[index];
309
+ }
310
+ if (maxMinData) {
311
+ results.maxCellWieght = maxMinData[0];
312
+ results.minCellWeight = maxMinData[3];
313
+ } else {
314
+ if (maxData) {
315
+ results.maxCellWieght = maxData[0];
316
+ results.totalCount = maxData[3];
317
+ }
318
+ if (minData) {
319
+ results.minCellWeight = minData[0];
320
+ results.totalCount = minData[3];
321
+ }
322
+ }
323
+ return results;
324
+ }
325
+ static getCellData({ countsData, size = 1 }) {
326
+ const numCells = countsData.length / 4;
327
+ const cellWeights = new Float32Array(numCells * size);
328
+ const cellCounts = new Uint32Array(numCells);
329
+ for (let i = 0; i < numCells; i++) {
330
+ for (let sizeIndex = 0; sizeIndex < size; sizeIndex++) {
331
+ cellWeights[i * size + sizeIndex] = countsData[i * 4 + sizeIndex];
332
+ }
333
+ cellCounts[i] = countsData[i * 4 + 3];
334
+ }
335
+ return { cellCounts, cellWeights };
336
+ }
337
+ static isSupported(device) {
338
+ return REQUIRED_FEATURES.every((feature) => device.features.has(feature));
339
+ }
340
+ constructor(device, props = {}) {
341
+ this.state = {
342
+ weightAttributes: {},
343
+ textures: {},
344
+ meanTextures: {},
345
+ buffers: {},
346
+ framebuffers: {},
347
+ maxMinFramebuffers: {},
348
+ minFramebuffers: {},
349
+ maxFramebuffers: {},
350
+ equations: {},
351
+ shaderOptions: {},
352
+ modelDirty: false,
353
+ resources: {},
354
+ results: {}
355
+ };
356
+ this.id = props.id || "gpu-grid-aggregator";
357
+ this.device = device;
358
+ const REQUIRED_FEATURES2 = [
359
+ "float32-renderable-webgl"
360
+ ];
361
+ this._hasGPUSupport = REQUIRED_FEATURES2.every((feature) => device.features.has(feature));
362
+ if (this._hasGPUSupport) {
363
+ this._setupModels();
364
+ }
365
+ }
366
+ delete() {
367
+ const { gridAggregationModel, allAggregationModel, meanTransform } = this;
368
+ const { textures, framebuffers, maxMinFramebuffers, minFramebuffers, maxFramebuffers, meanTextures, resources } = this.state;
369
+ gridAggregationModel == null ? void 0 : gridAggregationModel.destroy();
370
+ allAggregationModel == null ? void 0 : allAggregationModel.destroy();
371
+ meanTransform == null ? void 0 : meanTransform.destroy();
372
+ deleteResources([
373
+ framebuffers,
374
+ textures,
375
+ maxMinFramebuffers,
376
+ minFramebuffers,
377
+ maxFramebuffers,
378
+ meanTextures,
379
+ resources
380
+ ]);
381
+ }
382
+ run(opts = {}) {
383
+ this.setState({ results: {} });
384
+ const aggregationParams = this._normalizeAggregationParams(opts);
385
+ return this._runAggregation(aggregationParams);
386
+ }
387
+ getData(weightId) {
388
+ const data = {};
389
+ const results = this.state.results;
390
+ if (!results[weightId].aggregationData) {
391
+ results[weightId].aggregationData = results[weightId].aggregationBuffer.getData();
392
+ }
393
+ data.aggregationData = results[weightId].aggregationData;
394
+ for (const arrayName in ARRAY_BUFFER_MAP) {
395
+ const bufferName = ARRAY_BUFFER_MAP[arrayName];
396
+ if (results[weightId][arrayName] || results[weightId][bufferName]) {
397
+ results[weightId][arrayName] = results[weightId][arrayName] || results[weightId][bufferName].getData();
398
+ data[arrayName] = results[weightId][arrayName];
399
+ }
400
+ }
401
+ return data;
402
+ }
403
+ updateShaders(shaderOptions = {}) {
404
+ this.setState({ shaderOptions, modelDirty: true });
405
+ }
406
+ _normalizeAggregationParams(opts) {
407
+ const aggregationParams = { ...DEFAULT_RUN_PARAMS, ...opts };
408
+ const { weights } = aggregationParams;
409
+ if (weights) {
410
+ aggregationParams.weights = normalizeWeightParams(weights);
411
+ }
412
+ return aggregationParams;
413
+ }
414
+ setState(updateObject) {
415
+ Object.assign(this.state, updateObject);
416
+ }
417
+ _getAggregateData(opts) {
418
+ const results = {};
419
+ const { textures, framebuffers, maxMinFramebuffers, minFramebuffers, maxFramebuffers, resources } = this.state;
420
+ const { weights } = opts;
421
+ for (const id in weights) {
422
+ results[id] = {};
423
+ const { needMin, needMax, combineMaxMin } = weights[id];
424
+ results[id].aggregationTexture = textures[id];
425
+ results[id].aggregationBuffer = this.device.readPixelsToBufferWebGL(framebuffers[id], {
426
+ target: weights[id].aggregationBuffer,
427
+ sourceType: 5126
428
+ });
429
+ if (needMin && needMax && combineMaxMin) {
430
+ results[id].maxMinBuffer = this.device.readPixelsToBufferWebGL(maxMinFramebuffers[id], {
431
+ target: weights[id].maxMinBuffer,
432
+ sourceType: 5126
433
+ });
434
+ results[id].maxMinTexture = resources[`${id}-maxMinTexture`];
435
+ } else {
436
+ if (needMin) {
437
+ results[id].minBuffer = this.device.readPixelsToBufferWebGL(minFramebuffers[id], {
438
+ target: weights[id].minBuffer,
439
+ sourceType: 5126
440
+ });
441
+ results[id].minTexture = resources[`${id}-minTexture`];
442
+ }
443
+ if (needMax) {
444
+ results[id].maxBuffer = this.device.readPixelsToBufferWebGL(maxFramebuffers[id], {
445
+ target: weights[id].maxBuffer,
446
+ sourceType: 5126
447
+ });
448
+ results[id].maxTexture = resources[`${id}-maxTexture`];
449
+ }
450
+ }
451
+ }
452
+ this._trackGPUResultBuffers(results, weights);
453
+ return results;
454
+ }
455
+ _renderAggregateData(opts) {
456
+ const { cellSize, projectPoints, attributes, moduleSettings, numCol, numRow, weights, translation, scaling } = opts;
457
+ const { maxMinFramebuffers, minFramebuffers, maxFramebuffers } = this.state;
458
+ const gridSize = [numCol, numRow];
459
+ const parameters = {
460
+ blend: true,
461
+ depthTest: false,
462
+ blendFunc: [1, 1]
463
+ };
464
+ const uniforms = {
465
+ cellSize,
466
+ gridSize,
467
+ projectPoints,
468
+ translation,
469
+ scaling
470
+ };
471
+ for (const id in weights) {
472
+ const { needMin, needMax } = weights[id];
473
+ const combineMaxMin = needMin && needMax && weights[id].combineMaxMin;
474
+ this._renderToWeightsTexture({
475
+ id,
476
+ parameters,
477
+ moduleSettings,
478
+ uniforms,
479
+ gridSize,
480
+ attributes,
481
+ weights
482
+ });
483
+ if (combineMaxMin) {
484
+ this._renderToMaxMinTexture({
485
+ id,
486
+ parameters: { ...parameters, blendEquation: MAX_MIN_BLEND_EQUATION },
487
+ gridSize,
488
+ minOrMaxFb: maxMinFramebuffers[id],
489
+ clearParams: { clearColor: [0, 0, 0, MAX_32_BIT_FLOAT] },
490
+ combineMaxMin
491
+ });
492
+ } else {
493
+ if (needMin) {
494
+ this._renderToMaxMinTexture({
495
+ id,
496
+ parameters: { ...parameters, blendEquation: MIN_BLEND_EQUATION },
497
+ gridSize,
498
+ minOrMaxFb: minFramebuffers[id],
499
+ clearParams: { clearColor: [MAX_32_BIT_FLOAT, MAX_32_BIT_FLOAT, MAX_32_BIT_FLOAT, 0] },
500
+ combineMaxMin
501
+ });
502
+ }
503
+ if (needMax) {
504
+ this._renderToMaxMinTexture({
505
+ id,
506
+ parameters: { ...parameters, blendEquation: MAX_BLEND_EQUATION },
507
+ gridSize,
508
+ minOrMaxFb: maxFramebuffers[id],
509
+ clearParams: { clearColor: [0, 0, 0, 0] },
510
+ combineMaxMin
511
+ });
512
+ }
513
+ }
514
+ }
515
+ }
516
+ _renderToMaxMinTexture(opts) {
517
+ const { id, parameters, gridSize, minOrMaxFb, combineMaxMin, clearParams = {} } = opts;
518
+ const { framebuffers } = this.state;
519
+ const { allAggregationModel } = this;
520
+ this.device.withParametersWebGL({
521
+ ...clearParams,
522
+ framebuffer: minOrMaxFb,
523
+ viewport: [0, 0, gridSize[0], gridSize[1]]
524
+ }, () => {
525
+ this.device.clearWebGL({ color: true });
526
+ allAggregationModel.setUniforms({ gridSize, combineMaxMin });
527
+ allAggregationModel.setBindings({ uSampler: framebuffers[id].texture });
528
+ allAggregationModel.draw();
529
+ });
530
+ }
531
+ _renderToWeightsTexture(opts) {
532
+ const { id, parameters, moduleSettings, uniforms, gridSize, weights } = opts;
533
+ const { framebuffers, equations, weightAttributes } = this.state;
534
+ const { gridAggregationModel } = this;
535
+ const { operation } = weights[id];
536
+ const clearColor = operation === AGGREGATION_OPERATION.MIN ? [MAX_32_BIT_FLOAT, MAX_32_BIT_FLOAT, MAX_32_BIT_FLOAT, 0] : [0, 0, 0, 0];
537
+ this.device.withParametersWebGL({
538
+ framebuffer: framebuffers[id],
539
+ viewport: [0, 0, gridSize[0], gridSize[1]],
540
+ clearColor
541
+ }, () => {
542
+ this.device.clearWebGL({ color: true });
543
+ const attributes = { weights: weightAttributes[id] };
544
+ gridAggregationModel.draw({
545
+ parameters: { ...parameters, blendEquation: equations[id] },
546
+ moduleSettings,
547
+ uniforms,
548
+ attributes
549
+ });
550
+ });
551
+ if (operation === AGGREGATION_OPERATION.MEAN) {
552
+ const { meanTextures, textures } = this.state;
553
+ const transformOptions = {
554
+ _sourceTextures: { aggregationValues: meanTextures[id] },
555
+ _targetTexture: textures[id],
556
+ elementCount: textures[id].width * textures[id].height
557
+ };
558
+ if (this.meanTransform) {
559
+ this.meanTransform.update(transformOptions);
560
+ } else {
561
+ this.meanTransform = getMeanTransform(this.device, transformOptions);
562
+ }
563
+ this.meanTransform.run({
564
+ parameters: {
565
+ blend: false,
566
+ depthTest: false
567
+ }
568
+ });
569
+ framebuffers[id].attach({ [36064]: textures[id] });
570
+ }
571
+ }
572
+ _runAggregation(opts) {
573
+ this._updateModels(opts);
574
+ this._setupFramebuffers(opts);
575
+ this._renderAggregateData(opts);
576
+ const results = this._getAggregateData(opts);
577
+ this.setState({ results });
578
+ return results;
579
+ }
580
+ _setupFramebuffers(opts) {
581
+ const { textures, framebuffers, maxMinFramebuffers, minFramebuffers, maxFramebuffers, meanTextures, equations } = this.state;
582
+ const { weights } = opts;
583
+ const { numCol, numRow } = opts;
584
+ const framebufferSize = { width: numCol, height: numRow };
585
+ for (const id in weights) {
586
+ const { needMin, needMax, combineMaxMin, operation } = weights[id];
587
+ textures[id] = weights[id].aggregationTexture || textures[id] || getFloatTexture(this.device, { id: `${id}-texture`, width: numCol, height: numRow });
588
+ textures[id].resize(framebufferSize);
589
+ let texture = textures[id];
590
+ if (operation === AGGREGATION_OPERATION.MEAN) {
591
+ meanTextures[id] = meanTextures[id] || getFloatTexture(this.device, { id: `${id}-mean-texture`, width: numCol, height: numRow });
592
+ meanTextures[id].resize(framebufferSize);
593
+ texture = meanTextures[id];
594
+ }
595
+ if (framebuffers[id]) {
596
+ framebuffers[id].attach({ [36064]: texture });
597
+ } else {
598
+ framebuffers[id] = getFramebuffer(this.device, {
599
+ id: `${id}-fb`,
600
+ width: numCol,
601
+ height: numRow,
602
+ texture
603
+ });
604
+ }
605
+ framebuffers[id].resize(framebufferSize);
606
+ equations[id] = EQUATION_MAP[operation] || EQUATION_MAP[AGGREGATION_OPERATION.SUM];
607
+ if (needMin || needMax) {
608
+ if (needMin && needMax && combineMaxMin) {
609
+ if (!maxMinFramebuffers[id]) {
610
+ texture = weights[id].maxMinTexture || this._getMinMaxTexture(`${id}-maxMinTexture`);
611
+ maxMinFramebuffers[id] = getFramebuffer(this.device, { id: `${id}-maxMinFb`, texture });
612
+ }
613
+ } else {
614
+ if (needMin) {
615
+ if (!minFramebuffers[id]) {
616
+ texture = weights[id].minTexture || this._getMinMaxTexture(`${id}-minTexture`);
617
+ minFramebuffers[id] = getFramebuffer(this.device, {
618
+ id: `${id}-minFb`,
619
+ texture
620
+ });
621
+ }
622
+ }
623
+ if (needMax) {
624
+ if (!maxFramebuffers[id]) {
625
+ texture = weights[id].maxTexture || this._getMinMaxTexture(`${id}-maxTexture`);
626
+ maxFramebuffers[id] = getFramebuffer(this.device, {
627
+ id: `${id}-maxFb`,
628
+ texture
629
+ });
630
+ }
631
+ }
632
+ }
633
+ }
634
+ }
635
+ }
636
+ _getMinMaxTexture(name) {
637
+ const { resources } = this.state;
638
+ if (!resources[name]) {
639
+ resources[name] = getFloatTexture(this.device, { id: "resourceName" });
640
+ }
641
+ return resources[name];
642
+ }
643
+ _setupModels({ numCol = 0, numRow = 0 } = {}) {
644
+ var _a;
645
+ const { shaderOptions } = this.state;
646
+ (_a = this.gridAggregationModel) == null ? void 0 : _a.destroy();
647
+ this.gridAggregationModel = getAggregationModel(this.device, shaderOptions);
648
+ if (!this.allAggregationModel) {
649
+ const instanceCount = numCol * numRow;
650
+ this.allAggregationModel = getAllAggregationModel(this.device, instanceCount);
651
+ }
652
+ }
653
+ _setupWeightAttributes(opts) {
654
+ const { weightAttributes } = this.state;
655
+ const { weights } = opts;
656
+ for (const id in weights) {
657
+ weightAttributes[id] = opts.attributes[id];
658
+ }
659
+ }
660
+ _trackGPUResultBuffers(results, weights) {
661
+ const { resources } = this.state;
662
+ for (const id in results) {
663
+ if (results[id]) {
664
+ for (const bufferName of BUFFER_NAMES) {
665
+ if (results[id][bufferName] && weights[id][bufferName] !== results[id][bufferName]) {
666
+ const name = `gpu-result-${id}-${bufferName}`;
667
+ if (resources[name]) {
668
+ resources[name].delete();
669
+ }
670
+ resources[name] = results[id][bufferName];
671
+ }
672
+ }
673
+ }
674
+ }
675
+ }
676
+ _updateModels(opts) {
677
+ const { vertexCount, attributes, numCol, numRow } = opts;
678
+ const { modelDirty } = this.state;
679
+ if (modelDirty) {
680
+ this._setupModels(opts);
681
+ this.setState({ modelDirty: false });
682
+ }
683
+ this._setupWeightAttributes(opts);
684
+ this.gridAggregationModel.setVertexCount(vertexCount);
685
+ this.gridAggregationModel.setAttributes(attributes);
686
+ this.allAggregationModel.setInstanceCount(numCol * numRow);
687
+ }
688
+ };
689
+ function normalizeWeightParams(weights) {
690
+ const result = {};
691
+ for (const id in weights) {
692
+ result[id] = { ...DEFAULT_WEIGHT_PARAMS, ...weights[id] };
693
+ }
694
+ return result;
695
+ }
696
+ function deleteResources(resources) {
697
+ resources = Array.isArray(resources) ? resources : [resources];
698
+ resources.forEach((obj) => {
699
+ for (const name in obj) {
700
+ obj[name].delete();
701
+ }
702
+ });
703
+ }
704
+ function getAggregationModel(device, shaderOptions) {
705
+ const shaders = (0, import_core._mergeShaders)({
706
+ vs: aggregate_to_grid_vs_glsl_default,
707
+ fs: aggregate_to_grid_fs_glsl_default,
708
+ modules: [import_shadertools.fp64arithmetic, import_core.project32]
709
+ }, shaderOptions);
710
+ return new import_engine.Model(device, {
711
+ id: "Grid-Aggregation-Model",
712
+ vertexCount: 1,
713
+ drawMode: 0,
714
+ shaderAssembler: (0, import_core.getShaderAssembler)(),
715
+ ...shaders
716
+ });
717
+ }
718
+ function getAllAggregationModel(device, instanceCount) {
719
+ return new import_engine.Model(device, {
720
+ id: "All-Aggregation-Model",
721
+ vs: aggregate_all_vs_glsl_default,
722
+ fs: aggregate_all_fs_glsl_default,
723
+ modules: [import_shadertools.fp64arithmetic],
724
+ vertexCount: 1,
725
+ topology: "point-list",
726
+ isInstanced: true,
727
+ instanceCount,
728
+ attributes: {
729
+ position: [0, 0]
730
+ }
731
+ });
732
+ }
733
+ function getMeanTransform(device, opts) {
734
+ return new import_engine.TextureTransform(device, {
735
+ vs: transform_mean_vs_glsl_default,
736
+ _targetTextureVarying: "meanValues",
737
+ ...opts
738
+ });
739
+ }
740
+
741
+ // dist/screen-grid-layer/screen-grid-cell-layer.js
742
+ var import_engine2 = require("@luma.gl/engine");
743
+ var import_core2 = require("@deck.gl/core");
744
+
745
+ // dist/utils/color-utils.js
746
+ var defaultColorRange = [
747
+ [255, 255, 178],
748
+ [254, 217, 118],
749
+ [254, 178, 76],
750
+ [253, 141, 60],
751
+ [240, 59, 32],
752
+ [189, 0, 38]
753
+ ];
754
+ function colorRangeToFlatArray(colorRange, normalize = false, ArrayType = Float32Array) {
755
+ let flatArray;
756
+ if (Number.isFinite(colorRange[0])) {
757
+ flatArray = new ArrayType(colorRange);
758
+ } else {
759
+ flatArray = new ArrayType(colorRange.length * 4);
760
+ let index = 0;
761
+ for (let i = 0; i < colorRange.length; i++) {
762
+ const color = colorRange[i];
763
+ flatArray[index++] = color[0];
764
+ flatArray[index++] = color[1];
765
+ flatArray[index++] = color[2];
766
+ flatArray[index++] = Number.isFinite(color[3]) ? color[3] : 255;
767
+ }
768
+ }
769
+ if (normalize) {
770
+ for (let i = 0; i < flatArray.length; i++) {
771
+ flatArray[i] /= 255;
772
+ }
773
+ }
774
+ return flatArray;
775
+ }
776
+
777
+ // dist/screen-grid-layer/screen-grid-layer-vertex.glsl.js
778
+ var screen_grid_layer_vertex_glsl_default = `#version 300 es
779
+ #define SHADER_NAME screen-grid-layer-vertex-shader
780
+ #define RANGE_COUNT 6
781
+ in vec3 positions;
782
+ in vec3 instancePositions;
783
+ in vec4 instanceCounts;
784
+ in vec3 instancePickingColors;
785
+ uniform float opacity;
786
+ uniform vec3 cellScale;
787
+ uniform vec4 minColor;
788
+ uniform vec4 maxColor;
789
+ uniform vec4 colorRange[RANGE_COUNT];
790
+ uniform vec2 colorDomain;
791
+ uniform bool shouldUseMinMax;
792
+ uniform sampler2D maxTexture;
793
+ out vec4 vColor;
794
+ out float vSampleCount;
795
+ vec4 quantizeScale(vec2 domain, vec4 range[RANGE_COUNT], float value) {
796
+ vec4 outColor = vec4(0., 0., 0., 0.);
797
+ if (value >= domain.x && value <= domain.y) {
798
+ float domainRange = domain.y - domain.x;
799
+ if (domainRange <= 0.) {
800
+ outColor = colorRange[0];
801
+ } else {
802
+ float rangeCount = float(RANGE_COUNT);
803
+ float rangeStep = domainRange / rangeCount;
804
+ float idx = floor((value - domain.x) / rangeStep);
805
+ idx = clamp(idx, 0., rangeCount - 1.);
806
+ int intIdx = int(idx);
807
+ outColor = colorRange[intIdx];
808
+ }
809
+ }
810
+ outColor = outColor / 255.;
811
+ return outColor;
812
+ }
813
+ void main(void) {
814
+ vSampleCount = instanceCounts.a;
815
+ float weight = instanceCounts.r;
816
+ float maxWeight = texture(maxTexture, vec2(0.5)).r;
817
+ float step = weight / maxWeight;
818
+ vec4 minMaxColor = mix(minColor, maxColor, step) / 255.;
819
+ vec2 domain = colorDomain;
820
+ float domainMaxValid = float(colorDomain.y != 0.);
821
+ domain.y = mix(maxWeight, colorDomain.y, domainMaxValid);
822
+ vec4 rangeColor = quantizeScale(domain, colorRange, weight);
823
+ float rangeMinMax = float(shouldUseMinMax);
824
+ vec4 color = mix(rangeColor, minMaxColor, rangeMinMax);
825
+ vColor = vec4(color.rgb, color.a * opacity);
826
+ picking_setPickingColor(instancePickingColors);
827
+ gl_Position = vec4(instancePositions + positions * cellScale, 1.);
828
+ }
829
+ `;
830
+
831
+ // dist/screen-grid-layer/screen-grid-layer-fragment.glsl.js
832
+ var screen_grid_layer_fragment_glsl_default = `#version 300 es
833
+ #define SHADER_NAME screen-grid-layer-fragment-shader
834
+ precision highp float;
835
+ in vec4 vColor;
836
+ in float vSampleCount;
837
+ out vec4 fragColor;
838
+ void main(void) {
839
+ if (vSampleCount <= 0.0) {
840
+ discard;
841
+ }
842
+ fragColor = vColor;
843
+ DECKGL_FILTER_COLOR(fragColor, geometry);
844
+ }
845
+ `;
846
+
847
+ // dist/screen-grid-layer/screen-grid-cell-layer.js
848
+ var DEFAULT_MINCOLOR = [0, 0, 0, 0];
849
+ var DEFAULT_MAXCOLOR = [0, 255, 0, 255];
850
+ var COLOR_PROPS = ["minColor", "maxColor", "colorRange", "colorDomain"];
851
+ var defaultProps = {
852
+ cellSizePixels: { type: "number", value: 100, min: 1 },
853
+ cellMarginPixels: { type: "number", value: 2, min: 0, max: 5 },
854
+ colorDomain: null,
855
+ colorRange: defaultColorRange
856
+ };
857
+ var _ScreenGridCellLayer = class extends import_core2.Layer {
858
+ getShaders() {
859
+ return { vs: screen_grid_layer_vertex_glsl_default, fs: screen_grid_layer_fragment_glsl_default, modules: [import_core2.picking] };
860
+ }
861
+ initializeState() {
862
+ const attributeManager = this.getAttributeManager();
863
+ attributeManager.addInstanced({
864
+ instancePositions: { size: 3, update: this.calculateInstancePositions },
865
+ instanceCounts: { size: 4, noAlloc: true }
866
+ });
867
+ this.setState({
868
+ model: this._getModel()
869
+ });
870
+ }
871
+ shouldUpdateState({ changeFlags }) {
872
+ return changeFlags.somethingChanged;
873
+ }
874
+ updateState(params) {
875
+ super.updateState(params);
876
+ const { oldProps, props, changeFlags } = params;
877
+ const attributeManager = this.getAttributeManager();
878
+ if (props.numInstances !== oldProps.numInstances) {
879
+ attributeManager.invalidateAll();
880
+ } else if (oldProps.cellSizePixels !== props.cellSizePixels) {
881
+ attributeManager.invalidate("instancePositions");
882
+ }
883
+ this._updateUniforms(oldProps, props, changeFlags);
884
+ }
885
+ draw({ uniforms }) {
886
+ const { parameters, maxTexture } = this.props;
887
+ const minColor = this.props.minColor || DEFAULT_MINCOLOR;
888
+ const maxColor = this.props.maxColor || DEFAULT_MAXCOLOR;
889
+ const colorDomain = this.props.colorDomain || [1, 0];
890
+ const model = this.state.model;
891
+ model.setUniforms(uniforms);
892
+ model.setBindings({
893
+ maxTexture
894
+ });
895
+ model.setUniforms({
896
+ minColor,
897
+ maxColor,
898
+ colorDomain
899
+ });
900
+ model.setParameters({
901
+ depthWriteEnabled: false,
902
+ ...parameters
903
+ });
904
+ model.draw(this.context.renderPass);
905
+ }
906
+ calculateInstancePositions(attribute, { numInstances }) {
907
+ const { width, height } = this.context.viewport;
908
+ const { cellSizePixels } = this.props;
909
+ const numCol = Math.ceil(width / cellSizePixels);
910
+ const { value, size } = attribute;
911
+ for (let i = 0; i < numInstances; i++) {
912
+ const x = i % numCol;
913
+ const y = Math.floor(i / numCol);
914
+ value[i * size + 0] = x * cellSizePixels / width * 2 - 1;
915
+ value[i * size + 1] = 1 - y * cellSizePixels / height * 2;
916
+ value[i * size + 2] = 0;
917
+ }
918
+ }
919
+ _getModel() {
920
+ return new import_engine2.Model(this.context.device, {
921
+ ...this.getShaders(),
922
+ id: this.props.id,
923
+ bufferLayout: this.getAttributeManager().getBufferLayouts(),
924
+ geometry: new import_engine2.Geometry({
925
+ topology: "triangle-list",
926
+ attributes: {
927
+ positions: new Float32Array([
928
+ 0,
929
+ 0,
930
+ 0,
931
+ 1,
932
+ 0,
933
+ 0,
934
+ 1,
935
+ 1,
936
+ 0,
937
+ 0,
938
+ 0,
939
+ 0,
940
+ 1,
941
+ 1,
942
+ 0,
943
+ 0,
944
+ 1,
945
+ 0
946
+ ])
947
+ }
948
+ })
949
+ });
950
+ }
951
+ _shouldUseMinMax() {
952
+ const { minColor, maxColor, colorDomain, colorRange } = this.props;
953
+ if (minColor || maxColor) {
954
+ import_core2.log.deprecated("ScreenGridLayer props: minColor and maxColor", "colorRange, colorDomain")();
955
+ return true;
956
+ }
957
+ if (colorDomain || colorRange) {
958
+ return false;
959
+ }
960
+ return true;
961
+ }
962
+ _updateUniforms(oldProps, props, changeFlags) {
963
+ const model = this.state.model;
964
+ if (COLOR_PROPS.some((key) => oldProps[key] !== props[key])) {
965
+ model.setUniforms({ shouldUseMinMax: this._shouldUseMinMax() });
966
+ }
967
+ if (oldProps.colorRange !== props.colorRange) {
968
+ model.setUniforms({ colorRange: colorRangeToFlatArray(props.colorRange) });
969
+ }
970
+ if (oldProps.cellMarginPixels !== props.cellMarginPixels || oldProps.cellSizePixels !== props.cellSizePixels || changeFlags.viewportChanged) {
971
+ const { width, height } = this.context.viewport;
972
+ const { cellSizePixels, cellMarginPixels } = this.props;
973
+ const margin = cellSizePixels > cellMarginPixels ? cellMarginPixels : 0;
974
+ const cellScale = new Float32Array([
975
+ (cellSizePixels - margin) / width * 2,
976
+ -(cellSizePixels - margin) / height * 2,
977
+ 1
978
+ ]);
979
+ model.setUniforms({ cellScale });
980
+ }
981
+ }
982
+ };
983
+ var ScreenGridCellLayer = _ScreenGridCellLayer;
984
+ (() => {
985
+ _ScreenGridCellLayer.layerName = "ScreenGridCellLayer";
986
+ })();
987
+ (() => {
988
+ _ScreenGridCellLayer.defaultProps = defaultProps;
989
+ })();
990
+
991
+ // dist/grid-aggregation-layer.js
992
+ var import_constants3 = require("@luma.gl/constants");
993
+ var import_core7 = require("@deck.gl/core");
994
+
995
+ // dist/aggregation-layer.js
996
+ var import_core3 = require("@deck.gl/core");
997
+
998
+ // dist/utils/prop-utils.js
999
+ function filterProps(props, filterKeys) {
1000
+ const filteredProps = {};
1001
+ for (const key in props) {
1002
+ if (!filterKeys.includes(key)) {
1003
+ filteredProps[key] = props[key];
1004
+ }
1005
+ }
1006
+ return filteredProps;
1007
+ }
1008
+
1009
+ // dist/aggregation-layer.js
1010
+ var _AggregationLayer = class extends import_core3.CompositeLayer {
1011
+ initializeAggregationLayer(dimensions) {
1012
+ super.initializeState(this.context);
1013
+ this.setState({
1014
+ ignoreProps: filterProps(this.constructor._propTypes, dimensions.data.props),
1015
+ dimensions
1016
+ });
1017
+ }
1018
+ updateState(opts) {
1019
+ super.updateState(opts);
1020
+ const { changeFlags } = opts;
1021
+ if (changeFlags.extensionsChanged) {
1022
+ const shaders = this.getShaders({});
1023
+ if (shaders && shaders.defines) {
1024
+ shaders.defines.NON_INSTANCED_MODEL = 1;
1025
+ }
1026
+ this.updateShaders(shaders);
1027
+ }
1028
+ this._updateAttributes();
1029
+ }
1030
+ updateAttributes(changedAttributes) {
1031
+ this.setState({ changedAttributes });
1032
+ }
1033
+ getAttributes() {
1034
+ return this.getAttributeManager().getAttributes();
1035
+ }
1036
+ getModuleSettings() {
1037
+ const { viewport, mousePosition, device } = this.context;
1038
+ const moduleSettings = Object.assign(Object.create(this.props), {
1039
+ viewport,
1040
+ mousePosition,
1041
+ picking: {
1042
+ isActive: 0
1043
+ },
1044
+ devicePixelRatio: device.canvasContext.cssToDeviceRatio()
1045
+ });
1046
+ return moduleSettings;
1047
+ }
1048
+ updateShaders(shaders) {
1049
+ }
1050
+ isAggregationDirty(updateOpts, params = {}) {
1051
+ const { props, oldProps, changeFlags } = updateOpts;
1052
+ const { compareAll = false, dimension } = params;
1053
+ const { ignoreProps } = this.state;
1054
+ const { props: dataProps, accessors = [] } = dimension;
1055
+ const { updateTriggersChanged } = changeFlags;
1056
+ if (changeFlags.dataChanged) {
1057
+ return true;
1058
+ }
1059
+ if (updateTriggersChanged) {
1060
+ if (updateTriggersChanged.all) {
1061
+ return true;
1062
+ }
1063
+ for (const accessor of accessors) {
1064
+ if (updateTriggersChanged[accessor]) {
1065
+ return true;
1066
+ }
1067
+ }
1068
+ }
1069
+ if (compareAll) {
1070
+ if (changeFlags.extensionsChanged) {
1071
+ return true;
1072
+ }
1073
+ return (0, import_core3._compareProps)({
1074
+ oldProps,
1075
+ newProps: props,
1076
+ ignoreProps,
1077
+ propTypes: this.constructor._propTypes
1078
+ });
1079
+ }
1080
+ for (const name of dataProps) {
1081
+ if (props[name] !== oldProps[name]) {
1082
+ return true;
1083
+ }
1084
+ }
1085
+ return false;
1086
+ }
1087
+ isAttributeChanged(name) {
1088
+ const { changedAttributes } = this.state;
1089
+ if (!name) {
1090
+ return !isObjectEmpty(changedAttributes);
1091
+ }
1092
+ return changedAttributes && changedAttributes[name] !== void 0;
1093
+ }
1094
+ _getAttributeManager() {
1095
+ return new import_core3.AttributeManager(this.context.device, {
1096
+ id: this.props.id,
1097
+ stats: this.context.stats
1098
+ });
1099
+ }
1100
+ };
1101
+ var AggregationLayer = _AggregationLayer;
1102
+ (() => {
1103
+ _AggregationLayer.layerName = "AggregationLayer";
1104
+ })();
1105
+ function isObjectEmpty(obj) {
1106
+ let isEmpty = true;
1107
+ for (const key in obj) {
1108
+ isEmpty = false;
1109
+ break;
1110
+ }
1111
+ return isEmpty;
1112
+ }
1113
+
1114
+ // dist/utils/scale-utils.js
1115
+ var import_core4 = require("@deck.gl/core");
1116
+ function getScale(domain, range, scaleFunction) {
1117
+ const scale = scaleFunction;
1118
+ scale.domain = () => domain;
1119
+ scale.range = () => range;
1120
+ return scale;
1121
+ }
1122
+ function getQuantizeScale(domain, range) {
1123
+ const scaleFunction = (value) => quantizeScale(domain, range, value);
1124
+ return getScale(domain, range, scaleFunction);
1125
+ }
1126
+ function getLinearScale(domain, range) {
1127
+ const scaleFunction = (value) => linearScale(domain, range, value);
1128
+ return getScale(domain, range, scaleFunction);
1129
+ }
1130
+ function getQuantileScale(domain, range) {
1131
+ const sortedDomain = domain.sort(ascending);
1132
+ let i = 0;
1133
+ const n = Math.max(1, range.length);
1134
+ const thresholds = new Array(n - 1);
1135
+ while (++i < n) {
1136
+ thresholds[i - 1] = threshold(sortedDomain, i / n);
1137
+ }
1138
+ const scaleFunction = (value) => thresholdsScale(thresholds, range, value);
1139
+ scaleFunction.thresholds = () => thresholds;
1140
+ return getScale(domain, range, scaleFunction);
1141
+ }
1142
+ function ascending(a, b) {
1143
+ return a - b;
1144
+ }
1145
+ function threshold(domain, fraction) {
1146
+ const domainLength = domain.length;
1147
+ if (fraction <= 0 || domainLength < 2) {
1148
+ return domain[0];
1149
+ }
1150
+ if (fraction >= 1) {
1151
+ return domain[domainLength - 1];
1152
+ }
1153
+ const domainFraction = (domainLength - 1) * fraction;
1154
+ const lowIndex = Math.floor(domainFraction);
1155
+ const low = domain[lowIndex];
1156
+ const high = domain[lowIndex + 1];
1157
+ return low + (high - low) * (domainFraction - lowIndex);
1158
+ }
1159
+ function bisectRight(a, x) {
1160
+ let lo = 0;
1161
+ let hi = a.length;
1162
+ while (lo < hi) {
1163
+ const mid = lo + hi >>> 1;
1164
+ if (ascending(a[mid], x) > 0) {
1165
+ hi = mid;
1166
+ } else {
1167
+ lo = mid + 1;
1168
+ }
1169
+ }
1170
+ return lo;
1171
+ }
1172
+ function thresholdsScale(thresholds, range, value) {
1173
+ return range[bisectRight(thresholds, value)];
1174
+ }
1175
+ function ordinalScale(domain, domainMap, range, value) {
1176
+ const key = `${value}`;
1177
+ let d = domainMap.get(key);
1178
+ if (d === void 0) {
1179
+ d = domain.push(value);
1180
+ domainMap.set(key, d);
1181
+ }
1182
+ return range[(d - 1) % range.length];
1183
+ }
1184
+ function getOrdinalScale(domain, range) {
1185
+ const domainMap = /* @__PURE__ */ new Map();
1186
+ const uniqueDomain = [];
1187
+ for (const d of domain) {
1188
+ const key = `${d}`;
1189
+ if (!domainMap.has(key)) {
1190
+ domainMap.set(key, uniqueDomain.push(d));
1191
+ }
1192
+ }
1193
+ const scaleFunction = (value) => ordinalScale(uniqueDomain, domainMap, range, value);
1194
+ return getScale(domain, range, scaleFunction);
1195
+ }
1196
+ function quantizeScale(domain, range, value) {
1197
+ const domainRange = domain[1] - domain[0];
1198
+ if (domainRange <= 0) {
1199
+ import_core4.log.warn("quantizeScale: invalid domain, returning range[0]")();
1200
+ return range[0];
1201
+ }
1202
+ const step = domainRange / range.length;
1203
+ const idx = Math.floor((value - domain[0]) / step);
1204
+ const clampIdx = Math.max(Math.min(idx, range.length - 1), 0);
1205
+ return range[clampIdx];
1206
+ }
1207
+ function linearScale(domain, range, value) {
1208
+ return (value - domain[0]) / (domain[1] - domain[0]) * (range[1] - range[0]) + range[0];
1209
+ }
1210
+ function notNullOrUndefined(d) {
1211
+ return d !== void 0 && d !== null;
1212
+ }
1213
+ function unique(values) {
1214
+ const results = [];
1215
+ values.forEach((v) => {
1216
+ if (!results.includes(v) && notNullOrUndefined(v)) {
1217
+ results.push(v);
1218
+ }
1219
+ });
1220
+ return results;
1221
+ }
1222
+ function getTruthyValues(data, valueAccessor) {
1223
+ const values = typeof valueAccessor === "function" ? data.map(valueAccessor) : data;
1224
+ return values.filter(notNullOrUndefined);
1225
+ }
1226
+ function getQuantileDomain(data, valueAccessor) {
1227
+ return getTruthyValues(data, valueAccessor);
1228
+ }
1229
+ function getOrdinalDomain(data, valueAccessor) {
1230
+ return unique(getTruthyValues(data, valueAccessor));
1231
+ }
1232
+ function clamp(value, min, max) {
1233
+ return Math.max(min, Math.min(max, value));
1234
+ }
1235
+ function getScaleFunctionByScaleType(scaleType) {
1236
+ switch (scaleType) {
1237
+ case "quantize":
1238
+ return getQuantizeScale;
1239
+ case "linear":
1240
+ return getLinearScale;
1241
+ case "quantile":
1242
+ return getQuantileScale;
1243
+ case "ordinal":
1244
+ return getOrdinalScale;
1245
+ default:
1246
+ return getQuantizeScale;
1247
+ }
1248
+ }
1249
+
1250
+ // dist/utils/bin-sorter.js
1251
+ var defaultGetValue = (points) => points.length;
1252
+ var MAX_32_BIT_FLOAT2 = 3402823466e29;
1253
+ var defaultGetPoints = (bin) => bin.points;
1254
+ var defaultGetIndex = (bin) => bin.index;
1255
+ var ascending2 = (a, b) => a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
1256
+ var defaultProps2 = {
1257
+ getValue: defaultGetValue,
1258
+ getPoints: defaultGetPoints,
1259
+ getIndex: defaultGetIndex,
1260
+ filterData: null
1261
+ };
1262
+ var BinSorter = class {
1263
+ constructor(bins = [], props = defaultProps2) {
1264
+ this.aggregatedBins = this.getAggregatedBins(bins, props);
1265
+ this._updateMinMaxValues();
1266
+ this.binMap = this.getBinMap();
1267
+ }
1268
+ getAggregatedBins(bins, props) {
1269
+ const { getValue = defaultGetValue, getPoints = defaultGetPoints, getIndex = defaultGetIndex, filterData } = props;
1270
+ const hasFilter = typeof filterData === "function";
1271
+ const binCount = bins.length;
1272
+ const aggregatedBins = [];
1273
+ let index = 0;
1274
+ for (let binIndex = 0; binIndex < binCount; binIndex++) {
1275
+ const bin = bins[binIndex];
1276
+ const points = getPoints(bin);
1277
+ const i = getIndex(bin);
1278
+ const filteredPoints = hasFilter ? points.filter(filterData) : points;
1279
+ bin.filteredPoints = hasFilter ? filteredPoints : null;
1280
+ const value = filteredPoints.length ? getValue(filteredPoints) : null;
1281
+ if (value !== null && value !== void 0) {
1282
+ aggregatedBins[index] = {
1283
+ i: Number.isFinite(i) ? i : binIndex,
1284
+ value,
1285
+ counts: filteredPoints.length
1286
+ };
1287
+ index++;
1288
+ }
1289
+ }
1290
+ return aggregatedBins;
1291
+ }
1292
+ _percentileToIndex(percentileRange) {
1293
+ const len = this.sortedBins.length;
1294
+ if (len < 2) {
1295
+ return [0, 0];
1296
+ }
1297
+ const [lower, upper] = percentileRange.map((n) => clamp(n, 0, 100));
1298
+ const lowerIdx = Math.ceil(lower / 100 * (len - 1));
1299
+ const upperIdx = Math.floor(upper / 100 * (len - 1));
1300
+ return [lowerIdx, upperIdx];
1301
+ }
1302
+ getBinMap() {
1303
+ const binMap = {};
1304
+ for (const bin of this.aggregatedBins) {
1305
+ binMap[bin.i] = bin;
1306
+ }
1307
+ return binMap;
1308
+ }
1309
+ _updateMinMaxValues() {
1310
+ let maxCount = 0;
1311
+ let maxValue = 0;
1312
+ let minValue = MAX_32_BIT_FLOAT2;
1313
+ let totalCount = 0;
1314
+ for (const x of this.aggregatedBins) {
1315
+ maxCount = maxCount > x.counts ? maxCount : x.counts;
1316
+ maxValue = maxValue > x.value ? maxValue : x.value;
1317
+ minValue = minValue < x.value ? minValue : x.value;
1318
+ totalCount += x.counts;
1319
+ }
1320
+ this.maxCount = maxCount;
1321
+ this.maxValue = maxValue;
1322
+ this.minValue = minValue;
1323
+ this.totalCount = totalCount;
1324
+ }
1325
+ getValueRange(percentileRange) {
1326
+ if (!this.sortedBins) {
1327
+ this.sortedBins = this.aggregatedBins.sort((a, b) => ascending2(a.value, b.value));
1328
+ }
1329
+ if (!this.sortedBins.length) {
1330
+ return [];
1331
+ }
1332
+ let lowerIdx = 0;
1333
+ let upperIdx = this.sortedBins.length - 1;
1334
+ if (Array.isArray(percentileRange)) {
1335
+ const idxRange = this._percentileToIndex(percentileRange);
1336
+ lowerIdx = idxRange[0];
1337
+ upperIdx = idxRange[1];
1338
+ }
1339
+ return [this.sortedBins[lowerIdx].value, this.sortedBins[upperIdx].value];
1340
+ }
1341
+ getValueDomainByScale(scale, [lower = 0, upper = 100] = []) {
1342
+ if (!this.sortedBins) {
1343
+ this.sortedBins = this.aggregatedBins.sort((a, b) => ascending2(a.value, b.value));
1344
+ }
1345
+ if (!this.sortedBins.length) {
1346
+ return [];
1347
+ }
1348
+ const indexEdge = this._percentileToIndex([lower, upper]);
1349
+ return this._getScaleDomain(scale, indexEdge);
1350
+ }
1351
+ _getScaleDomain(scaleType, [lowerIdx, upperIdx]) {
1352
+ const bins = this.sortedBins;
1353
+ switch (scaleType) {
1354
+ case "quantize":
1355
+ case "linear":
1356
+ return [bins[lowerIdx].value, bins[upperIdx].value];
1357
+ case "quantile":
1358
+ return getQuantileDomain(bins.slice(lowerIdx, upperIdx + 1), (d) => d.value);
1359
+ case "ordinal":
1360
+ return getOrdinalDomain(bins, (d) => d.value);
1361
+ default:
1362
+ return [bins[lowerIdx].value, bins[upperIdx].value];
1363
+ }
1364
+ }
1365
+ };
1366
+
1367
+ // dist/cpu-grid-layer/grid-aggregator.js
1368
+ var import_core6 = require("@deck.gl/core");
1369
+
1370
+ // dist/utils/grid-aggregation-utils.js
1371
+ var import_core5 = require("@deck.gl/core");
1372
+ var R_EARTH = 6378e3;
1373
+ function toFinite(n) {
1374
+ return Number.isFinite(n) ? n : 0;
1375
+ }
1376
+ function getBoundingBox(attributes, vertexCount) {
1377
+ const positions = attributes.positions.value;
1378
+ let yMin = Infinity;
1379
+ let yMax = -Infinity;
1380
+ let xMin = Infinity;
1381
+ let xMax = -Infinity;
1382
+ let y;
1383
+ let x;
1384
+ for (let i = 0; i < vertexCount; i++) {
1385
+ x = positions[i * 3];
1386
+ y = positions[i * 3 + 1];
1387
+ yMin = y < yMin ? y : yMin;
1388
+ yMax = y > yMax ? y : yMax;
1389
+ xMin = x < xMin ? x : xMin;
1390
+ xMax = x > xMax ? x : xMax;
1391
+ }
1392
+ const boundingBox = {
1393
+ xMin: toFinite(xMin),
1394
+ xMax: toFinite(xMax),
1395
+ yMin: toFinite(yMin),
1396
+ yMax: toFinite(yMax)
1397
+ };
1398
+ return boundingBox;
1399
+ }
1400
+ function getTranslation(boundingBox, gridOffset, coordinateSystem, viewport) {
1401
+ const { width, height } = viewport;
1402
+ const worldOrigin = coordinateSystem === import_core5.COORDINATE_SYSTEM.CARTESIAN ? [-width / 2, -height / 2] : [-180, -90];
1403
+ import_core5.log.assert(coordinateSystem === import_core5.COORDINATE_SYSTEM.CARTESIAN || coordinateSystem === import_core5.COORDINATE_SYSTEM.LNGLAT || coordinateSystem === import_core5.COORDINATE_SYSTEM.DEFAULT);
1404
+ const { xMin, yMin } = boundingBox;
1405
+ return [
1406
+ -1 * (alignToCell(xMin - worldOrigin[0], gridOffset.xOffset) + worldOrigin[0]),
1407
+ -1 * (alignToCell(yMin - worldOrigin[1], gridOffset.yOffset) + worldOrigin[1])
1408
+ ];
1409
+ }
1410
+ function alignToCell(inValue, cellSize) {
1411
+ const sign = inValue < 0 ? -1 : 1;
1412
+ let value = sign < 0 ? Math.abs(inValue) + cellSize : Math.abs(inValue);
1413
+ value = Math.floor(value / cellSize) * cellSize;
1414
+ return value * sign;
1415
+ }
1416
+ function getGridOffset(boundingBox, cellSize, convertToMeters = true) {
1417
+ if (!convertToMeters) {
1418
+ return { xOffset: cellSize, yOffset: cellSize };
1419
+ }
1420
+ const { yMin, yMax } = boundingBox;
1421
+ const centerLat = (yMin + yMax) / 2;
1422
+ return calculateGridLatLonOffset(cellSize, centerLat);
1423
+ }
1424
+ function getGridParams(boundingBox, cellSize, viewport, coordinateSystem) {
1425
+ const gridOffset = getGridOffset(boundingBox, cellSize, coordinateSystem !== import_core5.COORDINATE_SYSTEM.CARTESIAN);
1426
+ const translation = getTranslation(boundingBox, gridOffset, coordinateSystem, viewport);
1427
+ const { xMin, yMin, xMax, yMax } = boundingBox;
1428
+ const width = xMax - xMin + gridOffset.xOffset;
1429
+ const height = yMax - yMin + gridOffset.yOffset;
1430
+ const numCol = Math.ceil(width / gridOffset.xOffset);
1431
+ const numRow = Math.ceil(height / gridOffset.yOffset);
1432
+ return { gridOffset, translation, width, height, numCol, numRow };
1433
+ }
1434
+ function calculateGridLatLonOffset(cellSize, latitude) {
1435
+ const yOffset = calculateLatOffset(cellSize);
1436
+ const xOffset = calculateLonOffset(latitude, cellSize);
1437
+ return { yOffset, xOffset };
1438
+ }
1439
+ function calculateLatOffset(dy) {
1440
+ return dy / R_EARTH * (180 / Math.PI);
1441
+ }
1442
+ function calculateLonOffset(lat, dx) {
1443
+ return dx / R_EARTH * (180 / Math.PI) / Math.cos(lat * Math.PI / 180);
1444
+ }
1445
+
1446
+ // dist/cpu-grid-layer/grid-aggregator.js
1447
+ function pointToDensityGridDataCPU(props, aggregationParams) {
1448
+ const hashInfo = pointsToGridHashing(props, aggregationParams);
1449
+ const result = getGridLayerDataFromGridHash(hashInfo);
1450
+ return {
1451
+ gridHash: hashInfo.gridHash,
1452
+ gridOffset: hashInfo.gridOffset,
1453
+ data: result
1454
+ };
1455
+ }
1456
+ function pointsToGridHashing(props, aggregationParams) {
1457
+ const { data = [], cellSize } = props;
1458
+ const { attributes, viewport, projectPoints, numInstances } = aggregationParams;
1459
+ const positions = attributes.positions.value;
1460
+ const { size } = attributes.positions.getAccessor();
1461
+ const boundingBox = aggregationParams.boundingBox || getPositionBoundingBox(attributes.positions, numInstances);
1462
+ const offsets = aggregationParams.posOffset || [180, 90];
1463
+ const gridOffset = aggregationParams.gridOffset || getGridOffset(boundingBox, cellSize);
1464
+ if (gridOffset.xOffset <= 0 || gridOffset.yOffset <= 0) {
1465
+ return { gridHash: {}, gridOffset, offsets: [0, 0] };
1466
+ }
1467
+ const { width, height } = viewport;
1468
+ const numCol = Math.ceil(width / gridOffset.xOffset);
1469
+ const numRow = Math.ceil(height / gridOffset.yOffset);
1470
+ const gridHash = {};
1471
+ const { iterable, objectInfo } = (0, import_core6.createIterable)(data);
1472
+ const position = new Array(3);
1473
+ for (const pt of iterable) {
1474
+ objectInfo.index++;
1475
+ position[0] = positions[objectInfo.index * size];
1476
+ position[1] = positions[objectInfo.index * size + 1];
1477
+ position[2] = size >= 3 ? positions[objectInfo.index * size + 2] : 0;
1478
+ const [x, y] = projectPoints ? viewport.project(position) : position;
1479
+ if (Number.isFinite(x) && Number.isFinite(y)) {
1480
+ const yIndex = Math.floor((y + offsets[1]) / gridOffset.yOffset);
1481
+ const xIndex = Math.floor((x + offsets[0]) / gridOffset.xOffset);
1482
+ if (!projectPoints || xIndex >= 0 && xIndex < numCol && yIndex >= 0 && yIndex < numRow) {
1483
+ const key = `${yIndex}-${xIndex}`;
1484
+ gridHash[key] = gridHash[key] || { count: 0, points: [], lonIdx: xIndex, latIdx: yIndex };
1485
+ gridHash[key].count += 1;
1486
+ gridHash[key].points.push({
1487
+ source: pt,
1488
+ index: objectInfo.index
1489
+ });
1490
+ }
1491
+ }
1492
+ }
1493
+ return { gridHash, gridOffset, offsets: [offsets[0] * -1, offsets[1] * -1] };
1494
+ }
1495
+ function getGridLayerDataFromGridHash({ gridHash, gridOffset, offsets }) {
1496
+ const data = new Array(Object.keys(gridHash).length);
1497
+ let i = 0;
1498
+ for (const key in gridHash) {
1499
+ const idxs = key.split("-");
1500
+ const latIdx = parseInt(idxs[0], 10);
1501
+ const lonIdx = parseInt(idxs[1], 10);
1502
+ const index = i++;
1503
+ data[index] = {
1504
+ index,
1505
+ position: [
1506
+ offsets[0] + gridOffset.xOffset * lonIdx,
1507
+ offsets[1] + gridOffset.yOffset * latIdx
1508
+ ],
1509
+ ...gridHash[key]
1510
+ };
1511
+ }
1512
+ return data;
1513
+ }
1514
+ function getPositionBoundingBox(positionAttribute, numInstance) {
1515
+ const positions = positionAttribute.value;
1516
+ const { size } = positionAttribute.getAccessor();
1517
+ let yMin = Infinity;
1518
+ let yMax = -Infinity;
1519
+ let xMin = Infinity;
1520
+ let xMax = -Infinity;
1521
+ let y;
1522
+ let x;
1523
+ for (let i = 0; i < numInstance; i++) {
1524
+ x = positions[i * size];
1525
+ y = positions[i * size + 1];
1526
+ if (Number.isFinite(x) && Number.isFinite(y)) {
1527
+ yMin = y < yMin ? y : yMin;
1528
+ yMax = y > yMax ? y : yMax;
1529
+ xMin = x < xMin ? x : xMin;
1530
+ xMax = x > xMax ? x : xMax;
1531
+ }
1532
+ }
1533
+ return { xMin, xMax, yMin, yMax };
1534
+ }
1535
+
1536
+ // dist/grid-aggregation-layer.js
1537
+ var _GridAggregationLayer = class extends AggregationLayer {
1538
+ initializeAggregationLayer({ dimensions }) {
1539
+ super.initializeAggregationLayer(dimensions);
1540
+ this.setState({
1541
+ layerData: {},
1542
+ gpuGridAggregator: new GPUGridAggregator(this.context.device, {
1543
+ id: `${this.id}-gpu-aggregator`
1544
+ }),
1545
+ cpuGridAggregator: pointToDensityGridDataCPU
1546
+ });
1547
+ }
1548
+ updateState(opts) {
1549
+ super.updateState(opts);
1550
+ this.updateAggregationState(opts);
1551
+ const { aggregationDataDirty, aggregationWeightsDirty, gpuAggregation } = this.state;
1552
+ if (this.getNumInstances() <= 0) {
1553
+ return;
1554
+ }
1555
+ let aggregationDirty = false;
1556
+ if (aggregationDataDirty || gpuAggregation && aggregationWeightsDirty) {
1557
+ this._updateAggregation(opts);
1558
+ aggregationDirty = true;
1559
+ }
1560
+ if (!gpuAggregation && (aggregationDataDirty || aggregationWeightsDirty)) {
1561
+ this._updateWeightBins();
1562
+ this._uploadAggregationResults();
1563
+ aggregationDirty = true;
1564
+ }
1565
+ this.setState({ aggregationDirty });
1566
+ }
1567
+ finalizeState(context) {
1568
+ var _a;
1569
+ const { count } = this.state.weights;
1570
+ if (count && count.aggregationBuffer) {
1571
+ count.aggregationBuffer.delete();
1572
+ }
1573
+ (_a = this.state.gpuGridAggregator) == null ? void 0 : _a.delete();
1574
+ super.finalizeState(context);
1575
+ }
1576
+ updateShaders(shaders) {
1577
+ if (this.state.gpuAggregation) {
1578
+ this.state.gpuGridAggregator.updateShaders(shaders);
1579
+ }
1580
+ }
1581
+ updateAggregationState(opts) {
1582
+ import_core7.log.assert(false);
1583
+ }
1584
+ allocateResources(numRow, numCol) {
1585
+ if (this.state.numRow !== numRow || this.state.numCol !== numCol) {
1586
+ const dataBytes = numCol * numRow * 4 * 4;
1587
+ const { weights } = this.state;
1588
+ for (const name in weights) {
1589
+ const weight = weights[name];
1590
+ if (weight.aggregationBuffer) {
1591
+ weight.aggregationBuffer.delete();
1592
+ }
1593
+ weight.aggregationBuffer = this.context.device.createBuffer({
1594
+ byteLength: dataBytes,
1595
+ accessor: {
1596
+ size: 4,
1597
+ type: 5126,
1598
+ divisor: 1
1599
+ }
1600
+ });
1601
+ }
1602
+ }
1603
+ }
1604
+ updateResults({ aggregationData, maxMinData, maxData, minData }) {
1605
+ const { count } = this.state.weights;
1606
+ if (count) {
1607
+ count.aggregationData = aggregationData;
1608
+ count.maxMinData = maxMinData;
1609
+ count.maxData = maxData;
1610
+ count.minData = minData;
1611
+ }
1612
+ }
1613
+ _updateAggregation(opts) {
1614
+ const { cpuGridAggregator, gpuGridAggregator, gridOffset, posOffset, translation = [0, 0], scaling = [0, 0, 0], boundingBox, projectPoints, gpuAggregation, numCol, numRow } = this.state;
1615
+ const { props } = opts;
1616
+ const { viewport } = this.context;
1617
+ const attributes = this.getAttributes();
1618
+ const vertexCount = this.getNumInstances();
1619
+ if (!gpuAggregation) {
1620
+ const result = cpuGridAggregator(props, {
1621
+ gridOffset,
1622
+ projectPoints,
1623
+ attributes,
1624
+ viewport,
1625
+ posOffset,
1626
+ boundingBox
1627
+ });
1628
+ this.setState({
1629
+ layerData: result
1630
+ });
1631
+ } else {
1632
+ const { weights } = this.state;
1633
+ gpuGridAggregator.run({
1634
+ weights,
1635
+ cellSize: [gridOffset.xOffset, gridOffset.yOffset],
1636
+ numCol,
1637
+ numRow,
1638
+ translation,
1639
+ scaling,
1640
+ vertexCount,
1641
+ projectPoints,
1642
+ attributes,
1643
+ moduleSettings: this.getModuleSettings()
1644
+ });
1645
+ }
1646
+ }
1647
+ _updateWeightBins() {
1648
+ const { getValue } = this.state;
1649
+ const sortedBins = new BinSorter(this.state.layerData.data || [], { getValue });
1650
+ this.setState({ sortedBins });
1651
+ }
1652
+ _uploadAggregationResults() {
1653
+ const { numCol, numRow } = this.state;
1654
+ const { data } = this.state.layerData;
1655
+ const { aggregatedBins, minValue, maxValue, totalCount } = this.state.sortedBins;
1656
+ const ELEMENTCOUNT = 4;
1657
+ const aggregationSize = numCol * numRow * ELEMENTCOUNT;
1658
+ const aggregationData = new Float32Array(aggregationSize).fill(0);
1659
+ for (const bin of aggregatedBins) {
1660
+ const { lonIdx, latIdx } = data[bin.i];
1661
+ const { value, counts } = bin;
1662
+ const cellIndex = (lonIdx + latIdx * numCol) * ELEMENTCOUNT;
1663
+ aggregationData[cellIndex] = value;
1664
+ aggregationData[cellIndex + ELEMENTCOUNT - 1] = counts;
1665
+ }
1666
+ const maxMinData = new Float32Array([maxValue, 0, 0, minValue]);
1667
+ const maxData = new Float32Array([maxValue, 0, 0, totalCount]);
1668
+ const minData = new Float32Array([minValue, 0, 0, totalCount]);
1669
+ this.updateResults({ aggregationData, maxMinData, maxData, minData });
1670
+ }
1671
+ };
1672
+ var GridAggregationLayer = _GridAggregationLayer;
1673
+ (() => {
1674
+ _GridAggregationLayer.layerName = "GridAggregationLayer";
1675
+ })();
1676
+
1677
+ // dist/screen-grid-layer/screen-grid-layer.js
1678
+ var defaultProps3 = {
1679
+ ...ScreenGridCellLayer.defaultProps,
1680
+ getPosition: { type: "accessor", value: (d) => d.position },
1681
+ getWeight: { type: "accessor", value: 1 },
1682
+ gpuAggregation: false,
1683
+ aggregation: "SUM"
1684
+ };
1685
+ var POSITION_ATTRIBUTE_NAME = "positions";
1686
+ var DIMENSIONS = {
1687
+ data: {
1688
+ props: ["cellSizePixels"]
1689
+ },
1690
+ weights: {
1691
+ props: ["aggregation"],
1692
+ accessors: ["getWeight"]
1693
+ }
1694
+ };
1695
+ var _ScreenGridLayer = class extends GridAggregationLayer {
1696
+ initializeState() {
1697
+ super.initializeAggregationLayer({
1698
+ dimensions: DIMENSIONS,
1699
+ getCellSize: (props) => props.cellSizePixels
1700
+ });
1701
+ const weights = {
1702
+ count: {
1703
+ size: 1,
1704
+ operation: AGGREGATION_OPERATION.SUM,
1705
+ needMax: true,
1706
+ maxTexture: getFloatTexture(this.context.device, { id: `${this.id}-max-texture` })
1707
+ }
1708
+ };
1709
+ this.setState({
1710
+ supported: true,
1711
+ projectPoints: true,
1712
+ weights,
1713
+ subLayerData: { attributes: {} },
1714
+ maxTexture: weights.count.maxTexture,
1715
+ positionAttributeName: "positions",
1716
+ posOffset: [0, 0],
1717
+ translation: [1, -1]
1718
+ });
1719
+ const attributeManager = this.getAttributeManager();
1720
+ attributeManager.add({
1721
+ [POSITION_ATTRIBUTE_NAME]: {
1722
+ size: 3,
1723
+ accessor: "getPosition",
1724
+ type: "float64",
1725
+ fp64: this.use64bitPositions()
1726
+ },
1727
+ count: { size: 3, accessor: "getWeight" }
1728
+ });
1729
+ }
1730
+ shouldUpdateState({ changeFlags }) {
1731
+ return this.state.supported && changeFlags.somethingChanged;
1732
+ }
1733
+ updateState(opts) {
1734
+ super.updateState(opts);
1735
+ }
1736
+ renderLayers() {
1737
+ if (!this.state.supported) {
1738
+ return [];
1739
+ }
1740
+ const { maxTexture, numRow, numCol, weights } = this.state;
1741
+ const { updateTriggers } = this.props;
1742
+ const { aggregationBuffer } = weights.count;
1743
+ const CellLayerClass = this.getSubLayerClass("cells", ScreenGridCellLayer);
1744
+ return new CellLayerClass(this.props, this.getSubLayerProps({
1745
+ id: "cell-layer",
1746
+ updateTriggers
1747
+ }), {
1748
+ data: { attributes: { instanceCounts: aggregationBuffer } },
1749
+ maxTexture,
1750
+ numInstances: numRow * numCol
1751
+ });
1752
+ }
1753
+ finalizeState(context) {
1754
+ super.finalizeState(context);
1755
+ const { aggregationBuffer, maxBuffer, maxTexture } = this.state;
1756
+ aggregationBuffer == null ? void 0 : aggregationBuffer.delete();
1757
+ maxBuffer == null ? void 0 : maxBuffer.delete();
1758
+ maxTexture == null ? void 0 : maxTexture.delete();
1759
+ }
1760
+ getPickingInfo({ info }) {
1761
+ const { index } = info;
1762
+ if (index >= 0) {
1763
+ const { gpuGridAggregator, gpuAggregation, weights } = this.state;
1764
+ const aggregationResults = gpuAggregation ? gpuGridAggregator.getData("count") : weights.count;
1765
+ info.object = GPUGridAggregator.getAggregationData({
1766
+ pixelIndex: index,
1767
+ ...aggregationResults
1768
+ });
1769
+ }
1770
+ return info;
1771
+ }
1772
+ updateResults({ aggregationData, maxData }) {
1773
+ const { count } = this.state.weights;
1774
+ count.aggregationData = aggregationData;
1775
+ count.aggregationBuffer.write(aggregationData);
1776
+ count.maxData = maxData;
1777
+ count.maxTexture.setImageData({ data: maxData });
1778
+ }
1779
+ updateAggregationState(opts) {
1780
+ const cellSize = opts.props.cellSizePixels;
1781
+ const cellSizeChanged = opts.oldProps.cellSizePixels !== cellSize;
1782
+ const { viewportChanged } = opts.changeFlags;
1783
+ let gpuAggregation = opts.props.gpuAggregation;
1784
+ if (this.state.gpuAggregation !== opts.props.gpuAggregation) {
1785
+ if (gpuAggregation && !GPUGridAggregator.isSupported(this.context.device)) {
1786
+ import_core8.log.warn("GPU Grid Aggregation not supported, falling back to CPU")();
1787
+ gpuAggregation = false;
1788
+ }
1789
+ }
1790
+ const gpuAggregationChanged = gpuAggregation !== this.state.gpuAggregation;
1791
+ this.setState({
1792
+ gpuAggregation
1793
+ });
1794
+ const positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME);
1795
+ const { dimensions } = this.state;
1796
+ const { data, weights } = dimensions;
1797
+ const aggregationDataDirty = positionsChanged || gpuAggregationChanged || viewportChanged || this.isAggregationDirty(opts, {
1798
+ compareAll: gpuAggregation,
1799
+ dimension: data
1800
+ });
1801
+ const aggregationWeightsDirty = this.isAggregationDirty(opts, { dimension: weights });
1802
+ this.setState({
1803
+ aggregationDataDirty,
1804
+ aggregationWeightsDirty
1805
+ });
1806
+ const { viewport } = this.context;
1807
+ if (viewportChanged || cellSizeChanged) {
1808
+ const { width, height } = viewport;
1809
+ const numCol = Math.ceil(width / cellSize);
1810
+ const numRow = Math.ceil(height / cellSize);
1811
+ this.allocateResources(numRow, numCol);
1812
+ this.setState({
1813
+ scaling: [width / 2, -height / 2, 1],
1814
+ gridOffset: { xOffset: cellSize, yOffset: cellSize },
1815
+ width,
1816
+ height,
1817
+ numCol,
1818
+ numRow
1819
+ });
1820
+ }
1821
+ if (aggregationWeightsDirty) {
1822
+ this._updateAccessors(opts);
1823
+ }
1824
+ if (aggregationDataDirty || aggregationWeightsDirty) {
1825
+ this._resetResults();
1826
+ }
1827
+ }
1828
+ _updateAccessors(opts) {
1829
+ const { getWeight, aggregation, data } = opts.props;
1830
+ const { count } = this.state.weights;
1831
+ if (count) {
1832
+ count.getWeight = getWeight;
1833
+ count.operation = AGGREGATION_OPERATION[aggregation];
1834
+ }
1835
+ this.setState({ getValue: getValueFunc(aggregation, getWeight, { data }) });
1836
+ }
1837
+ _resetResults() {
1838
+ const { count } = this.state.weights;
1839
+ if (count) {
1840
+ count.aggregationData = null;
1841
+ }
1842
+ }
1843
+ };
1844
+ var ScreenGridLayer = _ScreenGridLayer;
1845
+ (() => {
1846
+ _ScreenGridLayer.layerName = "ScreenGridLayer";
1847
+ })();
1848
+ (() => {
1849
+ _ScreenGridLayer.defaultProps = defaultProps3;
1850
+ })();
1851
+
1852
+ // dist/cpu-grid-layer/cpu-grid-layer.js
1853
+ var import_layers = require("@deck.gl/layers");
1854
+
1855
+ // dist/utils/cpu-aggregator.js
1856
+ function noop() {
1857
+ }
1858
+ var dimensionSteps = ["getBins", "getDomain", "getScaleFunc"];
1859
+ var defaultDimensions = [
1860
+ {
1861
+ key: "fillColor",
1862
+ accessor: "getFillColor",
1863
+ pickingInfo: "colorValue",
1864
+ getBins: {
1865
+ triggers: {
1866
+ value: {
1867
+ prop: "getColorValue",
1868
+ updateTrigger: "getColorValue"
1869
+ },
1870
+ weight: {
1871
+ prop: "getColorWeight",
1872
+ updateTrigger: "getColorWeight"
1873
+ },
1874
+ aggregation: {
1875
+ prop: "colorAggregation"
1876
+ },
1877
+ filterData: {
1878
+ prop: "_filterData",
1879
+ updateTrigger: "_filterData"
1880
+ }
1881
+ }
1882
+ },
1883
+ getDomain: {
1884
+ triggers: {
1885
+ lowerPercentile: {
1886
+ prop: "lowerPercentile"
1887
+ },
1888
+ upperPercentile: {
1889
+ prop: "upperPercentile"
1890
+ },
1891
+ scaleType: {
1892
+ prop: "colorScaleType"
1893
+ }
1894
+ }
1895
+ },
1896
+ getScaleFunc: {
1897
+ triggers: {
1898
+ domain: { prop: "colorDomain" },
1899
+ range: { prop: "colorRange" }
1900
+ },
1901
+ onSet: {
1902
+ props: "onSetColorDomain"
1903
+ }
1904
+ },
1905
+ nullValue: [0, 0, 0, 0]
1906
+ },
1907
+ {
1908
+ key: "elevation",
1909
+ accessor: "getElevation",
1910
+ pickingInfo: "elevationValue",
1911
+ getBins: {
1912
+ triggers: {
1913
+ value: {
1914
+ prop: "getElevationValue",
1915
+ updateTrigger: "getElevationValue"
1916
+ },
1917
+ weight: {
1918
+ prop: "getElevationWeight",
1919
+ updateTrigger: "getElevationWeight"
1920
+ },
1921
+ aggregation: {
1922
+ prop: "elevationAggregation"
1923
+ },
1924
+ filterData: {
1925
+ prop: "_filterData",
1926
+ updateTrigger: "_filterData"
1927
+ }
1928
+ }
1929
+ },
1930
+ getDomain: {
1931
+ triggers: {
1932
+ lowerPercentile: {
1933
+ prop: "elevationLowerPercentile"
1934
+ },
1935
+ upperPercentile: {
1936
+ prop: "elevationUpperPercentile"
1937
+ },
1938
+ scaleType: {
1939
+ prop: "elevationScaleType"
1940
+ }
1941
+ }
1942
+ },
1943
+ getScaleFunc: {
1944
+ triggers: {
1945
+ domain: { prop: "elevationDomain" },
1946
+ range: { prop: "elevationRange" }
1947
+ },
1948
+ onSet: {
1949
+ props: "onSetElevationDomain"
1950
+ }
1951
+ },
1952
+ nullValue: -1
1953
+ }
1954
+ ];
1955
+ var defaultGetCellSize = (props) => props.cellSize;
1956
+ var CPUAggregator = class {
1957
+ constructor(opts) {
1958
+ this.state = {
1959
+ layerData: {
1960
+ data: void 0
1961
+ },
1962
+ dimensions: {}
1963
+ };
1964
+ this.changeFlags = {};
1965
+ this.dimensionUpdaters = {};
1966
+ this._getCellSize = opts.getCellSize || defaultGetCellSize;
1967
+ this._getAggregator = opts.getAggregator;
1968
+ this._addDimension(opts.dimensions || defaultDimensions);
1969
+ }
1970
+ static defaultDimensions() {
1971
+ return defaultDimensions;
1972
+ }
1973
+ updateState(opts, aggregationParams) {
1974
+ const { oldProps, props, changeFlags } = opts;
1975
+ this.updateGetValueFuncs(oldProps, props, changeFlags);
1976
+ const reprojectNeeded = this.needsReProjectPoints(oldProps, props, changeFlags);
1977
+ let aggregationDirty = false;
1978
+ if (changeFlags.dataChanged || reprojectNeeded) {
1979
+ this.getAggregatedData(props, aggregationParams);
1980
+ aggregationDirty = true;
1981
+ } else {
1982
+ const dimensionChanges = this.getDimensionChanges(oldProps, props, changeFlags) || [];
1983
+ dimensionChanges.forEach((f) => typeof f === "function" && f());
1984
+ aggregationDirty = true;
1985
+ }
1986
+ this.setState({ aggregationDirty });
1987
+ return this.state;
1988
+ }
1989
+ setState(updateObject) {
1990
+ this.state = { ...this.state, ...updateObject };
1991
+ }
1992
+ setDimensionState(key, updateObject) {
1993
+ this.setState({
1994
+ dimensions: {
1995
+ ...this.state.dimensions,
1996
+ [key]: { ...this.state.dimensions[key], ...updateObject }
1997
+ }
1998
+ });
1999
+ }
2000
+ normalizeResult(result = {}) {
2001
+ if (result.hexagons) {
2002
+ return { data: result.hexagons, ...result };
2003
+ } else if (result.layerData) {
2004
+ return { data: result.layerData, ...result };
2005
+ }
2006
+ return result;
2007
+ }
2008
+ getAggregatedData(props, aggregationParams) {
2009
+ const aggregator = this._getAggregator(props);
2010
+ const result = aggregator(props, aggregationParams);
2011
+ this.setState({
2012
+ layerData: this.normalizeResult(result)
2013
+ });
2014
+ this.changeFlags = {
2015
+ layerData: true
2016
+ };
2017
+ this.getSortedBins(props);
2018
+ }
2019
+ updateGetValueFuncs(oldProps, props, changeFlags) {
2020
+ for (const key in this.dimensionUpdaters) {
2021
+ const { value, weight, aggregation } = this.dimensionUpdaters[key].getBins.triggers;
2022
+ let getValue = props[value.prop];
2023
+ const getValueChanged = this.needUpdateDimensionStep(this.dimensionUpdaters[key].getBins, oldProps, props, changeFlags);
2024
+ if (getValueChanged) {
2025
+ if (getValue) {
2026
+ getValue = wrapGetValueFunc(getValue, { data: props.data });
2027
+ } else {
2028
+ getValue = getValueFunc(props[aggregation.prop], props[weight.prop], { data: props.data });
2029
+ }
2030
+ }
2031
+ if (getValue) {
2032
+ this.setDimensionState(key, { getValue });
2033
+ }
2034
+ }
2035
+ }
2036
+ needsReProjectPoints(oldProps, props, changeFlags) {
2037
+ return this._getCellSize(oldProps) !== this._getCellSize(props) || this._getAggregator(oldProps) !== this._getAggregator(props) || changeFlags.updateTriggersChanged && (changeFlags.updateTriggersChanged.all || changeFlags.updateTriggersChanged.getPosition);
2038
+ }
2039
+ addDimension(dimensions) {
2040
+ this._addDimension(dimensions);
2041
+ }
2042
+ _addDimension(dimensions = []) {
2043
+ dimensions.forEach((dimension) => {
2044
+ const { key } = dimension;
2045
+ this.dimensionUpdaters[key] = this.getDimensionUpdaters(dimension);
2046
+ this.state.dimensions[key] = {
2047
+ getValue: null,
2048
+ domain: null,
2049
+ sortedBins: null,
2050
+ scaleFunc: noop
2051
+ };
2052
+ });
2053
+ }
2054
+ getDimensionUpdaters({ key, accessor, pickingInfo, getBins, getDomain, getScaleFunc, nullValue }) {
2055
+ return {
2056
+ key,
2057
+ accessor,
2058
+ pickingInfo,
2059
+ getBins: { updater: this.getDimensionSortedBins.bind(this), ...getBins },
2060
+ getDomain: { updater: this.getDimensionValueDomain.bind(this), ...getDomain },
2061
+ getScaleFunc: { updater: this.getDimensionScale.bind(this), ...getScaleFunc },
2062
+ attributeAccessor: this.getSubLayerDimensionAttribute(key, nullValue)
2063
+ };
2064
+ }
2065
+ needUpdateDimensionStep(dimensionStep, oldProps, props, changeFlags) {
2066
+ return Object.values(dimensionStep.triggers).some((item) => {
2067
+ if (item.updateTrigger) {
2068
+ return changeFlags.dataChanged || changeFlags.updateTriggersChanged && (changeFlags.updateTriggersChanged.all || changeFlags.updateTriggersChanged[item.updateTrigger]);
2069
+ }
2070
+ return oldProps[item.prop] !== props[item.prop];
2071
+ });
2072
+ }
2073
+ getDimensionChanges(oldProps, props, changeFlags) {
2074
+ const updaters = [];
2075
+ for (const key in this.dimensionUpdaters) {
2076
+ const needUpdate = dimensionSteps.find((step) => this.needUpdateDimensionStep(this.dimensionUpdaters[key][step], oldProps, props, changeFlags));
2077
+ if (needUpdate) {
2078
+ updaters.push(this.dimensionUpdaters[key][needUpdate].updater.bind(this, props, this.dimensionUpdaters[key]));
2079
+ }
2080
+ }
2081
+ return updaters.length ? updaters : null;
2082
+ }
2083
+ getUpdateTriggers(props) {
2084
+ const _updateTriggers = props.updateTriggers || {};
2085
+ const updateTriggers = {};
2086
+ for (const key in this.dimensionUpdaters) {
2087
+ const { accessor } = this.dimensionUpdaters[key];
2088
+ updateTriggers[accessor] = {};
2089
+ dimensionSteps.forEach((step) => {
2090
+ Object.values(this.dimensionUpdaters[key][step].triggers).forEach(({ prop, updateTrigger }) => {
2091
+ if (updateTrigger) {
2092
+ const fromProp = _updateTriggers[updateTrigger];
2093
+ if (typeof fromProp === "object" && !Array.isArray(fromProp)) {
2094
+ Object.assign(updateTriggers[accessor], fromProp);
2095
+ } else if (fromProp !== void 0) {
2096
+ updateTriggers[accessor][prop] = fromProp;
2097
+ }
2098
+ } else {
2099
+ updateTriggers[accessor][prop] = props[prop];
2100
+ }
2101
+ });
2102
+ });
2103
+ }
2104
+ return updateTriggers;
2105
+ }
2106
+ getSortedBins(props) {
2107
+ for (const key in this.dimensionUpdaters) {
2108
+ this.getDimensionSortedBins(props, this.dimensionUpdaters[key]);
2109
+ }
2110
+ }
2111
+ getDimensionSortedBins(props, dimensionUpdater) {
2112
+ const { key } = dimensionUpdater;
2113
+ const { getValue } = this.state.dimensions[key];
2114
+ const sortedBins = new BinSorter(this.state.layerData.data || [], {
2115
+ getValue,
2116
+ filterData: props._filterData
2117
+ });
2118
+ this.setDimensionState(key, { sortedBins });
2119
+ this.getDimensionValueDomain(props, dimensionUpdater);
2120
+ }
2121
+ getDimensionValueDomain(props, dimensionUpdater) {
2122
+ const { getDomain, key } = dimensionUpdater;
2123
+ const { triggers: { lowerPercentile, upperPercentile, scaleType } } = getDomain;
2124
+ const valueDomain = this.state.dimensions[key].sortedBins.getValueDomainByScale(props[scaleType.prop], [props[lowerPercentile.prop], props[upperPercentile.prop]]);
2125
+ this.setDimensionState(key, { valueDomain });
2126
+ this.getDimensionScale(props, dimensionUpdater);
2127
+ }
2128
+ getDimensionScale(props, dimensionUpdater) {
2129
+ const { key, getScaleFunc, getDomain } = dimensionUpdater;
2130
+ const { domain, range } = getScaleFunc.triggers;
2131
+ const { scaleType } = getDomain.triggers;
2132
+ const { onSet } = getScaleFunc;
2133
+ const dimensionRange = props[range.prop];
2134
+ const dimensionDomain = props[domain.prop] || this.state.dimensions[key].valueDomain;
2135
+ const getScaleFunction = getScaleFunctionByScaleType(scaleType && props[scaleType.prop]);
2136
+ const scaleFunc = getScaleFunction(dimensionDomain, dimensionRange);
2137
+ if (typeof onSet === "object" && typeof props[onSet.props] === "function") {
2138
+ props[onSet.props](scaleFunc.domain());
2139
+ }
2140
+ this.setDimensionState(key, { scaleFunc });
2141
+ }
2142
+ getSubLayerDimensionAttribute(key, nullValue) {
2143
+ return (cell) => {
2144
+ const { sortedBins, scaleFunc } = this.state.dimensions[key];
2145
+ const bin = sortedBins.binMap[cell.index];
2146
+ if (bin && bin.counts === 0) {
2147
+ return nullValue;
2148
+ }
2149
+ const cv = bin && bin.value;
2150
+ const domain = scaleFunc.domain();
2151
+ const isValueInDomain = cv >= domain[0] && cv <= domain[domain.length - 1];
2152
+ return isValueInDomain ? scaleFunc(cv) : nullValue;
2153
+ };
2154
+ }
2155
+ getSubLayerAccessors(props) {
2156
+ const accessors = {};
2157
+ for (const key in this.dimensionUpdaters) {
2158
+ const { accessor } = this.dimensionUpdaters[key];
2159
+ accessors[accessor] = this.getSubLayerDimensionAttribute(props, key);
2160
+ }
2161
+ return accessors;
2162
+ }
2163
+ getPickingInfo({ info }) {
2164
+ const isPicked = info.picked && info.index > -1;
2165
+ let object = null;
2166
+ if (isPicked) {
2167
+ const cell = this.state.layerData.data[info.index];
2168
+ const binInfo = {};
2169
+ for (const key in this.dimensionUpdaters) {
2170
+ const { pickingInfo } = this.dimensionUpdaters[key];
2171
+ const { sortedBins } = this.state.dimensions[key];
2172
+ const value = sortedBins.binMap[cell.index] && sortedBins.binMap[cell.index].value;
2173
+ binInfo[pickingInfo] = value;
2174
+ }
2175
+ object = Object.assign(binInfo, cell, {
2176
+ points: cell.filteredPoints || cell.points
2177
+ });
2178
+ }
2179
+ info.picked = Boolean(object);
2180
+ info.object = object;
2181
+ return info;
2182
+ }
2183
+ getAccessor(dimensionKey) {
2184
+ if (!this.dimensionUpdaters.hasOwnProperty(dimensionKey)) {
2185
+ return noop;
2186
+ }
2187
+ return this.dimensionUpdaters[dimensionKey].attributeAccessor;
2188
+ }
2189
+ };
2190
+
2191
+ // dist/cpu-grid-layer/cpu-grid-layer.js
2192
+ function nop() {
2193
+ }
2194
+ var defaultProps4 = {
2195
+ colorDomain: null,
2196
+ colorRange: defaultColorRange,
2197
+ getColorValue: { type: "accessor", value: null },
2198
+ getColorWeight: { type: "accessor", value: 1 },
2199
+ colorAggregation: "SUM",
2200
+ lowerPercentile: { type: "number", min: 0, max: 100, value: 0 },
2201
+ upperPercentile: { type: "number", min: 0, max: 100, value: 100 },
2202
+ colorScaleType: "quantize",
2203
+ onSetColorDomain: nop,
2204
+ elevationDomain: null,
2205
+ elevationRange: [0, 1e3],
2206
+ getElevationValue: { type: "accessor", value: null },
2207
+ getElevationWeight: { type: "accessor", value: 1 },
2208
+ elevationAggregation: "SUM",
2209
+ elevationLowerPercentile: { type: "number", min: 0, max: 100, value: 0 },
2210
+ elevationUpperPercentile: { type: "number", min: 0, max: 100, value: 100 },
2211
+ elevationScale: { type: "number", min: 0, value: 1 },
2212
+ elevationScaleType: "linear",
2213
+ onSetElevationDomain: nop,
2214
+ gridAggregator: pointToDensityGridDataCPU,
2215
+ cellSize: { type: "number", min: 0, max: 1e3, value: 1e3 },
2216
+ coverage: { type: "number", min: 0, max: 1, value: 1 },
2217
+ getPosition: { type: "accessor", value: (x) => x.position },
2218
+ extruded: false,
2219
+ material: true,
2220
+ _filterData: { type: "function", value: null, optional: true }
2221
+ };
2222
+ var _CPUGridLayer = class extends AggregationLayer {
2223
+ initializeState() {
2224
+ const cpuAggregator = new CPUAggregator({
2225
+ getAggregator: (props) => props.gridAggregator,
2226
+ getCellSize: (props) => props.cellSize
2227
+ });
2228
+ this.state = {
2229
+ cpuAggregator,
2230
+ aggregatorState: cpuAggregator.state
2231
+ };
2232
+ const attributeManager = this.getAttributeManager();
2233
+ attributeManager.add({
2234
+ positions: { size: 3, type: "float64", accessor: "getPosition" }
2235
+ });
2236
+ }
2237
+ updateState(opts) {
2238
+ super.updateState(opts);
2239
+ this.setState({
2240
+ aggregatorState: this.state.cpuAggregator.updateState(opts, {
2241
+ viewport: this.context.viewport,
2242
+ attributes: this.getAttributes(),
2243
+ numInstances: this.getNumInstances()
2244
+ })
2245
+ });
2246
+ }
2247
+ getPickingInfo({ info }) {
2248
+ return this.state.cpuAggregator.getPickingInfo({ info });
2249
+ }
2250
+ _onGetSublayerColor(cell) {
2251
+ return this.state.cpuAggregator.getAccessor("fillColor")(cell);
2252
+ }
2253
+ _onGetSublayerElevation(cell) {
2254
+ return this.state.cpuAggregator.getAccessor("elevation")(cell);
2255
+ }
2256
+ _getSublayerUpdateTriggers() {
2257
+ return this.state.cpuAggregator.getUpdateTriggers(this.props);
2258
+ }
2259
+ renderLayers() {
2260
+ const { elevationScale, extruded, cellSize, coverage, material, transitions } = this.props;
2261
+ const { cpuAggregator } = this.state;
2262
+ const SubLayerClass = this.getSubLayerClass("grid-cell", import_layers.GridCellLayer);
2263
+ const updateTriggers = this._getSublayerUpdateTriggers();
2264
+ return new SubLayerClass({
2265
+ cellSize,
2266
+ coverage,
2267
+ material,
2268
+ elevationScale,
2269
+ extruded,
2270
+ getFillColor: this._onGetSublayerColor.bind(this),
2271
+ getElevation: this._onGetSublayerElevation.bind(this),
2272
+ transitions: transitions && {
2273
+ getFillColor: transitions.getColorValue || transitions.getColorWeight,
2274
+ getElevation: transitions.getElevationValue || transitions.getElevationWeight
2275
+ }
2276
+ }, this.getSubLayerProps({
2277
+ id: "grid-cell",
2278
+ updateTriggers
2279
+ }), {
2280
+ data: cpuAggregator.state.layerData.data
2281
+ });
2282
+ }
2283
+ };
2284
+ var CPUGridLayer = _CPUGridLayer;
2285
+ (() => {
2286
+ _CPUGridLayer.layerName = "CPUGridLayer";
2287
+ })();
2288
+ (() => {
2289
+ _CPUGridLayer.defaultProps = defaultProps4;
2290
+ })();
2291
+
2292
+ // dist/hexagon-layer/hexagon-layer.js
2293
+ var import_core10 = require("@deck.gl/core");
2294
+ var import_layers2 = require("@deck.gl/layers");
2295
+
2296
+ // dist/hexagon-layer/hexagon-aggregator.js
2297
+ var import_d3_hexbin = require("d3-hexbin");
2298
+ var import_core9 = require("@deck.gl/core");
2299
+ function pointToHexbin(props, aggregationParams) {
2300
+ const { data, radius } = props;
2301
+ const { viewport, attributes } = aggregationParams;
2302
+ const centerLngLat = data.length ? getPointsCenter(data, aggregationParams) : null;
2303
+ const radiusCommon = getRadiusInCommon(radius, viewport, centerLngLat);
2304
+ const screenPoints = [];
2305
+ const { iterable, objectInfo } = (0, import_core9.createIterable)(data);
2306
+ const positions = attributes.positions.value;
2307
+ const { size } = attributes.positions.getAccessor();
2308
+ for (const object of iterable) {
2309
+ objectInfo.index++;
2310
+ const posIndex = objectInfo.index * size;
2311
+ const position = [positions[posIndex], positions[posIndex + 1]];
2312
+ const arrayIsFinite = Number.isFinite(position[0]) && Number.isFinite(position[1]);
2313
+ if (arrayIsFinite) {
2314
+ screenPoints.push({
2315
+ screenCoord: viewport.projectFlat(position),
2316
+ source: object,
2317
+ index: objectInfo.index
2318
+ });
2319
+ } else {
2320
+ import_core9.log.warn("HexagonLayer: invalid position")();
2321
+ }
2322
+ }
2323
+ const newHexbin = (0, import_d3_hexbin.hexbin)().radius(radiusCommon).x((d) => d.screenCoord[0]).y((d) => d.screenCoord[1]);
2324
+ const hexagonBins = newHexbin(screenPoints);
2325
+ return {
2326
+ hexagons: hexagonBins.map((hex, index) => ({
2327
+ position: viewport.unprojectFlat([hex.x, hex.y]),
2328
+ points: hex,
2329
+ index
2330
+ })),
2331
+ radiusCommon
2332
+ };
2333
+ }
2334
+ function getPointsCenter(data, aggregationParams) {
2335
+ const { attributes } = aggregationParams;
2336
+ const positions = attributes.positions.value;
2337
+ const { size } = attributes.positions.getAccessor();
2338
+ let minX = Infinity;
2339
+ let minY = Infinity;
2340
+ let maxX = -Infinity;
2341
+ let maxY = -Infinity;
2342
+ let i;
2343
+ for (i = 0; i < size * data.length; i += size) {
2344
+ const x = positions[i];
2345
+ const y = positions[i + 1];
2346
+ const arrayIsFinite = Number.isFinite(x) && Number.isFinite(y);
2347
+ if (arrayIsFinite) {
2348
+ minX = Math.min(x, minX);
2349
+ maxX = Math.max(x, maxX);
2350
+ minY = Math.min(y, minY);
2351
+ maxY = Math.max(y, maxY);
2352
+ }
2353
+ }
2354
+ return [minX, minY, maxX, maxY].every(Number.isFinite) ? [(minX + maxX) / 2, (minY + maxY) / 2] : null;
2355
+ }
2356
+ function getRadiusInCommon(radius, viewport, center) {
2357
+ const { unitsPerMeter } = viewport.getDistanceScales(center);
2358
+ return radius * unitsPerMeter[0];
2359
+ }
2360
+
2361
+ // dist/hexagon-layer/hexagon-layer.js
2362
+ function nop2() {
2363
+ }
2364
+ var defaultProps5 = {
2365
+ colorDomain: null,
2366
+ colorRange: defaultColorRange,
2367
+ getColorValue: { type: "accessor", value: null },
2368
+ getColorWeight: { type: "accessor", value: 1 },
2369
+ colorAggregation: "SUM",
2370
+ lowerPercentile: { type: "number", value: 0, min: 0, max: 100 },
2371
+ upperPercentile: { type: "number", value: 100, min: 0, max: 100 },
2372
+ colorScaleType: "quantize",
2373
+ onSetColorDomain: nop2,
2374
+ elevationDomain: null,
2375
+ elevationRange: [0, 1e3],
2376
+ getElevationValue: { type: "accessor", value: null },
2377
+ getElevationWeight: { type: "accessor", value: 1 },
2378
+ elevationAggregation: "SUM",
2379
+ elevationLowerPercentile: { type: "number", value: 0, min: 0, max: 100 },
2380
+ elevationUpperPercentile: { type: "number", value: 100, min: 0, max: 100 },
2381
+ elevationScale: { type: "number", min: 0, value: 1 },
2382
+ elevationScaleType: "linear",
2383
+ onSetElevationDomain: nop2,
2384
+ radius: { type: "number", value: 1e3, min: 1 },
2385
+ coverage: { type: "number", min: 0, max: 1, value: 1 },
2386
+ extruded: false,
2387
+ hexagonAggregator: pointToHexbin,
2388
+ getPosition: { type: "accessor", value: (x) => x.position },
2389
+ material: true,
2390
+ _filterData: { type: "function", value: null, optional: true }
2391
+ };
2392
+ var _HexagonLayer = class extends AggregationLayer {
2393
+ initializeState() {
2394
+ const cpuAggregator = new CPUAggregator({
2395
+ getAggregator: (props) => props.hexagonAggregator,
2396
+ getCellSize: (props) => props.radius
2397
+ });
2398
+ this.state = {
2399
+ cpuAggregator,
2400
+ aggregatorState: cpuAggregator.state,
2401
+ vertices: null
2402
+ };
2403
+ const attributeManager = this.getAttributeManager();
2404
+ attributeManager.add({
2405
+ positions: { size: 3, type: "float64", accessor: "getPosition" }
2406
+ });
2407
+ }
2408
+ updateState(opts) {
2409
+ super.updateState(opts);
2410
+ if (opts.changeFlags.propsOrDataChanged) {
2411
+ const aggregatorState = this.state.cpuAggregator.updateState(opts, {
2412
+ viewport: this.context.viewport,
2413
+ attributes: this.getAttributes()
2414
+ });
2415
+ if (this.state.aggregatorState.layerData !== aggregatorState.layerData) {
2416
+ const { hexagonVertices } = aggregatorState.layerData || {};
2417
+ this.setState({
2418
+ vertices: hexagonVertices && this.convertLatLngToMeterOffset(hexagonVertices)
2419
+ });
2420
+ }
2421
+ this.setState({
2422
+ aggregatorState
2423
+ });
2424
+ }
2425
+ }
2426
+ convertLatLngToMeterOffset(hexagonVertices) {
2427
+ const { viewport } = this.context;
2428
+ if (Array.isArray(hexagonVertices) && hexagonVertices.length === 6) {
2429
+ const vertex0 = hexagonVertices[0];
2430
+ const vertex3 = hexagonVertices[3];
2431
+ const centroid = [(vertex0[0] + vertex3[0]) / 2, (vertex0[1] + vertex3[1]) / 2];
2432
+ const centroidFlat = viewport.projectFlat(centroid);
2433
+ const { metersPerUnit } = viewport.getDistanceScales(centroid);
2434
+ const vertices = hexagonVertices.map((vt) => {
2435
+ const vtFlat = viewport.projectFlat(vt);
2436
+ return [
2437
+ (vtFlat[0] - centroidFlat[0]) * metersPerUnit[0],
2438
+ (vtFlat[1] - centroidFlat[1]) * metersPerUnit[1]
2439
+ ];
2440
+ });
2441
+ return vertices;
2442
+ }
2443
+ import_core10.log.error("HexagonLayer: hexagonVertices needs to be an array of 6 points")();
2444
+ return null;
2445
+ }
2446
+ getPickingInfo({ info }) {
2447
+ return this.state.cpuAggregator.getPickingInfo({ info });
2448
+ }
2449
+ _onGetSublayerColor(cell) {
2450
+ return this.state.cpuAggregator.getAccessor("fillColor")(cell);
2451
+ }
2452
+ _onGetSublayerElevation(cell) {
2453
+ return this.state.cpuAggregator.getAccessor("elevation")(cell);
2454
+ }
2455
+ _getSublayerUpdateTriggers() {
2456
+ return this.state.cpuAggregator.getUpdateTriggers(this.props);
2457
+ }
2458
+ renderLayers() {
2459
+ const { elevationScale, extruded, coverage, material, transitions } = this.props;
2460
+ const { aggregatorState, vertices } = this.state;
2461
+ const SubLayerClass = this.getSubLayerClass("hexagon-cell", import_layers2.ColumnLayer);
2462
+ const updateTriggers = this._getSublayerUpdateTriggers();
2463
+ const geometry = vertices ? { vertices, radius: 1 } : {
2464
+ radius: aggregatorState.layerData.radiusCommon || 1,
2465
+ radiusUnits: "common",
2466
+ angle: 90
2467
+ };
2468
+ return new SubLayerClass({
2469
+ ...geometry,
2470
+ diskResolution: 6,
2471
+ elevationScale,
2472
+ extruded,
2473
+ coverage,
2474
+ material,
2475
+ getFillColor: this._onGetSublayerColor.bind(this),
2476
+ getElevation: this._onGetSublayerElevation.bind(this),
2477
+ transitions: transitions && {
2478
+ getFillColor: transitions.getColorValue || transitions.getColorWeight,
2479
+ getElevation: transitions.getElevationValue || transitions.getElevationWeight
2480
+ }
2481
+ }, this.getSubLayerProps({
2482
+ id: "hexagon-cell",
2483
+ updateTriggers
2484
+ }), {
2485
+ data: aggregatorState.layerData.data
2486
+ });
2487
+ }
2488
+ };
2489
+ var HexagonLayer = _HexagonLayer;
2490
+ (() => {
2491
+ _HexagonLayer.layerName = "HexagonLayer";
2492
+ })();
2493
+ (() => {
2494
+ _HexagonLayer.defaultProps = defaultProps5;
2495
+ })();
2496
+
2497
+ // dist/contour-layer/contour-layer.js
2498
+ var import_layers3 = require("@deck.gl/layers");
2499
+
2500
+ // dist/contour-layer/marching-squares.js
2501
+ var import_core11 = require("@deck.gl/core");
2502
+
2503
+ // dist/contour-layer/marching-squares-codes.js
2504
+ var HALF = 0.5;
2505
+ var ONE6TH = 1 / 6;
2506
+ var OFFSET = {
2507
+ N: [0, HALF],
2508
+ E: [HALF, 0],
2509
+ S: [0, -HALF],
2510
+ W: [-HALF, 0],
2511
+ NE: [HALF, HALF],
2512
+ NW: [-HALF, HALF],
2513
+ SE: [HALF, -HALF],
2514
+ SW: [-HALF, -HALF]
2515
+ };
2516
+ var SW_TRIANGLE = [OFFSET.W, OFFSET.SW, OFFSET.S];
2517
+ var SE_TRIANGLE = [OFFSET.S, OFFSET.SE, OFFSET.E];
2518
+ var NE_TRIANGLE = [OFFSET.E, OFFSET.NE, OFFSET.N];
2519
+ var NW_TRIANGLE = [OFFSET.NW, OFFSET.W, OFFSET.N];
2520
+ var SW_TRAPEZOID = [
2521
+ [-HALF, ONE6TH],
2522
+ [-HALF, -ONE6TH],
2523
+ [-ONE6TH, -HALF],
2524
+ [ONE6TH, -HALF]
2525
+ ];
2526
+ var SE_TRAPEZOID = [
2527
+ [-ONE6TH, -HALF],
2528
+ [ONE6TH, -HALF],
2529
+ [HALF, -ONE6TH],
2530
+ [HALF, ONE6TH]
2531
+ ];
2532
+ var NE_TRAPEZOID = [
2533
+ [HALF, -ONE6TH],
2534
+ [HALF, ONE6TH],
2535
+ [ONE6TH, HALF],
2536
+ [-ONE6TH, HALF]
2537
+ ];
2538
+ var NW_TRAPEZOID = [
2539
+ [-HALF, ONE6TH],
2540
+ [-HALF, -ONE6TH],
2541
+ [ONE6TH, HALF],
2542
+ [-ONE6TH, HALF]
2543
+ ];
2544
+ var S_RECTANGLE = [OFFSET.W, OFFSET.SW, OFFSET.SE, OFFSET.E];
2545
+ var E_RECTANGLE = [OFFSET.S, OFFSET.SE, OFFSET.NE, OFFSET.N];
2546
+ var N_RECTANGLE = [OFFSET.NW, OFFSET.W, OFFSET.E, OFFSET.NE];
2547
+ var W_RECTANGLE = [OFFSET.NW, OFFSET.SW, OFFSET.S, OFFSET.N];
2548
+ var EW_RECTANGEL = [
2549
+ [-HALF, ONE6TH],
2550
+ [-HALF, -ONE6TH],
2551
+ [HALF, -ONE6TH],
2552
+ [HALF, ONE6TH]
2553
+ ];
2554
+ var SN_RECTANGEL = [
2555
+ [-ONE6TH, -HALF],
2556
+ [ONE6TH, -HALF],
2557
+ [ONE6TH, HALF],
2558
+ [-ONE6TH, HALF]
2559
+ ];
2560
+ var SQUARE = [OFFSET.NW, OFFSET.SW, OFFSET.SE, OFFSET.NE];
2561
+ var SW_PENTAGON = [OFFSET.NW, OFFSET.SW, OFFSET.SE, OFFSET.E, OFFSET.N];
2562
+ var SE_PENTAGON = [OFFSET.W, OFFSET.SW, OFFSET.SE, OFFSET.NE, OFFSET.N];
2563
+ var NE_PENTAGON = [OFFSET.NW, OFFSET.W, OFFSET.S, OFFSET.SE, OFFSET.NE];
2564
+ var NW_PENTAGON = [OFFSET.NW, OFFSET.SW, OFFSET.S, OFFSET.E, OFFSET.NE];
2565
+ var NW_N_PENTAGON = [OFFSET.NW, OFFSET.W, [HALF, -ONE6TH], [HALF, ONE6TH], OFFSET.N];
2566
+ var NE_E_PENTAGON = [[-ONE6TH, -HALF], [ONE6TH, -HALF], OFFSET.E, OFFSET.NE, OFFSET.N];
2567
+ var SE_S_PENTAGON = [[-HALF, ONE6TH], [-HALF, -ONE6TH], OFFSET.S, OFFSET.SE, OFFSET.E];
2568
+ var SW_W_PENTAGON = [OFFSET.W, OFFSET.SW, OFFSET.S, [ONE6TH, HALF], [-ONE6TH, HALF]];
2569
+ var NW_W_PENTAGON = [OFFSET.NW, OFFSET.W, [-ONE6TH, -HALF], [ONE6TH, -HALF], OFFSET.N];
2570
+ var NE_N_PENTAGON = [[-HALF, ONE6TH], [-HALF, -ONE6TH], OFFSET.E, OFFSET.NE, OFFSET.N];
2571
+ var SE_E_PENTAGON = [OFFSET.S, OFFSET.SE, OFFSET.E, [ONE6TH, HALF], [-ONE6TH, HALF]];
2572
+ var SW_S_PENTAGON = [OFFSET.W, OFFSET.SW, OFFSET.S, [HALF, -ONE6TH], [HALF, ONE6TH]];
2573
+ var S_HEXAGON = [OFFSET.W, OFFSET.SW, OFFSET.SE, OFFSET.E, [ONE6TH, HALF], [-ONE6TH, HALF]];
2574
+ var E_HEXAGON = [[-HALF, ONE6TH], [-HALF, -ONE6TH], OFFSET.S, OFFSET.SE, OFFSET.NE, OFFSET.N];
2575
+ var N_HEXAGON = [OFFSET.NW, OFFSET.W, [-ONE6TH, -HALF], [ONE6TH, -HALF], OFFSET.E, OFFSET.NE];
2576
+ var W_HEXAGON = [OFFSET.NW, OFFSET.SW, OFFSET.S, [HALF, -ONE6TH], [HALF, ONE6TH], OFFSET.N];
2577
+ var SW_NE_HEXAGON = [OFFSET.W, OFFSET.SW, OFFSET.S, OFFSET.E, OFFSET.NE, OFFSET.N];
2578
+ var NW_SE_HEXAGON = [OFFSET.NW, OFFSET.W, OFFSET.S, OFFSET.SE, OFFSET.E, OFFSET.N];
2579
+ var NE_HEPTAGON = [
2580
+ [-HALF, ONE6TH],
2581
+ [-HALF, -ONE6TH],
2582
+ [-ONE6TH, -HALF],
2583
+ [ONE6TH, -HALF],
2584
+ OFFSET.E,
2585
+ OFFSET.NE,
2586
+ OFFSET.N
2587
+ ];
2588
+ var SW_HEPTAGON = [
2589
+ OFFSET.W,
2590
+ OFFSET.SW,
2591
+ OFFSET.S,
2592
+ [HALF, -ONE6TH],
2593
+ [HALF, ONE6TH],
2594
+ [ONE6TH, HALF],
2595
+ [-ONE6TH, HALF]
2596
+ ];
2597
+ var NW_HEPTAGON = [
2598
+ OFFSET.NW,
2599
+ OFFSET.W,
2600
+ [-ONE6TH, -HALF],
2601
+ [ONE6TH, -HALF],
2602
+ [HALF, -ONE6TH],
2603
+ [HALF, ONE6TH],
2604
+ OFFSET.N
2605
+ ];
2606
+ var SE_HEPTAGON = [
2607
+ [-HALF, ONE6TH],
2608
+ [-HALF, -ONE6TH],
2609
+ OFFSET.S,
2610
+ OFFSET.SE,
2611
+ OFFSET.E,
2612
+ [ONE6TH, HALF],
2613
+ [-ONE6TH, HALF]
2614
+ ];
2615
+ var OCTAGON = [
2616
+ [-HALF, ONE6TH],
2617
+ [-HALF, -ONE6TH],
2618
+ [-ONE6TH, -HALF],
2619
+ [ONE6TH, -HALF],
2620
+ [HALF, -ONE6TH],
2621
+ [HALF, ONE6TH],
2622
+ [ONE6TH, HALF],
2623
+ [-ONE6TH, HALF]
2624
+ ];
2625
+ var ISOLINES_CODE_OFFSET_MAP = {
2626
+ 0: [],
2627
+ 1: [[OFFSET.W, OFFSET.S]],
2628
+ 2: [[OFFSET.S, OFFSET.E]],
2629
+ 3: [[OFFSET.W, OFFSET.E]],
2630
+ 4: [[OFFSET.N, OFFSET.E]],
2631
+ 5: {
2632
+ 0: [
2633
+ [OFFSET.W, OFFSET.S],
2634
+ [OFFSET.N, OFFSET.E]
2635
+ ],
2636
+ 1: [
2637
+ [OFFSET.W, OFFSET.N],
2638
+ [OFFSET.S, OFFSET.E]
2639
+ ]
2640
+ },
2641
+ 6: [[OFFSET.N, OFFSET.S]],
2642
+ 7: [[OFFSET.W, OFFSET.N]],
2643
+ 8: [[OFFSET.W, OFFSET.N]],
2644
+ 9: [[OFFSET.N, OFFSET.S]],
2645
+ 10: {
2646
+ 0: [
2647
+ [OFFSET.W, OFFSET.N],
2648
+ [OFFSET.S, OFFSET.E]
2649
+ ],
2650
+ 1: [
2651
+ [OFFSET.W, OFFSET.S],
2652
+ [OFFSET.N, OFFSET.E]
2653
+ ]
2654
+ },
2655
+ 11: [[OFFSET.N, OFFSET.E]],
2656
+ 12: [[OFFSET.W, OFFSET.E]],
2657
+ 13: [[OFFSET.S, OFFSET.E]],
2658
+ 14: [[OFFSET.W, OFFSET.S]],
2659
+ 15: []
2660
+ };
2661
+ function ternaryToIndex(ternary) {
2662
+ return parseInt(ternary, 4);
2663
+ }
2664
+ var ISOBANDS_CODE_OFFSET_MAP = {
2665
+ [ternaryToIndex("0000")]: [],
2666
+ [ternaryToIndex("2222")]: [],
2667
+ [ternaryToIndex("2221")]: [SW_TRIANGLE],
2668
+ [ternaryToIndex("2212")]: [SE_TRIANGLE],
2669
+ [ternaryToIndex("2122")]: [NE_TRIANGLE],
2670
+ [ternaryToIndex("1222")]: [NW_TRIANGLE],
2671
+ [ternaryToIndex("0001")]: [SW_TRIANGLE],
2672
+ [ternaryToIndex("0010")]: [SE_TRIANGLE],
2673
+ [ternaryToIndex("0100")]: [NE_TRIANGLE],
2674
+ [ternaryToIndex("1000")]: [NW_TRIANGLE],
2675
+ [ternaryToIndex("2220")]: [SW_TRAPEZOID],
2676
+ [ternaryToIndex("2202")]: [SE_TRAPEZOID],
2677
+ [ternaryToIndex("2022")]: [NE_TRAPEZOID],
2678
+ [ternaryToIndex("0222")]: [NW_TRAPEZOID],
2679
+ [ternaryToIndex("0002")]: [SW_TRAPEZOID],
2680
+ [ternaryToIndex("0020")]: [SE_TRAPEZOID],
2681
+ [ternaryToIndex("0200")]: [NE_TRAPEZOID],
2682
+ [ternaryToIndex("2000")]: [NW_TRAPEZOID],
2683
+ [ternaryToIndex("0011")]: [S_RECTANGLE],
2684
+ [ternaryToIndex("0110")]: [E_RECTANGLE],
2685
+ [ternaryToIndex("1100")]: [N_RECTANGLE],
2686
+ [ternaryToIndex("1001")]: [W_RECTANGLE],
2687
+ [ternaryToIndex("2211")]: [S_RECTANGLE],
2688
+ [ternaryToIndex("2112")]: [E_RECTANGLE],
2689
+ [ternaryToIndex("1122")]: [N_RECTANGLE],
2690
+ [ternaryToIndex("1221")]: [W_RECTANGLE],
2691
+ [ternaryToIndex("2200")]: [EW_RECTANGEL],
2692
+ [ternaryToIndex("2002")]: [SN_RECTANGEL],
2693
+ [ternaryToIndex("0022")]: [EW_RECTANGEL],
2694
+ [ternaryToIndex("0220")]: [SN_RECTANGEL],
2695
+ [ternaryToIndex("1111")]: [SQUARE],
2696
+ [ternaryToIndex("1211")]: [SW_PENTAGON],
2697
+ [ternaryToIndex("2111")]: [SE_PENTAGON],
2698
+ [ternaryToIndex("1112")]: [NE_PENTAGON],
2699
+ [ternaryToIndex("1121")]: [NW_PENTAGON],
2700
+ [ternaryToIndex("1011")]: [SW_PENTAGON],
2701
+ [ternaryToIndex("0111")]: [SE_PENTAGON],
2702
+ [ternaryToIndex("1110")]: [NE_PENTAGON],
2703
+ [ternaryToIndex("1101")]: [NW_PENTAGON],
2704
+ [ternaryToIndex("1200")]: [NW_N_PENTAGON],
2705
+ [ternaryToIndex("0120")]: [NE_E_PENTAGON],
2706
+ [ternaryToIndex("0012")]: [SE_S_PENTAGON],
2707
+ [ternaryToIndex("2001")]: [SW_W_PENTAGON],
2708
+ [ternaryToIndex("1022")]: [NW_N_PENTAGON],
2709
+ [ternaryToIndex("2102")]: [NE_E_PENTAGON],
2710
+ [ternaryToIndex("2210")]: [SE_S_PENTAGON],
2711
+ [ternaryToIndex("0221")]: [SW_W_PENTAGON],
2712
+ [ternaryToIndex("1002")]: [NW_W_PENTAGON],
2713
+ [ternaryToIndex("2100")]: [NE_N_PENTAGON],
2714
+ [ternaryToIndex("0210")]: [SE_E_PENTAGON],
2715
+ [ternaryToIndex("0021")]: [SW_S_PENTAGON],
2716
+ [ternaryToIndex("1220")]: [NW_W_PENTAGON],
2717
+ [ternaryToIndex("0122")]: [NE_N_PENTAGON],
2718
+ [ternaryToIndex("2012")]: [SE_E_PENTAGON],
2719
+ [ternaryToIndex("2201")]: [SW_S_PENTAGON],
2720
+ [ternaryToIndex("0211")]: [S_HEXAGON],
2721
+ [ternaryToIndex("2110")]: [E_HEXAGON],
2722
+ [ternaryToIndex("1102")]: [N_HEXAGON],
2723
+ [ternaryToIndex("1021")]: [W_HEXAGON],
2724
+ [ternaryToIndex("2011")]: [S_HEXAGON],
2725
+ [ternaryToIndex("0112")]: [E_HEXAGON],
2726
+ [ternaryToIndex("1120")]: [N_HEXAGON],
2727
+ [ternaryToIndex("1201")]: [W_HEXAGON],
2728
+ [ternaryToIndex("2101")]: [SW_NE_HEXAGON],
2729
+ [ternaryToIndex("0121")]: [SW_NE_HEXAGON],
2730
+ [ternaryToIndex("1012")]: [NW_SE_HEXAGON],
2731
+ [ternaryToIndex("1210")]: [NW_SE_HEXAGON],
2732
+ [ternaryToIndex("0101")]: {
2733
+ 0: [SW_TRIANGLE, NE_TRIANGLE],
2734
+ 1: [SW_NE_HEXAGON],
2735
+ 2: [SW_NE_HEXAGON]
2736
+ },
2737
+ [ternaryToIndex("1010")]: {
2738
+ 0: [NW_TRIANGLE, SE_TRIANGLE],
2739
+ 1: [NW_SE_HEXAGON],
2740
+ 2: [NW_SE_HEXAGON]
2741
+ },
2742
+ [ternaryToIndex("2121")]: {
2743
+ 0: [SW_NE_HEXAGON],
2744
+ 1: [SW_NE_HEXAGON],
2745
+ 2: [SW_TRIANGLE, NE_TRIANGLE]
2746
+ },
2747
+ [ternaryToIndex("1212")]: {
2748
+ 0: [NW_SE_HEXAGON],
2749
+ 1: [NW_SE_HEXAGON],
2750
+ 2: [NW_TRIANGLE, SE_TRIANGLE]
2751
+ },
2752
+ [ternaryToIndex("2120")]: {
2753
+ 0: [NE_HEPTAGON],
2754
+ 1: [NE_HEPTAGON],
2755
+ 2: [SW_TRAPEZOID, NE_TRIANGLE]
2756
+ },
2757
+ [ternaryToIndex("2021")]: {
2758
+ 0: [SW_HEPTAGON],
2759
+ 1: [SW_HEPTAGON],
2760
+ 2: [SW_TRIANGLE, NE_TRAPEZOID]
2761
+ },
2762
+ [ternaryToIndex("1202")]: {
2763
+ 0: [NW_HEPTAGON],
2764
+ 1: [NW_HEPTAGON],
2765
+ 2: [NW_TRIANGLE, SE_TRAPEZOID]
2766
+ },
2767
+ [ternaryToIndex("0212")]: {
2768
+ 0: [SE_HEPTAGON],
2769
+ 1: [SE_HEPTAGON],
2770
+ 2: [SE_TRIANGLE, NW_TRAPEZOID]
2771
+ },
2772
+ [ternaryToIndex("0102")]: {
2773
+ 0: [SW_TRAPEZOID, NE_TRIANGLE],
2774
+ 1: [NE_HEPTAGON],
2775
+ 2: [NE_HEPTAGON]
2776
+ },
2777
+ [ternaryToIndex("0201")]: {
2778
+ 0: [SW_TRIANGLE, NE_TRAPEZOID],
2779
+ 1: [SW_HEPTAGON],
2780
+ 2: [SW_HEPTAGON]
2781
+ },
2782
+ [ternaryToIndex("1020")]: {
2783
+ 0: [NW_TRIANGLE, SE_TRAPEZOID],
2784
+ 1: [NW_HEPTAGON],
2785
+ 2: [NW_HEPTAGON]
2786
+ },
2787
+ [ternaryToIndex("2010")]: {
2788
+ 0: [SE_TRIANGLE, NW_TRAPEZOID],
2789
+ 1: [SE_HEPTAGON],
2790
+ 2: [SE_HEPTAGON]
2791
+ },
2792
+ [ternaryToIndex("2020")]: {
2793
+ 0: [NW_TRAPEZOID, SE_TRAPEZOID],
2794
+ 1: [OCTAGON],
2795
+ 2: [SW_TRAPEZOID, NE_TRAPEZOID]
2796
+ },
2797
+ [ternaryToIndex("0202")]: {
2798
+ 0: [NE_TRAPEZOID, SW_TRAPEZOID],
2799
+ 1: [OCTAGON],
2800
+ 2: [NW_TRAPEZOID, SE_TRAPEZOID]
2801
+ }
2802
+ };
2803
+
2804
+ // dist/contour-layer/marching-squares.js
2805
+ var CONTOUR_TYPE = {
2806
+ ISO_LINES: 1,
2807
+ ISO_BANDS: 2
2808
+ };
2809
+ var DEFAULT_THRESHOLD_DATA = {
2810
+ zIndex: 0,
2811
+ zOffset: 5e-3
2812
+ };
2813
+ function getVertexCode(weight, threshold2) {
2814
+ if (Array.isArray(threshold2)) {
2815
+ if (weight < threshold2[0]) {
2816
+ return 0;
2817
+ }
2818
+ return weight < threshold2[1] ? 1 : 2;
2819
+ }
2820
+ return weight >= threshold2 ? 1 : 0;
2821
+ }
2822
+ function getCode(opts) {
2823
+ const { cellWeights, x, y, width, height } = opts;
2824
+ let threshold2 = opts.threshold;
2825
+ if (opts.thresholdValue) {
2826
+ import_core11.log.deprecated("thresholdValue", "threshold")();
2827
+ threshold2 = opts.thresholdValue;
2828
+ }
2829
+ const isLeftBoundary = x < 0;
2830
+ const isRightBoundary = x >= width - 1;
2831
+ const isBottomBoundary = y < 0;
2832
+ const isTopBoundary = y >= height - 1;
2833
+ const isBoundary = isLeftBoundary || isRightBoundary || isBottomBoundary || isTopBoundary;
2834
+ const weights = {};
2835
+ const codes = {};
2836
+ if (isLeftBoundary || isTopBoundary) {
2837
+ codes.top = 0;
2838
+ } else {
2839
+ weights.top = cellWeights[(y + 1) * width + x];
2840
+ codes.top = getVertexCode(weights.top, threshold2);
2841
+ }
2842
+ if (isRightBoundary || isTopBoundary) {
2843
+ codes.topRight = 0;
2844
+ } else {
2845
+ weights.topRight = cellWeights[(y + 1) * width + x + 1];
2846
+ codes.topRight = getVertexCode(weights.topRight, threshold2);
2847
+ }
2848
+ if (isRightBoundary || isBottomBoundary) {
2849
+ codes.right = 0;
2850
+ } else {
2851
+ weights.right = cellWeights[y * width + x + 1];
2852
+ codes.right = getVertexCode(weights.right, threshold2);
2853
+ }
2854
+ if (isLeftBoundary || isBottomBoundary) {
2855
+ codes.current = 0;
2856
+ } else {
2857
+ weights.current = cellWeights[y * width + x];
2858
+ codes.current = getVertexCode(weights.current, threshold2);
2859
+ }
2860
+ const { top, topRight, right, current } = codes;
2861
+ let code = -1;
2862
+ if (Number.isFinite(threshold2)) {
2863
+ code = top << 3 | topRight << 2 | right << 1 | current;
2864
+ }
2865
+ if (Array.isArray(threshold2)) {
2866
+ code = top << 6 | topRight << 4 | right << 2 | current;
2867
+ }
2868
+ let meanCode = 0;
2869
+ if (!isBoundary) {
2870
+ meanCode = getVertexCode((weights.top + weights.topRight + weights.right + weights.current) / 4, threshold2);
2871
+ }
2872
+ return { code, meanCode };
2873
+ }
2874
+ function getVertices(opts) {
2875
+ const { gridOrigin, cellSize, x, y, code, meanCode, type = CONTOUR_TYPE.ISO_LINES } = opts;
2876
+ const thresholdData = { ...DEFAULT_THRESHOLD_DATA, ...opts.thresholdData };
2877
+ let offsets = type === CONTOUR_TYPE.ISO_BANDS ? ISOBANDS_CODE_OFFSET_MAP[code] : ISOLINES_CODE_OFFSET_MAP[code];
2878
+ if (!Array.isArray(offsets)) {
2879
+ offsets = offsets[meanCode];
2880
+ }
2881
+ const vZ = thresholdData.zIndex * thresholdData.zOffset;
2882
+ const rX = (x + 1) * cellSize[0];
2883
+ const rY = (y + 1) * cellSize[1];
2884
+ const refVertexX = gridOrigin[0] + rX;
2885
+ const refVertexY = gridOrigin[1] + rY;
2886
+ if (type === CONTOUR_TYPE.ISO_BANDS) {
2887
+ const polygons = [];
2888
+ offsets.forEach((polygonOffsets) => {
2889
+ const polygon = [];
2890
+ polygonOffsets.forEach((xyOffset) => {
2891
+ const vX = refVertexX + xyOffset[0] * cellSize[0];
2892
+ const vY = refVertexY + xyOffset[1] * cellSize[1];
2893
+ polygon.push([vX, vY, vZ]);
2894
+ });
2895
+ polygons.push(polygon);
2896
+ });
2897
+ return polygons;
2898
+ }
2899
+ const lines = [];
2900
+ offsets.forEach((xyOffsets) => {
2901
+ xyOffsets.forEach((offset) => {
2902
+ const vX = refVertexX + offset[0] * cellSize[0];
2903
+ const vY = refVertexY + offset[1] * cellSize[1];
2904
+ lines.push([vX, vY, vZ]);
2905
+ });
2906
+ });
2907
+ return lines;
2908
+ }
2909
+
2910
+ // dist/contour-layer/contour-utils.js
2911
+ function generateContours({ thresholdData, cellWeights, gridSize, gridOrigin, cellSize }) {
2912
+ const contourSegments = [];
2913
+ const contourPolygons = [];
2914
+ const width = gridSize[0];
2915
+ const height = gridSize[1];
2916
+ let segmentIndex = 0;
2917
+ let polygonIndex = 0;
2918
+ for (const data of thresholdData) {
2919
+ const { contour } = data;
2920
+ const { threshold: threshold2 } = contour;
2921
+ for (let x = -1; x < width; x++) {
2922
+ for (let y = -1; y < height; y++) {
2923
+ const { code, meanCode } = getCode({
2924
+ cellWeights,
2925
+ threshold: threshold2,
2926
+ x,
2927
+ y,
2928
+ width,
2929
+ height
2930
+ });
2931
+ const opts = {
2932
+ type: CONTOUR_TYPE.ISO_BANDS,
2933
+ gridOrigin,
2934
+ cellSize,
2935
+ x,
2936
+ y,
2937
+ width,
2938
+ height,
2939
+ code,
2940
+ meanCode,
2941
+ thresholdData: data
2942
+ };
2943
+ if (Array.isArray(threshold2)) {
2944
+ opts.type = CONTOUR_TYPE.ISO_BANDS;
2945
+ const polygons = getVertices(opts);
2946
+ for (const polygon of polygons) {
2947
+ contourPolygons[polygonIndex++] = {
2948
+ vertices: polygon,
2949
+ contour
2950
+ };
2951
+ }
2952
+ } else {
2953
+ opts.type = CONTOUR_TYPE.ISO_LINES;
2954
+ const vertices = getVertices(opts);
2955
+ for (let i = 0; i < vertices.length; i += 2) {
2956
+ contourSegments[segmentIndex++] = {
2957
+ start: vertices[i],
2958
+ end: vertices[i + 1],
2959
+ contour
2960
+ };
2961
+ }
2962
+ }
2963
+ }
2964
+ }
2965
+ }
2966
+ return { contourSegments, contourPolygons };
2967
+ }
2968
+
2969
+ // dist/contour-layer/contour-layer.js
2970
+ var import_core12 = require("@deck.gl/core");
2971
+ var DEFAULT_COLOR = [255, 255, 255, 255];
2972
+ var DEFAULT_STROKE_WIDTH = 1;
2973
+ var DEFAULT_THRESHOLD = 1;
2974
+ var defaultProps6 = {
2975
+ cellSize: { type: "number", min: 1, max: 1e3, value: 1e3 },
2976
+ getPosition: { type: "accessor", value: (x) => x.position },
2977
+ getWeight: { type: "accessor", value: 1 },
2978
+ gpuAggregation: false,
2979
+ aggregation: "SUM",
2980
+ contours: {
2981
+ type: "object",
2982
+ value: [{ threshold: DEFAULT_THRESHOLD }],
2983
+ optional: true,
2984
+ compare: 3
2985
+ },
2986
+ zOffset: 5e-3
2987
+ };
2988
+ var POSITION_ATTRIBUTE_NAME2 = "positions";
2989
+ var DIMENSIONS2 = {
2990
+ data: {
2991
+ props: ["cellSize"]
2992
+ },
2993
+ weights: {
2994
+ props: ["aggregation"],
2995
+ accessors: ["getWeight"]
2996
+ }
2997
+ };
2998
+ var _ContourLayer = class extends GridAggregationLayer {
2999
+ initializeState() {
3000
+ super.initializeAggregationLayer({
3001
+ dimensions: DIMENSIONS2
3002
+ });
3003
+ this.setState({
3004
+ contourData: {},
3005
+ projectPoints: false,
3006
+ weights: {
3007
+ count: {
3008
+ size: 1,
3009
+ operation: AGGREGATION_OPERATION.SUM
3010
+ }
3011
+ }
3012
+ });
3013
+ const attributeManager = this.getAttributeManager();
3014
+ attributeManager.add({
3015
+ [POSITION_ATTRIBUTE_NAME2]: {
3016
+ size: 3,
3017
+ accessor: "getPosition",
3018
+ type: "float64",
3019
+ fp64: this.use64bitPositions()
3020
+ },
3021
+ count: { size: 3, accessor: "getWeight" }
3022
+ });
3023
+ }
3024
+ updateState(opts) {
3025
+ super.updateState(opts);
3026
+ let contoursChanged = false;
3027
+ const { oldProps, props } = opts;
3028
+ const { aggregationDirty } = this.state;
3029
+ if (oldProps.contours !== props.contours || oldProps.zOffset !== props.zOffset) {
3030
+ contoursChanged = true;
3031
+ this._updateThresholdData(opts.props);
3032
+ }
3033
+ if (this.getNumInstances() > 0 && (aggregationDirty || contoursChanged)) {
3034
+ this._generateContours();
3035
+ }
3036
+ }
3037
+ renderLayers() {
3038
+ const { contourSegments, contourPolygons } = this.state.contourData;
3039
+ const LinesSubLayerClass = this.getSubLayerClass("lines", import_layers3.LineLayer);
3040
+ const BandsSubLayerClass = this.getSubLayerClass("bands", import_layers3.SolidPolygonLayer);
3041
+ const lineLayer = contourSegments && contourSegments.length > 0 && new LinesSubLayerClass(this.getSubLayerProps({
3042
+ id: "lines"
3043
+ }), {
3044
+ data: this.state.contourData.contourSegments,
3045
+ getSourcePosition: (d) => d.start,
3046
+ getTargetPosition: (d) => d.end,
3047
+ getColor: (d) => d.contour.color || DEFAULT_COLOR,
3048
+ getWidth: (d) => d.contour.strokeWidth || DEFAULT_STROKE_WIDTH
3049
+ });
3050
+ const bandsLayer = contourPolygons && contourPolygons.length > 0 && new BandsSubLayerClass(this.getSubLayerProps({
3051
+ id: "bands"
3052
+ }), {
3053
+ data: this.state.contourData.contourPolygons,
3054
+ getPolygon: (d) => d.vertices,
3055
+ getFillColor: (d) => d.contour.color || DEFAULT_COLOR
3056
+ });
3057
+ return [lineLayer, bandsLayer];
3058
+ }
3059
+ updateAggregationState(opts) {
3060
+ const { props, oldProps } = opts;
3061
+ const { cellSize, coordinateSystem } = props;
3062
+ const { viewport } = this.context;
3063
+ const cellSizeChanged = oldProps.cellSize !== cellSize;
3064
+ let gpuAggregation = props.gpuAggregation;
3065
+ if (this.state.gpuAggregation !== props.gpuAggregation) {
3066
+ if (gpuAggregation && !GPUGridAggregator.isSupported(this.context.device)) {
3067
+ import_core12.log.warn("GPU Grid Aggregation not supported, falling back to CPU")();
3068
+ gpuAggregation = false;
3069
+ }
3070
+ }
3071
+ const gpuAggregationChanged = gpuAggregation !== this.state.gpuAggregation;
3072
+ this.setState({
3073
+ gpuAggregation
3074
+ });
3075
+ const { dimensions } = this.state;
3076
+ const positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME2);
3077
+ const { data, weights } = dimensions;
3078
+ let { boundingBox } = this.state;
3079
+ if (positionsChanged) {
3080
+ boundingBox = getBoundingBox(this.getAttributes(), this.getNumInstances());
3081
+ this.setState({ boundingBox });
3082
+ }
3083
+ if (positionsChanged || cellSizeChanged) {
3084
+ const { gridOffset, translation, width, height, numCol, numRow } = getGridParams(boundingBox, cellSize, viewport, coordinateSystem);
3085
+ this.allocateResources(numRow, numCol);
3086
+ this.setState({
3087
+ gridOffset,
3088
+ boundingBox,
3089
+ translation,
3090
+ posOffset: translation.slice(),
3091
+ gridOrigin: [-1 * translation[0], -1 * translation[1]],
3092
+ width,
3093
+ height,
3094
+ numCol,
3095
+ numRow
3096
+ });
3097
+ }
3098
+ const aggregationDataDirty = positionsChanged || gpuAggregationChanged || this.isAggregationDirty(opts, {
3099
+ dimension: data,
3100
+ compareAll: gpuAggregation
3101
+ });
3102
+ const aggregationWeightsDirty = this.isAggregationDirty(opts, {
3103
+ dimension: weights
3104
+ });
3105
+ if (aggregationWeightsDirty) {
3106
+ this._updateAccessors(opts);
3107
+ }
3108
+ if (aggregationDataDirty || aggregationWeightsDirty) {
3109
+ this._resetResults();
3110
+ }
3111
+ this.setState({
3112
+ aggregationDataDirty,
3113
+ aggregationWeightsDirty
3114
+ });
3115
+ }
3116
+ _updateAccessors(opts) {
3117
+ const { getWeight, aggregation, data } = opts.props;
3118
+ const { count } = this.state.weights;
3119
+ if (count) {
3120
+ count.getWeight = getWeight;
3121
+ count.operation = AGGREGATION_OPERATION[aggregation];
3122
+ }
3123
+ this.setState({ getValue: getValueFunc(aggregation, getWeight, { data }) });
3124
+ }
3125
+ _resetResults() {
3126
+ const { count } = this.state.weights;
3127
+ if (count) {
3128
+ count.aggregationData = null;
3129
+ }
3130
+ }
3131
+ _generateContours() {
3132
+ const { numCol, numRow, gridOrigin, gridOffset, thresholdData } = this.state;
3133
+ const { count } = this.state.weights;
3134
+ let { aggregationData } = count;
3135
+ if (!aggregationData) {
3136
+ aggregationData = count.aggregationBuffer.readSyncWebGL();
3137
+ count.aggregationData = aggregationData;
3138
+ }
3139
+ const { cellWeights } = GPUGridAggregator.getCellData({ countsData: aggregationData });
3140
+ const contourData = generateContours({
3141
+ thresholdData,
3142
+ cellWeights,
3143
+ gridSize: [numCol, numRow],
3144
+ gridOrigin,
3145
+ cellSize: [gridOffset.xOffset, gridOffset.yOffset]
3146
+ });
3147
+ this.setState({ contourData });
3148
+ }
3149
+ _updateThresholdData(props) {
3150
+ const { contours, zOffset } = props;
3151
+ const count = contours.length;
3152
+ const thresholdData = new Array(count);
3153
+ for (let i = 0; i < count; i++) {
3154
+ const contour = contours[i];
3155
+ thresholdData[i] = {
3156
+ contour,
3157
+ zIndex: contour.zIndex || i,
3158
+ zOffset
3159
+ };
3160
+ }
3161
+ this.setState({ thresholdData });
3162
+ }
3163
+ };
3164
+ var ContourLayer = _ContourLayer;
3165
+ (() => {
3166
+ _ContourLayer.layerName = "ContourLayer";
3167
+ })();
3168
+ (() => {
3169
+ _ContourLayer.defaultProps = defaultProps6;
3170
+ })();
3171
+
3172
+ // dist/grid-layer/grid-layer.js
3173
+ var import_core15 = require("@deck.gl/core");
3174
+
3175
+ // dist/gpu-grid-layer/gpu-grid-layer.js
3176
+ var import_constants5 = require("@luma.gl/constants");
3177
+ var import_core14 = require("@deck.gl/core");
3178
+
3179
+ // dist/gpu-grid-layer/gpu-grid-cell-layer.js
3180
+ var import_core13 = require("@deck.gl/core");
3181
+ var import_engine3 = require("@luma.gl/engine");
3182
+ var import_shadertools2 = require("@luma.gl/shadertools");
3183
+ var import_engine4 = require("@luma.gl/engine");
3184
+ var import_constants4 = require("@luma.gl/constants");
3185
+
3186
+ // dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js
3187
+ var gpu_grid_cell_layer_vertex_glsl_default = `#version 300 es
3188
+ #define SHADER_NAME gpu-grid-cell-layer-vertex-shader
3189
+ #define RANGE_COUNT 6
3190
+ in vec3 positions;
3191
+ in vec3 normals;
3192
+ in vec4 colors;
3193
+ in vec4 elevations;
3194
+ in vec3 instancePickingColors;
3195
+ uniform vec2 offset;
3196
+ uniform bool extruded;
3197
+ uniform float cellSize;
3198
+ uniform float coverage;
3199
+ uniform float opacity;
3200
+ uniform float elevationScale;
3201
+ uniform ivec2 gridSize;
3202
+ uniform vec2 gridOrigin;
3203
+ uniform vec2 gridOriginLow;
3204
+ uniform vec2 gridOffset;
3205
+ uniform vec2 gridOffsetLow;
3206
+ uniform vec4 colorRange[RANGE_COUNT];
3207
+ uniform vec2 elevationRange;
3208
+ uniform vec2 colorDomain;
3209
+ uniform bool colorDomainValid;
3210
+ uniform vec2 elevationDomain;
3211
+ uniform bool elevationDomainValid;
3212
+ layout(std140) uniform;
3213
+ uniform ColorData
3214
+ {
3215
+ vec4 maxMinCount;
3216
+ } colorData;
3217
+ uniform ElevationData
3218
+ {
3219
+ vec4 maxMinCount;
3220
+ } elevationData;
3221
+ #define EPSILON 0.00001
3222
+ out vec4 vColor;
3223
+ vec4 quantizeScale(vec2 domain, vec4 range[RANGE_COUNT], float value) {
3224
+ vec4 outColor = vec4(0., 0., 0., 0.);
3225
+ if (value >= (domain.x - EPSILON) && value <= (domain.y + EPSILON)) {
3226
+ float domainRange = domain.y - domain.x;
3227
+ if (domainRange <= 0.) {
3228
+ outColor = colorRange[0];
3229
+ } else {
3230
+ float rangeCount = float(RANGE_COUNT);
3231
+ float rangeStep = domainRange / rangeCount;
3232
+ float idx = floor((value - domain.x) / rangeStep);
3233
+ idx = clamp(idx, 0., rangeCount - 1.);
3234
+ int intIdx = int(idx);
3235
+ outColor = colorRange[intIdx];
3236
+ }
3237
+ }
3238
+ return outColor;
3239
+ }
3240
+ float linearScale(vec2 domain, vec2 range, float value) {
3241
+ if (value >= (domain.x - EPSILON) && value <= (domain.y + EPSILON)) {
3242
+ return ((value - domain.x) / (domain.y - domain.x)) * (range.y - range.x) + range.x;
3243
+ }
3244
+ return -1.;
3245
+ }
3246
+ void main(void) {
3247
+ vec2 clrDomain = colorDomainValid ? colorDomain : vec2(colorData.maxMinCount.a, colorData.maxMinCount.r);
3248
+ vec4 color = quantizeScale(clrDomain, colorRange, colors.r);
3249
+ float elevation = 0.0;
3250
+ if (extruded) {
3251
+ vec2 elvDomain = elevationDomainValid ? elevationDomain : vec2(elevationData.maxMinCount.a, elevationData.maxMinCount.r);
3252
+ elevation = linearScale(elvDomain, elevationRange, elevations.r);
3253
+ elevation = elevation * (positions.z + 1.0) / 2.0 * elevationScale;
3254
+ }
3255
+ float shouldRender = float(color.r > 0.0 && elevations.r >= 0.0);
3256
+ float dotRadius = cellSize / 2. * coverage * shouldRender;
3257
+ int yIndex = (gl_InstanceID / gridSize[0]);
3258
+ int xIndex = gl_InstanceID - (yIndex * gridSize[0]);
3259
+ vec2 instancePositionXFP64 = mul_fp64(vec2(gridOffset[0], gridOffsetLow[0]), vec2(float(xIndex), 0.));
3260
+ instancePositionXFP64 = sum_fp64(instancePositionXFP64, vec2(gridOrigin[0], gridOriginLow[0]));
3261
+ vec2 instancePositionYFP64 = mul_fp64(vec2(gridOffset[1], gridOffsetLow[1]), vec2(float(yIndex), 0.));
3262
+ instancePositionYFP64 = sum_fp64(instancePositionYFP64, vec2(gridOrigin[1], gridOriginLow[1]));
3263
+ vec3 centroidPosition = vec3(instancePositionXFP64[0], instancePositionYFP64[0], elevation);
3264
+ vec3 centroidPosition64Low = vec3(instancePositionXFP64[1], instancePositionYFP64[1], 0.0);
3265
+ geometry.worldPosition = centroidPosition;
3266
+ vec3 pos = vec3(project_size(positions.xy + offset) * dotRadius, 0.);
3267
+ picking_setPickingColor(instancePickingColors);
3268
+ gl_Position = project_position_to_clipspace(centroidPosition, centroidPosition64Low, pos, geometry.position);
3269
+ vec3 normals_commonspace = project_normal(normals);
3270
+ if (extruded) {
3271
+ vec3 lightColor = lighting_getLightColor(color.rgb, project_uCameraPosition, geometry.position.xyz, normals_commonspace);
3272
+ vColor = vec4(lightColor, color.a * opacity) / 255.;
3273
+ } else {
3274
+ vColor = vec4(color.rgb, color.a * opacity) / 255.;
3275
+ }
3276
+ }
3277
+ `;
3278
+
3279
+ // dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js
3280
+ var gpu_grid_cell_layer_fragment_glsl_default = `#version 300 es
3281
+ #define SHADER_NAME gpu-grid-cell-layer-fragment-shader
3282
+ precision highp float;
3283
+ in vec4 vColor;
3284
+ out vec4 fragColor;
3285
+ void main(void) {
3286
+ fragColor = vColor;
3287
+ fragColor = picking_filterColor(fragColor);
3288
+ }
3289
+ `;
3290
+
3291
+ // dist/gpu-grid-layer/gpu-grid-cell-layer.js
3292
+ var COLOR_DATA_UBO_INDEX = 0;
3293
+ var ELEVATION_DATA_UBO_INDEX = 1;
3294
+ var defaultProps7 = {
3295
+ colorDomain: null,
3296
+ colorRange: defaultColorRange,
3297
+ elevationDomain: null,
3298
+ elevationRange: [0, 1e3],
3299
+ elevationScale: { type: "number", min: 0, value: 1 },
3300
+ gridSize: { type: "array", value: [1, 1] },
3301
+ gridOrigin: { type: "array", value: [0, 0] },
3302
+ gridOffset: { type: "array", value: [0, 0] },
3303
+ cellSize: { type: "number", min: 0, max: 1e3, value: 1e3 },
3304
+ offset: { type: "array", value: [1, 1] },
3305
+ coverage: { type: "number", min: 0, max: 1, value: 1 },
3306
+ extruded: true,
3307
+ material: true
3308
+ };
3309
+ var _GPUGridCellLayer = class extends import_core13.Layer {
3310
+ getShaders() {
3311
+ return super.getShaders({
3312
+ vs: gpu_grid_cell_layer_vertex_glsl_default,
3313
+ fs: gpu_grid_cell_layer_fragment_glsl_default,
3314
+ modules: [import_core13.project32, import_core13.gouraudLighting, import_core13.picking, import_shadertools2.fp64arithmetic]
3315
+ });
3316
+ }
3317
+ initializeState() {
3318
+ const attributeManager = this.getAttributeManager();
3319
+ attributeManager.addInstanced({
3320
+ colors: {
3321
+ size: 4,
3322
+ noAlloc: true
3323
+ },
3324
+ elevations: {
3325
+ size: 4,
3326
+ noAlloc: true
3327
+ }
3328
+ });
3329
+ const model = this._getModel();
3330
+ this._setupUniformBuffer(model);
3331
+ this.setState({ model });
3332
+ }
3333
+ _getModel() {
3334
+ return new import_engine4.Model(this.context.device, {
3335
+ ...this.getShaders(),
3336
+ id: this.props.id,
3337
+ geometry: new import_engine3.CubeGeometry(),
3338
+ isInstanced: true
3339
+ });
3340
+ }
3341
+ draw({ uniforms }) {
3342
+ const { cellSize, offset, extruded, elevationScale, coverage, gridSize, gridOrigin, gridOffset, elevationRange, colorMaxMinBuffer, elevationMaxMinBuffer } = this.props;
3343
+ const model = this.state.model;
3344
+ const gridOriginLow = [(0, import_core13.fp64LowPart)(gridOrigin[0]), (0, import_core13.fp64LowPart)(gridOrigin[1])];
3345
+ const gridOffsetLow = [(0, import_core13.fp64LowPart)(gridOffset[0]), (0, import_core13.fp64LowPart)(gridOffset[1])];
3346
+ const domainUniforms = this.getDomainUniforms();
3347
+ const colorRange = colorRangeToFlatArray(this.props.colorRange);
3348
+ this.bindUniformBuffers(colorMaxMinBuffer, elevationMaxMinBuffer);
3349
+ model.setUniforms(uniforms);
3350
+ model.setUniforms(domainUniforms);
3351
+ model.setUniforms({
3352
+ cellSize,
3353
+ offset,
3354
+ extruded,
3355
+ elevationScale,
3356
+ coverage,
3357
+ gridSize,
3358
+ gridOrigin,
3359
+ gridOriginLow,
3360
+ gridOffset,
3361
+ gridOffsetLow,
3362
+ colorRange,
3363
+ elevationRange
3364
+ });
3365
+ model.draw(this.context.renderPass);
3366
+ this.unbindUniformBuffers(colorMaxMinBuffer, elevationMaxMinBuffer);
3367
+ }
3368
+ bindUniformBuffers(colorMaxMinBuffer, elevationMaxMinBuffer) {
3369
+ colorMaxMinBuffer.bind({ target: 35345, index: COLOR_DATA_UBO_INDEX });
3370
+ elevationMaxMinBuffer.bind({ target: 35345, index: ELEVATION_DATA_UBO_INDEX });
3371
+ }
3372
+ unbindUniformBuffers(colorMaxMinBuffer, elevationMaxMinBuffer) {
3373
+ colorMaxMinBuffer.unbind({ target: 35345, index: COLOR_DATA_UBO_INDEX });
3374
+ elevationMaxMinBuffer.unbind({ target: 35345, index: ELEVATION_DATA_UBO_INDEX });
3375
+ }
3376
+ getDomainUniforms() {
3377
+ const { colorDomain, elevationDomain } = this.props;
3378
+ const domainUniforms = {};
3379
+ if (colorDomain !== null) {
3380
+ domainUniforms.colorDomainValid = true;
3381
+ domainUniforms.colorDomain = colorDomain;
3382
+ } else {
3383
+ domainUniforms.colorDomainValid = false;
3384
+ }
3385
+ if (elevationDomain !== null) {
3386
+ domainUniforms.elevationDomainValid = true;
3387
+ domainUniforms.elevationDomain = elevationDomain;
3388
+ } else {
3389
+ domainUniforms.elevationDomainValid = false;
3390
+ }
3391
+ return domainUniforms;
3392
+ }
3393
+ _setupUniformBuffer(model) {
3394
+ const programHandle = model.pipeline.handle;
3395
+ const gl = this.context.gl;
3396
+ const colorIndex = gl.getUniformBlockIndex(programHandle, "ColorData");
3397
+ const elevationIndex = gl.getUniformBlockIndex(programHandle, "ElevationData");
3398
+ gl.uniformBlockBinding(programHandle, colorIndex, COLOR_DATA_UBO_INDEX);
3399
+ gl.uniformBlockBinding(programHandle, elevationIndex, ELEVATION_DATA_UBO_INDEX);
3400
+ }
3401
+ };
3402
+ var GPUGridCellLayer = _GPUGridCellLayer;
3403
+ (() => {
3404
+ _GPUGridCellLayer.layerName = "GPUGridCellLayer";
3405
+ })();
3406
+ (() => {
3407
+ _GPUGridCellLayer.defaultProps = defaultProps7;
3408
+ })();
3409
+
3410
+ // dist/gpu-grid-layer/gpu-grid-layer.js
3411
+ var defaultProps8 = {
3412
+ colorDomain: null,
3413
+ colorRange: defaultColorRange,
3414
+ getColorWeight: { type: "accessor", value: 1 },
3415
+ colorAggregation: "SUM",
3416
+ elevationDomain: null,
3417
+ elevationRange: [0, 1e3],
3418
+ getElevationWeight: { type: "accessor", value: 1 },
3419
+ elevationAggregation: "SUM",
3420
+ elevationScale: { type: "number", min: 0, value: 1 },
3421
+ cellSize: { type: "number", min: 1, max: 1e3, value: 1e3 },
3422
+ coverage: { type: "number", min: 0, max: 1, value: 1 },
3423
+ getPosition: { type: "accessor", value: (x) => x.position },
3424
+ extruded: false,
3425
+ material: true
3426
+ };
3427
+ var DIMENSIONS3 = {
3428
+ data: {
3429
+ props: ["cellSize", "colorAggregation", "elevationAggregation"]
3430
+ }
3431
+ };
3432
+ var POSITION_ATTRIBUTE_NAME3 = "positions";
3433
+ var _GPUGridLayer = class extends GridAggregationLayer {
3434
+ initializeState({ device }) {
3435
+ const isSupported = GPUGridAggregator.isSupported(device);
3436
+ if (!isSupported) {
3437
+ import_core14.log.error("GPUGridLayer is not supported on this browser, use GridLayer instead")();
3438
+ }
3439
+ super.initializeAggregationLayer({
3440
+ dimensions: DIMENSIONS3
3441
+ });
3442
+ this.setState({
3443
+ gpuAggregation: false,
3444
+ projectPoints: false,
3445
+ isSupported,
3446
+ weights: {
3447
+ color: {
3448
+ needMin: true,
3449
+ needMax: true,
3450
+ combineMaxMin: true,
3451
+ maxMinBuffer: device.createBuffer({
3452
+ byteLength: 4 * 4,
3453
+ accessor: { size: 4, type: 5126, divisor: 1 }
3454
+ })
3455
+ },
3456
+ elevation: {
3457
+ needMin: true,
3458
+ needMax: true,
3459
+ combineMaxMin: true,
3460
+ maxMinBuffer: device.createBuffer({
3461
+ byteLength: 4 * 4,
3462
+ accessor: { size: 4, type: 5126, divisor: 1 }
3463
+ })
3464
+ }
3465
+ },
3466
+ positionAttributeName: "positions"
3467
+ });
3468
+ const attributeManager = this.getAttributeManager();
3469
+ attributeManager.add({
3470
+ [POSITION_ATTRIBUTE_NAME3]: {
3471
+ size: 3,
3472
+ accessor: "getPosition",
3473
+ type: "float64",
3474
+ fp64: this.use64bitPositions()
3475
+ },
3476
+ color: { size: 3, accessor: "getColorWeight" },
3477
+ elevation: { size: 3, accessor: "getElevationWeight" }
3478
+ });
3479
+ }
3480
+ updateState(opts) {
3481
+ if (this.state.isSupported === false) {
3482
+ return;
3483
+ }
3484
+ super.updateState(opts);
3485
+ const { aggregationDirty } = this.state;
3486
+ if (aggregationDirty) {
3487
+ this.setState({
3488
+ gridHash: null
3489
+ });
3490
+ }
3491
+ }
3492
+ getHashKeyForIndex(index) {
3493
+ const { numRow, numCol, boundingBox, gridOffset } = this.state;
3494
+ const gridSize = [numCol, numRow];
3495
+ const gridOrigin = [boundingBox.xMin, boundingBox.yMin];
3496
+ const cellSize = [gridOffset.xOffset, gridOffset.yOffset];
3497
+ const yIndex = Math.floor(index / gridSize[0]);
3498
+ const xIndex = index - yIndex * gridSize[0];
3499
+ const latIdx = Math.floor((yIndex * cellSize[1] + gridOrigin[1] + 90 + cellSize[1] / 2) / cellSize[1]);
3500
+ const lonIdx = Math.floor((xIndex * cellSize[0] + gridOrigin[0] + 180 + cellSize[0] / 2) / cellSize[0]);
3501
+ return `${latIdx}-${lonIdx}`;
3502
+ }
3503
+ getPositionForIndex(index) {
3504
+ const { numRow, numCol, boundingBox, gridOffset } = this.state;
3505
+ const gridSize = [numCol, numRow];
3506
+ const gridOrigin = [boundingBox.xMin, boundingBox.yMin];
3507
+ const cellSize = [gridOffset.xOffset, gridOffset.yOffset];
3508
+ const yIndex = Math.floor(index / gridSize[0]);
3509
+ const xIndex = index - yIndex * gridSize[0];
3510
+ const yPos = yIndex * cellSize[1] + gridOrigin[1];
3511
+ const xPos = xIndex * cellSize[0] + gridOrigin[0];
3512
+ return [xPos, yPos];
3513
+ }
3514
+ getPickingInfo({ info, mode }) {
3515
+ const { index } = info;
3516
+ let object = null;
3517
+ if (index >= 0) {
3518
+ const gpuGridAggregator = this.state.gpuGridAggregator;
3519
+ const position = this.getPositionForIndex(index);
3520
+ const colorInfo = GPUGridAggregator.getAggregationData({
3521
+ pixelIndex: index,
3522
+ ...gpuGridAggregator.getData("color")
3523
+ });
3524
+ const elevationInfo = GPUGridAggregator.getAggregationData({
3525
+ pixelIndex: index,
3526
+ ...gpuGridAggregator.getData("elevation")
3527
+ });
3528
+ object = {
3529
+ colorValue: colorInfo.cellWeight,
3530
+ elevationValue: elevationInfo.cellWeight,
3531
+ count: colorInfo.cellCount || elevationInfo.cellCount,
3532
+ position,
3533
+ totalCount: colorInfo.totalCount || elevationInfo.totalCount
3534
+ };
3535
+ if (mode !== "hover") {
3536
+ const { props } = this;
3537
+ let { gridHash } = this.state;
3538
+ if (!gridHash) {
3539
+ const { gridOffset, translation, boundingBox } = this.state;
3540
+ const { viewport } = this.context;
3541
+ const attributes = this.getAttributes();
3542
+ const cpuAggregation = pointToDensityGridDataCPU(props, {
3543
+ gridOffset,
3544
+ attributes,
3545
+ viewport,
3546
+ translation,
3547
+ boundingBox
3548
+ });
3549
+ gridHash = cpuAggregation.gridHash;
3550
+ this.setState({ gridHash });
3551
+ }
3552
+ const key = this.getHashKeyForIndex(index);
3553
+ const cpuAggregationData = gridHash[key];
3554
+ Object.assign(object, cpuAggregationData);
3555
+ }
3556
+ }
3557
+ info.picked = Boolean(object);
3558
+ info.object = object;
3559
+ return info;
3560
+ }
3561
+ renderLayers() {
3562
+ if (!this.state.isSupported) {
3563
+ return null;
3564
+ }
3565
+ const { elevationScale, extruded, cellSize: cellSizeMeters, coverage, material, elevationRange, colorDomain, elevationDomain } = this.props;
3566
+ const { weights, numRow, numCol, gridOrigin, gridOffset } = this.state;
3567
+ const { color, elevation } = weights;
3568
+ const colorRange = colorRangeToFlatArray(this.props.colorRange);
3569
+ const SubLayerClass = this.getSubLayerClass("gpu-grid-cell", GPUGridCellLayer);
3570
+ return new SubLayerClass({
3571
+ gridSize: [numCol, numRow],
3572
+ gridOrigin,
3573
+ gridOffset: [gridOffset.xOffset, gridOffset.yOffset],
3574
+ colorRange,
3575
+ elevationRange,
3576
+ colorDomain,
3577
+ elevationDomain,
3578
+ cellSize: cellSizeMeters,
3579
+ coverage,
3580
+ material,
3581
+ elevationScale,
3582
+ extruded
3583
+ }, this.getSubLayerProps({
3584
+ id: "gpu-grid-cell"
3585
+ }), {
3586
+ data: {
3587
+ attributes: {
3588
+ colors: color.aggregationBuffer,
3589
+ elevations: elevation.aggregationBuffer
3590
+ }
3591
+ },
3592
+ colorMaxMinBuffer: color.maxMinBuffer,
3593
+ elevationMaxMinBuffer: elevation.maxMinBuffer,
3594
+ numInstances: numCol * numRow
3595
+ });
3596
+ }
3597
+ finalizeState(context) {
3598
+ const { color, elevation } = this.state.weights;
3599
+ [color, elevation].forEach((weight) => {
3600
+ const { aggregationBuffer, maxMinBuffer } = weight;
3601
+ maxMinBuffer == null ? void 0 : maxMinBuffer.destroy();
3602
+ aggregationBuffer == null ? void 0 : aggregationBuffer.destroy();
3603
+ });
3604
+ super.finalizeState(context);
3605
+ }
3606
+ updateAggregationState(opts) {
3607
+ const { props, oldProps } = opts;
3608
+ const { cellSize, coordinateSystem } = props;
3609
+ const { viewport } = this.context;
3610
+ const cellSizeChanged = oldProps.cellSize !== cellSize;
3611
+ const { dimensions } = this.state;
3612
+ const positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME3);
3613
+ const attributesChanged = positionsChanged || this.isAttributeChanged();
3614
+ let { boundingBox } = this.state;
3615
+ if (positionsChanged) {
3616
+ boundingBox = getBoundingBox(this.getAttributes(), this.getNumInstances());
3617
+ this.setState({ boundingBox });
3618
+ }
3619
+ if (positionsChanged || cellSizeChanged) {
3620
+ const { gridOffset, translation, width, height, numCol, numRow } = getGridParams(boundingBox, cellSize, viewport, coordinateSystem);
3621
+ this.allocateResources(numRow, numCol);
3622
+ this.setState({
3623
+ gridOffset,
3624
+ translation,
3625
+ gridOrigin: [-1 * translation[0], -1 * translation[1]],
3626
+ width,
3627
+ height,
3628
+ numCol,
3629
+ numRow
3630
+ });
3631
+ }
3632
+ const aggregationDataDirty = attributesChanged || this.isAggregationDirty(opts, {
3633
+ dimension: dimensions.data,
3634
+ compareAll: true
3635
+ });
3636
+ if (aggregationDataDirty) {
3637
+ this._updateAccessors(opts);
3638
+ }
3639
+ this.setState({
3640
+ aggregationDataDirty
3641
+ });
3642
+ }
3643
+ _updateAccessors(opts) {
3644
+ const { colorAggregation, elevationAggregation } = opts.props;
3645
+ const { color, elevation } = this.state.weights;
3646
+ color.operation = AGGREGATION_OPERATION[colorAggregation];
3647
+ elevation.operation = AGGREGATION_OPERATION[elevationAggregation];
3648
+ }
3649
+ };
3650
+ var GPUGridLayer = _GPUGridLayer;
3651
+ (() => {
3652
+ _GPUGridLayer.layerName = "GPUGridLayer";
3653
+ })();
3654
+ (() => {
3655
+ _GPUGridLayer.defaultProps = defaultProps8;
3656
+ })();
3657
+
3658
+ // dist/grid-layer/grid-layer.js
3659
+ var defaultProps9 = {
3660
+ ...GPUGridLayer.defaultProps,
3661
+ ...CPUGridLayer.defaultProps,
3662
+ gpuAggregation: false
3663
+ };
3664
+ var _GridLayer = class extends import_core15.CompositeLayer {
3665
+ initializeState() {
3666
+ this.state = {
3667
+ useGPUAggregation: false
3668
+ };
3669
+ }
3670
+ updateState({ props }) {
3671
+ this.setState({
3672
+ useGPUAggregation: false
3673
+ });
3674
+ }
3675
+ renderLayers() {
3676
+ const { data, updateTriggers } = this.props;
3677
+ const id = this.state.useGPUAggregation ? "GPU" : "CPU";
3678
+ const LayerType = this.state.useGPUAggregation ? this.getSubLayerClass("GPU", GPUGridLayer) : this.getSubLayerClass("CPU", CPUGridLayer);
3679
+ return new LayerType(this.props, this.getSubLayerProps({
3680
+ id,
3681
+ updateTriggers
3682
+ }), {
3683
+ data
3684
+ });
3685
+ }
3686
+ canUseGPUAggregation(props) {
3687
+ const { gpuAggregation, lowerPercentile, upperPercentile, getColorValue, getElevationValue, colorScaleType } = props;
3688
+ if (!gpuAggregation) {
3689
+ return false;
3690
+ }
3691
+ if (!GPUGridAggregator.isSupported(this.context.device)) {
3692
+ return false;
3693
+ }
3694
+ if (lowerPercentile !== 0 || upperPercentile !== 100) {
3695
+ return false;
3696
+ }
3697
+ if (getColorValue !== null || getElevationValue !== null) {
3698
+ return false;
3699
+ }
3700
+ if (colorScaleType === "quantile" || colorScaleType === "ordinal") {
3701
+ return false;
3702
+ }
3703
+ return true;
3704
+ }
3705
+ };
3706
+ var GridLayer = _GridLayer;
3707
+ (() => {
3708
+ _GridLayer.layerName = "GridLayer";
3709
+ })();
3710
+ (() => {
3711
+ _GridLayer.defaultProps = defaultProps9;
3712
+ })();
3713
+
3714
+ // dist/heatmap-layer/heatmap-layer-utils.js
3715
+ function getBounds(points) {
3716
+ const x = points.map((p) => p[0]);
3717
+ const y = points.map((p) => p[1]);
3718
+ const xMin = Math.min.apply(null, x);
3719
+ const xMax = Math.max.apply(null, x);
3720
+ const yMin = Math.min.apply(null, y);
3721
+ const yMax = Math.max.apply(null, y);
3722
+ return [xMin, yMin, xMax, yMax];
3723
+ }
3724
+ function boundsContain(currentBounds, targetBounds) {
3725
+ if (targetBounds[0] >= currentBounds[0] && targetBounds[2] <= currentBounds[2] && targetBounds[1] >= currentBounds[1] && targetBounds[3] <= currentBounds[3]) {
3726
+ return true;
3727
+ }
3728
+ return false;
3729
+ }
3730
+ var scratchArray = new Float32Array(12);
3731
+ function packVertices(points, dimensions = 2) {
3732
+ let index = 0;
3733
+ for (const point of points) {
3734
+ for (let i = 0; i < dimensions; i++) {
3735
+ scratchArray[index++] = point[i] || 0;
3736
+ }
3737
+ }
3738
+ return scratchArray;
3739
+ }
3740
+ function scaleToAspectRatio(boundingBox, width, height) {
3741
+ const [xMin, yMin, xMax, yMax] = boundingBox;
3742
+ const currentWidth = xMax - xMin;
3743
+ const currentHeight = yMax - yMin;
3744
+ let newWidth = currentWidth;
3745
+ let newHeight = currentHeight;
3746
+ if (currentWidth / currentHeight < width / height) {
3747
+ newWidth = width / height * currentHeight;
3748
+ } else {
3749
+ newHeight = height / width * currentWidth;
3750
+ }
3751
+ if (newWidth < width) {
3752
+ newWidth = width;
3753
+ newHeight = height;
3754
+ }
3755
+ const xCenter = (xMax + xMin) / 2;
3756
+ const yCenter = (yMax + yMin) / 2;
3757
+ return [
3758
+ xCenter - newWidth / 2,
3759
+ yCenter - newHeight / 2,
3760
+ xCenter + newWidth / 2,
3761
+ yCenter + newHeight / 2
3762
+ ];
3763
+ }
3764
+ function getTextureCoordinates(point, bounds) {
3765
+ const [xMin, yMin, xMax, yMax] = bounds;
3766
+ return [(point[0] - xMin) / (xMax - xMin), (point[1] - yMin) / (yMax - yMin)];
3767
+ }
3768
+
3769
+ // dist/heatmap-layer/heatmap-layer.js
3770
+ var import_engine6 = require("@luma.gl/engine");
3771
+ var import_core17 = require("@deck.gl/core");
3772
+
3773
+ // dist/heatmap-layer/triangle-layer.js
3774
+ var import_engine5 = require("@luma.gl/engine");
3775
+ var import_core16 = require("@deck.gl/core");
3776
+
3777
+ // dist/heatmap-layer/triangle-layer-vertex.glsl.js
3778
+ var triangle_layer_vertex_glsl_default = `#version 300 es
3779
+ #define SHADER_NAME heatp-map-layer-vertex-shader
3780
+ uniform sampler2D maxTexture;
3781
+ uniform float intensity;
3782
+ uniform vec2 colorDomain;
3783
+ uniform float threshold;
3784
+ uniform float aggregationMode;
3785
+ in vec3 positions;
3786
+ in vec2 texCoords;
3787
+ out vec2 vTexCoords;
3788
+ out float vIntensityMin;
3789
+ out float vIntensityMax;
3790
+ void main(void) {
3791
+ gl_Position = project_position_to_clipspace(positions, vec3(0.0), vec3(0.0));
3792
+ vTexCoords = texCoords;
3793
+ vec4 maxTexture = texture(maxTexture, vec2(0.5));
3794
+ float maxValue = aggregationMode < 0.5 ? maxTexture.r : maxTexture.g;
3795
+ float minValue = maxValue * threshold;
3796
+ if (colorDomain[1] > 0.) {
3797
+ maxValue = colorDomain[1];
3798
+ minValue = colorDomain[0];
3799
+ }
3800
+ vIntensityMax = intensity / maxValue;
3801
+ vIntensityMin = intensity / minValue;
3802
+ }
3803
+ `;
3804
+
3805
+ // dist/heatmap-layer/triangle-layer-fragment.glsl.js
3806
+ var triangle_layer_fragment_glsl_default = `#version 300 es
3807
+ #define SHADER_NAME triangle-layer-fragment-shader
3808
+ precision highp float;
3809
+ uniform float opacity;
3810
+ uniform sampler2D weightsTexture;
3811
+ uniform sampler2D colorTexture;
3812
+ uniform float aggregationMode;
3813
+ in vec2 vTexCoords;
3814
+ in float vIntensityMin;
3815
+ in float vIntensityMax;
3816
+ out vec4 fragColor;
3817
+ vec4 getLinearColor(float value) {
3818
+ float factor = clamp(value * vIntensityMax, 0., 1.);
3819
+ vec4 color = texture(colorTexture, vec2(factor, 0.5));
3820
+ color.a *= min(value * vIntensityMin, 1.0);
3821
+ return color;
3822
+ }
3823
+ void main(void) {
3824
+ vec4 weights = texture(weightsTexture, vTexCoords);
3825
+ float weight = weights.r;
3826
+ if (aggregationMode > 0.5) {
3827
+ weight /= max(1.0, weights.a);
3828
+ }
3829
+ if (weight <= 0.) {
3830
+ discard;
3831
+ }
3832
+ vec4 linearColor = getLinearColor(weight);
3833
+ linearColor.a *= opacity;
3834
+ fragColor = linearColor;
3835
+ }
3836
+ `;
3837
+
3838
+ // dist/heatmap-layer/triangle-layer.js
3839
+ var _TriangleLayer = class extends import_core16.Layer {
3840
+ getShaders() {
3841
+ return { vs: triangle_layer_vertex_glsl_default, fs: triangle_layer_fragment_glsl_default, modules: [import_core16.project32] };
3842
+ }
3843
+ initializeState({ device }) {
3844
+ this.setState({ model: this._getModel(device) });
3845
+ }
3846
+ _getModel(device) {
3847
+ const { vertexCount, data, weightsTexture, maxTexture, colorTexture } = this.props;
3848
+ return new import_engine5.Model(device, {
3849
+ ...this.getShaders(),
3850
+ id: this.props.id,
3851
+ bindings: { weightsTexture, maxTexture, colorTexture },
3852
+ attributes: data.attributes,
3853
+ bufferLayout: [
3854
+ { name: "positions", format: "float32x3" },
3855
+ { name: "texCoords", format: "float32x2" }
3856
+ ],
3857
+ topology: "triangle-fan-webgl",
3858
+ vertexCount
3859
+ });
3860
+ }
3861
+ draw({ uniforms }) {
3862
+ const { model } = this.state;
3863
+ const { intensity, threshold: threshold2, aggregationMode, colorDomain } = this.props;
3864
+ model.setUniforms({
3865
+ ...uniforms,
3866
+ intensity,
3867
+ threshold: threshold2,
3868
+ aggregationMode,
3869
+ colorDomain
3870
+ });
3871
+ model.draw(this.context.renderPass);
3872
+ }
3873
+ };
3874
+ var TriangleLayer = _TriangleLayer;
3875
+ (() => {
3876
+ _TriangleLayer.layerName = "TriangleLayer";
3877
+ })();
3878
+
3879
+ // dist/heatmap-layer/weights-vs.glsl.js
3880
+ var weights_vs_glsl_default = `#version 300 es
3881
+ in vec3 positions;
3882
+ in vec3 positions64Low;
3883
+ in float weights;
3884
+ out vec4 weightsTexture;
3885
+ uniform float radiusPixels;
3886
+ uniform float textureWidth;
3887
+ uniform vec4 commonBounds;
3888
+ uniform float weightsScale;
3889
+ void main()
3890
+ {
3891
+ weightsTexture = vec4(weights * weightsScale, 0., 0., 1.);
3892
+ float radiusTexels = project_pixel_size(radiusPixels) * textureWidth / (commonBounds.z - commonBounds.x);
3893
+ gl_PointSize = radiusTexels * 2.;
3894
+ vec3 commonPosition = project_position(positions, positions64Low);
3895
+ gl_Position.xy = (commonPosition.xy - commonBounds.xy) / (commonBounds.zw - commonBounds.xy) ;
3896
+ gl_Position.xy = (gl_Position.xy * 2.) - (1.);
3897
+ gl_Position.w = 1.0;
3898
+ }
3899
+ `;
3900
+
3901
+ // dist/heatmap-layer/weights-fs.glsl.js
3902
+ var weights_fs_glsl_default = `#version 300 es
3903
+ in vec4 weightsTexture;
3904
+ out vec4 fragColor;
3905
+ float gaussianKDE(float u){
3906
+ return pow(2.71828, -u*u/0.05555)/(1.77245385*0.166666);
3907
+ }
3908
+ void main()
3909
+ {
3910
+ float dist = length(gl_PointCoord - vec2(0.5, 0.5));
3911
+ if (dist > 0.5) {
3912
+ discard;
3913
+ }
3914
+ fragColor = weightsTexture * gaussianKDE(2. * dist);
3915
+ DECKGL_FILTER_COLOR(fragColor, geometry);
3916
+ }
3917
+ `;
3918
+
3919
+ // dist/heatmap-layer/max-vs.glsl.js
3920
+ var max_vs_glsl_default = `#version 300 es
3921
+ uniform sampler2D inTexture;
3922
+ uniform float textureSize;
3923
+ out vec4 outTexture;
3924
+ void main()
3925
+ {
3926
+ int yIndex = gl_VertexID / int(textureSize);
3927
+ int xIndex = gl_VertexID - (yIndex * int(textureSize));
3928
+ vec2 uv = (0.5 + vec2(float(xIndex), float(yIndex))) / textureSize;
3929
+ outTexture = texture(inTexture, uv);
3930
+ gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
3931
+ gl_PointSize = 1.0;
3932
+ }
3933
+ `;
3934
+
3935
+ // dist/heatmap-layer/max-fs.glsl.js
3936
+ var max_fs_glsl_default = `#version 300 es
3937
+ in vec4 outTexture;
3938
+ out vec4 fragColor;
3939
+ void main() {
3940
+ fragColor = outTexture;
3941
+ fragColor.g = outTexture.r / max(1.0, outTexture.a);
3942
+ }
3943
+ `;
3944
+
3945
+ // dist/heatmap-layer/heatmap-layer.js
3946
+ var RESOLUTION = 2;
3947
+ var TEXTURE_PROPS = {
3948
+ format: "rgba8unorm",
3949
+ mipmaps: false,
3950
+ sampler: {
3951
+ minFilter: "linear",
3952
+ magFilter: "linear",
3953
+ addressModeU: "clamp-to-edge",
3954
+ addressModeV: "clamp-to-edge"
3955
+ }
3956
+ };
3957
+ var DEFAULT_COLOR_DOMAIN = [0, 0];
3958
+ var AGGREGATION_MODE = {
3959
+ SUM: 0,
3960
+ MEAN: 1
3961
+ };
3962
+ var defaultProps10 = {
3963
+ getPosition: { type: "accessor", value: (x) => x.position },
3964
+ getWeight: { type: "accessor", value: 1 },
3965
+ intensity: { type: "number", min: 0, value: 1 },
3966
+ radiusPixels: { type: "number", min: 1, max: 100, value: 50 },
3967
+ colorRange: defaultColorRange,
3968
+ threshold: { type: "number", min: 0, max: 1, value: 0.05 },
3969
+ colorDomain: { type: "array", value: null, optional: true },
3970
+ aggregation: "SUM",
3971
+ weightsTextureSize: { type: "number", min: 128, max: 2048, value: 2048 },
3972
+ debounceTimeout: { type: "number", min: 0, max: 1e3, value: 500 }
3973
+ };
3974
+ var FLOAT_TARGET_FEATURES = [
3975
+ "float32-renderable-webgl",
3976
+ "texture-blend-float-webgl"
3977
+ ];
3978
+ var DIMENSIONS4 = {
3979
+ data: {
3980
+ props: ["radiusPixels"]
3981
+ }
3982
+ };
3983
+ var _HeatmapLayer = class extends AggregationLayer {
3984
+ initializeState() {
3985
+ super.initializeAggregationLayer(DIMENSIONS4);
3986
+ this.setState({ colorDomain: DEFAULT_COLOR_DOMAIN });
3987
+ this._setupTextureParams();
3988
+ this._setupAttributes();
3989
+ this._setupResources();
3990
+ }
3991
+ shouldUpdateState({ changeFlags }) {
3992
+ return changeFlags.somethingChanged;
3993
+ }
3994
+ updateState(opts) {
3995
+ super.updateState(opts);
3996
+ this._updateHeatmapState(opts);
3997
+ }
3998
+ _updateHeatmapState(opts) {
3999
+ const { props, oldProps } = opts;
4000
+ const changeFlags = this._getChangeFlags(opts);
4001
+ if (changeFlags.dataChanged || changeFlags.viewportChanged) {
4002
+ changeFlags.boundsChanged = this._updateBounds(changeFlags.dataChanged);
4003
+ this._updateTextureRenderingBounds();
4004
+ }
4005
+ if (changeFlags.dataChanged || changeFlags.boundsChanged) {
4006
+ clearTimeout(this.state.updateTimer);
4007
+ this.setState({ isWeightMapDirty: true });
4008
+ } else if (changeFlags.viewportZoomChanged) {
4009
+ this._debouncedUpdateWeightmap();
4010
+ }
4011
+ if (props.colorRange !== oldProps.colorRange) {
4012
+ this._updateColorTexture(opts);
4013
+ }
4014
+ if (this.state.isWeightMapDirty) {
4015
+ this._updateWeightmap();
4016
+ }
4017
+ this.setState({ zoom: opts.context.viewport.zoom });
4018
+ }
4019
+ renderLayers() {
4020
+ const { weightsTexture, triPositionBuffer, triTexCoordBuffer, maxWeightsTexture, colorTexture, colorDomain } = this.state;
4021
+ const { updateTriggers, intensity, threshold: threshold2, aggregation } = this.props;
4022
+ const TriangleLayerClass = this.getSubLayerClass("triangle", TriangleLayer);
4023
+ return new TriangleLayerClass(this.getSubLayerProps({
4024
+ id: "triangle-layer",
4025
+ updateTriggers
4026
+ }), {
4027
+ coordinateSystem: import_core17.COORDINATE_SYSTEM.DEFAULT,
4028
+ data: {
4029
+ attributes: {
4030
+ positions: triPositionBuffer,
4031
+ texCoords: triTexCoordBuffer
4032
+ }
4033
+ },
4034
+ vertexCount: 4,
4035
+ maxTexture: maxWeightsTexture,
4036
+ colorTexture,
4037
+ aggregationMode: AGGREGATION_MODE[aggregation] || 0,
4038
+ weightsTexture,
4039
+ intensity,
4040
+ threshold: threshold2,
4041
+ colorDomain
4042
+ });
4043
+ }
4044
+ finalizeState(context) {
4045
+ super.finalizeState(context);
4046
+ const { weightsTransform, weightsTexture, maxWeightTransform, maxWeightsTexture, triPositionBuffer, triTexCoordBuffer, colorTexture, updateTimer } = this.state;
4047
+ weightsTransform == null ? void 0 : weightsTransform.destroy();
4048
+ weightsTexture == null ? void 0 : weightsTexture.destroy();
4049
+ maxWeightTransform == null ? void 0 : maxWeightTransform.destroy();
4050
+ maxWeightsTexture == null ? void 0 : maxWeightsTexture.destroy();
4051
+ triPositionBuffer == null ? void 0 : triPositionBuffer.destroy();
4052
+ triTexCoordBuffer == null ? void 0 : triTexCoordBuffer.destroy();
4053
+ colorTexture == null ? void 0 : colorTexture.destroy();
4054
+ if (updateTimer) {
4055
+ clearTimeout(updateTimer);
4056
+ }
4057
+ }
4058
+ _getAttributeManager() {
4059
+ return new import_core17.AttributeManager(this.context.device, {
4060
+ id: this.props.id,
4061
+ stats: this.context.stats
4062
+ });
4063
+ }
4064
+ _getChangeFlags(opts) {
4065
+ const changeFlags = {};
4066
+ const { dimensions } = this.state;
4067
+ changeFlags.dataChanged = this.isAttributeChanged() && "attribute changed" || this.isAggregationDirty(opts, {
4068
+ compareAll: true,
4069
+ dimension: dimensions.data
4070
+ }) && "aggregation is dirty";
4071
+ changeFlags.viewportChanged = opts.changeFlags.viewportChanged;
4072
+ const { zoom } = this.state;
4073
+ if (!opts.context.viewport || opts.context.viewport.zoom !== zoom) {
4074
+ changeFlags.viewportZoomChanged = true;
4075
+ }
4076
+ return changeFlags;
4077
+ }
4078
+ _createTextures() {
4079
+ const { textureSize, format } = this.state;
4080
+ this.setState({
4081
+ weightsTexture: this.context.device.createTexture({
4082
+ ...TEXTURE_PROPS,
4083
+ width: textureSize,
4084
+ height: textureSize,
4085
+ format
4086
+ }),
4087
+ maxWeightsTexture: this.context.device.createTexture({
4088
+ ...TEXTURE_PROPS,
4089
+ width: 1,
4090
+ height: 1,
4091
+ format
4092
+ })
4093
+ });
4094
+ }
4095
+ _setupAttributes() {
4096
+ const attributeManager = this.getAttributeManager();
4097
+ attributeManager.add({
4098
+ positions: { size: 3, type: "float64", accessor: "getPosition" },
4099
+ weights: { size: 1, accessor: "getWeight" }
4100
+ });
4101
+ this.setState({ positionAttributeName: "positions" });
4102
+ }
4103
+ _setupTextureParams() {
4104
+ const { device } = this.context;
4105
+ const { weightsTextureSize } = this.props;
4106
+ const textureSize = Math.min(weightsTextureSize, device.limits.maxTextureDimension2D);
4107
+ const floatTargetSupport = FLOAT_TARGET_FEATURES.every((feature) => device.features.has(feature));
4108
+ const format = floatTargetSupport ? "rgba32float" : "rgba8unorm";
4109
+ const weightsScale = floatTargetSupport ? 1 : 1 / 255;
4110
+ this.setState({ textureSize, format, weightsScale });
4111
+ if (!floatTargetSupport) {
4112
+ import_core17.log.warn(`HeatmapLayer: ${this.id} rendering to float texture not supported, falling back to low precision format`)();
4113
+ }
4114
+ }
4115
+ _createWeightsTransform(shaders) {
4116
+ let { weightsTransform } = this.state;
4117
+ const { weightsTexture } = this.state;
4118
+ const attributeManager = this.getAttributeManager();
4119
+ weightsTransform == null ? void 0 : weightsTransform.destroy();
4120
+ weightsTransform = new import_engine6.TextureTransform(this.context.device, {
4121
+ id: `${this.id}-weights-transform`,
4122
+ bufferLayout: attributeManager.getBufferLayouts(),
4123
+ vertexCount: 1,
4124
+ targetTexture: weightsTexture,
4125
+ parameters: {
4126
+ depthWriteEnabled: false,
4127
+ blendColorOperation: "add",
4128
+ blendColorSrcFactor: "one",
4129
+ blendColorDstFactor: "one",
4130
+ blendAlphaSrcFactor: "one",
4131
+ blendAlphaDstFactor: "one"
4132
+ },
4133
+ topology: "point-list",
4134
+ ...shaders
4135
+ });
4136
+ this.setState({ weightsTransform });
4137
+ }
4138
+ _setupResources() {
4139
+ this._createTextures();
4140
+ const { device } = this.context;
4141
+ const { textureSize, weightsTexture, maxWeightsTexture } = this.state;
4142
+ const weightsTransformShaders = this.getShaders({
4143
+ vs: weights_vs_glsl_default,
4144
+ fs: weights_fs_glsl_default
4145
+ });
4146
+ this._createWeightsTransform(weightsTransformShaders);
4147
+ const maxWeightsTransformShaders = this.getShaders({ vs: max_vs_glsl_default, fs: max_fs_glsl_default });
4148
+ const maxWeightTransform = new import_engine6.TextureTransform(device, {
4149
+ id: `${this.id}-max-weights-transform`,
4150
+ bindings: { inTexture: weightsTexture },
4151
+ uniforms: { textureSize },
4152
+ targetTexture: maxWeightsTexture,
4153
+ ...maxWeightsTransformShaders,
4154
+ vertexCount: textureSize * textureSize,
4155
+ topology: "point-list",
4156
+ parameters: {
4157
+ depthWriteEnabled: false,
4158
+ blendColorOperation: "max",
4159
+ blendAlphaOperation: "max",
4160
+ blendColorSrcFactor: "one",
4161
+ blendColorDstFactor: "one",
4162
+ blendAlphaSrcFactor: "one",
4163
+ blendAlphaDstFactor: "one"
4164
+ }
4165
+ });
4166
+ this.setState({
4167
+ weightsTexture,
4168
+ maxWeightsTexture,
4169
+ maxWeightTransform,
4170
+ zoom: null,
4171
+ triPositionBuffer: device.createBuffer({ byteLength: 48 }),
4172
+ triTexCoordBuffer: device.createBuffer({ byteLength: 48 })
4173
+ });
4174
+ }
4175
+ updateShaders(shaderOptions) {
4176
+ this._createWeightsTransform({
4177
+ vs: weights_vs_glsl_default,
4178
+ fs: weights_fs_glsl_default,
4179
+ ...shaderOptions
4180
+ });
4181
+ }
4182
+ _updateMaxWeightValue() {
4183
+ const { maxWeightTransform, textureSize } = this.state;
4184
+ maxWeightTransform.run({
4185
+ parameters: { viewport: [0, 0, 1, 1] },
4186
+ clearColor: [0, 0, 0, 0]
4187
+ });
4188
+ }
4189
+ _updateBounds(forceUpdate = false) {
4190
+ const { viewport } = this.context;
4191
+ const viewportCorners = [
4192
+ viewport.unproject([0, 0]),
4193
+ viewport.unproject([viewport.width, 0]),
4194
+ viewport.unproject([viewport.width, viewport.height]),
4195
+ viewport.unproject([0, viewport.height])
4196
+ ].map((p) => p.map(Math.fround));
4197
+ const visibleWorldBounds = getBounds(viewportCorners);
4198
+ const newState = { visibleWorldBounds, viewportCorners };
4199
+ let boundsChanged = false;
4200
+ if (forceUpdate || !this.state.worldBounds || !boundsContain(this.state.worldBounds, visibleWorldBounds)) {
4201
+ const scaledCommonBounds = this._worldToCommonBounds(visibleWorldBounds);
4202
+ const worldBounds = this._commonToWorldBounds(scaledCommonBounds);
4203
+ if (this.props.coordinateSystem === import_core17.COORDINATE_SYSTEM.LNGLAT) {
4204
+ worldBounds[1] = Math.max(worldBounds[1], -85.051129);
4205
+ worldBounds[3] = Math.min(worldBounds[3], 85.051129);
4206
+ worldBounds[0] = Math.max(worldBounds[0], -360);
4207
+ worldBounds[2] = Math.min(worldBounds[2], 360);
4208
+ }
4209
+ const normalizedCommonBounds = this._worldToCommonBounds(worldBounds);
4210
+ newState.worldBounds = worldBounds;
4211
+ newState.normalizedCommonBounds = normalizedCommonBounds;
4212
+ boundsChanged = true;
4213
+ }
4214
+ this.setState(newState);
4215
+ return boundsChanged;
4216
+ }
4217
+ _updateTextureRenderingBounds() {
4218
+ const { triPositionBuffer, triTexCoordBuffer, normalizedCommonBounds, viewportCorners } = this.state;
4219
+ const { viewport } = this.context;
4220
+ triPositionBuffer.write(packVertices(viewportCorners, 3));
4221
+ const textureBounds = viewportCorners.map((p) => getTextureCoordinates(viewport.projectPosition(p), normalizedCommonBounds));
4222
+ triTexCoordBuffer.write(packVertices(textureBounds, 2));
4223
+ }
4224
+ _updateColorTexture(opts) {
4225
+ const { colorRange } = opts.props;
4226
+ let { colorTexture } = this.state;
4227
+ const colors = colorRangeToFlatArray(colorRange, false, Uint8Array);
4228
+ if (colorTexture && (colorTexture == null ? void 0 : colorTexture.width) === colorRange.length) {
4229
+ colorTexture.setSubImageData({ data: colors });
4230
+ } else {
4231
+ colorTexture == null ? void 0 : colorTexture.destroy();
4232
+ colorTexture = this.context.device.createTexture({
4233
+ ...TEXTURE_PROPS,
4234
+ data: colors,
4235
+ width: colorRange.length,
4236
+ height: 1
4237
+ });
4238
+ }
4239
+ this.setState({ colorTexture });
4240
+ }
4241
+ _updateWeightmap() {
4242
+ const { radiusPixels, colorDomain, aggregation } = this.props;
4243
+ const { worldBounds, textureSize, weightsScale } = this.state;
4244
+ const weightsTransform = this.state.weightsTransform;
4245
+ this.state.isWeightMapDirty = false;
4246
+ const commonBounds = this._worldToCommonBounds(worldBounds, {
4247
+ useLayerCoordinateSystem: true
4248
+ });
4249
+ if (colorDomain && aggregation === "SUM") {
4250
+ const { viewport } = this.context;
4251
+ const metersPerPixel = viewport.distanceScales.metersPerUnit[2] * (commonBounds[2] - commonBounds[0]) / textureSize;
4252
+ this.state.colorDomain = colorDomain.map((x) => x * metersPerPixel * weightsScale);
4253
+ } else {
4254
+ this.state.colorDomain = colorDomain || DEFAULT_COLOR_DOMAIN;
4255
+ }
4256
+ const attributeManager = this.getAttributeManager();
4257
+ const attributes = attributeManager.getAttributes();
4258
+ const moduleSettings = this.getModuleSettings();
4259
+ const positions = attributes.positions.buffer;
4260
+ const uniforms = { radiusPixels, commonBounds, textureWidth: textureSize, weightsScale };
4261
+ const weights = attributes.weights.buffer;
4262
+ weightsTransform.model.setAttributes({ positions, weights });
4263
+ weightsTransform.model.setVertexCount(this.getNumInstances());
4264
+ weightsTransform.model.setUniforms(uniforms);
4265
+ weightsTransform.model.updateModuleSettings(moduleSettings);
4266
+ weightsTransform.run({
4267
+ parameters: { viewport: [0, 0, textureSize, textureSize] },
4268
+ clearColor: [0, 0, 0, 0]
4269
+ });
4270
+ this._updateMaxWeightValue();
4271
+ }
4272
+ _debouncedUpdateWeightmap(fromTimer = false) {
4273
+ let { updateTimer } = this.state;
4274
+ const { debounceTimeout } = this.props;
4275
+ if (fromTimer) {
4276
+ updateTimer = null;
4277
+ this._updateBounds(true);
4278
+ this._updateTextureRenderingBounds();
4279
+ this.setState({ isWeightMapDirty: true });
4280
+ } else {
4281
+ this.setState({ isWeightMapDirty: false });
4282
+ clearTimeout(updateTimer);
4283
+ updateTimer = setTimeout(this._debouncedUpdateWeightmap.bind(this, true), debounceTimeout);
4284
+ }
4285
+ this.setState({ updateTimer });
4286
+ }
4287
+ _worldToCommonBounds(worldBounds, opts = {}) {
4288
+ const { useLayerCoordinateSystem = false } = opts;
4289
+ const [minLong, minLat, maxLong, maxLat] = worldBounds;
4290
+ const { viewport } = this.context;
4291
+ const { textureSize } = this.state;
4292
+ const { coordinateSystem } = this.props;
4293
+ const offsetMode = useLayerCoordinateSystem && (coordinateSystem === import_core17.COORDINATE_SYSTEM.LNGLAT_OFFSETS || coordinateSystem === import_core17.COORDINATE_SYSTEM.METER_OFFSETS);
4294
+ const offsetOriginCommon = offsetMode ? viewport.projectPosition(this.props.coordinateOrigin) : [0, 0];
4295
+ const size = textureSize * RESOLUTION / viewport.scale;
4296
+ let bottomLeftCommon;
4297
+ let topRightCommon;
4298
+ if (useLayerCoordinateSystem && !offsetMode) {
4299
+ bottomLeftCommon = this.projectPosition([minLong, minLat, 0]);
4300
+ topRightCommon = this.projectPosition([maxLong, maxLat, 0]);
4301
+ } else {
4302
+ bottomLeftCommon = viewport.projectPosition([minLong, minLat, 0]);
4303
+ topRightCommon = viewport.projectPosition([maxLong, maxLat, 0]);
4304
+ }
4305
+ return scaleToAspectRatio([
4306
+ bottomLeftCommon[0] - offsetOriginCommon[0],
4307
+ bottomLeftCommon[1] - offsetOriginCommon[1],
4308
+ topRightCommon[0] - offsetOriginCommon[0],
4309
+ topRightCommon[1] - offsetOriginCommon[1]
4310
+ ], size, size);
4311
+ }
4312
+ _commonToWorldBounds(commonBounds) {
4313
+ const [xMin, yMin, xMax, yMax] = commonBounds;
4314
+ const { viewport } = this.context;
4315
+ const bottomLeftWorld = viewport.unprojectPosition([xMin, yMin]);
4316
+ const topRightWorld = viewport.unprojectPosition([xMax, yMax]);
4317
+ return bottomLeftWorld.slice(0, 2).concat(topRightWorld.slice(0, 2));
4318
+ }
4319
+ };
4320
+ var HeatmapLayer = _HeatmapLayer;
4321
+ (() => {
4322
+ _HeatmapLayer.layerName = "HeatmapLayer";
4323
+ })();
4324
+ (() => {
4325
+ _HeatmapLayer.defaultProps = defaultProps10;
4326
+ })();
4327
+ //# sourceMappingURL=index.cjs.map