UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 3.91 kB
import{_ as e}from"../../../../chunks/tslib.es6.js";import{isSome as r}from"../../../../core/maybe.js";import{property as t}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{RasterTileContainer as i}from"../../engine/imagery/RasterTileContainer.js";import{BaseImageryTileSubView2D as o}from"./BaseImageryTileSubView2D.js";import{canUseMajorityInterpolationOnDataSource as a}from"../support/util.js";let n=class extends o{constructor(){super(...arguments),this.type="raster"}attach(){super.attach(),this.container=new i(this._tileInfoView),this.container.isCustomTilingScheme=this._isCustomTilingScheme,this.updateRasterFunctionParameters()}detach(){super.detach(),this.container.removeAllChildren(),this.container=null}canUseWebGLForProcessing(){return this.useWebGLForProcessing&&this.layer.symbolizer.canRenderInWebGL&&!("majority"===this.layer.interpolation&&a(this.layer))}fetchTile(e,r){return this.layer.fetchTile(e.level,e.row,e.col,r)}updateRasterFunctionParameters(){const{raster:e,type:r}=this.layer,{container:t}=this;if("Function"!==e.datasetFormat||"wcs"===r)return t.rasterFunctionChain=null,t.children.forEach((e=>{const{bitmap:r}=e;r&&(r.suspended=!0,r.processed=!1,r.projected&&(r.invalidateTexture(),r.rasterTexture=null))})),void(this._rasterFunctionState="na");const s=this._rasterFunctionState,{rasterFunction:i,primaryRasters:o}=e,a=i.supportsGPU&&(!o||o.rasters.length<=1),n=a?i.getFlatWebGLFunctionChain():null,{renderer:l}=this.layer,c=!a||!n?.functions.length||"raster-stretch"===l.type&&l.dynamicRangeAdjustment||!this.canUseWebGLForProcessing();t.rasterFunctionChain=c?null:n;const u=null==i?"na":t.rasterFunctionChain?"gpu":"cpu";t.children.forEach((e=>{const{bitmap:r}=e;r&&(r.suspended=s!==u,r.processed=!1,r.processedTexture=null)})),this._rasterFunctionState=u}async updateTileSource(e,t){const s=this._getBandIds(),i=this._getLayerInterpolation(),o=this.canUseWebGLForProcessing(),{source:a,globalSymbolizerParams:n,suspended:l,coords:c,resolution:u}=t,p=this.layerView.hasTilingEffects?n:t.symbolizerParams,{bitmap:d}=e;if([d.x,d.y]=c,d.resolution=u,a&&r(a)&&r(a.pixelBlock)){const e={extent:a.extent,pixelBlock:a.pixelBlock};if(d.rawPixelData=e,o)d.source=a.pixelBlock,d.isRendereredSource=!1;else{const r=await this.layer.applyRenderer(e,"stretch"===n?.type?n:void 0);d.source=r,d.isRendereredSource=!0}d.symbolizerParameters=o?p:null,o?d.transformGrid||(d.transformGrid=a.transformGrid):d.transformGrid=null}else{const e=this.createEmptyTilePixelBlock();d.source=e,d.symbolizerParameters=o?p:null,d.transformGrid=null}d.bandIds=o?s:null,d.width=this._tileInfoView.tileInfo.size[0],d.height=this._tileInfoView.tileInfo.size[1],d.interpolation=i,d.suspended=l,d.invalidateTexture()}async updateTileSymbolizerParameters(e,t){const{local:s,global:i}=t,o=this._getBandIds(),a=this._getLayerInterpolation(),n=this.canUseWebGLForProcessing(),{bitmap:l}=e,{rawPixelData:c}=l;!n&&r(c)?(l.source=await this.layer.applyRenderer(c,"stretch"===i?.type?i:void 0),l.isRendereredSource=!0):(l.isRendereredSource&&r(c)&&(l.source=c.pixelBlock),l.isRendereredSource=!1),l.symbolizerParameters=n?this.layerView.hasTilingEffects?i:s:null,l.bandIds=n?o:null,l.interpolation=a,l.suspended=!1}_getLayerInterpolation(){const e=this.layer.renderer.type;if("raster-colormap"===e||"unique-value"===e||"class-breaks"===e)return"nearest";const{interpolation:r}=this.layer,{renderer:t}=this.layer;return"raster-stretch"===t.type&&null!=t.colorRamp?"bilinear"===r||"cubic"===r?"bilinear":"nearest":r}};e([t()],n.prototype,"container",void 0),e([t()],n.prototype,"layer",void 0),e([t()],n.prototype,"type",void 0),n=e([s("esri.views.2d.layers.imagery.ImageryTileView2D")],n);const l=n;export{l as default};