chunk-VZFBPND4.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. import {
  2. o
  3. } from "./chunk-WR32EHFC.js";
  4. import {
  5. e as e2
  6. } from "./chunk-FTI5VP6T.js";
  7. import {
  8. a
  9. } from "./chunk-RMX2AZ4P.js";
  10. import {
  11. l,
  12. w
  13. } from "./chunk-YIS6BAC3.js";
  14. import {
  15. S
  16. } from "./chunk-RBZL6SRZ.js";
  17. import {
  18. U
  19. } from "./chunk-VNFRAYHO.js";
  20. import {
  21. I
  22. } from "./chunk-VBRY5KJM.js";
  23. import {
  24. s as s3
  25. } from "./chunk-GCDJLKH4.js";
  26. import {
  27. d,
  28. e,
  29. n2 as n,
  30. n5 as n2,
  31. y2 as y,
  32. y3 as y2
  33. } from "./chunk-Y3WMVFTW.js";
  34. import {
  35. g,
  36. m as m3,
  37. p,
  38. v
  39. } from "./chunk-ULGDPLM2.js";
  40. import {
  41. s,
  42. s3 as s2
  43. } from "./chunk-EMJ4ZSM2.js";
  44. import {
  45. m as m2
  46. } from "./chunk-IKP3YN53.js";
  47. import {
  48. m2 as m
  49. } from "./chunk-GZT4BVFP.js";
  50. // node_modules/@arcgis/core/layers/support/serviceTileInfoProperty.js
  51. var r = { type: S, json: { origins: { service: { read: { source: ["tileInfo", "minScale", "maxScale", "minLOD", "maxLOD"], reader: n3 } } } } };
  52. function n3(r2, n5, l3, o3) {
  53. if (!r2)
  54. return null;
  55. const { minScale: i, maxScale: t, minLOD: m4, maxLOD: s4 } = n5;
  56. if (m4 != null && s4 != null)
  57. return o3 && o3.ignoreMinMaxLOD ? S.fromJSON(r2) : S.fromJSON({ ...r2, lods: r2.lods.filter(({ level: e3 }) => e3 != null && e3 >= m4 && e3 <= s4) });
  58. if (i !== 0 && t !== 0) {
  59. const n6 = (e3) => Math.round(1e4 * e3) / 1e4, l4 = i ? n6(i) : 1 / 0, o4 = t ? n6(t) : -1 / 0;
  60. return S.fromJSON({ ...r2, lods: r2.lods.filter((e3) => {
  61. const r3 = n6(e3.scale);
  62. return r3 <= l4 && r3 >= o4;
  63. }) });
  64. }
  65. return S.fromJSON(r2);
  66. }
  67. // node_modules/@arcgis/core/layers/support/Tilemap.js
  68. var l2 = class {
  69. constructor() {
  70. this.location = { left: 0, top: 0, width: 0, height: 0 }, this._allAvailability = "unknown", this.byteSize = 40;
  71. }
  72. getAvailability(t, i) {
  73. if (this._allAvailability !== "unknown")
  74. return this._allAvailability;
  75. const e3 = (t - this.location.top) * this.location.width + (i - this.location.left), a2 = e3 % 8, l3 = e3 >> 3, o3 = this._tileAvailabilityBitSet;
  76. return l3 < 0 || l3 > o3.length ? "unknown" : o3[l3] & 1 << a2 ? "available" : "unavailable";
  77. }
  78. _updateFromData(t) {
  79. const i = this.location.width, e3 = this.location.height;
  80. let a2 = true, l3 = true;
  81. const o3 = Math.ceil(i * e3 / 8), n5 = new Uint8Array(o3);
  82. let r2 = 0;
  83. for (let s4 = 0; s4 < t.length; s4++) {
  84. const i2 = s4 % 8;
  85. t[s4] ? (l3 = false, n5[r2] |= 1 << i2) : a2 = false, i2 === 7 && ++r2;
  86. }
  87. l3 ? this._allAvailability = "unavailable" : a2 ? this._allAvailability = "available" : (this._allAvailability = "unknown", this._tileAvailabilityBitSet = n5, this.byteSize += n5.length);
  88. }
  89. static fromDefinition(a2, o3) {
  90. const r2 = a2.service.request || U, { row: s4, col: h, width: c, height: m4 } = a2, d2 = { query: { f: "json" } };
  91. return o3 = o3 ? { ...d2, ...o3 } : d2, r2(n4(a2), o3).then((t) => t.data).catch((t) => {
  92. if (t && t.details && t.details.httpStatus === 422)
  93. return { location: { top: s4, left: h, width: c, height: m4 }, valid: true, data: m(c * m4, 0) };
  94. throw t;
  95. }).then((t) => {
  96. if (t.location && (t.location.top !== s4 || t.location.left !== h || t.location.width !== c || t.location.height !== m4))
  97. throw new s2("tilemap:location-mismatch", "Tilemap response for different location than requested", { response: t, definition: { top: s4, left: h, width: c, height: m4 } });
  98. return l2.fromJSON(t);
  99. });
  100. }
  101. static fromJSON(t) {
  102. l2._validateJSON(t);
  103. const i = new l2();
  104. return i.location = Object.freeze(m2(t.location)), i._updateFromData(t.data), Object.freeze(i);
  105. }
  106. static _validateJSON(t) {
  107. if (!t || !t.location)
  108. throw new s2("tilemap:missing-location", "Location missing from tilemap response");
  109. if (t.valid === false)
  110. throw new s2("tilemap:invalid", "Tilemap response was marked as invalid");
  111. if (!t.data)
  112. throw new s2("tilemap:missing-data", "Data missing from tilemap response");
  113. if (!Array.isArray(t.data))
  114. throw new s2("tilemap:data-mismatch", "Data must be an array of numbers");
  115. if (t.data.length !== t.location.width * t.location.height)
  116. throw new s2("tilemap:data-mismatch", "Number of data items does not match width/height of tilemap");
  117. }
  118. };
  119. function o2(t) {
  120. return `${t.level}/${t.row}/${t.col}/${t.width}/${t.height}`;
  121. }
  122. function n4(t) {
  123. let i;
  124. if (t.service.type === "vector-tile")
  125. i = `${t.service.url}/tilemap/${t.level}/${t.row}/${t.col}/${t.width}/${t.height}`;
  126. else {
  127. const e4 = t.service.tileServers;
  128. i = `${e4 && e4.length ? e4[t.row % e4.length] : t.service.url}/tilemap/${t.level}/${t.row}/${t.col}/${t.width}/${t.height}`;
  129. }
  130. const e3 = t.service.query;
  131. return e3 && (i = `${i}?${e3}`), i;
  132. }
  133. // node_modules/@arcgis/core/layers/support/TilemapCache.js
  134. var T;
  135. var j = s.getLogger("esri.layers.support.TilemapCache");
  136. var z = T = class extends a(y2) {
  137. constructor(e3) {
  138. super(e3), this._pendingTilemapRequests = {}, this._availableLevels = {}, this.levels = 5, this.cacheByteSize = 2 * o.MEGABYTES, this.request = U, this._prefetchingEnabled = true;
  139. }
  140. initialize() {
  141. this._tilemapCache = new e2(this.cacheByteSize), this.own([l(() => {
  142. const { layer: e3 } = this;
  143. return [e3?.parsedUrl, e3?.tileServers, e3?.apiKey, e3?.customParameters];
  144. }, () => this._initializeTilemapDefinition()), l(() => this.layer?.tileInfo?.lods, (e3) => this._initializeAvailableLevels(e3), w)]), this._initializeTilemapDefinition();
  145. }
  146. castLevels(e3) {
  147. return e3 <= 2 ? (j.error("Minimum levels for Tilemap is 3, but got ", e3), 3) : e3;
  148. }
  149. get size() {
  150. return 1 << this.levels;
  151. }
  152. fetchTilemap(e3, t, i, r2) {
  153. if (!this._availableLevels[e3])
  154. return Promise.reject(new s2("tilemap-cache:level-unavailable", `Level ${e3} is unavailable in the service`));
  155. const l3 = this._tmpTilemapDefinition, a2 = this._tilemapFromCache(e3, t, i, l3);
  156. if (a2)
  157. return Promise.resolve(a2);
  158. const o3 = r2 && r2.signal;
  159. return r2 = { ...r2, signal: null }, new Promise((e4, t2) => {
  160. v(o3, () => t2(m3()));
  161. const i2 = o2(l3);
  162. let s4 = this._pendingTilemapRequests[i2];
  163. if (!s4) {
  164. s4 = l2.fromDefinition(l3, r2).then((e6) => (this._tilemapCache.put(i2, e6, e6.byteSize), e6));
  165. const e5 = () => delete this._pendingTilemapRequests[i2];
  166. this._pendingTilemapRequests[i2] = s4, s4.then(e5, e5);
  167. }
  168. s4.then(e4, t2);
  169. });
  170. }
  171. getAvailability(e3, t, i) {
  172. if (!this._availableLevels[e3])
  173. return "unavailable";
  174. const r2 = this._tilemapFromCache(e3, t, i, this._tmpTilemapDefinition);
  175. return r2 ? r2.getAvailability(t, i) : "unknown";
  176. }
  177. fetchAvailability(e3, t, i, r2) {
  178. return this._availableLevels[e3] ? this.fetchTilemap(e3, t, i, r2).catch((e4) => e4).then((r3) => {
  179. if (r3 instanceof l2) {
  180. const l3 = r3.getAvailability(t, i);
  181. if (l3 === "unavailable")
  182. throw new s2("tile-map:tile-unavailable", "Tile is not available", { level: e3, row: t, col: i });
  183. return l3;
  184. }
  185. if (g(r3))
  186. throw r3;
  187. return "unknown";
  188. }) : Promise.reject(new s2("tilemap-cache:level-unavailable", `Level ${e3} is unavailable in the service`));
  189. }
  190. fetchAvailabilityUpsample(e3, t, i, r2, s4) {
  191. r2.level = e3, r2.row = t, r2.col = i;
  192. const l3 = this.layer.tileInfo;
  193. l3.updateTileInfo(r2);
  194. const a2 = this.fetchAvailability(e3, t, i, s4).catch((e4) => {
  195. if (g(e4))
  196. throw e4;
  197. if (l3.upsampleTile(r2))
  198. return this.fetchAvailabilityUpsample(r2.level, r2.row, r2.col, r2);
  199. throw e4;
  200. });
  201. return this._fetchAvailabilityUpsamplePrefetch(r2.id, e3, t, i, s4, a2), a2;
  202. }
  203. async _fetchAvailabilityUpsamplePrefetch(e3, t, i, r2, s4, l3) {
  204. if (!this._prefetchingEnabled)
  205. return;
  206. const a2 = `prefetch-${e3}`;
  207. if (this.handles.has(a2))
  208. return;
  209. const o3 = new AbortController();
  210. l3.then(() => o3.abort(), () => o3.abort());
  211. let n5 = false;
  212. const c = { remove() {
  213. n5 || (n5 = true, o3.abort());
  214. } };
  215. if (this.handles.add(c, a2), await y(10, o3.signal).catch(() => {
  216. }), n5 || (n5 = true, this.handles.remove(a2)), p(o3))
  217. return;
  218. const h = { id: e3, level: t, row: i, col: r2 }, m4 = { ...s4, signal: o3.signal }, f = this.layer.tileInfo;
  219. for (let p2 = 0; T._prefetches.length < T._maxPrefetch && f.upsampleTile(h); ++p2) {
  220. const e4 = this.fetchAvailability(h.level, h.row, h.col, m4);
  221. T._prefetches.push(e4);
  222. const t2 = () => {
  223. T._prefetches.removeUnordered(e4);
  224. };
  225. e4.then(t2, t2);
  226. }
  227. }
  228. _initializeTilemapDefinition() {
  229. if (!this.layer.parsedUrl)
  230. return;
  231. const { parsedUrl: e3, apiKey: t, customParameters: i } = this.layer;
  232. this._tilemapCache.clear(), this._tmpTilemapDefinition = { service: { url: e3.path, query: I({ ...e3.query, ...i, token: t ?? e3.query?.token }), tileServers: this.layer.tileServers, request: this.request, type: this.layer.type }, width: this.size, height: this.size, level: 0, row: 0, col: 0 };
  233. }
  234. _tilemapFromCache(e3, t, i, r2) {
  235. r2.level = e3, r2.row = t - t % this.size, r2.col = i - i % this.size;
  236. const s4 = o2(r2);
  237. return this._tilemapCache.get(s4);
  238. }
  239. _initializeAvailableLevels(e3) {
  240. this._availableLevels = {}, e3 && e3.forEach((e4) => this._availableLevels[e4.level] = true);
  241. }
  242. get test() {
  243. const e3 = this;
  244. return { get prefetchingEnabled() {
  245. return e3._prefetchingEnabled;
  246. }, set prefetchingEnabled(t) {
  247. e3._prefetchingEnabled = t;
  248. }, hasTilemap: (t, i, r2) => !!e3._tilemapFromCache(t, i, r2, e3._tmpTilemapDefinition) };
  249. }
  250. };
  251. z._maxPrefetch = 4, z._prefetches = new n2({ initialSize: T._maxPrefetch }), e([d({ constructOnly: true, type: Number })], z.prototype, "levels", void 0), e([s3("levels")], z.prototype, "castLevels", null), e([d({ readOnly: true, type: Number })], z.prototype, "size", null), e([d({ constructOnly: true, type: Number })], z.prototype, "cacheByteSize", void 0), e([d({ constructOnly: true })], z.prototype, "layer", void 0), e([d({ constructOnly: true })], z.prototype, "request", void 0), z = T = e([n("esri.layers.support.TilemapCache")], z);
  252. export {
  253. r,
  254. n3 as n,
  255. z
  256. };
  257. //# sourceMappingURL=chunk-VZFBPND4.js.map