chunk-3G6RGU7K.js 6.2 KB

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