chunk-ZVHTCCQC.js 3.8 KB

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