chunk-I623MZCZ.js 24 KB

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