chunk-KTSVAGSV.js 10 KB

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