UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

3 lines (2 loc) 5.7 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import"../../../core/has.js";import{whenOnce as i,watch as r,sync as s}from"../../../core/reactiveUtils.js";import{property as l,subclass as a}from"../../../core/accessorSupport/decorators.js";import{computeSrcResolutions as n,projectDatasetExtent as o}from"../../../layers/raster/functions/rasterProjectionHelper.js";import{LayerView3D as h}from"./LayerView3D.js";import{TiledLayerView3D as m}from"./TiledLayerView3D.js";import u from"../support/flow/FlowSubViewTiles3D.js";import{RasterTile as d}from"../terrain/RasterTile.js";import p from"../../layers/ImageryTileLayerView.js";import{RefreshableLayerView as c}from"../../layers/RefreshableLayerView.js";import{createQueryGeometry as y}from"../../support/drapedUtils.js";import{getWebGLCapabilities as f}from"../../webgl/capabilities.js";let b=class extends(c(m(h(p)))){constructor(){super(...arguments),this._srcResolutions=[],this.type="imagery-tile-3d",this._isAlignedMapTile=!0,this._flowSubView=null,this.ignoresMemoryFactor=!1,this.unloadedMemory=0}initialize(){this.layer.increaseRasterJobHandlerUsage(),null==this.fullExtent&&this.addResolvingPromise(Promise.reject(new t("layerview:spatial-reference-incompatible","The layer extent cannot be projected to the view's spatial reference",{layer:this.layer})));const e=i(()=>this.view?.basemapTerrain?.tilingSchemeLocked).then(()=>{const e=this.view.basemapTerrain.tilingScheme,t=this.layer.tileInfo;this._isAlignedMapTile=["png","png24","png32","jpg","mixed"].includes(t.format)&&e.compatibleWith(t),this.tileInfo=this._isAlignedMapTile?t:e.toTileInfo(),this._srcResolutions=n(this.layer.serviceRasterInfo,this.tileInfo),this.addHandles([r(()=>this.layer.renderer,e=>{this._setSubView(e),this._updatingHandles.addPromise(this.doRefresh())},s),r(()=>[this.layer.interpolation,this.layer.bandIds,this.layer.multidimensionalDefinition,this.layer.multidimensionalSubset,this.layer.rasterFunction,this.timeExtent],()=>this._updatingHandles.addPromise(this.doRefresh()),s)])});this._setSubView(this.layer.renderer),this.addResolvingPromise(e)}destroy(){this.layer.decreaseRasterJobHandlerUsage(),this._flowSubView?.destroy()}get fullExtent(){try{return this.layer.loaded?this._getFullExtent():null}catch{return null}}_setSubView(e){if("wcs"===this.layer.type)return;const t="flow"===e?.type,i=this._flowSubView;t&&null!=i||(i?.destroy(),this._flowSubView=t?new u({layerView:this}):null)}get _blankTile(){const e=document.createElement("canvas"),t=e.getContext("2d"),[i,r]=this.tileInfo.size;return e.width=i,e.height=r,t.clearRect(0,0,i,r),t.getImageData(0,0,i,r)}get _hasFlow(){return null!=this._flowSubView}get imageFormatIsOpaque(){return"jpg"===this.layer.tileInfo.format}get hasMixedImageFormats(){return"mixed"===this.layer.tileInfo.format}get dataLevelRange(){const e=this.layer.tileInfo,t=this.tileInfo.lodAt(0)?.scale,i=e.lodAt(e.lods.length-1)?.scale;return this.levelRangeFromScaleRange(t,i)}get visibleAtCurrentScale(){return this._flowSubView?.visibleAtCurrentScale??this.tilesVisibleAtCurrentScale()}_getFullExtent(){return o(this.layer.serviceRasterInfo,this.view.basemapTerrain?.spatialReference??this.view.spatialReference)}async fetchTile(e,t){const i=this.tileInfo,r=this._canSymbolizeInWebGL(),s={tileInfo:i,requestRawData:r&&!this._hasFlow,signal:t.signal,timeExtent:this.timeExtent,requestAsImageElement:this._isAlignedMapTile,requestProjectedLocalDirections:this._hasFlow,srcResolution:this._srcResolutions[e[0]],noClip:!1},{layer:l}=this,[a,n,o]=e,h=await l.fetchTile(a,n,o,s);if(h instanceof HTMLImageElement)return h;let m=h?.pixelBlock;if(null==m)return this._blankTile;if(!r&&!this._hasFlow&&(m=await l.applyRenderer(h),null==m))return this._blankTile;const u=new d([a,n,o],m,i.size[0],i.size[1]);return r?(u.symbolizerRenderer=l.symbolizer.rendererJSON,u.symbolizerParameters=l.symbolizer.generateWebGLParameters(this._getSymbolizerOptions(a)),u.transformGrid=h.transformGrid,u.bandIds=l.bandIds):(u.isRendereredSource=!0,u.bandIds=null),u.interpolation=l.interpolation,u}_getSymbolizerOptions(e){const t=this.tileInfo.lodAt(e).resolution;return{pixelBlock:null,isGCS:null!=this.view.basemapTerrain?.spatialReference?this.view.basemapTerrain.spatialReference.isGeographic:this.view.spatialReference.isGeographic,resolution:{x:t,y:t},bandIds:this.layer.bandIds}}ensureSymbolizerParameters(e){this._canSymbolizeInWebGL()&&JSON.stringify(e.symbolizerRenderer)!==JSON.stringify(this.layer.symbolizer.rendererJSON)&&(e.symbolizerParameters=this.layer.symbolizer.generateWebGLParameters(this._getSymbolizerOptions(e.lij[0])))}createFetchPopupFeaturesQueryGeometry(e,t){return y(e,t,this.view)}async doRefresh(){this.suspended||(this._flowSubView?.doRefresh(),this.emit("data-changed"))}isUpdating(){return this._flowSubView?.updating??!1}_canSymbolizeInWebGL(){const e=f(),{symbolizer:t}=this.layer,i=t.lookup.colormapLut?.indexedColormap,r=!!this.layer.rasterFunction?.hasClipFunction,s=i&&i.length>4*(e.maxTextureSize||4096);return t.canRenderInWebGL&&!s&&!r}get usedMemory(){return this._flowSubView?.usedMemory??0}get test(){}};e([l()],b.prototype,"fullExtent",null),e([l({readOnly:!0})],b.prototype,"_blankTile",null),e([l()],b.prototype,"_hasFlow",null),e([l({readOnly:!0})],b.prototype,"imageFormatIsOpaque",null),e([l({readOnly:!0})],b.prototype,"hasMixedImageFormats",null),e([l()],b.prototype,"_flowSubView",void 0),e([l({readOnly:!0})],b.prototype,"dataLevelRange",null),e([l({readOnly:!0})],b.prototype,"visibleAtCurrentScale",null),b=e([a("esri.views.3d.layers.ImageryTileLayerView3D")],b);const g=b;export{g as default};