chunk-NAWSWIYX.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import {
  2. R as R2
  3. } from "./chunk-O6KMIRUU.js";
  4. import {
  5. h
  6. } from "./chunk-VQXMCZYH.js";
  7. import {
  8. e as e2
  9. } from "./chunk-TFHLTN6F.js";
  10. import {
  11. j
  12. } from "./chunk-YLEVJ6UV.js";
  13. import {
  14. f as f2,
  15. u
  16. } from "./chunk-2H5MD622.js";
  17. import {
  18. R
  19. } from "./chunk-PQFTYGF5.js";
  20. import {
  21. e,
  22. m,
  23. n5 as n,
  24. y3 as y
  25. } from "./chunk-2Z2TG5CU.js";
  26. import {
  27. E,
  28. f,
  29. w,
  30. x
  31. } from "./chunk-V6P2MAQQ.js";
  32. // node_modules/@arcgis/core/views/2d/viewStateUtils.js
  33. var t = Math.PI / 180;
  34. function n2(n3) {
  35. return n3 * t;
  36. }
  37. function o(t2, o2) {
  38. const a2 = n2(o2.rotation), r = Math.abs(Math.cos(a2)), s = Math.abs(Math.sin(a2)), [u2, c] = o2.size;
  39. return t2[0] = Math.round(c * s + u2 * r), t2[1] = Math.round(c * r + u2 * s), t2;
  40. }
  41. function a(t2, n3, o2, a2) {
  42. const [r, s] = n3, [u2, c] = a2, h2 = 0.5 * o2;
  43. return t2[0] = r - h2 * u2, t2[1] = s - h2 * c, t2[2] = r + h2 * u2, t2[3] = s + h2 * c, t2;
  44. }
  45. // node_modules/@arcgis/core/views/2d/layers/support/ExportStrategy.js
  46. var y2 = u();
  47. var x2 = [0, 0];
  48. var S = new e2(0, 0, 0, 0);
  49. var _ = { container: null, fetchSource: null, requestUpdate: null, imageMaxWidth: 2048, imageMaxHeight: 2048, imageRotationSupported: false, imageNormalizationSupported: false, hidpi: false };
  50. var w2 = class extends m {
  51. constructor(t2) {
  52. super(t2), this._imagePromise = null, this.bitmaps = [], this.hidpi = _.hidpi, this.imageMaxWidth = _.imageMaxWidth, this.imageMaxHeight = _.imageMaxHeight, this.imageRotationSupported = _.imageRotationSupported, this.imageNormalizationSupported = _.imageNormalizationSupported, this.update = x(async (t3, e3) => {
  53. if (f(e3), !t3.stationary || this.destroyed)
  54. return;
  55. const i = t3.state, s = R(i.spatialReference), a2 = this.hidpi ? t3.pixelRatio : 1, n3 = this.imageNormalizationSupported && i.worldScreenWidth && i.worldScreenWidth < i.size[0];
  56. n3 ? (x2[0] = i.worldScreenWidth, x2[1] = i.size[1]) : this.imageRotationSupported ? (x2[0] = i.size[0], x2[1] = i.size[1]) : o(x2, i);
  57. const p = Math.floor(x2[0] * a2) > this.imageMaxWidth || Math.floor(x2[1] * a2) > this.imageMaxHeight, m2 = s && (i.extent.xmin < s.valid[0] || i.extent.xmax > s.valid[1]), h2 = !this.imageNormalizationSupported && m2, c = !p && !h2, u2 = this.imageRotationSupported ? i.rotation : 0, g = this.container.children.slice();
  58. if (c) {
  59. const t4 = n3 ? i.paddedViewState.center : i.center;
  60. this._imagePromise && console.error("Image promise was not defined!"), this._imagePromise = this._singleExport(i, x2, t4, i.resolution, u2, a2, e3);
  61. } else {
  62. let t4 = Math.min(this.imageMaxWidth, this.imageMaxHeight);
  63. h2 && (t4 = Math.min(i.worldScreenWidth, t4)), this._imagePromise = this._tiledExport(i, t4, a2, e3);
  64. }
  65. try {
  66. const t4 = await this._imagePromise;
  67. f(e3);
  68. const i2 = [];
  69. if (this._imagePromise = null, this.destroyed)
  70. return;
  71. this.bitmaps = t4 != null ? t4 : [];
  72. for (const e4 of g)
  73. t4.includes(e4) || i2.push(e4.fadeOut().then(() => {
  74. e4.remove(), e4.destroy();
  75. }));
  76. for (const e4 of t4)
  77. i2.push(e4.fadeIn());
  78. await Promise.all(i2);
  79. } catch (f3) {
  80. this._imagePromise = null, w(f3);
  81. }
  82. }, 5e3), this.updateExports = x(async (t3) => {
  83. const e3 = [];
  84. for (const i of this.container.children) {
  85. if (!i.visible || !i.stage)
  86. return;
  87. e3.push(t3(i).then(() => {
  88. i.invalidateTexture(), i.requestRender();
  89. }));
  90. }
  91. this._imagePromise = E(e3).then(() => this._imagePromise = null), await this._imagePromise;
  92. });
  93. }
  94. destroy() {
  95. this.bitmaps.forEach((t2) => t2.destroy()), this.bitmaps = [];
  96. }
  97. get updating() {
  98. return !this.destroyed && null !== this._imagePromise;
  99. }
  100. async _export(t2, e3, i, r, s, a2) {
  101. const n3 = await this.fetchSource(t2, Math.floor(e3 * s), Math.floor(i * s), { rotation: r, pixelRatio: s, signal: a2 });
  102. f(a2);
  103. const p = new R2(null, { immutable: true, requestRenderOnSourceChangedEnabled: true });
  104. return p.x = t2.xmin, p.y = t2.ymax, p.resolution = t2.width / e3, p.rotation = r, p.pixelRatio = s, p.opacity = 0, this.container.addChild(p), await p.setSourceAsync(n3, a2), f(a2), p;
  105. }
  106. async _singleExport(t2, e3, i, o2, r, s, a2) {
  107. a(y2, i, o2, e3);
  108. const n3 = f2(y2, t2.spatialReference);
  109. return [await this._export(n3, e3[0], e3[1], r, s, a2)];
  110. }
  111. _tiledExport(t2, e3, i, o2) {
  112. const r = j.create({ size: e3, spatialReference: t2.spatialReference, scales: [t2.scale] }), s = new h(r), a2 = s.getTileCoverage(t2);
  113. if (!a2)
  114. return null;
  115. const n3 = [];
  116. return a2.forEach((r2, a3, p, l) => {
  117. S.set(r2, a3, p, 0), s.getTileBounds(y2, S);
  118. const h2 = f2(y2, t2.spatialReference);
  119. n3.push(this._export(h2, e3, e3, 0, i, o2).then((t3) => (0 !== l && (S.set(r2, a3, p, l), s.getTileBounds(y2, S), t3.x = y2[0], t3.y = y2[3]), t3)));
  120. }), Promise.all(n3);
  121. }
  122. };
  123. e([y()], w2.prototype, "_imagePromise", void 0), e([y()], w2.prototype, "bitmaps", void 0), e([y()], w2.prototype, "container", void 0), e([y()], w2.prototype, "fetchSource", void 0), e([y()], w2.prototype, "hidpi", void 0), e([y()], w2.prototype, "imageMaxWidth", void 0), e([y()], w2.prototype, "imageMaxHeight", void 0), e([y()], w2.prototype, "imageRotationSupported", void 0), e([y()], w2.prototype, "imageNormalizationSupported", void 0), e([y()], w2.prototype, "requestUpdate", void 0), e([y()], w2.prototype, "updating", null), w2 = e([n("esri.views.2d.layers.support.ExportStrategy")], w2);
  124. var v = w2;
  125. export {
  126. v
  127. };
  128. //# sourceMappingURL=chunk-NAWSWIYX.js.map