chunk-JMD675LG.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. import {
  2. s as s3
  3. } from "./chunk-L372ZBYB.js";
  4. import {
  5. E,
  6. X,
  7. y
  8. } from "./chunk-4VRSV2TU.js";
  9. import {
  10. i
  11. } from "./chunk-FMKGHOGD.js";
  12. import {
  13. p
  14. } from "./chunk-6URTNEGN.js";
  15. import {
  16. o as o2
  17. } from "./chunk-6B2LQBKM.js";
  18. import {
  19. d as d2,
  20. g,
  21. m
  22. } from "./chunk-X7DBH4KK.js";
  23. import {
  24. a
  25. } from "./chunk-RMX2AZ4P.js";
  26. import {
  27. v
  28. } from "./chunk-KHA63LLS.js";
  29. import {
  30. c
  31. } from "./chunk-FGKNEJKJ.js";
  32. import {
  33. f
  34. } from "./chunk-PSV473TI.js";
  35. import {
  36. O
  37. } from "./chunk-I3OBGWNS.js";
  38. import {
  39. n as n2
  40. } from "./chunk-CYI7KFYB.js";
  41. import {
  42. a as a2
  43. } from "./chunk-5LXROFTA.js";
  44. import {
  45. t
  46. } from "./chunk-W72F6AS3.js";
  47. import {
  48. b
  49. } from "./chunk-4DDBH2K5.js";
  50. import {
  51. U
  52. } from "./chunk-VNFRAYHO.js";
  53. import {
  54. I,
  55. Q,
  56. j
  57. } from "./chunk-VBRY5KJM.js";
  58. import {
  59. o
  60. } from "./chunk-ECW2QABR.js";
  61. import {
  62. s as s2
  63. } from "./chunk-GCDJLKH4.js";
  64. import {
  65. k2 as k,
  66. r as r2
  67. } from "./chunk-MRJEICT6.js";
  68. import {
  69. d,
  70. e,
  71. n2 as n
  72. } from "./chunk-Y3WMVFTW.js";
  73. import {
  74. w
  75. } from "./chunk-ULGDPLM2.js";
  76. import {
  77. s3 as s
  78. } from "./chunk-EMJ4ZSM2.js";
  79. import {
  80. r
  81. } from "./chunk-GZT4BVFP.js";
  82. // node_modules/@arcgis/core/layers/TileLayer.js
  83. var W = ["Canvas/World_Dark_Gray_Base", "Canvas/World_Dark_Gray_Reference", "Canvas/World_Light_Gray_Base", "Canvas/World_Light_Gray_Reference", "Elevation/World_Hillshade", "Elevation/World_Hillshade_Dark", "Ocean/World_Ocean_Base", "Ocean/World_Ocean_Reference", "Ocean_Basemap", "Reference/World_Boundaries_and_Places", "Reference/World_Boundaries_and_Places_Alternate", "Reference/World_Transportation", "World_Imagery", "World_Street_Map", "World_Topo_Map"];
  84. var I2 = class extends a2(E(t(c(v(s3(y(p(O(a(n2(i(o2(b))))))))))))) {
  85. constructor(...e2) {
  86. super(...e2), this.listMode = "show", this.isReference = null, this.operationalLayerType = "ArcGISTiledMapServiceLayer", this.resampling = true, this.sourceJSON = null, this.spatialReference = null, this.path = null, this.sublayers = null, this.type = "tile", this.url = null;
  87. }
  88. normalizeCtorArgs(e2, r3) {
  89. return typeof e2 == "string" ? { url: e2, ...r3 } : e2;
  90. }
  91. load(e2) {
  92. const r3 = r(e2) ? e2.signal : null;
  93. return this.addResolvingPromise(this.loadFromPortal({ supportedTypes: ["Map Service"] }, e2).catch(w).then(() => this._fetchService(r3))), Promise.resolve(this);
  94. }
  95. get attributionDataUrl() {
  96. const e2 = this.parsedUrl?.path.toLowerCase();
  97. return e2 && this._getDefaultAttribution(this._getMapName(e2));
  98. }
  99. readSpatialReference(e2, r3) {
  100. return (e2 = e2 || r3.tileInfo && r3.tileInfo.spatialReference) && k.fromJSON(e2);
  101. }
  102. writeSublayers(e2, r3, t2, s4) {
  103. if (!this.loaded || !e2)
  104. return;
  105. const i2 = e2.slice().reverse().flatten(({ sublayers: e3 }) => e3 && e3.toArray().reverse()).toArray(), o3 = [], a3 = { writeSublayerStructure: false, ...s4 };
  106. i2.forEach((e3) => {
  107. const r4 = e3.write({}, a3);
  108. o3.push(r4);
  109. });
  110. o3.some((e3) => Object.keys(e3).length > 1) && (r3.layers = o3);
  111. }
  112. get tileServers() {
  113. return this._getDefaultTileServers(this.parsedUrl.path);
  114. }
  115. castTileServers(e2) {
  116. return Array.isArray(e2) ? e2.map((e3) => j(e3).path) : null;
  117. }
  118. fetchTile(e2, t2, s4, i2 = {}) {
  119. const { signal: o3 } = i2, a3 = this.getTileUrl(e2, t2, s4), l = { responseType: "image", signal: o3, query: { ...this.refreshParameters } };
  120. return U(a3, l).then((e3) => e3.data);
  121. }
  122. getTileUrl(e2, r3, t2) {
  123. const s4 = !this.tilemapCache && this.supportsBlankTile, i2 = I({ ...this.parsedUrl.query, blankTile: !s4 && null, ...this.customParameters, token: this.apiKey }), o3 = this.tileServers;
  124. return `${o3 && o3.length ? o3[r3 % o3.length] : this.parsedUrl.path}/tile/${e2}/${r3}/${t2}${i2 ? "?" + i2 : ""}`;
  125. }
  126. _fetchService(e2) {
  127. return new Promise((s4, o3) => {
  128. if (this.sourceJSON) {
  129. if (this.sourceJSON.bandCount != null && this.sourceJSON.pixelSizeX != null)
  130. throw new s("tile-layer:unsupported-url", "use ImageryTileLayer to open a tiled image service");
  131. return void s4({ data: this.sourceJSON });
  132. }
  133. if (!this.parsedUrl)
  134. throw new s("tile-layer:undefined-url", "layer's url is not defined");
  135. const a3 = m(this.parsedUrl.path);
  136. if (r(a3) && a3.serverType === "ImageServer")
  137. throw new s("tile-layer:unsupported-url", "use ImageryTileLayer to open a tiled image service");
  138. U(this.parsedUrl.path, { query: { f: "json", ...this.parsedUrl.query, ...this.customParameters, token: this.apiKey }, responseType: "json", signal: e2 }).then(s4, o3);
  139. }).then((r3) => {
  140. if (r3.ssl && (this.url = this.url.replace(/^http:/i, "https:")), this.sourceJSON = r3.data, this.read(r3.data, { origin: "service", url: this.parsedUrl }), this.version === 10.1 && !g(this.url))
  141. return this._fetchServerVersion(this.url, e2).then((e3) => {
  142. this.read({ currentVersion: e3 });
  143. }).catch(() => {
  144. });
  145. });
  146. }
  147. _fetchServerVersion(e2, s4) {
  148. if (!d2(e2))
  149. return Promise.reject();
  150. const i2 = e2.replace(/(.*\/rest)\/.*/i, "$1") + "/info";
  151. return U(i2, { query: { f: "json", ...this.customParameters, token: this.apiKey }, responseType: "json", signal: s4 }).then((e3) => {
  152. if (e3.data && e3.data.currentVersion)
  153. return e3.data.currentVersion;
  154. throw new s("tile-layer:version-not-available");
  155. });
  156. }
  157. _getMapName(e2) {
  158. const r3 = e2.match(/^(?:https?:)?\/\/(server\.arcgisonline\.com|services\.arcgisonline\.com|ibasemaps-api\.arcgis\.com)\/arcgis\/rest\/services\/([^\/]+(\/[^\/]+)*)\/mapserver/i);
  159. return r3 && r3[2];
  160. }
  161. _getDefaultAttribution(e2) {
  162. if (!e2)
  163. return;
  164. let r3;
  165. e2 = e2.toLowerCase();
  166. for (let t2 = 0, s4 = W.length; t2 < s4; t2++)
  167. if (r3 = W[t2], r3.toLowerCase().includes(e2))
  168. return Q("//static.arcgis.com/attribution/" + r3);
  169. }
  170. _getDefaultTileServers(e2) {
  171. const r3 = e2.search(/^(?:https?:)?\/\/server\.arcgisonline\.com/i) !== -1, t2 = e2.search(/^(?:https?:)?\/\/services\.arcgisonline\.com/i) !== -1;
  172. return r3 || t2 ? [e2, e2.replace(r3 ? /server\.arcgisonline/i : /services\.arcgisonline/i, r3 ? "services.arcgisonline" : "server.arcgisonline")] : [];
  173. }
  174. get hasOverriddenFetchTile() {
  175. return !this.fetchTile.__isDefault__;
  176. }
  177. };
  178. e([d({ readOnly: true })], I2.prototype, "attributionDataUrl", null), e([d({ type: ["show", "hide", "hide-children"] })], I2.prototype, "listMode", void 0), e([d({ json: { read: true, write: true } })], I2.prototype, "blendMode", void 0), e([d({ type: Boolean, json: { read: false, write: { enabled: true, overridePolicy: () => ({ enabled: false }) } } })], I2.prototype, "isReference", void 0), e([d({ readOnly: true, type: ["ArcGISTiledMapServiceLayer"] })], I2.prototype, "operationalLayerType", void 0), e([d({ type: Boolean })], I2.prototype, "resampling", void 0), e([d()], I2.prototype, "sourceJSON", void 0), e([d({ type: k })], I2.prototype, "spatialReference", void 0), e([o("spatialReference", ["spatialReference", "tileInfo"])], I2.prototype, "readSpatialReference", null), e([d({ type: String, json: { origins: { "web-scene": { read: true, write: true } }, read: false } })], I2.prototype, "path", void 0), e([d({ readOnly: true })], I2.prototype, "sublayers", void 0), e([r2("sublayers", { layers: { type: [X] } })], I2.prototype, "writeSublayers", null), e([d({ json: { read: false, write: false } })], I2.prototype, "popupEnabled", void 0), e([d()], I2.prototype, "tileServers", null), e([s2("tileServers")], I2.prototype, "castTileServers", null), e([d({ readOnly: true, json: { read: false } })], I2.prototype, "type", void 0), e([d(f)], I2.prototype, "url", void 0), I2 = e([n("esri.layers.TileLayer")], I2), I2.prototype.fetchTile.__isDefault__ = true;
  179. var C = I2;
  180. export {
  181. C
  182. };
  183. //# sourceMappingURL=chunk-JMD675LG.js.map