Custom Gis Application with Arcgis Javascript API with modern layouting
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

13 lines
4.7 KiB

// All material copyright Esri, All Rights Reserved, unless otherwise specified.
// See https://js.arcgis.com/4.30/esri/copyright.txt for details.
//>>built
define("exports ../../chunks/tslib.es6 ../../request ../../core/Accessor ../../core/ByteSizeUnit ../../core/Error ../../core/handleUtils ../../core/has ../../core/LRUCache ../../core/PooledArray ../../core/promiseUtils ../../core/reactiveUtils ../../core/scheduling ../../core/urlUtils ../../core/accessorSupport/decorators/property ../../core/Logger ../../core/RandomLCG ../../core/accessorSupport/decorators/subclass ./TileKey ./Tilemap".split(" "),function(g,p,y,z,A,u,B,I,C,D,q,w,E,F,r,J,K,G,H,t){var n;
g.TilemapCache=n=class extends z{constructor(a){super(a);this._pendingTilemapRequests={};this.request=y;this.size=32;this._prefetchingEnabled=!0}initialize(){this._tilemapCache=new C.LRUCache(2*A.ByteSizeUnit.MEGABYTES);this.addHandles(w.watch(()=>{const {layer:a}=this;return[a?.parsedUrl,a?.tileServers,a?.apiKey,a?.customParameters]},()=>this._initializeTilemapDefinition(),w.initial))}get effectiveMinLOD(){return this.minLOD??this.layer.tileInfo.lods[0].level}get effectiveMaxLOD(){return this.maxLOD??
this.layer.tileInfo.lods[this.layer.tileInfo.lods.length-1].level}getAvailability(a,c,d){return!this.layer.tileInfo.lodAt(a)||a<this.effectiveMinLOD||a>this.effectiveMaxLOD?"unavailable":(a=this._tilemapFromCache(a,c,d,this._tmpTilemapDefinition))?a.getAvailability(c,d):"unknown"}fetchAvailability(a,c,d,b){return!this.layer.tileInfo.lodAt(a)||a<this.effectiveMinLOD||a>this.effectiveMaxLOD?Promise.reject(new u("tile-map:tile-unavailable","Tile is not available",{level:a,row:c,col:d})):this._fetchTilemap(a,
c,d,b).catch(e=>e).then(e=>{if(e instanceof t.Tilemap){e=e.getAvailability(c,d);if("unavailable"===e)throw new u("tile-map:tile-unavailable","Tile is not available",{level:a,row:c,col:d});return e}if(q.isAbortError(e))throw e;return"unknown"})}fetchAvailabilityUpsample(a,c,d,b,e){b.level=a;b.row=c;b.col=d;const l=this.layer.tileInfo;l.updateTileInfo(b);const m=this.fetchAvailability(a,c,d,e).catch(f=>{if(q.isAbortError(f))throw f;if(l.upsampleTile(b))return this.fetchAvailabilityUpsample(b.level,
b.row,b.col,b,e);throw f;});this._fetchAvailabilityUpsamplePrefetch(b.id,a,c,d,e,m);return m}async _fetchAvailabilityUpsamplePrefetch(a,c,d,b,e,l){if(this._prefetchingEnabled&&null!=a){var m=`prefetch-${a}`;if(!this.hasHandles(m)){var f=new AbortController;l.then(()=>f.abort(),()=>f.abort());var h=!1;l=B.makeHandle(()=>{h||(h=!0,f.abort())});this.addHandles(l,m);await E.waitTicks(10,f.signal).catch(()=>{});h||(h=!0,this.removeHandles(m));if(!q.isAborted(f))for(a=new H.TileKey(a,c,d,b),e={...e,signal:f.signal},
c=this.layer.tileInfo,d=0;n._prefetches.length<n._maxPrefetch&&c.upsampleTile(a);++d){const k=this.fetchAvailability(a.level,a.row,a.col,e);n._prefetches.push(k);b=()=>{n._prefetches.removeUnordered(k)};k.then(b,b)}}}}_fetchTilemap(a,c,d,b){if(!this.layer.tileInfo.lodAt(a)||a<this.effectiveMinLOD||a>this.effectiveMaxLOD)return Promise.reject(new u("tilemap-cache:level-unavailable",`Level ${a} is unavailable in the service`));const e=this._tmpTilemapDefinition;if(a=this._tilemapFromCache(a,c,d,e))return Promise.resolve(a);
const l=b?.signal;b={...b,signal:null};return new Promise((m,f)=>{q.onAbort(l,()=>f(q.createAbortError()));const h=t.tilemapDefinitionId(e);let k=this._pendingTilemapRequests[h];if(!k){k=t.Tilemap.fromDefinition(e,b).then(v=>{this._tilemapCache.put(h,v,v.byteSize);return v});const x=()=>{delete this._pendingTilemapRequests[h]};this._pendingTilemapRequests[h]=k;k.then(x,x)}k.then(m,f)})}_initializeTilemapDefinition(){if(this.layer.parsedUrl){var {parsedUrl:a,apiKey:c,customParameters:d}=this.layer;
this._tilemapCache.clear();this._tmpTilemapDefinition={service:{url:a.path,query:F.objectToQuery({...a.query,...d,token:c??a.query?.token}),tileServers:this.layer.tileServers,request:this.request},width:this.size,height:this.size,level:0,row:0,col:0}}}_tilemapFromCache(a,c,d,b){b.level=a;b.row=c-c%this.size;b.col=d-d%this.size;a=t.tilemapDefinitionId(b);return this._tilemapCache.get(a)}get test(){}};g.TilemapCache._maxPrefetch=4;g.TilemapCache._prefetches=new D({initialSize:n._maxPrefetch});p.__decorate([r.property({constructOnly:!0})],
g.TilemapCache.prototype,"layer",void 0);p.__decorate([r.property({constructOnly:!0})],g.TilemapCache.prototype,"minLOD",void 0);p.__decorate([r.property({constructOnly:!0})],g.TilemapCache.prototype,"maxLOD",void 0);p.__decorate([r.property({constructOnly:!0})],g.TilemapCache.prototype,"request",void 0);p.__decorate([r.property({constructOnly:!0})],g.TilemapCache.prototype,"size",void 0);g.TilemapCache=n=p.__decorate([G.subclass("esri.layers.support.TilemapCache")],g.TilemapCache);Object.defineProperty(g,
Symbol.toStringTag,{value:"Module"})});