UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 4.4 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{_ as e}from"../../../../chunks/tslib.es6.js";import{property as t}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{RasterTileContainer as s}from"../../engine/imagery/RasterTileContainer.js";import{BaseImageryTileSubView2D as i}from"./BaseImageryTileSubView2D.js";import{canUseMajorityInterpolationOnDataSource as o}from"../support/util.js";import n from"../../../layers/support/Geometry.js";let a=class extends i{constructor(){super(...arguments),this.type="raster"}attach(){super.attach(),this.container=new s(this._tileInfoView),this.container.isCustomTilingScheme=this._isCustomTilingScheme,this.updateRasterFunctionParameters()}detach(){super.detach(),this.container.removeAllChildren(),this.container=null}canUseWebGLForProcessing(){const{symbolizer:e}=this.layer,t=e.lookup?.colormapLut?.indexedColormap,r=t&&t.length>this._maxIndexedColormapSize;return this.useWebGLForProcessing&&e.canRenderInWebGL&&!r&&!("majority"===this.layer.interpolation&&o(this.layer))}fetchTile(e,t){return this.layer.fetchTile(e.level,e.row,e.col,t)}updateRasterFunctionParameters(){const{clips:e,view:t}=this.layerView;null!=this._geometry&&e.remove(this._geometry);const{raster:r,type:s}=this.layer;if("Function"===r.datasetFormat){const s=r.getClippingGeometry(t.spatialReference);if(s){const t=new n({geometry:s});e.add(t),this._geometry=t}}const{container:i}=this;if("Function"!==r.datasetFormat||"wcs"===s)return i.rasterFunctionChain=null,i.children.forEach((e=>{const{bitmap:t}=e;t&&(t.suspended=!0,t.processed=!1,t.projected&&(t.invalidateTexture(),t.rasterTexture=null))})),void(this._rasterFunctionState="na");const o=this._rasterFunctionState,{rasterFunction:a,primaryRasters:l}=r,c=a.supportsGPU&&(!l||l.rasters.length<=1),u=c?a.flatWebGLFunctionChain:null,{renderer:p}=this.layer,d=!c||!u?.functions.length||"raster-stretch"===p?.type&&p.dynamicRangeAdjustment||!this.canUseWebGLForProcessing();i.rasterFunctionChain=d?null:u;const h=null==a?"na":i.rasterFunctionChain?"gpu":"cpu",m=o===h||"na"===o&&"cpu"===h&&0===u?.functions?.length;i.children.forEach((e=>{const{bitmap:t}=e;t&&(t.suspended=!m,t.processed=!1,t.processedTexture=null)})),this._rasterFunctionState=h}async updateTileSource(e,t){const r=this._getBandIds(),s=this._getLayerInterpolation(),i=this.canUseWebGLForProcessing(),{source:o,globalSymbolizerParams:n,suspended:a,coords:l,resolution:c}=t,u=this.layerView.hasTilingEffects?n:t.symbolizerParams,{bitmap:p}=e;if([p.x,p.y]=l,p.resolution=c,null!=o?.pixelBlock){const e={extent:o.extent,pixelBlock:o.pixelBlock,srcPixelSize:o.srcTilePixelSize};if(p.rawPixelData=e,i)p.source=o.pixelBlock,p.isRendereredSource=!1;else{const t=await this.layer.applyRenderer(e,"stretch"===n?.type?n:void 0);p.source=t,p.isRendereredSource=!0}p.symbolizerParameters=i?u:null,p.transformGrid=i?o.transformGrid:null}else{const e=this.createEmptyTilePixelBlock();p.source=e,p.symbolizerParameters=i?u:null,p.transformGrid=null}p.bandIds=i?r:null,p.width=this._tileInfoView.tileInfo.size[0],p.height=this._tileInfoView.tileInfo.size[1],p.interpolation=s,p.suspended=a,p.invalidateTexture()}async updateTileSymbolizerParameters(e,t){const{local:r,global:s}=t,i=this._getBandIds(),o=this._getLayerInterpolation(),n=this.canUseWebGLForProcessing(),{bitmap:a}=e,{rawPixelData:l}=a;n||null==l?(a.isRendereredSource&&null!=l&&(a.source=l.pixelBlock),a.isRendereredSource=!1):(a.source=await this.layer.applyRenderer(l,"stretch"===s?.type?s:void 0),a.isRendereredSource=!0),a.symbolizerParameters=n?this.layerView.hasTilingEffects?s:r:null,a.bandIds=n?i:null,a.interpolation=o,a.suspended=!1}_getLayerInterpolation(){const{interpolation:e,renderer:t}=this.layer;if(!t)return e;const r=t.type;return"raster-colormap"===r||"unique-value"===r?"nearest":"raster-stretch"===t.type&&null!=t.colorRamp?"bilinear"===e||"cubic"===e?"bilinear":"nearest":e}};e([t()],a.prototype,"container",void 0),e([t()],a.prototype,"layer",void 0),e([t()],a.prototype,"type",void 0),a=e([r("esri.views.2d.layers.imagery.ImageryTileView2D")],a);const l=a;export{l as default};