chunk-PJNBFKPF.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import {
  2. n
  3. } from "./chunk-C7742RNZ.js";
  4. import {
  5. e,
  6. u
  7. } from "./chunk-UVVU4UUO.js";
  8. import {
  9. a
  10. } from "./chunk-RYY6632W.js";
  11. import {
  12. j
  13. } from "./chunk-YAEIHDJH.js";
  14. // node_modules/@arcgis/core/renderers/support/heatmapUtils.js
  15. var a2 = 2.4;
  16. function i(t) {
  17. return e(t * a2);
  18. }
  19. function c(t) {
  20. return u(t) / a2;
  21. }
  22. function f(r, n2, e2, a3) {
  23. let { color: i2, ratio: c2 } = n2, { color: f2, ratio: u3 } = e2;
  24. if (u3 === c2) {
  25. const t = 1e-6;
  26. 1 === u3 ? c2 -= t : u3 += t;
  27. }
  28. const s2 = a((a3 - c2) / (u3 - c2), 0, 1);
  29. j(r, i2.toArray(), f2.toArray(), s2);
  30. }
  31. function u2(t) {
  32. const r = 512, n2 = new Uint8ClampedArray(4 * r);
  33. if (t = t.filter(({ ratio: t2 }) => t2 >= 0 && t2 <= 1).sort((t2, r2) => t2.ratio - r2.ratio).map(({ color: t2, ratio: r2 }) => ({ color: t2, ratio: Math.max(r2, 1e-3) })), t.length < 1)
  34. return n2;
  35. let o = t[0], a3 = t[0], i2 = 1;
  36. const c2 = n();
  37. for (let e2 = 0; e2 < r; e2++) {
  38. const u3 = (e2 + 0.5) / r;
  39. for (; u3 > a3.ratio && i2 < t.length; )
  40. o = a3, a3 = t[i2++];
  41. f(c2, o, a3, u3), n2.set(c2, 4 * e2);
  42. }
  43. return n2;
  44. }
  45. function s(t, r, o, e2) {
  46. const { radius: a3, fieldOffset: i2, field: c2 } = r, f2 = Math.round(u(a3)), u3 = new Float64Array(o * e2);
  47. let s2, l2 = Number.NEGATIVE_INFINITY;
  48. const h2 = d(c2, i2), y2 = /* @__PURE__ */ new Set();
  49. for (const n2 of t) {
  50. const t2 = n2.getCursor();
  51. for (; t2.next(); ) {
  52. const r2 = t2.getObjectId();
  53. if (y2.has(r2))
  54. continue;
  55. y2.add(r2);
  56. const n3 = t2.readLegacyPointGeometry(), a4 = 128;
  57. if (n3.x < -a4 || n3.x >= o + a4 || n3.y < -a4 || n3.y > e2 + a4)
  58. continue;
  59. const i3 = +h2(t2), c3 = Math.max(0, Math.round(n3.x) - f2), d2 = Math.max(0, Math.round(n3.y) - f2), g = Math.min(e2, Math.round(n3.y) + f2), A = Math.min(o, Math.round(n3.x) + f2);
  60. for (let t3 = d2; t3 < g; t3++)
  61. for (let r3 = c3; r3 < A; r3++) {
  62. const e3 = t3 * o + r3, a5 = m(n3.x - r3, n3.y - t3, f2);
  63. s2 = u3[e3] += a5 * i3, s2 > l2 && (l2 = s2);
  64. }
  65. }
  66. }
  67. return { matrix: u3.buffer, max: l2 };
  68. }
  69. function l(t, r, n2, o, e2, a3) {
  70. t.canvas.width = t.canvas.height = r, t.clearRect(0, 0, r, r);
  71. const i2 = t.getImageData(0, 0, r, r);
  72. n2 && o && i2.data.set(new Uint8ClampedArray(h(r, n2, o, e2, a3))), t.putImageData(i2, 0, 0);
  73. }
  74. function h(r, n2, o, e2, a3) {
  75. const i2 = new Uint32Array(r * r), c2 = "buffer" in n2 ? n2 : new Float64Array(n2), f2 = "buffer" in o ? new Uint32Array(o.buffer) : new Uint32Array(new Uint8Array(o).buffer), u3 = f2.length / (a3 - e2);
  76. for (let s2 = 0; s2 < c2.length; s2++) {
  77. const r2 = c2[s2], n3 = Math.floor((r2 - e2) * u3);
  78. i2[s2] = f2[a(n3, 0, f2.length - 1)];
  79. }
  80. return i2.buffer;
  81. }
  82. function m(t, r, n2) {
  83. const o = Math.sqrt(t ** 2 + r ** 2) / n2;
  84. return o > 1 ? 0 : 3 / (Math.PI * n2 ** 2) * (1 - o ** 2) ** 2;
  85. }
  86. function y(t, r) {
  87. return "function" == typeof t ? t : t ? "string" == typeof r ? (r2) => -1 * +r2[t] : (n2) => +n2[t] + r : () => 1;
  88. }
  89. function d(t, r) {
  90. return null != t ? "string" == typeof r ? (r2) => -1 * +r2.readAttribute(t) : (n2) => +n2.readAttribute(t) + r : (t2) => 1;
  91. }
  92. export {
  93. a2 as a,
  94. i,
  95. c,
  96. u2 as u,
  97. s,
  98. l,
  99. m,
  100. y
  101. };
  102. //# sourceMappingURL=chunk-PJNBFKPF.js.map