WMTSLayer-S4MQFUPQ.js 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. import {
  2. o as o2
  3. } from "./chunk-FEH5F4VW.js";
  4. import {
  5. o as o3
  6. } from "./chunk-JARMALQK.js";
  7. import {
  8. p,
  9. x
  10. } from "./chunk-UYUDNSNC.js";
  11. import {
  12. u
  13. } from "./chunk-NE3ESGA6.js";
  14. import {
  15. U,
  16. l as l2
  17. } from "./chunk-YIS6BAC3.js";
  18. import {
  19. v
  20. } from "./chunk-KHA63LLS.js";
  21. import {
  22. c
  23. } from "./chunk-FGKNEJKJ.js";
  24. import "./chunk-PSV473TI.js";
  25. import {
  26. O
  27. } from "./chunk-I3OBGWNS.js";
  28. import "./chunk-FONIFA5N.js";
  29. import "./chunk-EG5OI4V4.js";
  30. import "./chunk-65BYCSII.js";
  31. import "./chunk-WZQZRKNH.js";
  32. import "./chunk-LRDX4TO7.js";
  33. import "./chunk-6A4U74YA.js";
  34. import {
  35. S
  36. } from "./chunk-RBZL6SRZ.js";
  37. import {
  38. n as n2
  39. } from "./chunk-CYI7KFYB.js";
  40. import {
  41. a
  42. } from "./chunk-5LXROFTA.js";
  43. import "./chunk-GJXW4HL5.js";
  44. import "./chunk-WJW5DUN6.js";
  45. import {
  46. t as t2
  47. } from "./chunk-W72F6AS3.js";
  48. import "./chunk-PJ7ZQ4VD.js";
  49. import "./chunk-WDLTDV2L.js";
  50. import "./chunk-TERAW6FT.js";
  51. import "./chunk-N2663GRX.js";
  52. import {
  53. u as u2
  54. } from "./chunk-O4FY3ITT.js";
  55. import "./chunk-WEMIK25H.js";
  56. import {
  57. b
  58. } from "./chunk-4DDBH2K5.js";
  59. import "./chunk-7N4X6GF3.js";
  60. import "./chunk-JXW4QTJA.js";
  61. import "./chunk-UXF37FQ4.js";
  62. import "./chunk-ZOEK6QHJ.js";
  63. import "./chunk-XNLG7T2T.js";
  64. import "./chunk-IR4PV7VK.js";
  65. import "./chunk-2Z6LERTI.js";
  66. import "./chunk-OWVBLVP3.js";
  67. import "./chunk-EGZW6HC3.js";
  68. import "./chunk-4NKD334K.js";
  69. import "./chunk-65K7LC56.js";
  70. import "./chunk-ATPLLI5W.js";
  71. import "./chunk-WJ3OEUD3.js";
  72. import "./chunk-MXB2XLKV.js";
  73. import "./chunk-XH7RUGVZ.js";
  74. import "./chunk-TBBTRX4O.js";
  75. import "./chunk-YBSUITLL.js";
  76. import {
  77. j as j2
  78. } from "./chunk-ALDCDSPV.js";
  79. import "./chunk-DT6EAZQ5.js";
  80. import "./chunk-HNOZUNJ4.js";
  81. import {
  82. U as U2
  83. } from "./chunk-VNFRAYHO.js";
  84. import "./chunk-R5IG2D6H.js";
  85. import {
  86. I,
  87. j as j3
  88. } from "./chunk-VBRY5KJM.js";
  89. import "./chunk-PDKDCAAD.js";
  90. import {
  91. M2 as M,
  92. j2 as j,
  93. o
  94. } from "./chunk-ECW2QABR.js";
  95. import "./chunk-GCDJLKH4.js";
  96. import {
  97. r as r2,
  98. r2 as r3
  99. } from "./chunk-MRJEICT6.js";
  100. import {
  101. d,
  102. e,
  103. l3 as l,
  104. n2 as n
  105. } from "./chunk-Y3WMVFTW.js";
  106. import "./chunk-SAS7RONY.js";
  107. import "./chunk-WSRBH7BF.js";
  108. import "./chunk-IHXECKQQ.js";
  109. import {
  110. q,
  111. w
  112. } from "./chunk-ULGDPLM2.js";
  113. import {
  114. s3 as s
  115. } from "./chunk-EMJ4ZSM2.js";
  116. import {
  117. m,
  118. t
  119. } from "./chunk-IKP3YN53.js";
  120. import {
  121. r
  122. } from "./chunk-GZT4BVFP.js";
  123. import "./chunk-A5ICIBVI.js";
  124. // node_modules/@arcgis/core/layers/support/TileInfoTilemapCache.js
  125. var l3 = class {
  126. constructor(i2, l5 = 0, a2 = i2.lods.length - 1) {
  127. this.tileInfo = i2, this.minLOD = l5, this.maxLOD = a2;
  128. }
  129. getAvailability(i2, l5, a2) {
  130. const t3 = this.tileInfo.lodAt(i2);
  131. return !t3 || i2 < this.minLOD || i2 > this.maxLOD ? "unavailable" : t3.cols && t3.rows ? a2 >= t3.cols[0] && a2 <= t3.cols[1] && l5 >= t3.rows[0] && l5 <= t3.rows[1] ? "available" : "unavailable" : "available";
  132. }
  133. async fetchAvailability(l5, a2, t3, e2) {
  134. return await q(e2), this.getAvailability(l5, a2, t3);
  135. }
  136. async fetchAvailabilityUpsample(l5, a2, t3, e2, s2) {
  137. await q(s2), e2.level = l5, e2.row = a2, e2.col = t3;
  138. const o5 = this.tileInfo;
  139. for (o5.updateTileInfo(e2); ; ) {
  140. const i2 = this.getAvailability(e2.level, e2.row, e2.col);
  141. if (i2 !== "unavailable")
  142. return i2;
  143. if (!o5.upsampleTile(e2))
  144. return "unavailable";
  145. }
  146. }
  147. };
  148. // node_modules/@arcgis/core/layers/support/TileMatrixSet.js
  149. var l4;
  150. var n3 = l4 = class extends l {
  151. constructor(t3) {
  152. super(t3), this.fullExtent = null, this.id = null, this.tileInfo = null;
  153. }
  154. clone() {
  155. const t3 = new l4();
  156. return this.hasOwnProperty("fullExtent") && (t3.fullExtent = this.fullExtent && this.fullExtent.clone()), this.hasOwnProperty("id") && (t3.id = this.id), this.hasOwnProperty("tileInfo") && (t3.tileInfo = this.tileInfo && this.tileInfo.clone()), t3;
  157. }
  158. };
  159. e([d({ type: M, json: { read: { source: "fullExtent" } } })], n3.prototype, "fullExtent", void 0), e([d({ type: String, json: { read: { source: "id" } } })], n3.prototype, "id", void 0), e([d({ type: S, json: { read: { source: "tileInfo" } } })], n3.prototype, "tileInfo", void 0), n3 = l4 = e([n("esri.layer.support.TileMatrixSet")], n3);
  160. var p2 = n3;
  161. // node_modules/@arcgis/core/layers/support/WMTSStyle.js
  162. var o4;
  163. var i = o4 = class extends l {
  164. constructor(r4) {
  165. super(r4), this.id = null, this.title = null, this.description = null, this.legendUrl = null;
  166. }
  167. clone() {
  168. const r4 = new o4();
  169. return this.hasOwnProperty("description") && (r4.description = this.description), this.hasOwnProperty("id") && (r4.id = this.id), this.hasOwnProperty("isDefault") && (r4.isDefault = this.isDefault), this.hasOwnProperty("keywords") && (r4.keywords = this.keywords && this.keywords.slice()), this.hasOwnProperty("legendUrl") && (r4.legendUrl = this.legendUrl), this.hasOwnProperty("title") && (r4.title = this.title), r4;
  170. }
  171. };
  172. e([d({ json: { read: { source: "id" } } })], i.prototype, "id", void 0), e([d({ json: { read: { source: "title" } } })], i.prototype, "title", void 0), e([d({ json: { read: { source: "abstract" } } })], i.prototype, "description", void 0), e([d({ json: { read: { source: "legendUrl" } } })], i.prototype, "legendUrl", void 0), e([d({ json: { read: { source: "isDefault" } } })], i.prototype, "isDefault", void 0), e([d({ json: { read: { source: "keywords" } } })], i.prototype, "keywords", void 0), i = o4 = e([n("esri.layer.support.WMTSStyle")], i);
  173. var p3 = i;
  174. // node_modules/@arcgis/core/layers/support/WMTSSublayer.js
  175. var p4;
  176. var h = p4 = class extends l {
  177. constructor(t3) {
  178. super(t3), this.fullExtent = null, this.fullExtents = null, this.imageFormats = null, this.id = null, this.layer = null, this.styles = null, this.tileMatrixSetId = null, this.tileMatrixSets = null;
  179. }
  180. get description() {
  181. return this._get("description");
  182. }
  183. set description(t3) {
  184. this._set("description", t3);
  185. }
  186. readFullExtent(t3, e2) {
  187. return (t3 = e2.fullExtent) ? M.fromJSON(t3) : null;
  188. }
  189. readFullExtents(t3, e2) {
  190. return e2.fullExtents?.length ? e2.fullExtents.map((t4) => M.fromJSON(t4)) : e2.tileMatrixSets.map((t4) => M.fromJSON(t4.fullExtent)).filter((t4) => t4);
  191. }
  192. get imageFormat() {
  193. let t3 = this._get("imageFormat");
  194. return t3 || (t3 = this.imageFormats && this.imageFormats.length ? this.imageFormats[0] : ""), t3;
  195. }
  196. set imageFormat(t3) {
  197. const e2 = this.imageFormats;
  198. t3 && (t3.includes("image/") || e2 && !e2.includes(t3)) && (t3.includes("image/") || (t3 = "image/" + t3), e2 && !e2.includes(t3)) ? console.error("The layer doesn't support the format of " + t3) : this._set("imageFormat", t3);
  199. }
  200. get styleId() {
  201. let t3 = this._get("styleId");
  202. return t3 || (t3 = this.styles && this.styles.length ? this.styles.getItemAt(0).id : ""), t3;
  203. }
  204. set styleId(t3) {
  205. this._set("styleId", t3);
  206. }
  207. get title() {
  208. return this._get("title");
  209. }
  210. set title(t3) {
  211. this._set("title", t3);
  212. }
  213. get tileMatrixSet() {
  214. return this.tileMatrixSets ? this.tileMatrixSets.find((t3) => t3.id === this.tileMatrixSetId) : null;
  215. }
  216. clone() {
  217. const t3 = new p4();
  218. return this.hasOwnProperty("description") && (t3.description = this.description), this.hasOwnProperty("imageFormats") && (t3.imageFormats = this.imageFormats && this.imageFormats.slice()), this.hasOwnProperty("imageFormat") && (t3.imageFormat = this.imageFormat), this.hasOwnProperty("fullExtent") && (t3.fullExtent = this.fullExtent && this.fullExtent.clone()), this.hasOwnProperty("id") && (t3.id = this.id), this.hasOwnProperty("layer") && (t3.layer = this.layer), this.hasOwnProperty("styleId") && (t3.styleId = this.styleId), this.hasOwnProperty("styles") && (t3.styles = this.styles && this.styles.clone()), this.hasOwnProperty("tileMatrixSetId") && (t3.tileMatrixSetId = this.tileMatrixSetId), this.hasOwnProperty("tileMatrixSets") && (t3.tileMatrixSets = this.tileMatrixSets.clone()), this.hasOwnProperty("title") && (t3.title = this.title), t3;
  219. }
  220. };
  221. e([d()], h.prototype, "description", null), e([d()], h.prototype, "fullExtent", void 0), e([o("fullExtent", ["fullExtent"])], h.prototype, "readFullExtent", null), e([d({ readOnly: true })], h.prototype, "fullExtents", void 0), e([o("fullExtents", ["fullExtents", "tileMatrixSets"])], h.prototype, "readFullExtents", null), e([d()], h.prototype, "imageFormat", null), e([d({ json: { read: { source: "formats" } } })], h.prototype, "imageFormats", void 0), e([d()], h.prototype, "id", void 0), e([d()], h.prototype, "layer", void 0), e([d()], h.prototype, "styleId", null), e([d({ type: j2.ofType(p3), json: { read: { source: "styles" } } })], h.prototype, "styles", void 0), e([d({ value: null, json: { write: { ignoreOrigin: true } } })], h.prototype, "title", null), e([d()], h.prototype, "tileMatrixSetId", void 0), e([d({ readOnly: true })], h.prototype, "tileMatrixSet", null), e([d({ type: j2.ofType(p2), json: { read: { source: "tileMatrixSets" } } })], h.prototype, "tileMatrixSets", void 0), h = p4 = e([n("esri.layers.support.WMTSSublayer")], h);
  222. var m2 = h;
  223. // node_modules/@arcgis/core/layers/support/wmtsUtils.js
  224. var c2 = 90.71428571428571;
  225. function u3(t3) {
  226. const n4 = t3.replace(/ows:/gi, "");
  227. if (!m3("Contents", new DOMParser().parseFromString(n4, "text/xml").documentElement))
  228. throw new s("wmtslayer:wmts-capabilities-xml-is-not-valid", "the wmts get capabilities response is not compliant", { text: t3 });
  229. }
  230. function p5(t3, n4) {
  231. t3 = t3.replace(/ows:/gi, "");
  232. const i2 = new DOMParser().parseFromString(t3, "text/xml").documentElement, r4 = new Map(), o5 = new Map(), l5 = m3("Contents", i2);
  233. if (!l5)
  234. throw new s("wmtslayer:wmts-capabilities-xml-is-not-valid");
  235. const s2 = m3("OperationsMetadata", i2)?.querySelector("[name='GetTile']"), a2 = s2?.getElementsByTagName("Get"), c3 = a2 && Array.prototype.slice.call(a2), u4 = n4?.url?.indexOf("https") > -1;
  236. let p6, f2, d3 = n4.serviceMode, x3 = n4 && n4.url;
  237. if (c3 && c3.length && c3.some((e2) => {
  238. const t4 = m3("Constraint", e2);
  239. return !t4 || w2("AllowedValues", "Value", d3, t4) ? (x3 = e2.attributes[0].nodeValue, true) : (!t4 || w2("AllowedValues", "Value", "RESTful", t4) || w2("AllowedValues", "Value", "REST", t4) ? f2 = e2.attributes[0].nodeValue : t4 && !w2("AllowedValues", "Value", "KVP", t4) || (p6 = e2.attributes[0].nodeValue), false);
  240. }), !x3)
  241. if (f2)
  242. x3 = f2, d3 = "RESTful";
  243. else if (p6)
  244. x3 = p6, d3 = "KVP";
  245. else {
  246. const e2 = m3("ServiceMetadataURL", i2);
  247. x3 = e2 && e2.getAttribute("xlink:href");
  248. }
  249. const M3 = x3.indexOf("1.0.0/");
  250. M3 === -1 && d3 === "RESTful" ? x3 += "/" : M3 > -1 && (x3 = x3.substring(0, M3)), d3 === "KVP" && (x3 += M3 > -1 ? "" : "?"), u4 && (x3 = x3.replace(/^http:/i, "https:"));
  251. const T2 = h2("ServiceIdentification>ServiceTypeVersion", i2), y2 = h2("ServiceIdentification>AccessConstraints", i2), S3 = /^none$/i.test(y2) ? null : y2, R2 = g("Layer", l5), V3 = g("TileMatrixSet", l5), b3 = R2.map((e2) => {
  252. const t4 = h2("Identifier", e2);
  253. return r4.set(t4, e2), C(t4, e2, V3, u4, T2);
  254. });
  255. return { copyright: S3, dimensionMap: o5, layerMap: r4, layers: b3, serviceMode: d3, tileUrl: x3 };
  256. }
  257. function f(e2) {
  258. return e2.layers.forEach((e3) => {
  259. e3.tileMatrixSets.forEach((e4) => {
  260. const t3 = e4.tileInfo;
  261. t3.dpi !== 96 && (t3.lods.forEach((n4) => {
  262. n4.scale = 96 * n4.scale / t3.dpi, n4.resolution = U3(t3.spatialReference.wkid, n4.scale * c2 / 96, e4.id);
  263. }), t3.dpi = 96);
  264. });
  265. }), e2;
  266. }
  267. function d2(e2) {
  268. return e2.nodeType === Node.ELEMENT_NODE;
  269. }
  270. function m3(e2, t3) {
  271. for (let n4 = 0; n4 < t3.childNodes.length; n4++) {
  272. const i2 = t3.childNodes[n4];
  273. if (d2(i2) && i2.nodeName === e2)
  274. return i2;
  275. }
  276. return null;
  277. }
  278. function g(e2, t3) {
  279. const n4 = [];
  280. for (let i2 = 0; i2 < t3.childNodes.length; i2++) {
  281. const r4 = t3.childNodes[i2];
  282. d2(r4) && r4.nodeName === e2 && n4.push(r4);
  283. }
  284. return n4;
  285. }
  286. function x2(e2, t3) {
  287. const n4 = [];
  288. for (let i2 = 0; i2 < t3.childNodes.length; i2++) {
  289. const r4 = t3.childNodes[i2];
  290. d2(r4) && r4.nodeName === e2 && n4.push(r4);
  291. }
  292. return n4.map((e3) => e3.textContent);
  293. }
  294. function h2(e2, t3) {
  295. return e2.split(">").forEach((e3) => {
  296. t3 && (t3 = m3(e3, t3));
  297. }), t3 && t3.textContent;
  298. }
  299. function w2(e2, t3, n4, i2) {
  300. let r4;
  301. return Array.prototype.slice.call(i2.childNodes).some((i3) => {
  302. if (i3.nodeName.includes(e2)) {
  303. const e3 = m3(t3, i3), o5 = e3 && e3.textContent;
  304. if (o5 === n4 || n4.split(":") && n4.split(":")[1] === o5)
  305. return r4 = i3, true;
  306. }
  307. return false;
  308. }), r4;
  309. }
  310. function C(e2, t3, n4, i2, r4) {
  311. const o5 = h2("Abstract", t3), l5 = x2("Format", t3);
  312. return { id: e2, fullExtent: R(t3), fullExtents: V(t3), description: o5, formats: l5, styles: b2(t3, i2), title: h2("Title", t3), tileMatrixSets: E(r4, t3, n4) };
  313. }
  314. function M2(e2, t3) {
  315. const n4 = [], i2 = e2.layerMap?.get(t3);
  316. if (!i2)
  317. return;
  318. const r4 = g("ResourceURL", i2), o5 = g("Dimension", i2);
  319. let l5, s2, a2, c3;
  320. return o5.length && (l5 = h2("Identifier", o5[0]), s2 = x2("Default", o5[0]) || x2("Value", o5[0])), o5.length > 1 && (a2 = h2("Identifier", o5[1]), c3 = x2("Default", o5[1]) || x2("Value", o5[1])), e2.dimensionMap.set(t3, { dimensions: s2, dimensions2: c3 }), r4.forEach((e3) => {
  321. let t4 = e3.getAttribute("template");
  322. if (e3.getAttribute("resourceType") === "tile") {
  323. if (l5 && s2.length)
  324. if (t4.includes("{" + l5 + "}"))
  325. t4 = t4.replace("{" + l5 + "}", "{dimensionValue}");
  326. else {
  327. const e4 = t4.toLowerCase().indexOf("{" + l5.toLowerCase() + "}");
  328. e4 > -1 && (t4 = t4.substring(0, e4) + "{dimensionValue}" + t4.substring(e4 + l5.length + 2));
  329. }
  330. if (a2 && c3.length)
  331. if (t4.includes("{" + a2 + "}"))
  332. t4 = t4.replace("{" + a2 + "}", "{dimensionValue2}");
  333. else {
  334. const e4 = t4.toLowerCase().indexOf("{" + a2.toLowerCase() + "}");
  335. e4 > -1 && (t4 = t4.substring(0, e4) + "{dimensionValue2}" + t4.substring(e4 + a2.length + 2));
  336. }
  337. n4.push({ template: t4, format: e3.getAttribute("format"), resourceType: "tile" });
  338. }
  339. }), n4;
  340. }
  341. function T(e2, t3, n4, i2, r4, o5, l5, s2) {
  342. const a2 = y(e2, t3, i2);
  343. if (!(a2?.length > 0))
  344. return "";
  345. const { dimensionMap: c3 } = e2, u4 = c3.get(t3).dimensions?.[0], p6 = c3.get(t3).dimensions2?.[0];
  346. return a2[l5 % a2.length].template.replace(/\{Style\}/gi, r4).replace(/\{TileMatrixSet\}/gi, n4).replace(/\{TileMatrix\}/gi, o5).replace(/\{TileRow\}/gi, "" + l5).replace(/\{TileCol\}/gi, "" + s2).replace(/\{dimensionValue\}/gi, u4).replace(/\{dimensionValue2\}/gi, p6);
  347. }
  348. function y(e2, t3, n4) {
  349. const i2 = M2(e2, t3), r4 = i2.filter((e3) => e3.format === n4);
  350. return r4.length ? r4 : i2;
  351. }
  352. function S2(e2, t3, n4, i2) {
  353. const { dimensionMap: r4 } = e2, o5 = M2(e2, t3);
  354. let l5 = "";
  355. if (o5 && o5.length > 0) {
  356. const e3 = r4.get(t3).dimensions && r4.get(t3).dimensions[0], s2 = r4.get(t3).dimensions2 && r4.get(t3).dimensions2[0];
  357. l5 = o5[0].template, l5.indexOf(".xxx") === l5.length - 4 && (l5 = l5.slice(0, l5.length - 4)), l5 = l5.replace(/\{Style\}/gi, i2), l5 = l5.replace(/\{TileMatrixSet\}/gi, n4), l5 = l5.replace(/\{TileMatrix\}/gi, "{level}"), l5 = l5.replace(/\{TileRow\}/gi, "{row}"), l5 = l5.replace(/\{TileCol\}/gi, "{col}"), l5 = l5.replace(/\{dimensionValue\}/gi, e3), l5 = l5.replace(/\{dimensionValue2\}/gi, s2);
  358. }
  359. return l5;
  360. }
  361. function R(e2) {
  362. const t3 = m3("WGS84BoundingBox", e2), n4 = t3 ? h2("LowerCorner", t3).split(" ") : ["-180", "-90"], i2 = t3 ? h2("UpperCorner", t3).split(" ") : ["180", "90"];
  363. return { xmin: parseFloat(n4[0]), ymin: parseFloat(n4[1]), xmax: parseFloat(i2[0]), ymax: parseFloat(i2[1]), spatialReference: { wkid: 4326 } };
  364. }
  365. function V(e2) {
  366. const t3 = [];
  367. return o2(e2, { BoundingBox: (e3) => {
  368. if (!e3.getAttribute("crs"))
  369. return;
  370. const n4 = e3.getAttribute("crs").toLowerCase(), i2 = I2(n4), r4 = n4.includes("epsg") && o3(i2.wkid);
  371. let o5, a2, c3, u4;
  372. o2(e3, { LowerCorner: (e4) => {
  373. [o5, a2] = e4.textContent.split(" ").map((e5) => Number.parseFloat(e5)), r4 && ([o5, a2] = [a2, o5]);
  374. }, UpperCorner: (e4) => {
  375. [c3, u4] = e4.textContent.split(" ").map((e5) => Number.parseFloat(e5)), r4 && ([c3, u4] = [u4, c3]);
  376. } }), t3.push({ xmin: o5, ymin: a2, xmax: c3, ymax: u4, spatialReference: i2 });
  377. } }), t3;
  378. }
  379. function b2(e2, t3) {
  380. return g("Style", e2).map((e3) => {
  381. const n4 = m3("LegendURL", e3), i2 = m3("Keywords", e3), r4 = i2 && x2("Keyword", i2);
  382. let o5 = n4 && n4.getAttribute("xlink:href");
  383. t3 && (o5 = o5 && o5.replace(/^http:/i, "https:"));
  384. return { abstract: h2("Abstract", e3), id: h2("Identifier", e3), isDefault: e3.getAttribute("isDefault") === "true", keywords: r4, legendUrl: o5, title: h2("Title", e3) };
  385. });
  386. }
  387. function E(e2, t3, n4) {
  388. return g("TileMatrixSetLink", t3).map((t4) => L(e2, t4, n4));
  389. }
  390. function L(e2, t3, n4) {
  391. const i2 = m3("TileMatrixSet", t3).textContent, r4 = x2("TileMatrix", t3), o5 = n4.find((e3) => {
  392. const t4 = m3("Identifier", e3), n5 = t4 && t4.textContent;
  393. return !!(n5 === i2 || i2.split(":") && i2.split(":")[1] === n5);
  394. }), l5 = m3("TileMatrixSetLimits", t3), s2 = l5 && g("TileMatrixLimits", l5), c3 = new Map();
  395. if (s2?.length)
  396. for (const a2 of s2) {
  397. const e3 = m3("TileMatrix", a2).textContent, t4 = +m3("MinTileRow", a2).textContent, n5 = +m3("MaxTileRow", a2).textContent, i3 = +m3("MinTileCol", a2).textContent, r5 = +m3("MaxTileCol", a2).textContent;
  398. c3.set(e3, { minCol: i3, maxCol: r5, minRow: t4, maxRow: n5 });
  399. }
  400. const u4 = h2("SupportedCRS", o5).toLowerCase(), p6 = N(o5, u4), f2 = p6.spatialReference, d3 = m3("TileMatrix", o5), C2 = [parseInt(h2("TileWidth", d3), 10), parseInt(h2("TileHeight", d3), 10)], M3 = [];
  401. if (r4.length)
  402. r4.forEach((e3, t4) => {
  403. const n5 = w2("TileMatrix", "Identifier", e3, o5);
  404. M3.push(D(n5, u4, t4, i2, c3));
  405. });
  406. else {
  407. g("TileMatrix", o5).forEach((e3, t4) => {
  408. M3.push(D(e3, u4, t4, i2, c3));
  409. });
  410. }
  411. const T2 = F(e2, o5, p6, C2, M3[0]).toJSON(), y2 = new S({ dpi: 96, spatialReference: f2, size: C2, origin: p6, lods: M3 }).toJSON();
  412. return { id: i2, fullExtent: T2, tileInfo: y2 };
  413. }
  414. function I2(e2) {
  415. e2 = e2.toLowerCase();
  416. let n4 = parseInt(e2.split(":").pop(), 10);
  417. n4 !== 900913 && n4 !== 3857 || (n4 = 102100);
  418. const i2 = k(e2);
  419. return r(i2) && (n4 = i2), { wkid: n4 };
  420. }
  421. function N(e2, t3) {
  422. return A(m3("TileMatrix", e2), t3);
  423. }
  424. function A(e2, t3) {
  425. const n4 = I2(t3), [r4, o5] = h2("TopLeftCorner", e2).split(" ").map((e3) => parseFloat(e3)), s2 = t3.includes("epsg") && o3(n4.wkid);
  426. return new j(s2 ? { x: o5, y: r4, spatialReference: n4 } : { x: r4, y: o5, spatialReference: n4 });
  427. }
  428. function F(e2, t3, i2, r4, o5) {
  429. const l5 = m3("BoundingBox", t3);
  430. let s2, a2, c3, u4, p6, f2;
  431. if (l5 && (s2 = h2("LowerCorner", l5).split(" "), a2 = h2("UpperCorner", l5).split(" ")), s2 && s2.length > 1 && a2 && a2.length > 1)
  432. c3 = parseFloat(s2[0]), p6 = parseFloat(s2[1]), u4 = parseFloat(a2[0]), f2 = parseFloat(a2[1]);
  433. else {
  434. const e3 = m3("TileMatrix", t3), n4 = parseInt(h2("MatrixWidth", e3), 10), l6 = parseInt(h2("MatrixHeight", e3), 10);
  435. c3 = i2.x, f2 = i2.y, u4 = c3 + n4 * r4[0] * o5.resolution, p6 = f2 - l6 * r4[1] * o5.resolution;
  436. }
  437. return v2(e2, i2.spatialReference) ? new M(p6, c3, f2, u4, i2.spatialReference) : new M(c3, p6, u4, f2, i2.spatialReference);
  438. }
  439. function v2(e2, t3) {
  440. return e2 === "1.0.0" && o3(t3.wkid);
  441. }
  442. var O2;
  443. function k(e2) {
  444. return e2.includes("crs84") || e2.includes("crs:84") ? O2.CRS84 : e2.includes("crs83") || e2.includes("crs:83") ? O2.CRS83 : e2.includes("crs27") || e2.includes("crs:27") ? O2.CRS27 : null;
  445. }
  446. function D(e2, t3, n4, i2, r4) {
  447. const o5 = I2(t3), l5 = h2("Identifier", e2);
  448. let s2 = parseFloat(h2("ScaleDenominator", e2));
  449. const a2 = U3(o5.wkid, s2, i2);
  450. s2 *= 96 / c2;
  451. const u4 = +h2("MatrixWidth", e2), p6 = +h2("MatrixHeight", e2), { maxCol: f2 = u4 - 1, maxRow: d3 = p6 - 1, minCol: m4 = 0, minRow: g2 = 0 } = r4.get(l5) ?? {}, { x: x3, y: w3 } = A(e2, t3);
  452. return { cols: [m4, f2], level: n4, levelValue: l5, origin: [x3, w3], scale: s2, resolution: a2, rows: [g2, d3] };
  453. }
  454. function U3(e2, t3, n4) {
  455. let i2;
  456. return i2 = r3.hasOwnProperty("" + e2) ? r3.values[r3[e2]] : n4 === "default028mm" ? 6370997 * Math.PI / 180 : u2(e2).metersPerDegree, 7 * t3 / 25e3 / i2;
  457. }
  458. !function(e2) {
  459. e2[e2.CRS84 = 4326] = "CRS84", e2[e2.CRS83 = 4269] = "CRS83", e2[e2.CRS27 = 4267] = "CRS27";
  460. }(O2 || (O2 = {}));
  461. // node_modules/@arcgis/core/layers/WMTSLayer.js
  462. var O3 = { "image/png": ".png", "image/png8": ".png", "image/png24": ".png", "image/png32": ".png", "image/jpg": ".jpg", "image/jpeg": ".jpeg", "image/gif": ".gif", "image/bmp": ".bmp", "image/tiff": ".tif", "image/jpgpng": "", "image/jpegpng": "", "image/unknown": "" };
  463. var W = new Set(["version", "service", "request", "layer", "style", "format", "tilematrixset", "tilematrix", "tilerow", "tilecol"]);
  464. var A2 = class extends a(n2(t2(c(v(O(b)))))) {
  465. constructor(...e2) {
  466. super(...e2), this._sublayersHandles = new u(), this.copyright = "", this.customParameters = null, this.customLayerParameters = null, this.fullExtent = null, this.operationalLayerType = "WebTiledLayer", this.resourceInfo = null, this.serviceMode = "RESTful", this.sublayers = null, this.type = "wmts", this.version = "1.0.0", this.own([l2(() => this.activeLayer, (e3, t3) => {
  467. t3 && (t3.layer = null), e3 && (e3.layer = this);
  468. }, U), l2(() => this.sublayers, (e3, t3) => {
  469. t3 && (t3.forEach((e4) => {
  470. e4.layer = null;
  471. }), this._sublayersHandles.removeAll(), this._sublayersHandles = null), e3 && (e3.forEach((e4) => {
  472. e4.layer = this;
  473. }), this._sublayersHandles || (this._sublayersHandles = new u()), this._sublayersHandles.add([e3.on("after-add", ({ item: e4 }) => {
  474. e4.layer = this;
  475. }), e3.on("after-remove", ({ item: e4 }) => {
  476. e4.layer = null;
  477. })]));
  478. }, U)]);
  479. }
  480. normalizeCtorArgs(e2, t3) {
  481. return typeof e2 == "string" ? { url: e2, ...t3 } : e2;
  482. }
  483. load(e2) {
  484. if (this.serviceMode === "KVP" || this.serviceMode === "RESTful")
  485. return this.addResolvingPromise(this.loadFromPortal({ supportedTypes: ["WMTS"] }, e2).catch(w).then(() => this._fetchService(e2)).catch((e3) => {
  486. throw w(e3), new s("wmtslayer:unsupported-service-data", "Invalid response from the WMTS service.", { error: e3 });
  487. })), Promise.resolve(this);
  488. console.error("WMTS mode could only be 'KVP' or 'RESTful'");
  489. }
  490. get activeLayer() {
  491. return this._get("activeLayer");
  492. }
  493. set activeLayer(e2) {
  494. this._set("activeLayer", e2);
  495. }
  496. readActiveLayerFromService(e2, t3, r4) {
  497. this.activeLayer || (this.activeLayer = new m2());
  498. let i2 = t3.layers.find((e3) => e3.id === this.activeLayer.id);
  499. return i2 || (i2 = t3.layers[0]), this.activeLayer.read(i2, r4), this.activeLayer;
  500. }
  501. readActiveLayerFromItemOrWebDoc(e2, t3) {
  502. const { templateUrl: r4, wmtsInfo: i2 } = t3, s2 = r4 ? this._getLowerCasedUrlParams(r4) : null, a2 = i2?.layerIdentifier;
  503. let o5 = null;
  504. const l5 = i2?.tileMatrixSet;
  505. l5 && (Array.isArray(l5) ? l5.length && (o5 = l5[0]) : o5 = l5);
  506. const n4 = s2?.format, m4 = s2?.style;
  507. return new m2({ id: a2, imageFormat: n4, styleId: m4, tileMatrixSetId: o5 });
  508. }
  509. writeActiveLayer(e2, t3, r4, i2) {
  510. const s2 = this.activeLayer;
  511. t3.templateUrl = this.getUrlTemplate(s2.id, s2.tileMatrixSetId, s2.imageFormat, s2.styleId);
  512. const a2 = t("tileMatrixSet.tileInfo", s2);
  513. t3.tileInfo = a2 ? a2.toJSON(i2) : null, t3.wmtsInfo = { ...t3.wmtsInfo, layerIdentifier: s2.id, tileMatrixSet: s2.tileMatrixSetId };
  514. }
  515. readCustomParameters(e2, t3) {
  516. const r4 = t3.wmtsInfo;
  517. return r4 ? this._mergeParams(r4.customParameters, r4.url) : null;
  518. }
  519. get fullExtents() {
  520. return this.activeLayer.fullExtents;
  521. }
  522. readServiceMode(e2, t3) {
  523. return t3.templateUrl.includes("?") ? "KVP" : "RESTful";
  524. }
  525. readSublayersFromService(e2, t3, r4) {
  526. return F2(t3.layers, r4);
  527. }
  528. get supportedSpatialReferences() {
  529. return this.activeLayer.tileMatrixSets.map((e2) => e2.tileInfo.spatialReference).toArray();
  530. }
  531. get tilemapCache() {
  532. const e2 = this.activeLayer?.tileMatrixSet?.tileInfo;
  533. return new l3(e2);
  534. }
  535. get title() {
  536. return this.activeLayer?.title ?? "Layer";
  537. }
  538. set title(e2) {
  539. e2 ? this._override("title", e2) : this._clearOverride("title");
  540. }
  541. get url() {
  542. return this._get("url");
  543. }
  544. set url(e2) {
  545. e2 && e2.substr(-1) === "/" ? this._set("url", e2.slice(0, -1)) : this._set("url", e2);
  546. }
  547. createWebTileLayer(e2) {
  548. const t3 = this.getUrlTemplate(this.activeLayer.id, this.activeLayer.tileMatrixSetId, this.activeLayer.imageFormat, this.activeLayer.styleId), r4 = this._getTileMatrixSetById(e2.tileMatrixSetId).tileInfo, i2 = e2.fullExtent, s2 = new p({ layerIdentifier: e2.id, tileMatrixSet: e2.tileMatrixSetId, url: this.url });
  549. return this.customLayerParameters && (s2.customLayerParameters = this.customLayerParameters), this.customParameters && (s2.customParameters = this.customParameters), new x({ fullExtent: i2, urlTemplate: t3, tileInfo: r4, wmtsInfo: s2 });
  550. }
  551. fetchTile(e2, r4, i2) {
  552. const s2 = this.getTileUrl(e2, r4, i2);
  553. return U2(s2, { responseType: "image" }).then((e3) => e3.data);
  554. }
  555. findSublayerById(e2) {
  556. return this.sublayers.find((t3) => t3.id === e2);
  557. }
  558. getTileUrl(e2, t3, r4) {
  559. const i2 = this._getTileMatrixSetById(this.activeLayer.tileMatrixSetId).tileInfo.lods[e2], s2 = i2 ? i2.levelValue ? i2.levelValue : `${i2.level}` : `${e2}`;
  560. let a2 = this.resourceInfo ? "" : T({ dimensionMap: this.dimensionMap, layerMap: this.layerMap }, this.activeLayer.id, this.activeLayer.tileMatrixSetId, this.activeLayer.imageFormat, this.activeLayer.styleId, s2, t3, r4);
  561. if (!a2) {
  562. a2 = this.getUrlTemplate(this.activeLayer.id, this.activeLayer.tileMatrixSetId, this.activeLayer.imageFormat, this.activeLayer.styleId).replace(/\{level\}/gi, s2).replace(/\{row\}/gi, `${t3}`).replace(/\{col\}/gi, `${r4}`);
  563. }
  564. return a2 = this._appendCustomLayerParameters(a2), a2;
  565. }
  566. getUrlTemplate(e2, t3, r4, i2) {
  567. if (!this.resourceInfo) {
  568. const r5 = S2({ dimensionMap: this.dimensionMap, layerMap: this.layerMap }, e2, t3, i2);
  569. if (r5)
  570. return r5;
  571. }
  572. if (this.serviceMode === "KVP")
  573. return this.url + "?SERVICE=WMTS&VERSION=" + this.version + "&REQUEST=GetTile&LAYER=" + e2 + "&STYLE=" + i2 + "&FORMAT=" + r4 + "&TILEMATRIXSET=" + t3 + "&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}";
  574. if (this.serviceMode === "RESTful") {
  575. let s2 = "";
  576. return O3[r4.toLowerCase()] && (s2 = O3[r4.toLowerCase()]), this.url + e2 + "/" + i2 + "/" + t3 + "/{level}/{row}/{col}" + s2;
  577. }
  578. return "";
  579. }
  580. async _fetchService(e2) {
  581. let t3;
  582. if (this.resourceInfo)
  583. this.resourceInfo.serviceMode === "KVP" && (this.url += this.url.includes("?") ? "" : "?"), t3 = { ssl: false, data: this.resourceInfo };
  584. else
  585. try {
  586. t3 = await this._getCapabilities(this.serviceMode, e2), u3(t3.data);
  587. } catch {
  588. const s2 = this.serviceMode === "KVP" ? "RESTful" : "KVP";
  589. try {
  590. t3 = await this._getCapabilities(s2, e2), u3(t3.data), this.serviceMode = s2;
  591. } catch (r4) {
  592. throw new s("wmtslayer:unsupported-service-data", "Services does not support RESTful or KVP service modes.", { error: r4 });
  593. }
  594. }
  595. this.resourceInfo ? t3.data = f(t3.data) : t3.data = p5(t3.data, { serviceMode: this.serviceMode, url: this.url }), t3.data && this.read(t3.data, { origin: "service" });
  596. }
  597. async _getCapabilities(e2, r4) {
  598. const i2 = this._getCapabilitiesUrl(e2);
  599. return await U2(i2, { ...r4, responseType: "text" });
  600. }
  601. _getTileMatrixSetById(e2) {
  602. return this.findSublayerById(this.activeLayer.id).tileMatrixSets.find((t3) => t3.id === e2);
  603. }
  604. _appendCustomParameters(e2) {
  605. return this._appendParameters(e2, this.customParameters);
  606. }
  607. _appendCustomLayerParameters(e2) {
  608. return this._appendParameters(e2, { ...m(this.customParameters), ...this.customLayerParameters });
  609. }
  610. _appendParameters(e2, t3) {
  611. const r4 = j3(e2), i2 = { ...r4.query, ...t3 }, s2 = I(i2);
  612. return s2 === "" ? r4.path : `${r4.path}?${s2}`;
  613. }
  614. _getCapabilitiesUrl(e2) {
  615. this.url = this.url.split("?")[0];
  616. const t3 = e2 === "KVP" ? `${this.url}?request=GetCapabilities&service=WMTS&version=${this.version}` : `${this.url}/${this.version}/WMTSCapabilities.xml`;
  617. return this._appendCustomParameters(t3);
  618. }
  619. _getLowerCasedUrlParams(e2) {
  620. if (!e2)
  621. return null;
  622. const t3 = j3(e2).query;
  623. if (!t3)
  624. return null;
  625. const r4 = {};
  626. return Object.keys(t3).forEach((e3) => {
  627. r4[e3.toLowerCase()] = t3[e3];
  628. }), r4;
  629. }
  630. _mergeParams(e2, t3) {
  631. const r4 = this._getLowerCasedUrlParams(t3);
  632. if (r4) {
  633. const t4 = Object.keys(r4);
  634. t4.length && (e2 = e2 ? m(e2) : {}, t4.forEach((t5) => {
  635. e2.hasOwnProperty(t5) || W.has(t5) || (e2[t5] = r4[t5]);
  636. }));
  637. }
  638. return e2;
  639. }
  640. };
  641. function F2(e2, t3) {
  642. return e2.map((e3) => {
  643. const r4 = new m2();
  644. return r4.read(e3, t3), r4;
  645. });
  646. }
  647. e([d()], A2.prototype, "dimensionMap", void 0), e([d()], A2.prototype, "layerMap", void 0), e([d({ type: m2, json: { origins: { "web-document": { write: { ignoreOrigin: true } } } } })], A2.prototype, "activeLayer", null), e([o("service", "activeLayer", ["layers"])], A2.prototype, "readActiveLayerFromService", null), e([o(["web-document", "portal-item"], "activeLayer", ["wmtsInfo"])], A2.prototype, "readActiveLayerFromItemOrWebDoc", null), e([r2(["web-document", "portal-item"], "activeLayer", { templateUrl: { type: String }, tileInfo: { type: S }, "wmtsInfo.layerIdentifier": { type: String }, "wmtsInfo.tileMatrixSet": { type: String } })], A2.prototype, "writeActiveLayer", null), e([d({ type: String, value: "", json: { write: true } })], A2.prototype, "copyright", void 0), e([d({ type: ["show", "hide"] })], A2.prototype, "listMode", void 0), e([d({ json: { read: true, write: true } })], A2.prototype, "blendMode", void 0), e([d({ json: { origins: { "web-document": { read: { source: ["wmtsInfo.customParameters", "wmtsInfo.url"] }, write: { target: "wmtsInfo.customParameters" } }, "portal-item": { read: { source: ["wmtsInfo.customParameters", "wmtsInfo.url"] }, write: { target: "wmtsInfo.customParameters" } } } } })], A2.prototype, "customParameters", void 0), e([o(["portal-item", "web-document"], "customParameters")], A2.prototype, "readCustomParameters", null), e([d({ json: { origins: { "web-document": { read: { source: "wmtsInfo.customLayerParameters" }, write: { target: "wmtsInfo.customLayerParameters" } }, "portal-item": { read: { source: "wmtsInfo.customLayerParameters" }, write: { target: "wmtsInfo.customLayerParameters" } } } } })], A2.prototype, "customLayerParameters", void 0), e([d({ type: M, json: { write: { ignoreOrigin: true }, origins: { "web-document": { read: { source: "fullExtent" } }, "portal-item": { read: { source: "fullExtent" } } } } })], A2.prototype, "fullExtent", void 0), e([d({ readOnly: true })], A2.prototype, "fullExtents", null), e([d({ type: ["WebTiledLayer"] })], A2.prototype, "operationalLayerType", void 0), e([d()], A2.prototype, "resourceInfo", void 0), e([d()], A2.prototype, "serviceMode", void 0), e([o(["portal-item", "web-document"], "serviceMode", ["templateUrl"])], A2.prototype, "readServiceMode", null), e([d({ type: j2.ofType(m2) })], A2.prototype, "sublayers", void 0), e([o("service", "sublayers", ["layers"])], A2.prototype, "readSublayersFromService", null), e([d({ readOnly: true })], A2.prototype, "supportedSpatialReferences", null), e([d({ readOnly: true })], A2.prototype, "tilemapCache", null), e([d({ json: { read: { source: "title" } } })], A2.prototype, "title", null), e([d({ json: { read: false }, readOnly: true, value: "wmts" })], A2.prototype, "type", void 0), e([d({ json: { origins: { service: { read: { source: "tileUrl" } }, "web-document": { read: { source: "wmtsInfo.url" }, write: { target: "wmtsInfo.url" } }, "portal-item": { read: { source: "wmtsInfo.url" }, write: { target: "wmtsInfo.url" } } } } })], A2.prototype, "url", null), e([d()], A2.prototype, "version", void 0), A2 = e([n("esri.layers.WMTSLayer")], A2);
  648. var V2 = A2;
  649. export {
  650. V2 as default
  651. };
  652. //# sourceMappingURL=WMTSLayer-S4MQFUPQ.js.map