chunk-PCGDLSZ4.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. import {
  2. l
  3. } from "./chunk-6RAL4JPQ.js";
  4. import {
  5. e
  6. } from "./chunk-FIYKFRB2.js";
  7. import {
  8. b
  9. } from "./chunk-6P6NA7JB.js";
  10. import {
  11. R,
  12. u
  13. } from "./chunk-N2663GRX.js";
  14. // node_modules/@arcgis/core/views/2d/tiling/TileCache.js
  15. var t = class {
  16. constructor(e2, t2, i2) {
  17. this.maxSize = e2, this.tileInfoView = t2, this.removedFunc = i2, this._tilePerId = new Map(), this._tileKeysPerLevel = [];
  18. }
  19. has(e2) {
  20. return this._tilePerId.has(e2);
  21. }
  22. get(e2) {
  23. return this._tilePerId.get(e2);
  24. }
  25. pop(e2) {
  26. const t2 = this._tilePerId.get(e2);
  27. if (!t2)
  28. return null;
  29. const s = t2.key.level, r2 = this._tileKeysPerLevel[s];
  30. i(this._tilePerId, e2);
  31. for (let i2 = 0; i2 < r2.length; i2++)
  32. if (r2[i2].id === e2) {
  33. r2.splice(i2, 1);
  34. break;
  35. }
  36. return t2.visible = true, t2;
  37. }
  38. add(e2) {
  39. e2.visible = false;
  40. const t2 = e2.key, i2 = t2.id;
  41. if (this._tilePerId.has(i2))
  42. return;
  43. this._tilePerId.set(i2, e2);
  44. const s = t2.level;
  45. this._tileKeysPerLevel[s] || (this._tileKeysPerLevel[s] = []), this._tileKeysPerLevel[s].push(t2);
  46. }
  47. prune(e2, t2, i2) {
  48. let s = this._tilePerId.size;
  49. if (s <= this.maxSize)
  50. return;
  51. let r2 = this._tileKeysPerLevel.length - 1;
  52. for (; s > this.maxSize && r2 >= 0; )
  53. r2 !== e2 && (s = this._pruneAroundCenterTile(s, t2, i2, r2)), r2--;
  54. s > this.maxSize && (s = this._pruneAroundCenterTile(s, t2, i2, e2));
  55. }
  56. _pruneAroundCenterTile(t2, i2, s, r2) {
  57. const l2 = this._tileKeysPerLevel[r2];
  58. if (!l2 || l2.length === 0)
  59. return t2;
  60. const { size: n, origin: h2 } = this.tileInfoView.tileInfo, o2 = s * n[0], u2 = s * n[1], d = [0, 0], _ = [0, 0];
  61. for (l2.sort((t3, s2) => (d[0] = h2.x + o2 * (t3.col + 0.5), d[1] = h2.y - u2 * (t3.row + 0.5), _[0] = h2.x + o2 * (s2.col + 0.5), _[1] = h2.y - u2 * (s2.row + 0.5), b(d, i2) - b(_, i2))); l2.length > 0; ) {
  62. const e2 = l2.pop();
  63. if (this._removeTile(e2.id), --t2 === this.maxSize)
  64. break;
  65. }
  66. return t2;
  67. }
  68. _removeTile(e2) {
  69. const t2 = this._tilePerId.get(e2);
  70. this.removedFunc && this.removedFunc(t2), i(this._tilePerId, e2);
  71. }
  72. };
  73. function i(e2, t2) {
  74. e2.delete(t2);
  75. }
  76. // node_modules/@arcgis/core/views/2d/tiling/TileStrategy.js
  77. var a = new e(0, 0, 0, 0);
  78. var h = new Map();
  79. var o = [];
  80. var c = [];
  81. var r = class {
  82. constructor(e2) {
  83. this._previousScale = Number.POSITIVE_INFINITY, this.cachePolicy = "keep", this.coveragePolicy = "closest", this.resampling = true, this.tileIndex = new Map(), this.tiles = [], this.buffer = 192, this.acquireTile = e2.acquireTile, this.releaseTile = e2.releaseTile, this.tileInfoView = e2.tileInfoView, this.resampling = e2.resampling == null || !!e2.resampling, e2.cachePolicy && (this.cachePolicy = e2.cachePolicy), e2.coveragePolicy && (this.coveragePolicy = e2.coveragePolicy), e2.buffer != null && (this.buffer = e2.buffer), e2.cacheSize && (this._tileCache = new t(e2.cacheSize, this.tileInfoView, (e3) => {
  84. this.releaseTile(e3);
  85. }));
  86. }
  87. destroy() {
  88. this.tileIndex.clear();
  89. }
  90. update(e2) {
  91. const { resampling: i2, tileIndex: t2 } = this, l2 = this.tileInfoView.getTileCoverage(e2.state, this.buffer, this.coveragePolicy);
  92. if (c.length = 0, o.length = 0, h.clear(), !l2)
  93. return;
  94. const { minScale: r2, maxScale: n } = this.tileInfoView.tileInfo, { spans: f, lodInfo: d } = l2, { level: u2 } = d, { scale: p, center: g, resolution: y } = e2.state, I = !e2.stationary && p > this._previousScale;
  95. if (this._previousScale = p, this.tiles.length = 0, !i2 && (p > r2 || p < n))
  96. return this.tiles.length = 0, h.clear(), t2.forEach((e3) => {
  97. this.releaseTile(e3);
  98. }), t2.clear(), c.length = 0, o.length = 0, h.clear(), l.pool.release(l2), true;
  99. t2.forEach((e3) => e3.visible = true);
  100. let T = 0, _ = 0;
  101. if (f.length > 0)
  102. for (const { row: s, colFrom: o2, colTo: c2 } of f)
  103. for (let e3 = o2; e3 <= c2; e3++) {
  104. T++;
  105. const i3 = a.set(u2, s, d.normalizeCol(e3), d.getWorldForColumn(e3)).id;
  106. if (t2.has(i3)) {
  107. const e4 = t2.get(i3);
  108. e4.isReady ? (h.set(i3, e4), _++) : I || this._addParentTile(i3, h);
  109. } else {
  110. let e4;
  111. if (this._tileCache && this._tileCache.has(i3)) {
  112. if (e4 = this._tileCache.pop(i3), this.tileIndex.set(i3, e4), e4.isReady) {
  113. h.set(i3, e4), _++;
  114. continue;
  115. }
  116. } else
  117. e4 = this.acquireTile(a), this.tileIndex.set(i3, e4);
  118. I || this._addParentTile(i3, h);
  119. }
  120. }
  121. const m = _ === T;
  122. t2.forEach((e3, i3) => {
  123. if (a.set(i3), h.has(i3))
  124. return;
  125. const t3 = this.tileInfoView.intersects(l2, a), s = this.cachePolicy === "purge" ? a.level !== u2 : a.level > u2;
  126. !t3 || !I && m ? !s && t3 || o.push(i3) : e3.isReady ? s && this.cachePolicy === "purge" && this._hasReadyAncestor(a, u2) ? o.push(i3) : c.push(i3) : s && o.push(i3);
  127. });
  128. for (const s of c) {
  129. const e3 = t2.get(s);
  130. e3 && e3.isReady && h.set(s, e3);
  131. }
  132. for (const s of o) {
  133. const e3 = t2.get(s);
  134. this._tileCache ? this._tileCache.add(e3) : this.releaseTile(e3), t2.delete(s);
  135. }
  136. return h.forEach((e3) => this.tiles.push(e3)), t2.forEach((e3) => {
  137. h.has(e3.key.id) || (e3.visible = false);
  138. }), this._tileCache && this._tileCache.prune(u2, g, y), l.pool.release(l2), h.clear(), m;
  139. }
  140. clear(e2 = true) {
  141. const { tileIndex: i2 } = this;
  142. e2 && i2.forEach((e3) => {
  143. this.releaseTile(e3);
  144. }), i2.clear();
  145. }
  146. updateCacheSize(e2) {
  147. this._tileCache && (this._tileCache.maxSize = e2);
  148. }
  149. _addParentTile(e2, i2) {
  150. let t2 = e2, s = null;
  151. for (; t2 = this.tileInfoView.getTileParentId(t2), t2; )
  152. if (this.tileIndex.has(t2)) {
  153. if (s = this.tileIndex.get(t2), s && s.isReady) {
  154. i2.has(s.key.id) || i2.set(s.key.id, s);
  155. break;
  156. }
  157. } else if (this._tileCache && this._tileCache.has(t2) && (s = this._tileCache.pop(t2), this.tileIndex.set(t2, s), s && s.isReady)) {
  158. i2.has(s.key.id) || i2.set(s.key.id, s);
  159. break;
  160. }
  161. }
  162. _hasReadyAncestor(t2, s) {
  163. const l2 = u();
  164. this.tileInfoView.getTileBounds(l2, t2, true);
  165. for (const a2 of this.tileIndex.values())
  166. if (a2.isReady && a2.key.level >= s && a2.key.level < t2.level) {
  167. const t3 = u();
  168. if (this.tileInfoView.getTileBounds(t3, a2.key, true), R(t3, l2))
  169. return true;
  170. }
  171. return false;
  172. }
  173. };
  174. export {
  175. r
  176. };
  177. //# sourceMappingURL=chunk-PCGDLSZ4.js.map