chunk-2U5S3G7I.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. import {
  2. C,
  3. J,
  4. oe
  5. } from "./chunk-I623MZCZ.js";
  6. import {
  7. w
  8. } from "./chunk-6T6G6LCQ.js";
  9. import {
  10. r
  11. } from "./chunk-YXWMMD76.js";
  12. // node_modules/@arcgis/core/layers/support/rasterDatasets/EphemeralBlockCache.js
  13. var t = class {
  14. constructor(t2 = 15e3, e = 5e3) {
  15. this._timer = null, this._cachedBlocks = /* @__PURE__ */ new Map(), this._size = -1, this._duration = t2, this._interval = Math.min(t2, e);
  16. }
  17. decreaseRefCount(t2, e) {
  18. const s = t2 + "/" + e, r2 = this._cachedBlocks;
  19. if (r2.has(s)) {
  20. const t3 = r2.get(s);
  21. return t3.refCount--, t3.refCount <= 0 && (r2.delete(s), t3.controller && t3.controller.abort()), t3.refCount;
  22. }
  23. return 0;
  24. }
  25. getBlock(t2, e) {
  26. const s = t2 + "/" + e, r2 = this._cachedBlocks;
  27. if (r2.has(s)) {
  28. const t3 = r2.get(s);
  29. return t3.ts = Date.now(), t3.refCount++, r2.delete(s), r2.set(s, t3), t3.block;
  30. }
  31. return null;
  32. }
  33. putBlock(t2, e, s, r2) {
  34. const i2 = this._cachedBlocks, c2 = t2 + "/" + e;
  35. if (i2.has(c2)) {
  36. const t3 = i2.get(c2);
  37. t3.ts = Date.now(), t3.refCount++;
  38. } else
  39. i2.set(c2, { block: s, ts: Date.now(), refCount: 1, controller: r2 });
  40. this._trim(), this._updateTimer();
  41. }
  42. deleteBlock(t2, e) {
  43. const s = this._cachedBlocks, r2 = t2 + "/" + e;
  44. s.has(r2) && s.delete(r2);
  45. }
  46. updateMaxSize(t2) {
  47. this._size = t2, this._trim();
  48. }
  49. empty() {
  50. this._cachedBlocks.clear(), this._clearTimer();
  51. }
  52. getCurrentSize() {
  53. return this._cachedBlocks.size;
  54. }
  55. _updateTimer() {
  56. if (null != this._timer)
  57. return;
  58. const t2 = this._cachedBlocks;
  59. this._timer = setInterval(() => {
  60. const e = Array.from(t2), s = Date.now();
  61. for (let r2 = 0; r2 < e.length && e[r2][1].ts <= s - this._duration; r2++)
  62. t2.delete(e[r2][0]);
  63. 0 === t2.size && this._clearTimer();
  64. }, this._interval);
  65. }
  66. _trim() {
  67. const t2 = this._cachedBlocks;
  68. if (-1 === this._size || this._size >= t2.size)
  69. return;
  70. const e = Array.from(t2);
  71. for (let s = 0; s < e.length - this._size; s++)
  72. t2.delete(e[s][0]);
  73. }
  74. _clearTimer() {
  75. null != this._timer && (clearInterval(this._timer), this._timer = null);
  76. }
  77. };
  78. // node_modules/@arcgis/core/layers/support/rasterDatasets/RawBlockCache.js
  79. var c = /* @__PURE__ */ new Map();
  80. var i = new t();
  81. function a(e, t2) {
  82. return null == t2 ? e : `${e}?sliceId=${t2}`;
  83. }
  84. function u(e, t2) {
  85. const n = { extent: null, rasterInfo: t2, cache: /* @__PURE__ */ new Map() }, o = c.get(e);
  86. return o ? (o.push(n), o.length - 1) : (c.set(e, [n]), 0);
  87. }
  88. function f(e, t2) {
  89. const n = c.get(e);
  90. n && (n[t2] = null, n.some((e2) => null != e2) || c.delete(e));
  91. }
  92. function m(e, t2, n) {
  93. var _a, _b;
  94. const o = c.get(e);
  95. if (!o)
  96. return null == t2 ? i.decreaseRefCount(e, n) : 0;
  97. if (null == t2 || null == o[t2])
  98. return i.decreaseRefCount(e, n);
  99. const l = (_a = o[t2]) == null ? void 0 : _a.cache, r2 = l == null ? void 0 : l.get(n);
  100. if (l && r2) {
  101. if (r2.refCount--, 0 === r2.refCount) {
  102. l.delete(n);
  103. for (let e2 = 0; e2 < o.length; e2++)
  104. (_b = o[e2]) == null ? void 0 : _b.cache.delete(n);
  105. r2.controller && r2.controller.abort();
  106. }
  107. return r2.refCount;
  108. }
  109. return 0;
  110. }
  111. function x(e, t2, n) {
  112. var _a, _b, _c;
  113. const o = c.get(e);
  114. if (!o)
  115. return null == t2 ? i.getBlock(e, n) : null;
  116. if (null == t2 || null == o[t2]) {
  117. for (let e2 = 0; e2 < o.length; e2++) {
  118. const t3 = (_a = o[e2]) == null ? void 0 : _a.cache.get(n);
  119. if (t3)
  120. return t3.refCount++, t3.block;
  121. }
  122. return i.getBlock(e, n);
  123. }
  124. const l = (_b = o[t2]) == null ? void 0 : _b.cache.get(n);
  125. if (l)
  126. return l.refCount++, l.block;
  127. for (let r2 = 0; r2 < o.length; r2++) {
  128. if (r2 === t2 || !o[r2])
  129. continue;
  130. const e2 = (_c = o[r2]) == null ? void 0 : _c.cache, l2 = e2 == null ? void 0 : e2.get(n);
  131. if (e2 && l2)
  132. return l2.refCount++, e2.set(n, l2), l2.block;
  133. }
  134. return null;
  135. }
  136. function h(e, t2, n, o, l = null) {
  137. var _a;
  138. const r2 = c.get(e);
  139. if (!r2)
  140. return void (null == t2 && i.putBlock(e, n, o, l));
  141. if (null == t2 || null == r2[t2])
  142. return void i.putBlock(e, n, o, l);
  143. const a2 = { refCount: 1, block: o, isResolved: false, isRejected: false, controller: l };
  144. o.then(() => a2.isResolved = true).catch(() => a2.isRejected = true), (_a = r2[t2]) == null ? void 0 : _a.cache.set(n, a2);
  145. }
  146. function d(e, t2, n) {
  147. var _a;
  148. const o = c.get(e);
  149. o ? null != t2 && null != o[t2] ? (_a = o[t2]) == null ? void 0 : _a.cache.delete(n) : i.deleteBlock(e, n) : null == t2 && i.deleteBlock(e, n);
  150. }
  151. function y(e, t2) {
  152. var _a;
  153. const n = c.get(e);
  154. return n ? (_a = n[t2]) != null ? _a : null : null;
  155. }
  156. function g(t2, c2, i2, a2, u2, f2, s = null) {
  157. const m2 = y(t2, c2);
  158. if (!m2)
  159. return;
  160. const x2 = m2.extent, { cache: h2, rasterInfo: d2 } = m2;
  161. if (x2 && x2.xmin === i2.xmin && x2.xmax === i2.xmax && x2.ymin === i2.ymin && x2.ymax === i2.ymax)
  162. return;
  163. a2 = a2 != null ? a2 : 0;
  164. const g2 = i2.clone().normalize(), { spatialReference: p, transform: k } = d2, M = /* @__PURE__ */ new Set();
  165. for (let y2 = 0; y2 < g2.length; y2++) {
  166. const t3 = g2[y2];
  167. if (t3.xmax - t3.xmin <= a2 || t3.ymax - t3.ymin <= a2)
  168. continue;
  169. let c3 = J(t3, p, s);
  170. r(k) && (c3 = k.inverseTransform(c3));
  171. const i3 = new w({ x: a2, y: a2, spatialReference: t3.spatialReference });
  172. if (null == u2 && !(u2 = C(i3, p, t3, s)))
  173. return;
  174. const { pyramidLevel: m3, pyramidResolution: x3, excessiveReading: h3 } = oe(u2, d2, f2 || "closest");
  175. if (h3)
  176. return;
  177. const { storageInfo: R } = d2, { origin: C2 } = R, j = { x: Math.max(0, Math.floor((c3.xmin - C2.x) / x3.x)), y: Math.max(0, Math.floor((C2.y - c3.ymax) / x3.y)) }, B = Math.ceil((c3.xmax - c3.xmin) / x3.x - 0.1), b = Math.ceil((c3.ymax - c3.ymin) / x3.y - 0.1), v = m3 > 0 ? R.pyramidBlockWidth : R.blockWidth, w2 = m3 > 0 ? R.pyramidBlockHeight : R.blockHeight, $ = 1, I = Math.max(0, Math.floor(j.x / v) - $), H = Math.max(0, Math.floor(j.y / w2) - $), E = Math.floor((j.x + B - 1) / v) + $, P = Math.floor((j.y + b - 1) / w2) + $;
  178. for (let e = H; e <= P; e++)
  179. for (let t4 = I; t4 <= E; t4++)
  180. M.add(`${m3}/${e}/${t4}`);
  181. }
  182. h2.forEach((e, t3) => {
  183. if (!M.has(t3)) {
  184. const e2 = h2.get(t3);
  185. (null == e2 || e2.isResolved || e2.isRejected) && h2.delete(t3);
  186. }
  187. }), m2.extent = { xmin: i2.xmin, ymin: i2.ymin, xmax: i2.xmax, ymax: i2.ymax };
  188. }
  189. export {
  190. a,
  191. u,
  192. f,
  193. m,
  194. x,
  195. h,
  196. d,
  197. g
  198. };
  199. //# sourceMappingURL=chunk-2U5S3G7I.js.map