123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- import {
- o
- } from "./chunk-WR32EHFC.js";
- import {
- e as e2
- } from "./chunk-FTI5VP6T.js";
- import {
- a
- } from "./chunk-RMX2AZ4P.js";
- import {
- l,
- w
- } from "./chunk-YIS6BAC3.js";
- import {
- S
- } from "./chunk-RBZL6SRZ.js";
- import {
- U
- } from "./chunk-VNFRAYHO.js";
- import {
- I
- } from "./chunk-VBRY5KJM.js";
- import {
- s as s3
- } from "./chunk-GCDJLKH4.js";
- import {
- d,
- e,
- n2 as n,
- n5 as n2,
- y2 as y,
- y3 as y2
- } from "./chunk-Y3WMVFTW.js";
- import {
- g,
- m as m3,
- p,
- v
- } from "./chunk-ULGDPLM2.js";
- import {
- s,
- s3 as s2
- } from "./chunk-EMJ4ZSM2.js";
- import {
- m as m2
- } from "./chunk-IKP3YN53.js";
- import {
- m2 as m
- } from "./chunk-GZT4BVFP.js";
- // node_modules/@arcgis/core/layers/support/serviceTileInfoProperty.js
- var r = { type: S, json: { origins: { service: { read: { source: ["tileInfo", "minScale", "maxScale", "minLOD", "maxLOD"], reader: n3 } } } } };
- function n3(r2, n5, l3, o3) {
- if (!r2)
- return null;
- const { minScale: i, maxScale: t, minLOD: m4, maxLOD: s4 } = n5;
- if (m4 != null && s4 != null)
- return o3 && o3.ignoreMinMaxLOD ? S.fromJSON(r2) : S.fromJSON({ ...r2, lods: r2.lods.filter(({ level: e3 }) => e3 != null && e3 >= m4 && e3 <= s4) });
- if (i !== 0 && t !== 0) {
- const n6 = (e3) => Math.round(1e4 * e3) / 1e4, l4 = i ? n6(i) : 1 / 0, o4 = t ? n6(t) : -1 / 0;
- return S.fromJSON({ ...r2, lods: r2.lods.filter((e3) => {
- const r3 = n6(e3.scale);
- return r3 <= l4 && r3 >= o4;
- }) });
- }
- return S.fromJSON(r2);
- }
- // node_modules/@arcgis/core/layers/support/Tilemap.js
- var l2 = class {
- constructor() {
- this.location = { left: 0, top: 0, width: 0, height: 0 }, this._allAvailability = "unknown", this.byteSize = 40;
- }
- getAvailability(t, i) {
- if (this._allAvailability !== "unknown")
- return this._allAvailability;
- const e3 = (t - this.location.top) * this.location.width + (i - this.location.left), a2 = e3 % 8, l3 = e3 >> 3, o3 = this._tileAvailabilityBitSet;
- return l3 < 0 || l3 > o3.length ? "unknown" : o3[l3] & 1 << a2 ? "available" : "unavailable";
- }
- _updateFromData(t) {
- const i = this.location.width, e3 = this.location.height;
- let a2 = true, l3 = true;
- const o3 = Math.ceil(i * e3 / 8), n5 = new Uint8Array(o3);
- let r2 = 0;
- for (let s4 = 0; s4 < t.length; s4++) {
- const i2 = s4 % 8;
- t[s4] ? (l3 = false, n5[r2] |= 1 << i2) : a2 = false, i2 === 7 && ++r2;
- }
- l3 ? this._allAvailability = "unavailable" : a2 ? this._allAvailability = "available" : (this._allAvailability = "unknown", this._tileAvailabilityBitSet = n5, this.byteSize += n5.length);
- }
- static fromDefinition(a2, o3) {
- const r2 = a2.service.request || U, { row: s4, col: h, width: c, height: m4 } = a2, d2 = { query: { f: "json" } };
- return o3 = o3 ? { ...d2, ...o3 } : d2, r2(n4(a2), o3).then((t) => t.data).catch((t) => {
- if (t && t.details && t.details.httpStatus === 422)
- return { location: { top: s4, left: h, width: c, height: m4 }, valid: true, data: m(c * m4, 0) };
- throw t;
- }).then((t) => {
- if (t.location && (t.location.top !== s4 || t.location.left !== h || t.location.width !== c || t.location.height !== m4))
- throw new s2("tilemap:location-mismatch", "Tilemap response for different location than requested", { response: t, definition: { top: s4, left: h, width: c, height: m4 } });
- return l2.fromJSON(t);
- });
- }
- static fromJSON(t) {
- l2._validateJSON(t);
- const i = new l2();
- return i.location = Object.freeze(m2(t.location)), i._updateFromData(t.data), Object.freeze(i);
- }
- static _validateJSON(t) {
- if (!t || !t.location)
- throw new s2("tilemap:missing-location", "Location missing from tilemap response");
- if (t.valid === false)
- throw new s2("tilemap:invalid", "Tilemap response was marked as invalid");
- if (!t.data)
- throw new s2("tilemap:missing-data", "Data missing from tilemap response");
- if (!Array.isArray(t.data))
- throw new s2("tilemap:data-mismatch", "Data must be an array of numbers");
- if (t.data.length !== t.location.width * t.location.height)
- throw new s2("tilemap:data-mismatch", "Number of data items does not match width/height of tilemap");
- }
- };
- function o2(t) {
- return `${t.level}/${t.row}/${t.col}/${t.width}/${t.height}`;
- }
- function n4(t) {
- let i;
- if (t.service.type === "vector-tile")
- i = `${t.service.url}/tilemap/${t.level}/${t.row}/${t.col}/${t.width}/${t.height}`;
- else {
- const e4 = t.service.tileServers;
- i = `${e4 && e4.length ? e4[t.row % e4.length] : t.service.url}/tilemap/${t.level}/${t.row}/${t.col}/${t.width}/${t.height}`;
- }
- const e3 = t.service.query;
- return e3 && (i = `${i}?${e3}`), i;
- }
- // node_modules/@arcgis/core/layers/support/TilemapCache.js
- var T;
- var j = s.getLogger("esri.layers.support.TilemapCache");
- var z = T = class extends a(y2) {
- constructor(e3) {
- super(e3), this._pendingTilemapRequests = {}, this._availableLevels = {}, this.levels = 5, this.cacheByteSize = 2 * o.MEGABYTES, this.request = U, this._prefetchingEnabled = true;
- }
- initialize() {
- this._tilemapCache = new e2(this.cacheByteSize), this.own([l(() => {
- const { layer: e3 } = this;
- return [e3?.parsedUrl, e3?.tileServers, e3?.apiKey, e3?.customParameters];
- }, () => this._initializeTilemapDefinition()), l(() => this.layer?.tileInfo?.lods, (e3) => this._initializeAvailableLevels(e3), w)]), this._initializeTilemapDefinition();
- }
- castLevels(e3) {
- return e3 <= 2 ? (j.error("Minimum levels for Tilemap is 3, but got ", e3), 3) : e3;
- }
- get size() {
- return 1 << this.levels;
- }
- fetchTilemap(e3, t, i, r2) {
- if (!this._availableLevels[e3])
- return Promise.reject(new s2("tilemap-cache:level-unavailable", `Level ${e3} is unavailable in the service`));
- const l3 = this._tmpTilemapDefinition, a2 = this._tilemapFromCache(e3, t, i, l3);
- if (a2)
- return Promise.resolve(a2);
- const o3 = r2 && r2.signal;
- return r2 = { ...r2, signal: null }, new Promise((e4, t2) => {
- v(o3, () => t2(m3()));
- const i2 = o2(l3);
- let s4 = this._pendingTilemapRequests[i2];
- if (!s4) {
- s4 = l2.fromDefinition(l3, r2).then((e6) => (this._tilemapCache.put(i2, e6, e6.byteSize), e6));
- const e5 = () => delete this._pendingTilemapRequests[i2];
- this._pendingTilemapRequests[i2] = s4, s4.then(e5, e5);
- }
- s4.then(e4, t2);
- });
- }
- getAvailability(e3, t, i) {
- if (!this._availableLevels[e3])
- return "unavailable";
- const r2 = this._tilemapFromCache(e3, t, i, this._tmpTilemapDefinition);
- return r2 ? r2.getAvailability(t, i) : "unknown";
- }
- fetchAvailability(e3, t, i, r2) {
- return this._availableLevels[e3] ? this.fetchTilemap(e3, t, i, r2).catch((e4) => e4).then((r3) => {
- if (r3 instanceof l2) {
- const l3 = r3.getAvailability(t, i);
- if (l3 === "unavailable")
- throw new s2("tile-map:tile-unavailable", "Tile is not available", { level: e3, row: t, col: i });
- return l3;
- }
- if (g(r3))
- throw r3;
- return "unknown";
- }) : Promise.reject(new s2("tilemap-cache:level-unavailable", `Level ${e3} is unavailable in the service`));
- }
- fetchAvailabilityUpsample(e3, t, i, r2, s4) {
- r2.level = e3, r2.row = t, r2.col = i;
- const l3 = this.layer.tileInfo;
- l3.updateTileInfo(r2);
- const a2 = this.fetchAvailability(e3, t, i, s4).catch((e4) => {
- if (g(e4))
- throw e4;
- if (l3.upsampleTile(r2))
- return this.fetchAvailabilityUpsample(r2.level, r2.row, r2.col, r2);
- throw e4;
- });
- return this._fetchAvailabilityUpsamplePrefetch(r2.id, e3, t, i, s4, a2), a2;
- }
- async _fetchAvailabilityUpsamplePrefetch(e3, t, i, r2, s4, l3) {
- if (!this._prefetchingEnabled)
- return;
- const a2 = `prefetch-${e3}`;
- if (this.handles.has(a2))
- return;
- const o3 = new AbortController();
- l3.then(() => o3.abort(), () => o3.abort());
- let n5 = false;
- const c = { remove() {
- n5 || (n5 = true, o3.abort());
- } };
- if (this.handles.add(c, a2), await y(10, o3.signal).catch(() => {
- }), n5 || (n5 = true, this.handles.remove(a2)), p(o3))
- return;
- const h = { id: e3, level: t, row: i, col: r2 }, m4 = { ...s4, signal: o3.signal }, f = this.layer.tileInfo;
- for (let p2 = 0; T._prefetches.length < T._maxPrefetch && f.upsampleTile(h); ++p2) {
- const e4 = this.fetchAvailability(h.level, h.row, h.col, m4);
- T._prefetches.push(e4);
- const t2 = () => {
- T._prefetches.removeUnordered(e4);
- };
- e4.then(t2, t2);
- }
- }
- _initializeTilemapDefinition() {
- if (!this.layer.parsedUrl)
- return;
- const { parsedUrl: e3, apiKey: t, customParameters: i } = this.layer;
- 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 };
- }
- _tilemapFromCache(e3, t, i, r2) {
- r2.level = e3, r2.row = t - t % this.size, r2.col = i - i % this.size;
- const s4 = o2(r2);
- return this._tilemapCache.get(s4);
- }
- _initializeAvailableLevels(e3) {
- this._availableLevels = {}, e3 && e3.forEach((e4) => this._availableLevels[e4.level] = true);
- }
- get test() {
- const e3 = this;
- return { get prefetchingEnabled() {
- return e3._prefetchingEnabled;
- }, set prefetchingEnabled(t) {
- e3._prefetchingEnabled = t;
- }, hasTilemap: (t, i, r2) => !!e3._tilemapFromCache(t, i, r2, e3._tmpTilemapDefinition) };
- }
- };
- 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);
- export {
- r,
- n3 as n,
- z
- };
- //# sourceMappingURL=chunk-VZFBPND4.js.map
|