chunk-Y4GPJDDM.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. import {
  2. An,
  3. E,
  4. S,
  5. c,
  6. en,
  7. i,
  8. on,
  9. rn,
  10. s as s2,
  11. tn
  12. } from "./chunk-DH2OBAUC.js";
  13. import {
  14. z
  15. } from "./chunk-O4FY3ITT.js";
  16. import {
  17. v2 as v
  18. } from "./chunk-OWVBLVP3.js";
  19. import {
  20. M2 as M,
  21. j2 as j
  22. } from "./chunk-ECW2QABR.js";
  23. import {
  24. k2 as k
  25. } from "./chunk-MRJEICT6.js";
  26. import {
  27. s3 as s
  28. } from "./chunk-EMJ4ZSM2.js";
  29. import {
  30. r,
  31. t
  32. } from "./chunk-GZT4BVFP.js";
  33. // node_modules/@arcgis/core/layers/support/rasterFunctions/rasterProjectionHelper.js
  34. var d;
  35. function M2(e, t2, n) {
  36. return !An(e, t2, n);
  37. }
  38. function w(t2, n, o) {
  39. const i2 = M2(t2, n, o);
  40. if (i2 && !en())
  41. throw new s("rasterprojectionhelper-project", "projection engine is not loaded");
  42. return i2;
  43. }
  44. !function(e) {
  45. e[e.None = 0] = "None", e[e.North = 1] = "North", e[e.South = 2] = "South", e[e.Both = 3] = "Both";
  46. }(d || (d = {}));
  47. var R = (e, t2, n, o = 0) => {
  48. if (n[0] === 1)
  49. return [0, 0];
  50. let i2 = 1, r2 = -1, s3 = 1, a = -1;
  51. for (let g = 0; g < e.length; g += 2)
  52. isNaN(e[g]) || (i2 = i2 > e[g] ? e[g] : i2, r2 = r2 > e[g] ? r2 : e[g], s3 = s3 > e[g + 1] ? e[g + 1] : s3, a = a > e[g + 1] ? a : e[g + 1]);
  53. const { cols: l, rows: c2 } = t2, f = (r2 - i2) / l / n[0], u = (a - s3) / c2 / n[1], m = 2 * o;
  54. let x = 0, h = false, p = [0, 0];
  55. for (let g = 0; g < l - 3; g++) {
  56. for (let t3 = 0; t3 < c2 - 3; t3++) {
  57. const n2 = g * c2 * 2 + 2 * t3, o2 = (e[n2] + e[n2 + 4] + e[n2 + 4 * c2] + e[n2 + 4 * c2 + 4]) / 4, i3 = (e[n2 + 1] + e[n2 + 5] + e[n2 + 4 * c2 + 1] + e[n2 + 4 * c2 + 5]) / 4, r3 = Math.abs((o2 - e[n2 + 2 * c2 + 2]) / f), s4 = Math.abs((i3 - e[n2 + 2 * c2 + 3]) / u);
  58. if (r3 + s4 > x && (x = r3 + s4, p = [r3, s4]), m && x > m) {
  59. h = true;
  60. break;
  61. }
  62. }
  63. if (h)
  64. break;
  65. }
  66. return p;
  67. };
  68. var P = { 3395: 20037508342789244e-9, 3410: 17334193943686873e-9, 3857: 20037508342788905e-9, 3975: 17367530445161372e-9, 4087: 20037508342789244e-9, 4088: 20015108787169147e-9, 6933: 17367530445161372e-9, 32662: 20037508342789244e-9, 53001: 2001508679602057e-8, 53002: 1000754339801029e-8, 53003: 2001508679602057e-8, 53004: 2001508679602057e-8, 53016: 14152803599503474e-9, 53017: 17333573624304302e-9, 53034: 2001508679602057e-8, 53079: 20015114352186374e-9, 53080: 20015114352186374e-9, 54001: 20037508342789244e-9, 54002: 10018754171394624e-9, 54003: 20037508342789244e-9, 54004: 20037508342789244e-9, 54016: 14168658027268292e-9, 54017: 1736753044516137e-8, 54034: 20037508342789244e-9, 54079: 20037508342789244e-9, 54080: 20037508342789244e-9, 54100: 20037508342789244e-9, 54101: 20037508342789244e-9 };
  69. var S2 = 32;
  70. var b = 4;
  71. var E2 = b;
  72. var G = new Map();
  73. var N = new Map();
  74. async function k2() {
  75. if (en())
  76. return null;
  77. await tn();
  78. }
  79. function T(e, t2, n) {
  80. if (!w(e.spatialReference, t2))
  81. return null;
  82. return n ? on(t2, e.spatialReference, e) : on(e.spatialReference, t2, e);
  83. }
  84. function v2(e, i2, r2, s3 = null) {
  85. const a = e.spatialReference;
  86. if (a.equals(i2))
  87. return e;
  88. w(a, i2, s3);
  89. const l = r2.center, c2 = new M({ xmin: l.x - e.x / 2, xmax: l.x + e.x / 2, ymin: l.y - e.y / 2, ymax: l.y + e.y / 2, spatialReference: a }), f = rn(c2, i2, s3), u = X(i2);
  90. let m;
  91. if (t(f) || r(u) && f.width >= u) {
  92. const t2 = z(a) / z(i2);
  93. m = { x: e.x * t2, y: e.y * t2 };
  94. } else
  95. m = { x: f.width, y: f.height };
  96. return m;
  97. }
  98. function C(e, t2 = 0.01) {
  99. return z(e) ? t2 / z(e) : 0;
  100. }
  101. function _(e, t2, o = null, i2 = true) {
  102. const r2 = e.spatialReference;
  103. if (r2.equals(t2))
  104. return e;
  105. w(r2, t2, o);
  106. const s3 = rn(e, t2, o);
  107. if (!i2 || !s3)
  108. return s3;
  109. const a = K(r2, true), l = K(t2, true), c2 = C(r2);
  110. return c2 && r(a) && r(l) && (s3.x > 0 && Math.abs(e.x - a[0]) < c2 ? s3.x -= l[1] - l[0] : s3.x < 0 && Math.abs(e.x - a[1]) < c2 && (s3.x += l[1] - l[0])), s3;
  111. }
  112. function j2(e) {
  113. const { inSR: t2, outSR: o, datumTransformation: i2, preferPE: r2 } = e;
  114. if (t2.equals(o)) {
  115. const { points: t3 } = B(e, null);
  116. return t3;
  117. }
  118. if (t2.isWebMercator && o.isWGS84 || t2.isWGS84 && o.isWebMercator)
  119. return O(e);
  120. if (w(t2, o, i2) && r2) {
  121. if (t2.isGeographic)
  122. return W(e);
  123. const o2 = L(t2);
  124. if (r(o2))
  125. return W(e);
  126. }
  127. return z2(e);
  128. }
  129. function z2(e) {
  130. const { points: t2 } = B(e, null), n = t2.map((t3) => new j(t3[0], t3[1], e.inSR));
  131. return rn(n, e.outSR, e.datumTransformation).map((e2) => e2 ? [e2.x, e2.y] : [NaN, NaN]);
  132. }
  133. function W(e) {
  134. const { inSR: t2, outSR: o, datumTransformation: l } = e, c2 = L(t2), { points: f, mask: u } = B(e, c2);
  135. if (!t2.isGeographic) {
  136. const e2 = t2.wkid ? i.coordsys(t2.wkid) : i.fromString(t2.isGeographic ? E.PE_TYPE_GEOGCS : E.PE_TYPE_PROJCS, t2.wkt);
  137. s2.projToGeog(e2, f.length, f);
  138. }
  139. if (r(l) && l.steps.length && l.steps.forEach((e2) => {
  140. const t3 = e2.wkid ? i.geogtran(e2.wkid) : i.fromString(E.PE_TYPE_GEOGTRAN, e2.wkt);
  141. c.geogToGeog(t3, f.length, f, null, e2.isInverse ? E.PE_TRANSFORM_2_TO_1 : E.PE_TRANSFORM_1_TO_2);
  142. }), !o.isGeographic) {
  143. const e2 = L(o, true), t3 = r(e2) && e2.isEnvelope ? [e2.bbox[1], e2.bbox[3]] : [-90, 90];
  144. I(f, t3);
  145. const a = o.wkid ? i.coordsys(o.wkid) : i.fromString(o.isGeographic ? E.PE_TYPE_GEOGCS : E.PE_TYPE_PROJCS, o.wkt);
  146. s2.geogToProj(a, f.length, f);
  147. }
  148. let m = f;
  149. if (u && f.length !== u.length) {
  150. m = [];
  151. for (let e2 = 0, t3 = 0; e2 < u.length; e2++)
  152. u[e2] ? m.push(f[t3++]) : m.push([NaN, NaN]);
  153. }
  154. return m;
  155. }
  156. function O(e) {
  157. const { cols: t2, rows: n, xres: o, yres: i2, usePixelCenter: r2, inSR: s3, outSR: a } = e;
  158. let { xmin: l, ymax: c2 } = e;
  159. r2 && (l += o / 2, c2 -= i2 / 2);
  160. const f = [], u = [], m = Math.max(t2, n);
  161. for (let g = 0; g < m; g++) {
  162. const e2 = l + o * Math.min(t2, g), r3 = c2 - i2 * Math.min(n, g), m2 = rn(new j({ x: e2, y: r3, spatialReference: s3 }), a);
  163. g <= t2 && f.push(m2.x), g <= n && u.push(m2.y);
  164. }
  165. const h = [];
  166. for (let x = 0; x < t2; x++)
  167. for (let e2 = 0; e2 < n; e2++)
  168. h.push([f[x], u[e2]]);
  169. return h;
  170. }
  171. function L(e, t2 = false) {
  172. let n = e.wkid || e.wkt;
  173. if (!n || e.isGeographic)
  174. return null;
  175. if (n = String(n), G.has(n)) {
  176. const e2 = G.get(n);
  177. return t2 ? e2?.gcs : e2?.pcs;
  178. }
  179. const o = e.wkid ? i.coordsys(e.wkid) : i.fromString(e.isGeographic ? E.PE_TYPE_GEOGCS : E.PE_TYPE_PROJCS, e.wkt), s3 = A(o, C(e, 1e-4)), a = A(o, 0, true);
  180. return G.set(n, { pcs: s3, gcs: a }), t2 ? a : s3;
  181. }
  182. function A(e, t2 = 0, n = false) {
  183. const o = S.generate(e), i2 = n ? e.horizonGcsGenerate() : e.horizonPcsGenerate();
  184. if (!i2?.length)
  185. return null;
  186. let r2 = false, s3 = i2.find((e2) => e2.getInclusive() === 1 && e2.getKind() === 1);
  187. if (!s3) {
  188. if (s3 = i2.find((e2) => e2.getInclusive() === 1 && e2.getKind() === 0), !s3)
  189. return null;
  190. r2 = true;
  191. }
  192. const a = n ? 0 : (o.getNorthPoleLocation() === 2 ? 1 : 0) | (o.getSouthPoleLocation() === 2 ? 2 : 0), c2 = o.isPannableRectangle(), f = s3.getCoord();
  193. if (r2)
  194. return { isEnvelope: r2, isPannable: c2, vertices: f, coef: null, bbox: [f[0][0] - t2, f[0][1] - t2, f[1][0] + t2, f[1][1] + t2], poleLocation: a };
  195. let u = 0;
  196. const m = [];
  197. let [x, h] = f[0], [p, g] = f[0];
  198. for (let l = 0, y = f.length; l < y; l++) {
  199. u++, u === y && (u = 0);
  200. const [e2, t3] = f[l], [n2, o2] = f[u];
  201. if (o2 === t3)
  202. m.push([e2, n2, t3, o2, 2]);
  203. else {
  204. const i3 = (n2 - e2) / (o2 - t3 || 1e-4), r3 = e2 - i3 * t3;
  205. t3 < o2 ? m.push([i3, r3, t3, o2, 0]) : m.push([i3, r3, o2, t3, 1]);
  206. }
  207. x = x < e2 ? x : e2, h = h < t3 ? h : t3, p = p > e2 ? p : e2, g = g > t3 ? g : t3;
  208. }
  209. return { isEnvelope: false, isPannable: c2, vertices: f, coef: m, bbox: [x, h, p, g], poleLocation: a };
  210. }
  211. function B(e, n) {
  212. const o = [], { cols: i2, rows: r2, xres: s3, yres: a, usePixelCenter: l } = e;
  213. let { xmin: c2, ymax: f } = e;
  214. if (l && (c2 += s3 / 2, f -= a / 2), t(n)) {
  215. for (let e2 = 0; e2 < i2; e2++)
  216. for (let t2 = 0; t2 < r2; t2++)
  217. o.push([c2 + s3 * e2, f - a * t2]);
  218. return { points: o };
  219. }
  220. const u = new Uint8Array(i2 * r2);
  221. if (n.isEnvelope) {
  222. const { bbox: [e2, t2, l2, m2] } = n;
  223. for (let x2 = 0, h = 0; x2 < i2; x2++) {
  224. const i3 = c2 + s3 * x2, p = n.isPannable || i3 >= e2 && i3 <= l2;
  225. for (let e3 = 0; e3 < r2; e3++, h++) {
  226. const n2 = f - a * e3;
  227. p && n2 >= t2 && n2 <= m2 && (o.push([i3, n2]), u[h] = 1);
  228. }
  229. }
  230. return { points: o, mask: u };
  231. }
  232. const { coef: m } = n, x = [];
  233. for (let t2 = 0; t2 < r2; t2++) {
  234. const e2 = f - a * t2, n2 = [], o2 = [];
  235. for (let t3 = 0; t3 < m.length; t3++) {
  236. const [i4, r3, s4, a2, l2] = m[t3];
  237. if (e2 === s4 && s4 === a2)
  238. n2.push(i4), n2.push(r3), o2.push(2), o2.push(2);
  239. else if (e2 >= s4 && e2 <= a2) {
  240. const t4 = i4 * e2 + r3;
  241. n2.push(t4), o2.push(l2);
  242. }
  243. }
  244. let i3 = n2;
  245. if (n2.length > 2) {
  246. let e3 = o2[0] === 2 ? 0 : o2[0], t3 = n2[0];
  247. i3 = [];
  248. for (let r3 = 1; r3 < o2.length; r3++)
  249. o2[r3] === 2 && r3 !== o2.length - 1 || (o2[r3] !== e3 && (i3.push(e3 === 0 ? Math.min(t3, n2[r3 - 1]) : Math.max(t3, n2[r3 - 1])), e3 = o2[r3], t3 = n2[r3]), r3 === o2.length - 1 && i3.push(o2[r3] === 0 ? Math.min(t3, n2[r3]) : Math.max(t3, n2[r3])));
  250. i3.sort((e4, t4) => e4 - t4);
  251. } else
  252. n2[0] > n2[1] && (i3 = [n2[1], n2[0]]);
  253. x.push(i3);
  254. }
  255. for (let t2 = 0, h = 0; t2 < i2; t2++) {
  256. const e2 = c2 + s3 * t2;
  257. for (let t3 = 0; t3 < r2; t3++, h++) {
  258. const n2 = f - a * t3, i3 = x[t3];
  259. if (i3.length === 2)
  260. e2 >= i3[0] && e2 <= i3[1] && (o.push([e2, n2]), u[h] = 1);
  261. else if (i3.length > 2) {
  262. let t4 = false;
  263. for (let n3 = 0; n3 < i3.length; n3 += 2)
  264. if (e2 >= i3[n3] && e2 <= i3[n3 + 1]) {
  265. t4 = true;
  266. break;
  267. }
  268. t4 && (o.push([e2, n2]), u[h] = 1);
  269. }
  270. }
  271. }
  272. return { points: o, mask: u };
  273. }
  274. function I(e, t2) {
  275. const [n, o] = t2;
  276. for (let i2 = 0; i2 < e.length; i2++) {
  277. const t3 = e[i2][1];
  278. (t3 < n || t3 > o) && (e[i2] = [NaN, NaN]);
  279. }
  280. }
  281. function Y(e) {
  282. const n = X(e[0].spatialReference);
  283. if (e.length < 2 || t(n))
  284. return e[0];
  285. let { xmin: o, xmax: i2, ymin: r2, ymax: s3 } = e[0];
  286. for (let t2 = 1; t2 < e.length; t2++) {
  287. const o2 = e[t2];
  288. i2 = o2.xmax + n * t2, r2 = Math.min(r2, o2.ymin), s3 = Math.max(s3, o2.ymax);
  289. }
  290. return new M({ xmin: o, xmax: i2, ymin: r2, ymax: s3, spatialReference: e[0].spatialReference });
  291. }
  292. function F(e, o, i2 = null, r2 = true) {
  293. const s3 = e.spatialReference;
  294. if (s3.equals(o))
  295. return e;
  296. const a = D(e), l = X(s3, true), c2 = X(o);
  297. if (a === 0 || t(l) || t(c2)) {
  298. const a2 = J(e, o, i2, r2);
  299. if (t(l) && r(c2) && Math.abs(a2.width - c2) < C(o) && en()) {
  300. const t2 = L(s3);
  301. if (r(t2) && t2.poleLocation === d.None && e.width < (t2.bbox[2] - t2.bbox[0]) / 2)
  302. return q(e, o) || a2;
  303. }
  304. return a2;
  305. }
  306. const u = e.clone().normalize();
  307. if (u.length === 1 && e.xmax < l && e.xmax - l / 2 > C(s3)) {
  308. const { xmin: t2, xmax: n } = e;
  309. for (let o2 = 0; o2 <= a; o2++) {
  310. const i3 = o2 === 0 ? t2 : -l / 2, r3 = o2 === a ? n - l * o2 : l / 2;
  311. u[o2] = new M({ xmin: i3, xmax: r3, ymin: e.ymin, ymax: e.ymax, spatialReference: s3 });
  312. }
  313. }
  314. return Y(u.map((e2) => J(e2, o, i2, r2)).filter((e2) => !!e2));
  315. }
  316. function q(e, n) {
  317. const o = X(n);
  318. if (t(o))
  319. return null;
  320. let { xmin: i2, ymin: r2, xmax: s3, ymax: a } = e;
  321. const l = e.spatialReference, c2 = new v({ spatialReference: l, rings: [[[i2, r2], [s3, r2], [s3, a], [i2, a], [i2, r2]]] }), f = rn(c2, n);
  322. if (f.rings.length !== 2 || !f.rings[0].length || !f.rings[1].length)
  323. return null;
  324. const { rings: u } = f, m = C(l), p = new M({ spatialReference: n });
  325. for (let t2 = 0; t2 < 2; t2++) {
  326. i2 = s3 = u[t2][0][0], r2 = a = u[t2][0][1];
  327. for (let e2 = 0; e2 < u[t2].length; e2++)
  328. i2 = i2 > u[t2][e2][0] ? u[t2][e2][0] : i2, s3 = s3 < u[t2][e2][0] ? u[t2][e2][0] : s3, r2 = r2 > u[t2][e2][1] ? u[t2][e2][1] : r2, a = a < u[t2][e2][1] ? u[t2][e2][1] : a;
  329. if (t2 === 0)
  330. p.ymin = r2, p.ymax = a, p.xmin = i2, p.xmax = s3;
  331. else if (p.ymin = Math.min(p.ymin, r2), p.ymax = Math.max(p.ymax, a), Math.abs(s3 - o / 2) < m)
  332. p.xmin = i2, p.xmax = p.xmax + o;
  333. else {
  334. if (!(Math.abs(i2 + o / 2) < m))
  335. return null;
  336. p.xmax = s3 + o;
  337. }
  338. }
  339. return p;
  340. }
  341. function J(e, n, o = null, i2 = true, r2 = true) {
  342. const s3 = e.spatialReference;
  343. if (s3.equals(n))
  344. return e;
  345. w(s3, n, o);
  346. const a = rn(e, n, o);
  347. if (r2 && n.isWebMercator && a && (a.ymax = Math.min(20037508342787e-6, a.ymax), a.ymin = Math.max(-20037508342787e-6, a.ymin), a.ymin >= a.ymax))
  348. return null;
  349. if (!i2 || !a)
  350. return a;
  351. const l = K(s3, true), c2 = K(n, true);
  352. if (t(l) || t(c2))
  353. return a;
  354. const f = C(s3, 1e-3), u = C(s3, 500), m = C(n, 1e-3);
  355. if (Math.abs(a.xmin - c2[0]) < m && Math.abs(a.xmax - c2[1]) < m) {
  356. const t2 = Math.abs(e.xmin - l[0]), i3 = Math.abs(l[1] - e.xmax);
  357. if (t2 < f && i3 > u) {
  358. a.xmin = c2[0];
  359. const t3 = [];
  360. t3.push(new j(e.xmax, e.ymin, s3)), t3.push(new j(e.xmax, (e.ymin + e.ymax) / 2, s3)), t3.push(new j(e.xmax, e.ymax, s3));
  361. const i4 = t3.map((e2) => _(e2, n, o)).filter((e2) => !isNaN(e2?.x)).map((e2) => e2.x);
  362. a.xmax = Math.max.apply(null, i4);
  363. }
  364. if (i3 < f && t2 > u) {
  365. a.xmax = c2[1];
  366. const t3 = [];
  367. t3.push(new j(e.xmin, e.ymin, s3)), t3.push(new j(e.xmin, (e.ymin + e.ymax) / 2, s3)), t3.push(new j(e.xmin, e.ymax, s3));
  368. const i4 = t3.map((e2) => _(e2, n, o)).filter((e2) => !isNaN(e2?.x)).map((e2) => e2.x);
  369. a.xmin = Math.min.apply(null, i4);
  370. }
  371. } else {
  372. const e2 = C(n, 1e-3);
  373. Math.abs(a.xmin - c2[0]) < e2 && (a.xmin = c2[0]), Math.abs(a.xmax - c2[1]) < e2 && (a.xmax = c2[1]);
  374. }
  375. return a;
  376. }
  377. function X(e, t2 = false) {
  378. const n = t2 ? 20037508342787e-6 : 20037508342788905e-9;
  379. return e.isWebMercator ? 2 * n : e.wkid && e.isGeographic ? 360 : 2 * P[e.wkid] || null;
  380. }
  381. function K(e, t2 = false) {
  382. if (e.isGeographic)
  383. return [-180, 180];
  384. const o = X(e, t2);
  385. return r(o) ? [-o / 2, o / 2] : null;
  386. }
  387. function U(e, t2, n, o) {
  388. let i2 = (e - t2) / n;
  389. return i2 - Math.floor(i2) != 0 ? i2 = Math.floor(i2) : o && (i2 -= 1), i2;
  390. }
  391. function D(e, n = false) {
  392. const o = X(e.spatialReference);
  393. if (t(o))
  394. return 0;
  395. const i2 = n ? 0 : -(o / 2), r2 = C(e.spatialReference), s3 = !n && Math.abs(e.xmax - o / 2) < r2 ? o / 2 : e.xmax, a = !n && Math.abs(e.xmin + o / 2) < r2 ? -o / 2 : e.xmin;
  396. return U(s3, i2, o, true) - U(a, i2, o, false);
  397. }
  398. function H(e) {
  399. const o = e.storageInfo.origin.x, i2 = X(e.spatialReference, true);
  400. if (t(i2))
  401. return { originX: o, halfWorldWidth: null, pyramidsInfo: null };
  402. const r2 = i2 / 2, { nativePixelSize: s3, storageInfo: a, extent: l } = e, { maximumPyramidLevel: c2, blockWidth: f, pyramidScalingFactor: u } = a;
  403. let m = s3.x;
  404. const x = [], h = r(e.transform) && e.transform.type === "gcs-shift", p = o + (h ? 0 : r2), g = h ? i2 - o : r2 - o;
  405. for (let t2 = 0; t2 <= c2; t2++) {
  406. const e2 = (l.xmax - o) / m / f, t3 = e2 - Math.floor(e2) == 0 ? e2 : Math.ceil(e2), n = g / m / f, i3 = n - Math.floor(n) == 0 ? n : Math.ceil(n), r3 = Math.floor(p / m / f), s4 = Math.round(p / m) % f, a2 = (f - Math.round(g / m) % f) % f;
  407. x.push({ resolutionX: m, blockWidth: f, datsetColumnCount: t3, worldColumnCountFromOrigin: i3, leftMargin: s4, rightPadding: a2, originColumnOffset: r3 }), m *= u;
  408. }
  409. return { originX: o, halfWorldWidth: r2, pyramidsInfo: x, hasGCSSShiftTransform: h };
  410. }
  411. function Q(e) {
  412. if (!e || e.isGeographic)
  413. return e;
  414. const t2 = String(e.wkid || e.wkt);
  415. let n;
  416. if (N.has(t2))
  417. n = N.get(t2);
  418. else {
  419. n = (e.wkid ? i.coordsys(e.wkid) : i.fromString(E.PE_TYPE_PROJCS, e.wkt)).getGeogcs().getCode(), N.set(t2, n);
  420. }
  421. return new k({ wkid: n });
  422. }
  423. function V(e) {
  424. const t2 = e.isAdaptive && e.spacing == null;
  425. let o = e.spacing || [S2, S2], i2 = Z(e), r2 = { cols: i2.size[0] + 1, rows: i2.size[1] + 1 };
  426. const s3 = i2.outofBoundPointCount > 0 && i2.outofBoundPointCount < i2.offsets.length / 2;
  427. let a = i2.outofBoundPointCount === i2.offsets.length / 2 || t2 && s3 ? [0, 0] : R(i2.offsets, r2, o, E2);
  428. const l = (a[0] + a[1]) / 2, c2 = e.projectedExtent.spatialReference, f = e.srcBufferExtent.spatialReference;
  429. if (t2 && (s3 || l > E2)) {
  430. M2(c2, f, e.datumTransformation) && (c2.isGeographic || r(L(c2))), o = [b, b], i2 = Z({ ...e, spacing: o }), r2 = { cols: i2.size[0] + 1, rows: i2.size[1] + 1 }, a = R(i2.offsets, r2, o, E2);
  431. }
  432. if (i2.error = a, o[0] > 1 && (i2.coefficients = $(i2.offsets, r2, s3)), e.includeGCSGrid && !c2.isGeographic && !c2.isWebMercator)
  433. if (f.isGeographic)
  434. i2.gcsGrid = { offsets: i2.offsets, coefficients: i2.coefficients, spacing: o };
  435. else {
  436. const t3 = L(c2);
  437. if (r(t3) && !t3.isEnvelope) {
  438. const t4 = Q(c2), n = F(e.projectedExtent, t4), { offsets: a2 } = Z({ ...e, srcBufferExtent: n, spacing: o }), l2 = $(a2, r2, s3);
  439. i2.gcsGrid = { offsets: a2, coefficients: l2, spacing: o };
  440. }
  441. }
  442. return i2;
  443. }
  444. function Z(e) {
  445. const { projectedExtent: t2, srcBufferExtent: o, pixelSize: i2, datumTransformation: r2, rasterTransform: s3 } = e, a = t2.spatialReference, l = o.spatialReference, c2 = w(a, l), { xmin: f, ymin: u, xmax: m, ymax: x } = t2, h = X(l), g = r(h) && (e.hasWrapAround || s3?.type === "gcs-shift"), y = e.spacing || [S2, S2], d2 = y[0] * i2.x, M3 = y[1] * i2.y, R2 = y[0] === 1, P2 = Math.ceil((m - f) / d2 - 0.1 / y[0]) + (R2 ? 0 : 1), E3 = Math.ceil((x - u) / M3 - 0.1 / y[1]) + (R2 ? 0 : 1), G2 = j2({ cols: P2, rows: E3, xmin: f, ymax: x, xres: d2, yres: M3, inSR: a, outSR: l, datumTransformation: r2, preferPE: y[0] <= b, usePixelCenter: R2 }), N2 = [];
  446. let k3, T2 = 0;
  447. const v3 = R2 ? -1 : NaN, { xmin: _2, xmax: z3, ymax: W2, width: O2, height: A2 } = o, B2 = C(l, 500), I2 = r(h) && _2 > 0 && z3 > h / 2;
  448. let Y2 = false;
  449. if (c2) {
  450. const e2 = L(a);
  451. Y2 = r(e2) && e2.poleLocation > 0;
  452. }
  453. for (let n = 0; n < P2; n++) {
  454. const e2 = [];
  455. for (let t3 = 0; t3 < E3; t3++) {
  456. let o2 = G2[n * E3 + t3];
  457. if (g && o2[0] > z3 && o2[0] > h / 2 - B2 ? o2[0] -= h : g && n === 0 && o2[0] < 0 && I2 && !s3 && (o2[0] += h), !o2 || isNaN(o2[0]) || isNaN(o2[1]))
  458. N2.push(v3), N2.push(v3), e2.push(null), T2++;
  459. else {
  460. if (s3) {
  461. const e3 = s3.inverseTransform(new j({ x: o2[0], y: o2[1], spatialReference: l }));
  462. o2 = [e3.x, e3.y];
  463. }
  464. e2.push(o2), n > 0 && g && k3[t3] && o2[0] < k3[t3][0] && (o2[0] += h, Y2 && o2[0] > z3 && o2[0] > h && (o2[0] -= h)), N2.push((o2[0] - _2) / O2), N2.push((W2 - o2[1]) / A2);
  465. }
  466. }
  467. k3 = e2;
  468. }
  469. return { offsets: N2, error: null, coefficients: null, outofBoundPointCount: T2, spacing: y, size: R2 ? [P2, E3] : [P2 - 1, E3 - 1] };
  470. }
  471. function $(e, t2, n) {
  472. const { cols: o, rows: i2 } = t2, r2 = new Float32Array((o - 1) * (i2 - 1) * 2 * 6), s3 = new Float32Array([-0, -1, 1, -1, 1, -0, 1, -0, -0]), a = new Float32Array([-1, 1, 0, 0, -1, 1, 1, 0, 0]);
  473. for (let l = 0; l < o - 1; l++) {
  474. for (let t3 = 0; t3 < i2 - 1; t3++) {
  475. let n2 = l * i2 * 2 + 2 * t3;
  476. const c2 = e[n2], f = e[n2 + 1], u = e[n2 + 2], m = e[n2 + 3];
  477. n2 += 2 * i2;
  478. const x = e[n2], h = e[n2 + 1], p = e[n2 + 2], g = e[n2 + 3];
  479. let y = 0, d2 = 12 * (t3 * (o - 1) + l);
  480. for (let e2 = 0; e2 < 3; e2++)
  481. r2[d2++] = s3[y++] * c2 + s3[y++] * u + s3[y++] * p;
  482. y = 0;
  483. for (let e2 = 0; e2 < 3; e2++)
  484. r2[d2++] = s3[y++] * f + s3[y++] * m + s3[y++] * g;
  485. y = 0;
  486. for (let e2 = 0; e2 < 3; e2++)
  487. r2[d2++] = a[y++] * c2 + a[y++] * x + a[y++] * p;
  488. y = 0;
  489. for (let e2 = 0; e2 < 3; e2++)
  490. r2[d2++] = a[y++] * f + a[y++] * h + a[y++] * g;
  491. }
  492. if (n)
  493. for (let e2 = 0; e2 < r2.length; e2++)
  494. isNaN(r2[e2]) && (r2[e2] = -1);
  495. }
  496. return r2;
  497. }
  498. function ee(e) {
  499. const t2 = e.clone().normalize();
  500. return t2.length === 1 ? t2[0] : Y(t2);
  501. }
  502. function te(e, t2, i2) {
  503. const { storageInfo: r2, pixelSize: s3 } = t2;
  504. let a, l = false;
  505. const { pyramidResolutions: c2 } = r2;
  506. if (r(c2) && c2.length) {
  507. const n = (e.x + e.y) / 2, r3 = c2[c2.length - 1], f2 = (r3.x + r3.y) / 2, u2 = (s3.x + s3.y) / 2;
  508. if (n <= u2)
  509. a = 0;
  510. else if (n >= f2)
  511. a = c2.length, l = n / f2 > 8;
  512. else {
  513. let e2, t3 = u2;
  514. for (let o = 1; o <= c2.length; o++) {
  515. if (e2 = (c2[o - 1].x + c2[o - 1].y) / 2, n <= e2) {
  516. n === e2 ? a = o : i2 === "down" ? (a = o - 1, l = n / t3 > 8) : a = i2 === "up" || n - t3 > e2 - n || n / t3 > 2 ? o : o - 1;
  517. break;
  518. }
  519. t3 = e2;
  520. }
  521. }
  522. const m2 = a === 0 ? s3 : c2[a - 1];
  523. if (l) {
  524. Math.min(m2.x, m2.y) * z(t2.spatialReference) > 19567 && (l = false);
  525. }
  526. return { pyramidLevel: a, pyramidResolution: new j({ x: m2.x, y: m2.y, spatialReference: t2.spatialReference }), excessiveReading: l };
  527. }
  528. const f = Math.log(e.x / s3.x) / Math.LN2, u = Math.log(e.y / s3.y) / Math.LN2, m = t2.storageInfo.maximumPyramidLevel || 0;
  529. a = i2 === "down" ? Math.floor(Math.min(f, u)) : i2 === "up" ? Math.ceil(Math.max(f, u)) : Math.round((f + u) / 2), a < 0 ? a = 0 : a > m && (l = a > m + 3, a = m);
  530. const x = 2 ** a;
  531. return { pyramidLevel: a, pyramidResolution: new j({ x: x * t2.nativePixelSize.x, y: x * t2.nativePixelSize.y, spatialReference: t2.spatialReference }), excessiveReading: l };
  532. }
  533. function ne(e, t2, n = 512, i2 = true) {
  534. const { extent: r2, spatialReference: s3, pixelSize: a } = e, l = v2(new j({ x: a.x, y: a.y, spatialReference: s3 }), t2, r2);
  535. if (l == null)
  536. return { projectedPixelSize: null, scales: null, srcResolutions: null, isCustomTilingScheme: false };
  537. const c2 = (l.x + l.y) / 2, f = z(t2), u = c2 * f * 96 * 39.37, m = t2.isGeographic ? 256 / n * 2958287637958547e-7 : 256 / n * 591657527591555e-6;
  538. let x = e.dataType === "vector-magdir" || e.dataType === "vector-uv";
  539. const h = F(r2, t2);
  540. x || i2 && (t2.isGeographic || t2.isWebMercator) && (x = h.xmin * h.xmax < 0);
  541. let g, y = u;
  542. const d2 = 1.001;
  543. if (x) {
  544. y = m;
  545. const e2 = t2.isGeographic ? 1341104507446289e-21 : 0.29858214164761665, n2 = e2 * (96 * f * 39.37), o = t2.isGeographic ? 4326 : 3857;
  546. g = v2(new j({ x: e2, y: e2, spatialReference: { wkid: o } }), s3, h), g.x *= y / n2, g.y *= y / n2;
  547. } else {
  548. g = { x: a.x, y: a.y };
  549. const t3 = Math.ceil(Math.log(Math.min(e.width, e.height) / 32) / Math.LN2);
  550. let n2 = 0;
  551. for (; y < m * (d2 / 2) && n2 < t3; )
  552. n2++, y *= 2, g.x *= 2, g.y *= 2;
  553. Math.max(y, m) / Math.min(y, m) <= d2 && (y = m);
  554. }
  555. const M3 = [y], w2 = [{ x: g.x, y: g.y }], R2 = 70.5310735, P2 = Math.min(R2, u) / d2;
  556. for (; y >= P2; )
  557. y /= 2, g.x /= 2, g.y /= 2, M3.push(y), w2.push({ x: g.x, y: g.y });
  558. return { projectedPixelSize: l, scales: M3, srcResolutions: w2, isCustomTilingScheme: !x };
  559. }
  560. export {
  561. M2 as M,
  562. k2 as k,
  563. T,
  564. v2 as v,
  565. _,
  566. F,
  567. X,
  568. D,
  569. H,
  570. V,
  571. ee,
  572. te,
  573. ne
  574. };
  575. //# sourceMappingURL=chunk-Y4GPJDDM.js.map