chunk-E7ZLMIQ7.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import {
  2. l
  3. } from "./chunk-QC7NCR5N.js";
  4. import {
  5. m as m2
  6. } from "./chunk-E3G7BRZB.js";
  7. import {
  8. e,
  9. m,
  10. n5 as n,
  11. y3 as y
  12. } from "./chunk-2Z2TG5CU.js";
  13. import {
  14. s
  15. } from "./chunk-YXWMMD76.js";
  16. // node_modules/@arcgis/core/views/2d/tiling/TileQueue.js
  17. function u(e2, t) {
  18. return e2.length = 0, t.forEach((t2) => e2.push(t2)), e2;
  19. }
  20. var c = /* @__PURE__ */ new Set();
  21. var a = [];
  22. var h = /* @__PURE__ */ new Map();
  23. var l2 = [0, 0];
  24. var p = class extends m {
  25. constructor(e2) {
  26. super(e2), this._keyToItem = /* @__PURE__ */ new Map(), this.concurrency = 6, this.strategy = "scale-first", this.tileInfoView = null;
  27. }
  28. initialize() {
  29. const { concurrency: e2, process: t, strategy: s2 } = this;
  30. this._queue = new l({ concurrency: e2, process: (e3, s3) => {
  31. const r = this._keyToItem.get(e3);
  32. return t(r, { signal: s3 });
  33. }, peeker: "scale-first" === s2 ? (e3) => this._peekByScaleFirst(e3) : (e3) => this._peekByCenterFirst(e3) });
  34. }
  35. destroy() {
  36. this.clear(), this._queue = s(this._queue);
  37. }
  38. get length() {
  39. return this._queue ? this._queue.length : 0;
  40. }
  41. get onGoingCount() {
  42. return this._keyToItem.size;
  43. }
  44. get updating() {
  45. return this.length > 0 || this.onGoingCount > 0;
  46. }
  47. abort(e2) {
  48. const t = "string" == typeof e2 ? e2 : e2.id;
  49. this._queue.abort(t);
  50. }
  51. clear() {
  52. this._queue.clear(), this._keyToItem.clear(), this.notifyChange("updating");
  53. }
  54. has(e2) {
  55. return "string" == typeof e2 ? this._keyToItem.has(e2) : this._keyToItem.has(e2.id);
  56. }
  57. isOngoing(e2) {
  58. const t = "string" == typeof e2 ? e2 : e2.id;
  59. return this.has(t) && this._queue.isOngoing(t);
  60. }
  61. pause() {
  62. this._queue.pause();
  63. }
  64. push(e2) {
  65. const t = e2.key.id;
  66. if (this._queue.has(t))
  67. return this._queue.get(t);
  68. const s2 = this._queue.push(t), r = () => {
  69. this._keyToItem.delete(t), this.notifyChange("updating");
  70. };
  71. return this._keyToItem.set(t, e2), s2.then(r, r), this.notifyChange("updating"), s2;
  72. }
  73. reset() {
  74. this._queue.reset();
  75. }
  76. resume() {
  77. this._queue.resume();
  78. }
  79. _peekByScaleFirst(e2) {
  80. if (!this.state)
  81. return e2.values().next().value;
  82. const t = this.tileInfoView;
  83. let s2 = Number.NEGATIVE_INFINITY, r = Number.POSITIVE_INFINITY;
  84. e2.forEach((e3) => {
  85. const t2 = this._keyToItem.get(e3), o2 = this.tileInfoView.getTileScale(t2.key);
  86. h.has(o2) || (h.set(o2, []), s2 = Math.max(o2, s2), r = Math.min(o2, r)), h.get(o2).push(t2.key), c.add(o2);
  87. });
  88. let o = this.state.scale;
  89. h.has(o) || (u(a, c), a.sort((e3, t2) => e3 - t2), o = a.reduce((e3, t2) => Math.abs(t2 - o) < Math.abs(e3 - o) ? t2 : e3, a[0])), o = Math.min(o, s2), o = Math.max(o, r);
  90. const i = h.get(o), n2 = t.getClosestInfoForScale(o), l3 = n2.getColumnForX(this.state.center[0]), p2 = n2.getRowForY(this.state.center[1]);
  91. return i.sort((e3, t2) => {
  92. const s3 = n2.denormalizeCol(e3.col, e3.world), r2 = n2.denormalizeCol(t2.col, t2.world);
  93. return Math.sqrt((l3 - s3) * (l3 - s3) + (p2 - e3.row) * (p2 - e3.row)) - Math.sqrt((l3 - r2) * (l3 - r2) + (p2 - t2.row) * (p2 - t2.row));
  94. }), c.clear(), h.clear(), i[0].id;
  95. }
  96. _peekByCenterFirst(e2) {
  97. if (!this.state)
  98. return e2.values().next().value;
  99. const t = this.tileInfoView, s2 = this.state.center;
  100. let r, o = Number.POSITIVE_INFINITY;
  101. return e2.forEach((e3) => {
  102. const n2 = this._keyToItem.get(e3);
  103. t.getTileCoords(l2, n2.key);
  104. const u2 = m2(l2, s2);
  105. u2 < o && (o = u2, r = n2.key);
  106. }), r.id;
  107. }
  108. };
  109. e([y({ constructOnly: true })], p.prototype, "concurrency", void 0), e([y({ constructOnly: true })], p.prototype, "process", void 0), e([y()], p.prototype, "state", void 0), e([y({ constructOnly: true })], p.prototype, "strategy", void 0), e([y({ constructOnly: true })], p.prototype, "tileInfoView", void 0), e([y({ readOnly: true })], p.prototype, "updating", null), p = e([n("esri.views.2d.tiling.TileQueue")], p);
  110. var y2 = p;
  111. export {
  112. y2 as y
  113. };
  114. //# sourceMappingURL=chunk-E7ZLMIQ7.js.map