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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (336) hide show
  1. package/dist/aggregation-layer.js +153 -0
  2. package/dist/contour-layer/contour-layer.js +241 -0
  3. package/dist/contour-layer/contour-utils.js +64 -0
  4. package/dist/contour-layer/marching-squares-codes.js +337 -0
  5. package/dist/contour-layer/marching-squares.js +147 -0
  6. package/dist/cpu-grid-layer/cpu-grid-layer.js +130 -0
  7. package/dist/cpu-grid-layer/grid-aggregator.js +141 -0
  8. package/dist/dist.dev.js +1187 -10528
  9. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +34 -0
  10. package/dist/{esm/gpu-grid-layer → gpu-grid-layer}/gpu-grid-cell-layer-vertex.glsl.js +20 -1
  11. package/dist/gpu-grid-layer/gpu-grid-cell-layer.js +145 -0
  12. package/dist/gpu-grid-layer/gpu-grid-layer.js +288 -0
  13. package/dist/grid-aggregation-layer.js +172 -0
  14. package/dist/grid-layer/grid-layer.js +63 -0
  15. package/{typed → dist}/heatmap-layer/heatmap-layer-utils.d.ts +0 -9
  16. package/dist/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -0
  17. package/dist/heatmap-layer/heatmap-layer-utils.js +63 -0
  18. package/{typed → dist}/heatmap-layer/heatmap-layer.d.ts +4 -4
  19. package/dist/heatmap-layer/heatmap-layer.d.ts.map +1 -0
  20. package/dist/heatmap-layer/heatmap-layer.js +471 -0
  21. package/dist/{esm/heatmap-layer → heatmap-layer}/max-fs.glsl.js +0 -1
  22. package/dist/heatmap-layer/max-vs.glsl.d.ts +3 -0
  23. package/{typed → dist}/heatmap-layer/max-vs.glsl.d.ts.map +1 -1
  24. package/dist/heatmap-layer/max-vs.glsl.js +19 -0
  25. package/dist/heatmap-layer/triangle-layer-fragment.glsl.d.ts +3 -0
  26. package/dist/heatmap-layer/triangle-layer-fragment.glsl.js +61 -0
  27. package/dist/heatmap-layer/triangle-layer-vertex.glsl.js +52 -0
  28. package/{typed → dist}/heatmap-layer/triangle-layer.d.ts +10 -2
  29. package/dist/heatmap-layer/triangle-layer.d.ts.map +1 -0
  30. package/dist/heatmap-layer/triangle-layer.js +59 -0
  31. package/dist/{esm/heatmap-layer → heatmap-layer}/weights-fs.glsl.js +0 -1
  32. package/dist/heatmap-layer/weights-vs.glsl.d.ts +3 -0
  33. package/{typed → dist}/heatmap-layer/weights-vs.glsl.d.ts.map +1 -1
  34. package/dist/{esm/heatmap-layer → heatmap-layer}/weights-vs.glsl.js +4 -3
  35. package/dist/hexagon-layer/hexagon-aggregator.js +112 -0
  36. package/dist/hexagon-layer/hexagon-layer.js +174 -0
  37. package/dist/index.cjs +4494 -0
  38. package/dist/index.cjs.map +7 -0
  39. package/dist/index.js +32 -0
  40. package/dist/screen-grid-layer/screen-grid-cell-layer.js +166 -0
  41. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.js +40 -0
  42. package/dist/{esm/screen-grid-layer → screen-grid-layer}/screen-grid-layer-vertex.glsl.js +19 -1
  43. package/dist/screen-grid-layer/screen-grid-layer.js +216 -0
  44. package/dist/types.js +1 -0
  45. package/dist/utils/aggregation-operation-utils.js +94 -0
  46. package/dist/utils/bin-sorter.js +167 -0
  47. package/dist/utils/color-utils.js +53 -0
  48. package/dist/utils/cpu-aggregator.js +421 -0
  49. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +39 -0
  50. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +53 -0
  51. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +34 -0
  52. package/dist/{esm/utils → utils}/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +19 -1
  53. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +41 -0
  54. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +1 -0
  55. package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts.map +1 -1
  56. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +566 -0
  57. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +37 -0
  58. package/dist/utils/grid-aggregation-utils.js +114 -0
  59. package/dist/utils/prop-utils.js +28 -0
  60. package/dist/utils/resource-utils.js +38 -0
  61. package/dist/utils/scale-utils.js +184 -0
  62. package/dist.min.js +74 -178
  63. package/package.json +18 -11
  64. package/src/heatmap-layer/heatmap-layer-utils.ts +0 -23
  65. package/src/heatmap-layer/heatmap-layer.ts +87 -105
  66. package/src/heatmap-layer/max-vs.glsl.ts +11 -5
  67. package/src/heatmap-layer/triangle-layer-fragment.glsl.ts +2 -2
  68. package/src/heatmap-layer/triangle-layer.ts +17 -23
  69. package/src/heatmap-layer/weights-vs.glsl.ts +4 -2
  70. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.ts +10 -13
  71. package/dist/es5/aggregation-layer.js +0 -215
  72. package/dist/es5/aggregation-layer.js.map +0 -1
  73. package/dist/es5/contour-layer/contour-layer.js +0 -353
  74. package/dist/es5/contour-layer/contour-layer.js.map +0 -1
  75. package/dist/es5/contour-layer/contour-utils.js +0 -110
  76. package/dist/es5/contour-layer/contour-utils.js.map +0 -1
  77. package/dist/es5/contour-layer/marching-squares-codes.js +0 -152
  78. package/dist/es5/contour-layer/marching-squares-codes.js.map +0 -1
  79. package/dist/es5/contour-layer/marching-squares.js +0 -168
  80. package/dist/es5/contour-layer/marching-squares.js.map +0 -1
  81. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +0 -235
  82. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +0 -1
  83. package/dist/es5/cpu-grid-layer/grid-aggregator.js +0 -180
  84. package/dist/es5/cpu-grid-layer/grid-aggregator.js.map +0 -1
  85. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -9
  86. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js.map +0 -1
  87. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +0 -9
  88. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js.map +0 -1
  89. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +0 -247
  90. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +0 -1
  91. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +0 -424
  92. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +0 -1
  93. package/dist/es5/grid-aggregation-layer.js +0 -280
  94. package/dist/es5/grid-aggregation-layer.js.map +0 -1
  95. package/dist/es5/grid-layer/grid-layer.js +0 -125
  96. package/dist/es5/grid-layer/grid-layer.js.map +0 -1
  97. package/dist/es5/heatmap-layer/heatmap-layer-utils.js +0 -122
  98. package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +0 -1
  99. package/dist/es5/heatmap-layer/heatmap-layer.js +0 -672
  100. package/dist/es5/heatmap-layer/heatmap-layer.js.map +0 -1
  101. package/dist/es5/heatmap-layer/max-fs.glsl.js +0 -9
  102. package/dist/es5/heatmap-layer/max-fs.glsl.js.map +0 -1
  103. package/dist/es5/heatmap-layer/max-vs.glsl.js +0 -9
  104. package/dist/es5/heatmap-layer/max-vs.glsl.js.map +0 -1
  105. package/dist/es5/heatmap-layer/triangle-layer-fragment.glsl.js +0 -9
  106. package/dist/es5/heatmap-layer/triangle-layer-fragment.glsl.js.map +0 -1
  107. package/dist/es5/heatmap-layer/triangle-layer-vertex.glsl.js +0 -9
  108. package/dist/es5/heatmap-layer/triangle-layer-vertex.glsl.js.map +0 -1
  109. package/dist/es5/heatmap-layer/triangle-layer.js +0 -122
  110. package/dist/es5/heatmap-layer/triangle-layer.js.map +0 -1
  111. package/dist/es5/heatmap-layer/weights-fs.glsl.js +0 -9
  112. package/dist/es5/heatmap-layer/weights-fs.glsl.js.map +0 -1
  113. package/dist/es5/heatmap-layer/weights-vs.glsl.js +0 -9
  114. package/dist/es5/heatmap-layer/weights-vs.glsl.js.map +0 -1
  115. package/dist/es5/hexagon-layer/hexagon-aggregator.js +0 -118
  116. package/dist/es5/hexagon-layer/hexagon-aggregator.js.map +0 -1
  117. package/dist/es5/hexagon-layer/hexagon-layer.js +0 -289
  118. package/dist/es5/hexagon-layer/hexagon-layer.js.map +0 -1
  119. package/dist/es5/index.js +0 -104
  120. package/dist/es5/index.js.map +0 -1
  121. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +0 -244
  122. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +0 -1
  123. package/dist/es5/screen-grid-layer/screen-grid-layer-fragment.glsl.js +0 -9
  124. package/dist/es5/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +0 -1
  125. package/dist/es5/screen-grid-layer/screen-grid-layer-vertex.glsl.js +0 -9
  126. package/dist/es5/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +0 -1
  127. package/dist/es5/screen-grid-layer/screen-grid-layer.js +0 -317
  128. package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +0 -1
  129. package/dist/es5/types.js +0 -2
  130. package/dist/es5/types.js.map +0 -1
  131. package/dist/es5/utils/aggregation-operation-utils.js +0 -123
  132. package/dist/es5/utils/aggregation-operation-utils.js.map +0 -1
  133. package/dist/es5/utils/bin-sorter.js +0 -248
  134. package/dist/es5/utils/bin-sorter.js.map +0 -1
  135. package/dist/es5/utils/color-utils.js +0 -39
  136. package/dist/es5/utils/color-utils.js.map +0 -1
  137. package/dist/es5/utils/cpu-aggregator.js +0 -496
  138. package/dist/es5/utils/cpu-aggregator.js.map +0 -1
  139. package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -9
  140. package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js.map +0 -1
  141. package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -9
  142. package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js.map +0 -1
  143. package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -9
  144. package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js.map +0 -1
  145. package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +0 -9
  146. package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js.map +0 -1
  147. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -63
  148. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +0 -1
  149. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -2
  150. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js.map +0 -1
  151. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -732
  152. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +0 -1
  153. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +0 -155
  154. package/dist/es5/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -9
  155. package/dist/es5/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js.map +0 -1
  156. package/dist/es5/utils/grid-aggregation-utils.js +0 -118
  157. package/dist/es5/utils/grid-aggregation-utils.js.map +0 -1
  158. package/dist/es5/utils/prop-utils.js +0 -19
  159. package/dist/es5/utils/prop-utils.js.map +0 -1
  160. package/dist/es5/utils/resource-utils.js +0 -59
  161. package/dist/es5/utils/resource-utils.js.map +0 -1
  162. package/dist/es5/utils/scale-utils.js +0 -254
  163. package/dist/es5/utils/scale-utils.js.map +0 -1
  164. package/dist/esm/aggregation-layer.js +0 -156
  165. package/dist/esm/aggregation-layer.js.map +0 -1
  166. package/dist/esm/contour-layer/contour-layer.js +0 -316
  167. package/dist/esm/contour-layer/contour-layer.js.map +0 -1
  168. package/dist/esm/contour-layer/contour-utils.js +0 -81
  169. package/dist/esm/contour-layer/contour-utils.js.map +0 -1
  170. package/dist/esm/contour-layer/marching-squares-codes.js +0 -219
  171. package/dist/esm/contour-layer/marching-squares-codes.js.map +0 -1
  172. package/dist/esm/contour-layer/marching-squares.js +0 -151
  173. package/dist/esm/contour-layer/marching-squares.js.map +0 -1
  174. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js +0 -186
  175. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js.map +0 -1
  176. package/dist/esm/cpu-grid-layer/grid-aggregator.js +0 -142
  177. package/dist/esm/cpu-grid-layer/grid-aggregator.js.map +0 -1
  178. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -16
  179. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js.map +0 -1
  180. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js.map +0 -1
  181. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js +0 -196
  182. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js.map +0 -1
  183. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js +0 -399
  184. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js.map +0 -1
  185. package/dist/esm/grid-aggregation-layer.js +0 -240
  186. package/dist/esm/grid-aggregation-layer.js.map +0 -1
  187. package/dist/esm/grid-layer/grid-layer.js +0 -80
  188. package/dist/esm/grid-layer/grid-layer.js.map +0 -1
  189. package/dist/esm/heatmap-layer/heatmap-layer-utils.js +0 -68
  190. package/dist/esm/heatmap-layer/heatmap-layer-utils.js.map +0 -1
  191. package/dist/esm/heatmap-layer/heatmap-layer.js +0 -626
  192. package/dist/esm/heatmap-layer/heatmap-layer.js.map +0 -1
  193. package/dist/esm/heatmap-layer/max-fs.glsl.js.map +0 -1
  194. package/dist/esm/heatmap-layer/max-vs.glsl.js +0 -14
  195. package/dist/esm/heatmap-layer/max-vs.glsl.js.map +0 -1
  196. package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js +0 -43
  197. package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js.map +0 -1
  198. package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js +0 -33
  199. package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js.map +0 -1
  200. package/dist/esm/heatmap-layer/triangle-layer.js +0 -80
  201. package/dist/esm/heatmap-layer/triangle-layer.js.map +0 -1
  202. package/dist/esm/heatmap-layer/weights-fs.glsl.js.map +0 -1
  203. package/dist/esm/heatmap-layer/weights-vs.glsl.js.map +0 -1
  204. package/dist/esm/hexagon-layer/hexagon-aggregator.js +0 -87
  205. package/dist/esm/hexagon-layer/hexagon-aggregator.js.map +0 -1
  206. package/dist/esm/hexagon-layer/hexagon-layer.js +0 -232
  207. package/dist/esm/hexagon-layer/hexagon-layer.js.map +0 -1
  208. package/dist/esm/index.js +0 -13
  209. package/dist/esm/index.js.map +0 -1
  210. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js +0 -203
  211. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js.map +0 -1
  212. package/dist/esm/screen-grid-layer/screen-grid-layer-fragment.glsl.js +0 -21
  213. package/dist/esm/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +0 -1
  214. package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +0 -1
  215. package/dist/esm/screen-grid-layer/screen-grid-layer.js +0 -285
  216. package/dist/esm/screen-grid-layer/screen-grid-layer.js.map +0 -1
  217. package/dist/esm/types.js +0 -2
  218. package/dist/esm/types.js.map +0 -1
  219. package/dist/esm/utils/aggregation-operation-utils.js +0 -91
  220. package/dist/esm/utils/aggregation-operation-utils.js.map +0 -1
  221. package/dist/esm/utils/bin-sorter.js +0 -165
  222. package/dist/esm/utils/bin-sorter.js.map +0 -1
  223. package/dist/esm/utils/color-utils.js +0 -28
  224. package/dist/esm/utils/color-utils.js.map +0 -1
  225. package/dist/esm/utils/cpu-aggregator.js +0 -487
  226. package/dist/esm/utils/cpu-aggregator.js.map +0 -1
  227. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -21
  228. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js.map +0 -1
  229. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -35
  230. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js.map +0 -1
  231. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -16
  232. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js.map +0 -1
  233. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js.map +0 -1
  234. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -42
  235. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +0 -1
  236. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -2
  237. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js.map +0 -1
  238. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -720
  239. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +0 -1
  240. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +0 -155
  241. package/dist/esm/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -19
  242. package/dist/esm/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js.map +0 -1
  243. package/dist/esm/utils/grid-aggregation-utils.js +0 -109
  244. package/dist/esm/utils/grid-aggregation-utils.js.map +0 -1
  245. package/dist/esm/utils/prop-utils.js +0 -12
  246. package/dist/esm/utils/prop-utils.js.map +0 -1
  247. package/dist/esm/utils/resource-utils.js +0 -44
  248. package/dist/esm/utils/resource-utils.js.map +0 -1
  249. package/dist/esm/utils/scale-utils.js +0 -192
  250. package/dist/esm/utils/scale-utils.js.map +0 -1
  251. package/typed/heatmap-layer/heatmap-layer-utils.d.ts.map +0 -1
  252. package/typed/heatmap-layer/heatmap-layer.d.ts.map +0 -1
  253. package/typed/heatmap-layer/max-vs.glsl.d.ts +0 -3
  254. package/typed/heatmap-layer/triangle-layer-fragment.glsl.d.ts +0 -3
  255. package/typed/heatmap-layer/triangle-layer.d.ts.map +0 -1
  256. package/typed/heatmap-layer/weights-vs.glsl.d.ts +0 -3
  257. /package/{typed → dist}/aggregation-layer.d.ts +0 -0
  258. /package/{typed → dist}/aggregation-layer.d.ts.map +0 -0
  259. /package/{typed → dist}/contour-layer/contour-layer.d.ts +0 -0
  260. /package/{typed → dist}/contour-layer/contour-layer.d.ts.map +0 -0
  261. /package/{typed → dist}/contour-layer/contour-utils.d.ts +0 -0
  262. /package/{typed → dist}/contour-layer/contour-utils.d.ts.map +0 -0
  263. /package/{typed → dist}/contour-layer/marching-squares-codes.d.ts +0 -0
  264. /package/{typed → dist}/contour-layer/marching-squares-codes.d.ts.map +0 -0
  265. /package/{typed → dist}/contour-layer/marching-squares.d.ts +0 -0
  266. /package/{typed → dist}/contour-layer/marching-squares.d.ts.map +0 -0
  267. /package/{typed → dist}/cpu-grid-layer/cpu-grid-layer.d.ts +0 -0
  268. /package/{typed → dist}/cpu-grid-layer/cpu-grid-layer.d.ts.map +0 -0
  269. /package/{typed → dist}/cpu-grid-layer/grid-aggregator.d.ts +0 -0
  270. /package/{typed → dist}/cpu-grid-layer/grid-aggregator.d.ts.map +0 -0
  271. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts +0 -0
  272. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts.map +0 -0
  273. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts +0 -0
  274. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts.map +0 -0
  275. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer.d.ts +0 -0
  276. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +0 -0
  277. /package/{typed → dist}/gpu-grid-layer/gpu-grid-layer.d.ts +0 -0
  278. /package/{typed → dist}/gpu-grid-layer/gpu-grid-layer.d.ts.map +0 -0
  279. /package/{typed → dist}/grid-aggregation-layer.d.ts +0 -0
  280. /package/{typed → dist}/grid-aggregation-layer.d.ts.map +0 -0
  281. /package/{typed → dist}/grid-layer/grid-layer.d.ts +0 -0
  282. /package/{typed → dist}/grid-layer/grid-layer.d.ts.map +0 -0
  283. /package/{typed → dist}/heatmap-layer/max-fs.glsl.d.ts +0 -0
  284. /package/{typed → dist}/heatmap-layer/max-fs.glsl.d.ts.map +0 -0
  285. /package/{typed → dist}/heatmap-layer/triangle-layer-fragment.glsl.d.ts.map +0 -0
  286. /package/{typed → dist}/heatmap-layer/triangle-layer-vertex.glsl.d.ts +0 -0
  287. /package/{typed → dist}/heatmap-layer/triangle-layer-vertex.glsl.d.ts.map +0 -0
  288. /package/{typed → dist}/heatmap-layer/weights-fs.glsl.d.ts +0 -0
  289. /package/{typed → dist}/heatmap-layer/weights-fs.glsl.d.ts.map +0 -0
  290. /package/{typed → dist}/hexagon-layer/hexagon-aggregator.d.ts +0 -0
  291. /package/{typed → dist}/hexagon-layer/hexagon-aggregator.d.ts.map +0 -0
  292. /package/{typed → dist}/hexagon-layer/hexagon-layer.d.ts +0 -0
  293. /package/{typed → dist}/hexagon-layer/hexagon-layer.d.ts.map +0 -0
  294. /package/{typed → dist}/index.d.ts +0 -0
  295. /package/{typed → dist}/index.d.ts.map +0 -0
  296. /package/{typed → dist}/screen-grid-layer/screen-grid-cell-layer.d.ts +0 -0
  297. /package/{typed → dist}/screen-grid-layer/screen-grid-cell-layer.d.ts.map +0 -0
  298. /package/{typed → dist}/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts +0 -0
  299. /package/{typed → dist}/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts.map +0 -0
  300. /package/{typed → dist}/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts +0 -0
  301. /package/{typed → dist}/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts.map +0 -0
  302. /package/{typed → dist}/screen-grid-layer/screen-grid-layer.d.ts +0 -0
  303. /package/{typed → dist}/screen-grid-layer/screen-grid-layer.d.ts.map +0 -0
  304. /package/{typed → dist}/types.d.ts +0 -0
  305. /package/{typed → dist}/types.d.ts.map +0 -0
  306. /package/{typed → dist}/utils/aggregation-operation-utils.d.ts +0 -0
  307. /package/{typed → dist}/utils/aggregation-operation-utils.d.ts.map +0 -0
  308. /package/{typed → dist}/utils/bin-sorter.d.ts +0 -0
  309. /package/{typed → dist}/utils/bin-sorter.d.ts.map +0 -0
  310. /package/{typed → dist}/utils/color-utils.d.ts +0 -0
  311. /package/{typed → dist}/utils/color-utils.d.ts.map +0 -0
  312. /package/{typed → dist}/utils/cpu-aggregator.d.ts +0 -0
  313. /package/{typed → dist}/utils/cpu-aggregator.d.ts.map +0 -0
  314. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts +0 -0
  315. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts.map +0 -0
  316. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts +0 -0
  317. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts.map +0 -0
  318. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts +0 -0
  319. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts.map +0 -0
  320. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts +0 -0
  321. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts.map +0 -0
  322. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts +0 -0
  323. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts.map +0 -0
  324. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts +0 -0
  325. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts.map +0 -0
  326. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts +0 -0
  327. /package/{typed → dist}/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts +0 -0
  328. /package/{typed → dist}/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts.map +0 -0
  329. /package/{typed → dist}/utils/grid-aggregation-utils.d.ts +0 -0
  330. /package/{typed → dist}/utils/grid-aggregation-utils.d.ts.map +0 -0
  331. /package/{typed → dist}/utils/prop-utils.d.ts +0 -0
  332. /package/{typed → dist}/utils/prop-utils.d.ts.map +0 -0
  333. /package/{typed → dist}/utils/resource-utils.d.ts +0 -0
  334. /package/{typed → dist}/utils/resource-utils.d.ts.map +0 -0
  335. /package/{typed → dist}/utils/scale-utils.d.ts +0 -0
  336. /package/{typed → dist}/utils/scale-utils.d.ts.map +0 -0
@@ -0,0 +1,153 @@
1
+ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ // of this software and associated documentation files (the "Software"), to deal
5
+ // in the Software without restriction, including without limitation the rights
6
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ // copies of the Software, and to permit persons to whom the Software is
8
+ // furnished to do so, subject to the following conditions:
9
+ //
10
+ // The above copyright notice and this permission notice shall be included in
11
+ // all copies or substantial portions of the Software.
12
+ //
13
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ // THE SOFTWARE.
20
+ import { CompositeLayer, AttributeManager, _compareProps as compareProps } from '@deck.gl/core';
21
+ import { filterProps } from "./utils/prop-utils.js";
22
+ export default class AggregationLayer extends CompositeLayer {
23
+ static { this.layerName = 'AggregationLayer'; }
24
+ initializeAggregationLayer(dimensions) {
25
+ super.initializeState(this.context);
26
+ this.setState({
27
+ // Layer props , when changed doesn't require updating aggregation
28
+ ignoreProps: filterProps(this.constructor._propTypes, dimensions.data.props),
29
+ dimensions
30
+ });
31
+ }
32
+ updateState(opts) {
33
+ super.updateState(opts);
34
+ const { changeFlags } = opts;
35
+ if (changeFlags.extensionsChanged) {
36
+ const shaders = this.getShaders({});
37
+ if (shaders && shaders.defines) {
38
+ shaders.defines.NON_INSTANCED_MODEL = 1;
39
+ }
40
+ this.updateShaders(shaders);
41
+ }
42
+ // Explictly call to update attributes as 'CompositeLayer' doesn't call this
43
+ this._updateAttributes();
44
+ }
45
+ updateAttributes(changedAttributes) {
46
+ // Super classes, can refer to state.changedAttributes to determine what
47
+ // attributes changed
48
+ this.setState({ changedAttributes });
49
+ }
50
+ getAttributes() {
51
+ return this.getAttributeManager().getAttributes();
52
+ }
53
+ getModuleSettings() {
54
+ // For regular layer draw this happens during draw cycle (_drawLayersInViewport) not during update cycle
55
+ // For aggregation layers this is called during updateState to update aggregation data
56
+ // NOTE: it is similar to LayerPass._getModuleParameters() but doesn't inlcude `effects` it is not needed for aggregation
57
+ const { viewport, mousePosition, device } = this.context;
58
+ const moduleSettings = Object.assign(Object.create(this.props), {
59
+ viewport,
60
+ mousePosition,
61
+ picking: {
62
+ isActive: 0
63
+ },
64
+ // @ts-expect-error TODO - assuming WebGL context
65
+ devicePixelRatio: device.canvasContext.cssToDeviceRatio()
66
+ });
67
+ return moduleSettings;
68
+ }
69
+ updateShaders(shaders) {
70
+ // Default implemention is empty, subclasses can update their Model objects if needed
71
+ }
72
+ /**
73
+ * Checks if aggregation is dirty
74
+ * @param {Object} updateOpts - object {props, oldProps, changeFlags}
75
+ * @param {Object} params - object {dimension, compareAll}
76
+ * @param {Object} params.dimension - {props, accessors} array of props and/or accessors
77
+ * @param {Boolean} params.compareAll - when `true` it will include non layer props for comparision
78
+ * @returns {Boolean} - returns true if dimensions' prop or accessor is changed
79
+ **/
80
+ isAggregationDirty(updateOpts, params = {}) {
81
+ const { props, oldProps, changeFlags } = updateOpts;
82
+ const { compareAll = false, dimension } = params;
83
+ const { ignoreProps } = this.state;
84
+ const { props: dataProps, accessors = [] } = dimension;
85
+ const { updateTriggersChanged } = changeFlags;
86
+ if (changeFlags.dataChanged) {
87
+ return true;
88
+ }
89
+ if (updateTriggersChanged) {
90
+ if (updateTriggersChanged.all) {
91
+ return true;
92
+ }
93
+ for (const accessor of accessors) {
94
+ if (updateTriggersChanged[accessor]) {
95
+ return true;
96
+ }
97
+ }
98
+ }
99
+ if (compareAll) {
100
+ if (changeFlags.extensionsChanged) {
101
+ return true;
102
+ }
103
+ // Compare non layer props too (like extension props)
104
+ // ignoreprops refers to all Layer props other than aggregation props that need to be comapred
105
+ return compareProps({
106
+ oldProps,
107
+ newProps: props,
108
+ ignoreProps,
109
+ propTypes: this.constructor._propTypes
110
+ });
111
+ }
112
+ // Compare props of the dimension
113
+ for (const name of dataProps) {
114
+ if (props[name] !== oldProps[name]) {
115
+ return true;
116
+ }
117
+ }
118
+ return false;
119
+ }
120
+ /**
121
+ * Checks if an attribute is changed
122
+ * @param {String} name - name of the attribute
123
+ * @returns {Boolean} - `true` if attribute `name` is changed, `false` otherwise,
124
+ * If `name` is not passed or `undefiend`, `true` if any attribute is changed, `false` otherwise
125
+ **/
126
+ isAttributeChanged(name) {
127
+ const { changedAttributes } = this.state;
128
+ if (!name) {
129
+ // if name not specified return true if any attribute is changed
130
+ return !isObjectEmpty(changedAttributes);
131
+ }
132
+ return changedAttributes && changedAttributes[name] !== undefined;
133
+ }
134
+ // Private
135
+ // override Composite layer private method to create AttributeManager instance
136
+ _getAttributeManager() {
137
+ return new AttributeManager(this.context.device, {
138
+ id: this.props.id,
139
+ stats: this.context.stats
140
+ });
141
+ }
142
+ }
143
+ // Helper methods
144
+ // Returns true if given object is empty, false otherwise.
145
+ function isObjectEmpty(obj) {
146
+ let isEmpty = true;
147
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
148
+ for (const key in obj) {
149
+ isEmpty = false;
150
+ break;
151
+ }
152
+ return isEmpty;
153
+ }
@@ -0,0 +1,241 @@
1
+ // Copyright (c) 2015 - 2018 Uber Technologies, Inc.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ // of this software and associated documentation files (the "Software"), to deal
5
+ // in the Software without restriction, including without limitation the rights
6
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ // copies of the Software, and to permit persons to whom the Software is
8
+ // furnished to do so, subject to the following conditions:
9
+ //
10
+ // The above copyright notice and this permission notice shall be included in
11
+ // all copies or substantial portions of the Software.
12
+ //
13
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ // THE SOFTWARE.
20
+ import { GL } from '@luma.gl/constants';
21
+ import { LineLayer, SolidPolygonLayer } from '@deck.gl/layers';
22
+ import { generateContours } from "./contour-utils.js";
23
+ import { log } from '@deck.gl/core';
24
+ import GPUGridAggregator from "../utils/gpu-grid-aggregation/gpu-grid-aggregator.js";
25
+ import { AGGREGATION_OPERATION, getValueFunc } from "../utils/aggregation-operation-utils.js";
26
+ import { getBoundingBox, getGridParams } from "../utils/grid-aggregation-utils.js";
27
+ import GridAggregationLayer from "../grid-aggregation-layer.js";
28
+ const DEFAULT_COLOR = [255, 255, 255, 255];
29
+ const DEFAULT_STROKE_WIDTH = 1;
30
+ const DEFAULT_THRESHOLD = 1;
31
+ const defaultProps = {
32
+ // grid aggregation
33
+ cellSize: { type: 'number', min: 1, max: 1000, value: 1000 },
34
+ getPosition: { type: 'accessor', value: (x) => x.position },
35
+ getWeight: { type: 'accessor', value: 1 },
36
+ gpuAggregation: false, // TODO(v9): Re-enable GPU aggregation.
37
+ aggregation: 'SUM',
38
+ // contour lines
39
+ contours: {
40
+ type: 'object',
41
+ value: [{ threshold: DEFAULT_THRESHOLD }],
42
+ optional: true,
43
+ compare: 3
44
+ },
45
+ zOffset: 0.005
46
+ };
47
+ const POSITION_ATTRIBUTE_NAME = 'positions';
48
+ const DIMENSIONS = {
49
+ data: {
50
+ props: ['cellSize']
51
+ },
52
+ weights: {
53
+ props: ['aggregation'],
54
+ accessors: ['getWeight']
55
+ }
56
+ };
57
+ /** Aggregate data into iso-lines or iso-bands for a given threshold and cell size. */
58
+ export default class ContourLayer extends GridAggregationLayer {
59
+ static { this.layerName = 'ContourLayer'; }
60
+ static { this.defaultProps = defaultProps; }
61
+ initializeState() {
62
+ super.initializeAggregationLayer({
63
+ dimensions: DIMENSIONS
64
+ });
65
+ this.setState({
66
+ contourData: {},
67
+ projectPoints: false,
68
+ weights: {
69
+ count: {
70
+ size: 1,
71
+ operation: AGGREGATION_OPERATION.SUM
72
+ }
73
+ }
74
+ });
75
+ const attributeManager = this.getAttributeManager();
76
+ attributeManager.add({
77
+ [POSITION_ATTRIBUTE_NAME]: {
78
+ size: 3,
79
+ accessor: 'getPosition',
80
+ type: GL.DOUBLE,
81
+ fp64: this.use64bitPositions()
82
+ },
83
+ // this attribute is used in gpu aggregation path only
84
+ count: { size: 3, accessor: 'getWeight' }
85
+ });
86
+ }
87
+ updateState(opts) {
88
+ super.updateState(opts);
89
+ let contoursChanged = false;
90
+ const { oldProps, props } = opts;
91
+ const { aggregationDirty } = this.state;
92
+ if (oldProps.contours !== props.contours || oldProps.zOffset !== props.zOffset) {
93
+ contoursChanged = true;
94
+ this._updateThresholdData(opts.props);
95
+ }
96
+ if (this.getNumInstances() > 0 && (aggregationDirty || contoursChanged)) {
97
+ this._generateContours();
98
+ }
99
+ }
100
+ renderLayers() {
101
+ const { contourSegments, contourPolygons } = this.state.contourData;
102
+ const LinesSubLayerClass = this.getSubLayerClass('lines', LineLayer);
103
+ const BandsSubLayerClass = this.getSubLayerClass('bands', SolidPolygonLayer);
104
+ // Contour lines layer
105
+ const lineLayer = contourSegments &&
106
+ contourSegments.length > 0 &&
107
+ new LinesSubLayerClass(this.getSubLayerProps({
108
+ id: 'lines'
109
+ }), {
110
+ data: this.state.contourData.contourSegments,
111
+ getSourcePosition: d => d.start,
112
+ getTargetPosition: d => d.end,
113
+ getColor: d => d.contour.color || DEFAULT_COLOR,
114
+ getWidth: d => d.contour.strokeWidth || DEFAULT_STROKE_WIDTH
115
+ });
116
+ // Contour bands layer
117
+ const bandsLayer = contourPolygons &&
118
+ contourPolygons.length > 0 &&
119
+ new BandsSubLayerClass(this.getSubLayerProps({
120
+ id: 'bands'
121
+ }), {
122
+ data: this.state.contourData.contourPolygons,
123
+ getPolygon: d => d.vertices,
124
+ getFillColor: d => d.contour.color || DEFAULT_COLOR
125
+ });
126
+ return [lineLayer, bandsLayer];
127
+ }
128
+ // Aggregation Overrides
129
+ /* eslint-disable max-statements, complexity */
130
+ updateAggregationState(opts) {
131
+ const { props, oldProps } = opts;
132
+ const { cellSize, coordinateSystem } = props;
133
+ const { viewport } = this.context;
134
+ const cellSizeChanged = oldProps.cellSize !== cellSize;
135
+ let gpuAggregation = props.gpuAggregation;
136
+ if (this.state.gpuAggregation !== props.gpuAggregation) {
137
+ if (gpuAggregation && !GPUGridAggregator.isSupported(this.context.device)) {
138
+ log.warn('GPU Grid Aggregation not supported, falling back to CPU')();
139
+ gpuAggregation = false;
140
+ }
141
+ }
142
+ const gpuAggregationChanged = gpuAggregation !== this.state.gpuAggregation;
143
+ this.setState({
144
+ gpuAggregation
145
+ });
146
+ const { dimensions } = this.state;
147
+ const positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME);
148
+ const { data, weights } = dimensions;
149
+ let { boundingBox } = this.state;
150
+ if (positionsChanged) {
151
+ boundingBox = getBoundingBox(this.getAttributes(), this.getNumInstances());
152
+ this.setState({ boundingBox });
153
+ }
154
+ if (positionsChanged || cellSizeChanged) {
155
+ const { gridOffset, translation, width, height, numCol, numRow } = getGridParams(boundingBox, cellSize, viewport, coordinateSystem);
156
+ this.allocateResources(numRow, numCol);
157
+ this.setState({
158
+ gridOffset,
159
+ boundingBox,
160
+ translation,
161
+ posOffset: translation.slice(), // Used for CPU aggregation, to offset points
162
+ gridOrigin: [-1 * translation[0], -1 * translation[1]],
163
+ width,
164
+ height,
165
+ numCol,
166
+ numRow
167
+ });
168
+ }
169
+ const aggregationDataDirty = positionsChanged ||
170
+ gpuAggregationChanged ||
171
+ this.isAggregationDirty(opts, {
172
+ dimension: data,
173
+ compareAll: gpuAggregation // check for all (including extentions props) when using gpu aggregation
174
+ });
175
+ const aggregationWeightsDirty = this.isAggregationDirty(opts, {
176
+ dimension: weights
177
+ });
178
+ if (aggregationWeightsDirty) {
179
+ this._updateAccessors(opts);
180
+ }
181
+ if (aggregationDataDirty || aggregationWeightsDirty) {
182
+ this._resetResults();
183
+ }
184
+ this.setState({
185
+ aggregationDataDirty,
186
+ aggregationWeightsDirty
187
+ });
188
+ }
189
+ /* eslint-enable max-statements, complexity */
190
+ // Private (Aggregation)
191
+ _updateAccessors(opts) {
192
+ const { getWeight, aggregation, data } = opts.props;
193
+ const { count } = this.state.weights;
194
+ if (count) {
195
+ count.getWeight = getWeight;
196
+ count.operation = AGGREGATION_OPERATION[aggregation];
197
+ }
198
+ this.setState({ getValue: getValueFunc(aggregation, getWeight, { data }) });
199
+ }
200
+ _resetResults() {
201
+ const { count } = this.state.weights;
202
+ if (count) {
203
+ count.aggregationData = null;
204
+ }
205
+ }
206
+ // Private (Contours)
207
+ _generateContours() {
208
+ const { numCol, numRow, gridOrigin, gridOffset, thresholdData } = this.state;
209
+ const { count } = this.state.weights;
210
+ let { aggregationData } = count;
211
+ if (!aggregationData) {
212
+ // @ts-ignore
213
+ aggregationData = count.aggregationBuffer.readSyncWebGL2();
214
+ count.aggregationData = aggregationData;
215
+ }
216
+ const { cellWeights } = GPUGridAggregator.getCellData({ countsData: aggregationData });
217
+ const contourData = generateContours({
218
+ thresholdData,
219
+ cellWeights,
220
+ gridSize: [numCol, numRow],
221
+ gridOrigin,
222
+ cellSize: [gridOffset.xOffset, gridOffset.yOffset]
223
+ });
224
+ // contourData contains both iso-lines and iso-bands if requested.
225
+ this.setState({ contourData });
226
+ }
227
+ _updateThresholdData(props) {
228
+ const { contours, zOffset } = props;
229
+ const count = contours.length;
230
+ const thresholdData = new Array(count);
231
+ for (let i = 0; i < count; i++) {
232
+ const contour = contours[i];
233
+ thresholdData[i] = {
234
+ contour,
235
+ zIndex: contour.zIndex || i,
236
+ zOffset
237
+ };
238
+ }
239
+ this.setState({ thresholdData });
240
+ }
241
+ }
@@ -0,0 +1,64 @@
1
+ import { getCode, getVertices, CONTOUR_TYPE } from "./marching-squares.js";
2
+ // Given all the cell weights, generates contours for each threshold.
3
+ /* eslint-disable max-depth */
4
+ export function generateContours({ thresholdData, cellWeights, gridSize, gridOrigin, cellSize }) {
5
+ const contourSegments = [];
6
+ const contourPolygons = [];
7
+ const width = gridSize[0];
8
+ const height = gridSize[1];
9
+ let segmentIndex = 0;
10
+ let polygonIndex = 0;
11
+ for (const data of thresholdData) {
12
+ const { contour } = data;
13
+ const { threshold } = contour;
14
+ for (let x = -1; x < width; x++) {
15
+ for (let y = -1; y < height; y++) {
16
+ // Get the MarchingSquares code based on neighbor cell weights.
17
+ const { code, meanCode } = getCode({
18
+ cellWeights,
19
+ threshold,
20
+ x,
21
+ y,
22
+ width,
23
+ height
24
+ });
25
+ const opts = {
26
+ type: CONTOUR_TYPE.ISO_BANDS,
27
+ gridOrigin,
28
+ cellSize,
29
+ x,
30
+ y,
31
+ width,
32
+ height,
33
+ code,
34
+ meanCode,
35
+ thresholdData: data
36
+ };
37
+ if (Array.isArray(threshold)) {
38
+ opts.type = CONTOUR_TYPE.ISO_BANDS;
39
+ const polygons = getVertices(opts);
40
+ for (const polygon of polygons) {
41
+ contourPolygons[polygonIndex++] = {
42
+ vertices: polygon,
43
+ contour
44
+ };
45
+ }
46
+ }
47
+ else {
48
+ // Get the intersection vertices based on MarchingSquares code.
49
+ opts.type = CONTOUR_TYPE.ISO_LINES;
50
+ const vertices = getVertices(opts);
51
+ for (let i = 0; i < vertices.length; i += 2) {
52
+ contourSegments[segmentIndex++] = {
53
+ start: vertices[i],
54
+ end: vertices[i + 1],
55
+ contour
56
+ };
57
+ }
58
+ }
59
+ }
60
+ }
61
+ }
62
+ return { contourSegments, contourPolygons };
63
+ }
64
+ /* eslint-enable max-depth */