2 lines
50 KiB
JavaScript
2 lines
50 KiB
JavaScript
import{eA as R,ez as F,eC as fe,eD as O,eE as B,eG as ge,eO as _e,a3 as ae,M as A,N as H,eL as ne,gD as ye,A as d,B as p,C,bk as xe,i9 as be,eM as ve,t as J,ab as Te,eH as we,q as Pe,y as Se,c3 as Y,aH as Re,v as I,z as U,a2 as Ie,D as G,bj as Ue,s as K,K as oe,et as $e,P as Fe}from"./index-b5c8f851.js";import{o as X}from"./multidimensionalUtils-bffdf14d.js";import{f as Ce,d as ze,h as Me}from"./RasterVFDisplayObject-d868527b.js";import{m as Ve,u as Be}from"./LayerView-c5a0067c.js";import{i as Le}from"./Container-f991c035.js";import{L as q,P as Ge,G as ke,U as De,D as Ee,R as L,O as Z}from"./enums-bdecffa2.js";import{m as Oe,c as Ae,l as ee,O as S,E as b,p as j,T as qe,A as je,_ as We,h as Ne,g as Qe}from"./rasterUtils-b491b95a.js";import{e as He,T as Je}from"./Texture-507d5ea8.js";import{c as $}from"./definitions-1467ba4a.js";import{e as Ye,a as te}from"./WGLContainer-21aabd6b.js";import{E as Ke}from"./FramebufferObject-4be671ef.js";import{r as le}from"./TiledDisplayObject-a2315f25.js";import{T as D}from"./color-0916c686.js";import{i as ue}from"./TileContainer-1c596b67.js";import{u as Xe,S as Ze}from"./dataUtils-c2b057a0.js";import{g as se,a as re,u as et,i as tt}from"./RawBlockCache-63593c2d.js";import{D as st,a as rt,s as ie,v as it}from"./rasterProjectionHelper-68eba0c9.js";import{r as ce}from"./util-a6af6461.js";import{p as at}from"./popupUtils-8fdcef26.js";import{a as nt}from"./RefreshableLayerView-4421c564.js";import"./ProgramTemplate-a9187eb2.js";import"./VertexElementDescriptor-2925c6af.js";import"./scaleUtils-7ebacf58.js";import"./GeometryUtils-7a7937c3.js";import"./StyleDefinition-29c49b98.js";import"./enums-f1a6a48a.js";import"./config-1337d16e.js";import"./earcut-d423749e.js";import"./featureConversionUtils-6aca8295.js";import"./OptimizedGeometry-d94e541f.js";import"./OptimizedFeatureSet-1d1ac4b9.js";const ot={bandCount:3,outMin:0,outMax:1,minCutOff:[0,0,0],maxCutOff:[255,255,255],factor:[1/255,1/255,1/255],useGamma:!1,gamma:[1,1,1],gammaCorrection:[1,1,1],colormap:null,colormapOffset:null,stretchType:"none",type:"stretch"};let lt=class extends Le{constructor(e=null,t=null,r=null){super(),this._textureInvalidated=!0,this._colormapTextureInvalidated=!0,this._rasterTexture=null,this._rasterTextureBandIds=null,this._transformGridTexture=null,this._colormapTexture=null,this._colormap=null,this._supportsBilinearTexture=!0,this._processedTexture=null,this.functionTextures=[],this.projected=!1,this.stencilRef=0,this.coordScale=[1,1],this._processed=!1,this._symbolizerParameters=null,this.height=null,this.isRendereredSource=!1,this.pixelRatio=1,this.resolution=0,this.rotation=0,this._source=null,this.rawPixelData=null,this._suspended=!1,this._bandIds=null,this._interpolation=null,this._transformGrid=null,this.width=null,this.x=0,this.y=0,this.source=e,this.transformGrid=t,this.interpolation=r}destroy(){this._disposeTextures()}get processedTexture(){return this._processedTexture}set processedTexture(e){this._processedTexture!==e&&(this._disposeTextures(!0),this._processedTexture=e)}get rasterTexture(){return this._rasterTexture}set rasterTexture(e){var t;this._rasterTexture!==e&&((t=this._rasterTexture)==null||t.dispose(),this._rasterTexture=e),e==null&&(this.projected=!1)}get processed(){return this._processed}set processed(e){this._processed=e,e||(R(this.processedTexture),this.invalidateTexture())}get symbolizerParameters(){return this._symbolizerParameters||ot}set symbolizerParameters(e){this._symbolizerParameters!==e&&(this._symbolizerParameters=e,this._colormapTextureInvalidated=!0,this.commonUniforms=null)}get source(){return this._source}set source(e){this._source!==e&&(this._source=e,this._rasterTexture&&(this._rasterTexture.dispose(),this._rasterTexture=null,this._rasterTextureBandIds=null),this.commonUniforms=null,this.projected=!1,this.invalidateTexture())}get suspended(){return this._suspended}set suspended(e){this._suspended&&!e&&this.stage&&(this.ready(),this.requestRender()),this._suspended=e}get bandIds(){return this._bandIds}set bandIds(e){this._bandIds=e,this._isBandIdschanged(e)&&(this.projected=!1,this.invalidateTexture())}get interpolation(){return this._interpolation||"nearest"}set interpolation(e){this._interpolation=e,this._rasterTexture&&this._rasterTexture.setSamplingMode(this._getTextureSamplingMethod(e||"nearest")==="bilinear"?q.LINEAR:q.NEAREST)}get transformGrid(){return this._transformGrid}set transformGrid(e){this._transformGrid!==e&&(this._transformGrid=e,this._transformGridTexture=R(this._transformGridTexture))}invalidateTexture(){this._textureInvalidated||(this._textureInvalidated=!0,this.requestRender())}getRasterTextureSize(e=!1){var r,i;const t=e||this.projected;return[t?this.width:((r=this.source)==null?void 0:r.width)||this.width,t?this.height:((i=this.source)==null?void 0:i.height)||this.height]}getRasterCellSize(){var i;const e=(i=this.rawPixelData)==null?void 0:i.srcPixelSize,{projected:t,resolution:r}=this;return e&&!t?[e.x,e.y]:[r,r]}_createTransforms(){return{dvs:F()}}setTransform(e){const t=fe(this.transforms.dvs),[r,i]=e.toScreenNoRotation([0,0],[this.x,this.y]),a=this.resolution/this.pixelRatio/e.resolution,n=a*this.width,o=a*this.height,l=Math.PI*this.rotation/180;O(t,t,B(r,i)),O(t,t,B(n/2,o/2)),ge(t,t,-l),O(t,t,B(-n/2,-o/2)),_e(t,t,B(n,o)),ae(this.transforms.dvs,e.displayViewMat3,t)}getTextures({forProcessing:e=!1,useProcessedTexture:t=!1}={}){const r=t?this._processedTexture??this._rasterTexture:this._rasterTexture,i=[],a=[];return r?(this._transformGridTexture&&!this.projected&&(a.push(this._transformGridTexture),i.push("u_transformGrid")),t?(a.push(r),i.push("u_image"),this._colormapTexture&&(a.push(this._colormapTexture),i.push("u_colormap")),{names:i,textures:a}):(a.push(r),i.push("u_image"),this._colormapTexture&&!e&&(a.push(this._colormapTexture),i.push("u_colormap")),{names:i,textures:a})):{names:i,textures:a}}onAttach(){this.invalidateTexture()}onDetach(){this.invalidateTexture()}updateTexture({context:e}){if(!this.stage)return void this._disposeTextures();const t=this._isValidSource(this.source);t&&this._colormapTextureInvalidated&&(this._colormapTextureInvalidated=!1,this._updateColormapTexture(e)),this._textureInvalidated&&(this._textureInvalidated=!1,this._createOrDestroyRasterTexture(e),this._rasterTexture&&(t?this.transformGrid&&!this._transformGridTexture&&(this._transformGridTexture=Oe(e,this.transformGrid)):this._rasterTexture.setData(null)),this.suspended||(this.ready(),this.requestRender()))}updateProcessedTexture(){const{functionTextures:e}=this;e.length!==0&&(this.processedTexture=e.shift(),e.forEach(t=>t==null?void 0:t.dispose()),e.length=0)}_createOrDestroyRasterTexture(e){var n,o,l;const t=(n=this.source)==null?void 0:n.extractBands(this.bandIds);if(!this._isValidSource(t))return void(this._rasterTexture&&(this._rasterTexture.dispose(),this._rasterTextureBandIds=null,this._rasterTexture=null));const r=!this._isBandIdschanged(this.bandIds);if(this._rasterTexture){if(r)return;this._rasterTexture.dispose(),this._rasterTextureBandIds=null,this._rasterTexture=null}this._supportsBilinearTexture=!!((o=e.capabilities.textureFloat)!=null&&o.textureFloatLinear);const i=this._getTextureSamplingMethod(this.interpolation),a=this.isRendereredSource||!((l=e.capabilities.textureFloat)!=null&&l.textureFloat);this._rasterTexture=Ae(e,t,i,a),this.projected=!1,this._processed=!1,this._rasterTextureBandIds=this.bandIds?[...this.bandIds]:null}_isBandIdschanged(e){const t=this._rasterTextureBandIds;return!(t==null&&e==null||t&&e&&t.join("")===e.join(""))}_isValidSource(e){var t;return e!=null&&((t=e.pixels)==null?void 0:t.length)>0}_getTextureSamplingMethod(e){const{type:t}=this.symbolizerParameters,r=t==="lut"||t==="hillshade"||t==="stretch"&&this.symbolizerParameters.bandCount===1;return!this._supportsBilinearTexture||r||e!=="bilinear"&&e!=="cubic"?"nearest":"bilinear"}_updateColormapTexture(e){const t=this._colormap,r=this.symbolizerParameters.colormap;return r?t?r.length!==t.length||r.some((i,a)=>i!==t[a])?(this._colormapTexture&&(this._colormapTexture.dispose(),this._colormapTexture=null),this._colormapTexture=ee(e,r),void(this._colormap=r)):void 0:(this._colormapTexture=ee(e,r),void(this._colormap=r)):(this._colormapTexture&&(this._colormapTexture.dispose(),this._colormapTexture=null),void(this._colormap=null))}_disposeTextures(e=!1){!this._transformGridTexture||e&&!this.projected||(this._transformGridTexture.dispose(),this._transformGridTexture=null),!e&&this._colormapTexture&&(this._colormapTexture.dispose(),this._colormapTexture=null,this._colormap=null,this._colormapTextureInvalidated=!0),!e&&this._rasterTexture&&(this._rasterTexture.dispose(),this._rasterTexture=null,this._rasterTextureBandIds=null),this._processedTexture&&(this._processedTexture.dispose(),this._processedTexture=null)}};function ut(s){return s.source!=null}function W(s){const e=[];return s&&(e.push("applyProjection"),s.spacing[0]===1&&e.push("lookupProjection")),e}function he(s,e,t){var a;const r=!((a=t.capabilities.textureFloat)!=null&&a.textureFloatLinear),i=[];return s==="cubic"?i.push("bicubic"):s==="bilinear"&&(e?(i.push("bilinear"),i.push("nnedge")):r&&i.push("bilinear")),i}const ct={vsPath:"raster/common",fsPath:"raster/lut",attributes:new Map([["a_position",0],["a_texcoord",1]])};function ht(s,e,t){const r=t?[]:W(e.transformGrid);return{defines:r,program:s.painter.materialManager.getProgram(ct,r)}}function dt(s,e,t,r,i=!1){const{names:a,textures:n}=t.getTextures({useProcessedTexture:i});S(s.context,e,a,n),b(e,r,t.commonUniforms),e.setUniformMatrix3fv("u_dvsMat3",t.transforms.dvs);const{colormap:o,colormapOffset:l}=t.symbolizerParameters,u=j(o,l);b(e,r,u)}const mt={createProgram:ht,bindTextureAndUniforms:dt},pt={vsPath:"raster/common",fsPath:"raster/hillshade",attributes:new Map([["a_position",0],["a_texcoord",1]])};function ft(s,e,t){const{colormap:r}=e.symbolizerParameters,i=[...t?[]:W(e.transformGrid),...he(e.interpolation,!0,s.context)];return r!=null&&i.push("applyColormap"),{defines:i,program:s.painter.materialManager.getProgram(pt,i)}}function gt(s,e,t,r,i=!1){const{names:a,textures:n}=t.getTextures({useProcessedTexture:i});S(s.context,e,a,n),b(e,r,t.commonUniforms),e.setUniformMatrix3fv("u_dvsMat3",t.transforms.dvs);const o=t.symbolizerParameters,{colormap:l,colormapOffset:u}=o;if(l!=null){const m=j(l,u);b(e,r,m)}const h=qe(o);b(e,r,h)}const _t={createProgram:ft,bindTextureAndUniforms:gt},yt={vsPath:"raster/common",fsPath:"raster/stretch",attributes:new Map([["a_position",0],["a_texcoord",1]])};function xt(s,e,t){const{colormap:r,bandCount:i}=e.symbolizerParameters,a=[...t?[]:W(e.transformGrid),...he(e.interpolation,i===1,s.context)];return e.isRendereredSource&&!t?a.push("noop"):r!=null&&a.push("applyColormap"),{defines:a,program:s.painter.materialManager.getProgram(yt,a)}}function bt(s,e,t,r,i=!1){const{names:a,textures:n}=t.getTextures({useProcessedTexture:i});S(s.context,e,a,n),b(e,r,t.commonUniforms),e.setUniformMatrix3fv("u_dvsMat3",t.transforms.dvs);const o=t.symbolizerParameters,{colormap:l,colormapOffset:u}=o;if(l!=null){const m=j(l,u);b(e,r,m)}const h=je(o);b(e,r,h)}const vt={createProgram:xt,bindTextureAndUniforms:bt},k=new Map;function Tt(s){return k.get(s)}k.set("lut",mt),k.set("hillshade",_t),k.set("stretch",vt);const wt=[1,1],Pt=[2,0,0,0,2,0,-1,-1,0];function x(s,e,t){const{context:r,rasterFunction:i,hasBranches:a}=s,{raster:n}=i.parameters,o=a?(n==null?void 0:n.id)??-1:0,l=t.functionTextures[o]??t.rasterTexture;S(r,e,["u_image"],[l])}function de(s,e,t){const{rasters:r}=s.rasterFunction.parameters;if(!r)return;if(r.length<2)return x(s,e,t);const i=r.filter(a=>a.name!=="Constant").map(a=>a.id!=null&&a.name!=="Identity"?t.functionTextures[a.id]:t.rasterTexture);if(S(s.context,e,["u_image","u_image1","u_image2"].slice(0,i.length),i),i.length!==r.length){if(r.length===2){const a=r.findIndex(l=>l.name==="Constant"),n=a===0?[0,1,0,1,0,0,0,0,0]:[1,0,0,0,1,0,0,0,0],{value:o}=r[a].parameters;e.setUniform1f("u_image1Const",o),e.setUniformMatrix3fv("u_imageSwap",n)}else if(r.length===3){const a=[];if(r.forEach((n,o)=>n.name==="Constant"&&a.push(o)),a.length===1){const{value:n}=r[a[0]].parameters;e.setUniform1f("u_image1Const",n);const o=a[0]===0?[0,1,0,0,0,1,1,0,0]:a[0]===1?[1,0,0,0,0,1,0,1,0]:[1,0,0,0,1,0,0,0,1];e.setUniformMatrix3fv("u_imageSwap",o)}else if(a.length===2){const{value:n}=r[a[0]].parameters;e.setUniform1f("u_image1Const",n);const{value:o}=r[a[1]].parameters;e.setUniform1f("u_image2Const",o);const l=r.findIndex(h=>h.name!=="Constant"),u=l===0?[1,0,0,0,1,0,0,0,1]:l===1?[0,1,0,1,0,0,0,0,1]:[0,0,1,1,0,0,0,1,0];e.setUniformMatrix3fv("u_imageSwap",u)}}}}function y(s){s.setUniform2fv("u_coordScale",wt),s.setUniformMatrix3fv("u_dvsMat3",Pt)}const St={vsPath:"raster/rfx/vs",fsPath:"raster/rfx/aspect",attributes:new Map([["a_position",0],["a_texcoord",1]])};function Rt(s,e){return s.painter.materialManager.getProgram(St,[])}function It(s,e,t){x(s,e,t),y(e);const r=t.getRasterTextureSize();e.setUniform2fv("u_srcImageSize",r);const i=t.getRasterCellSize();e.setUniform2fv("u_cellSize",i)}const Ut={createProgram:Rt,bindTextureAndUniforms:It},$t={vsPath:"raster/rfx/vs",fsPath:"raster/rfx/bandarithmetic",attributes:new Map([["a_position",0],["a_texcoord",1]])};function Ft(s,e){const{painter:t,rasterFunction:r}=s,{indexType:i}=r.parameters;return t.materialManager.getProgram($t,[i])}function Ct(s,e,t){x(s,e,t),y(e);const{bandIndexMat3:r}=s.rasterFunction.parameters;e.setUniformMatrix3fv("u_bandIndexMat3",r)}const zt={createProgram:Ft,bindTextureAndUniforms:Ct},Mt={vsPath:"raster/rfx/vs",fsPath:"raster/rfx/compositeband",attributes:new Map([["a_position",0],["a_texcoord",1]])};function Vt(s,e){return s.painter.materialManager.getProgram(Mt,[])}function Bt(s,e,t){de(s,e,t),y(e)}const Lt={createProgram:Vt,bindTextureAndUniforms:Bt},Gt={vsPath:"raster/rfx/vs",fsPath:"raster/rfx/contrast",attributes:new Map([["a_position",0],["a_texcoord",1]])};function kt(s,e){return s.painter.materialManager.getProgram(Gt,[])}function Dt(s,e,t){x(s,e,t),y(e);const{contrastOffset:r,brightnessOffset:i}=s.rasterFunction.parameters;e.setUniform1f("u_contrastOffset",r),e.setUniform1f("u_brightnessOffset",i)}const Et={createProgram:kt,bindTextureAndUniforms:Dt},Ot={vsPath:"raster/rfx/vs",fsPath:"raster/rfx/convolution",attributes:new Map([["a_position",0],["a_texcoord",1]])};function At(s,e){const{painter:t,rasterFunction:r}=s,{kernelRows:i,kernelCols:a}=r.parameters,n=[{name:"rows",value:i},{name:"cols",value:a}];return t.materialManager.getProgram(Ot,n)}function qt(s,e,t){x(s,e,t),y(e),e.setUniform2fv("u_srcImageSize",[t.width,t.height]);const{kernel:r,clampRange:i}=s.rasterFunction.parameters;e.setUniform1fv("u_kernel",r),e.setUniform2fv("u_clampRange",i)}const jt={createProgram:At,bindTextureAndUniforms:qt},Wt={vsPath:"raster/rfx/vs",fsPath:"raster/rfx/curvature",attributes:new Map([["a_position",0],["a_texcoord",1]])};function Nt(s,e){const{painter:t,rasterFunction:r}=s,{curvatureType:i}=r.parameters,a=[i];return t.materialManager.getProgram(Wt,a)}function Qt(s,e,t){x(s,e,t),y(e);const r=t.getRasterTextureSize();e.setUniform2fv("u_srcImageSize",r);const{zFactor:i}=s.rasterFunction.parameters,a=t.getRasterCellSize();e.setUniform1f("u_zlFactor",200*i/a[0]/a[1])}const Ht={createProgram:Nt,bindTextureAndUniforms:Qt},Jt={vsPath:"raster/rfx/vs",fsPath:"raster/rfx/extractband",attributes:new Map([["a_position",0],["a_texcoord",1]])};function Yt(s,e){return s.painter.materialManager.getProgram(Jt,[])}function Kt(s,e,t){x(s,e,t),y(e);const{bandIndexMat3:r}=s.rasterFunction.parameters;e.setUniformMatrix3fv("u_bandIndexMat3",r)}const Xt={createProgram:Yt,bindTextureAndUniforms:Kt},Zt={vsPath:"raster/rfx/vs",fsPath:"raster/rfx/focalstatistics",attributes:new Map([["a_position",0],["a_texcoord",1]])};function es(s,e){const{painter:t,rasterFunction:r}=s,{kernelRows:i,kernelCols:a,fillNoDataOnly:n,statisticsType:o}=r.parameters,l=[{name:"rows",value:i},{name:"cols",value:a},o];return n&&l.push("fill"),t.materialManager.getProgram(Zt,l)}function ts(s,e,t){x(s,e,t),y(e),e.setUniform2fv("u_srcImageSize",[t.width,t.height]);const{clampRange:r}=s.rasterFunction.parameters;e.setUniform2fv("u_clampRange",r)}const ss={createProgram:es,bindTextureAndUniforms:ts},rs={vsPath:"raster/rfx/vs",fsPath:"raster/rfx/local",attributes:new Map([["a_position",0],["a_texcoord",1]])},is=new Set(["sinh","cosh","tanh","asinh","acosh","atanh"]);function as(s){const{painter:e,rasterFunction:t}=s,{imageCount:r,operationName:i,rasters:a,isOutputRounded:n}=t.parameters;let o=i.toLowerCase();s.context.type===A.WEBGL1&&is.has(o)&&(o=`polyfill${o}`);const l=[o];r===2&&l.push("twoImages");const u=a.filter(h=>h.name==="Constant");return u.length&&(l.push("oneConstant"),u.length===2&&l.push("twoConstant")),n&&l.push("roundOutput"),e.materialManager.getProgram(rs,l)}function ns(s,e,t){de(s,e,t),y(e);const{domainRange:r}=s.rasterFunction.parameters;e.setUniform2fv("u_domainRange",r)}const os={createProgram:as,bindTextureAndUniforms:ns},ls={vsPath:"raster/rfx/vs",fsPath:"raster/rfx/mask",attributes:new Map([["a_position",0],["a_texcoord",1]])};function us(s,e){const{painter:t,rasterFunction:r}=s,i=r.parameters.bandCount>1?["multiBand"]:[];return t.materialManager.getProgram(ls,i)}function cs(s,e,t){x(s,e,t),y(e);const{includedRanges:r,noDataValues:i}=s.rasterFunction.parameters;e.setUniform1fv("u_includedRanges",r),e.setUniform1fv("u_noDataValues",i)}const hs={createProgram:us,bindTextureAndUniforms:cs},ds={vsPath:"raster/rfx/vs",fsPath:"raster/rfx/ndvi",attributes:new Map([["a_position",0],["a_texcoord",1]])};function ms(s,e){const{painter:t,rasterFunction:r}=s,i=r.parameters.scaled?["scaled"]:[];return t.materialManager.getProgram(ds,i)}function ps(s,e,t){x(s,e,t),y(e);const{bandIndexMat3:r}=s.rasterFunction.parameters;e.setUniformMatrix3fv("u_bandIndexMat3",r)}const fs={createProgram:ms,bindTextureAndUniforms:ps},gs={vsPath:"raster/rfx/vs",fsPath:"raster/rfx/remap",attributes:new Map([["a_position",0],["a_texcoord",1]])};function _s(s,e){return s.painter.materialManager.getProgram(gs,[])}function ys(s,e,t){x(s,e,t),y(e);const{noDataRanges:r,rangeMaps:i,allowUnmatched:a,clampRange:n}=s.rasterFunction.parameters;e.setUniform1fv("u_noDataRanges",r),e.setUniform1fv("u_rangeMaps",i),e.setUniform1f("u_unmatchMask",a?1:0),e.setUniform2fv("u_clampRange",n)}const xs={createProgram:_s,bindTextureAndUniforms:ys},bs={vsPath:"raster/common",fsPath:"raster/reproject",attributes:new Map([["a_position",0],["a_texcoord",1]])};function vs(s,e){var l,u,h;const{painter:t}=s,r=[],{interpolation:i,transformGrid:a}=e,n=!!((u=(l=s.rasterFunction)==null?void 0:l.parameters)!=null&&u.requireBilinear),o=i==="bilinear"?!((h=s.context.capabilities.textureFloat)!=null&&h.textureFloatLinear):n;return i==="cubic"?r.push("bicubic"):o&&r.push("bilinear"),a&&(r.push("applyProjection"),a.spacing[0]===1&&r.push("lookupProjection")),t.materialManager.getProgram(bs,r)}function Ts(s,e,t){const{names:r,textures:i}=t.getTextures({forProcessing:!0});S(s.context,e,r,i),e.setUniform1f("u_scale",1),e.setUniform2fv("u_offset",[0,0]),e.setUniform2fv("u_coordScale",[1,1]),e.setUniformMatrix3fv("u_dvsMat3",[2,0,0,0,2,0,-1,-1,0]),e.setUniform1i("u_flipY",0),e.setUniform1f("u_opacity",1);const{width:a,height:n,source:o,transformGrid:l}=t;e.setUniform2fv("u_srcImageSize",[o.width,o.height]),e.setUniform2fv("u_targetImageSize",[a,n]),e.setUniform2fv("u_transformSpacing",l?l.spacing:H),e.setUniform2fv("u_transformGridSize",l?l.size:H)}const ws={createProgram:vs,bindTextureAndUniforms:Ts},Ps={vsPath:"raster/rfx/vs",fsPath:"raster/rfx/slope",attributes:new Map([["a_position",0],["a_texcoord",1]])};function Ss(s,e){const{painter:t,rasterFunction:r}=s,{slopeType:i}=r.parameters,a=i==="percent-rise"?["percentRise"]:[];return t.materialManager.getProgram(Ps,a)}function Rs(s,e,t){x(s,e,t),y(e);const r=t.getRasterTextureSize();e.setUniform2fv("u_srcImageSize",r);const i=t.getRasterCellSize();e.setUniform2fv("u_cellSize",i);const{zFactor:a,slopeType:n,pixelSizePower:o,pixelSizeFactor:l}=s.rasterFunction.parameters;e.setUniform1f("u_zFactor",a),e.setUniform1f("u_pixelSizePower",n==="adjusted"?o:0),e.setUniform1f("u_pixelSizeFactor",n==="adjusted"?l:0)}const Is={createProgram:Ss,bindTextureAndUniforms:Rs},Us={vsPath:"raster/rfx/vs",fsPath:"raster/rfx/stretch",attributes:new Map([["a_position",0],["a_texcoord",1]])};function $s(s,e){const{useGamma:t,bandCount:r,isOutputRounded:i}=s.rasterFunction.parameters,a=[];return t&&a.push("useGamma"),r>1&&a.push("multiBand"),i&&a.push("roundOutput"),s.painter.materialManager.getProgram(Us,a)}function Fs(s,e,t){x(s,e,t),y(e);const{width:r,height:i}=t,a=s.rasterFunction.parameters;e.setUniform2fv("u_srcImageSize",[r,i]),e.setUniform1f("u_minOutput",a.outMin),e.setUniform1f("u_maxOutput",a.outMax),e.setUniform1fv("u_factor",a.factor),e.setUniform1fv("u_minCutOff",a.minCutOff),e.setUniform1fv("u_maxCutOff",a.maxCutOff),e.setUniform1fv("u_gamma",a.gamma),e.setUniform1fv("u_gammaCorrection",a.gammaCorrection)}const Cs={createProgram:$s,bindTextureAndUniforms:Fs},g=new Map;function me(s,e,t){const r=new He;return r.width=e,r.height=t,r.internalFormat=s.type===A.WEBGL2?Ge.RGBA32F:ke.RGBA,r.samplingMode=q.NEAREST,r.dataType=De.FLOAT,r.isImmutable=s.type===A.WEBGL2,r.wrapMode=Ee.CLAMP_TO_EDGE,r}function zs(s,e,t,r){const{context:i,requestRender:a,allowDelayedRender:n}=s,o=r.createProgram(s,t);return n&&a!=null&&!o.compiled?(a(),null):(i.bindFramebuffer(e),i.setViewport(0,0,e.width,e.height),i.useProgram(o),o)}function Ms(s){return g.get(s.toLowerCase())}function Vs(s,e,t,r){const i=s.rasterFunction.name.toLowerCase(),a=i==="reproject"?ws:Ms(i);if(a==null)return;const n=zs(s,t,r,a);if(!n)return;a.bindTextureAndUniforms(s,n,r),e.draw();const[o,l]=r.getRasterTextureSize(i==="reproject"),u=me(s.context,o,l),h=new Je(s.context,u);if(t.copyToTexture(0,0,o,l,0,0,h),i==="reproject")r.rasterTexture=h,r.projected=!0;else{const m=s.hasBranches?s.rasterFunction.id:0;r.functionTextures[m]=h}}g.set("aspect",Ut),g.set("bandarithmetic",zt),g.set("compositeband",Lt),g.set("convolution",jt),g.set("contrastbrightness",Et),g.set("curvature",Ht),g.set("extractband",Xt),g.set("statistics",ss),g.set("local",os),g.set("mask",hs),g.set("ndvi",fs),g.set("remap",xs),g.set("slope",Is),g.set("stretch",Cs);class Bs extends Ye{constructor(){super(...arguments),this.name="raster",this._quad=null,this._rendererUniformInfos=new Map,this._fbo=null}dispose(){R(this._quad),R(this._fbo)}prepareState(e){const{context:t,renderPass:r}=e,i=r==="raster";t.setBlendingEnabled(!i),t.setBlendFunctionSeparate(L.ONE,L.ONE_MINUS_SRC_ALPHA,L.ONE,L.ONE_MINUS_SRC_ALPHA),t.setColorMask(!0,!0,!0,!0),t.setStencilWriteMask(0),t.setStencilTestEnabled(!i)}draw(e,t){if(!ut(t)||t.suspended)return;const{renderPass:r}=e;if(r!=="raster-bitmap")return r==="raster"?this._process(e,t):void this._drawBitmap(e,t,!0);this._drawBitmap(e,t)}_process(e,t){const{rasterFunction:r}=e,i=r.name==="Reproject";if(!(i?!(t.rasterTexture&&t.projected):!t.processed))return;const{timeline:a,context:n}=e;a.begin(this.name);const o=n.getBoundFramebufferObject(),l=n.getViewport();i||(t.processedTexture=R(t.processedTexture)),n.setStencilFunction(Z.EQUAL,t.stencilRef,255),t.updateTexture(e),this._initQuad(n);const[u,h]=t.getRasterTextureSize(i),{isStandardRasterTileSize:m,fbo:c}=this._getRasterFBO(n,u,h);Vs(e,this._quad,c,t),m||c.dispose(),n.bindFramebuffer(o),n.setViewport(l.x,l.y,l.width,l.height),a.end(this.name)}_drawBitmap(e,t,r=!1){const{timeline:i,context:a}=e;if(i.begin(this.name),a.setStencilFunction(Z.EQUAL,t.stencilRef,255),t.updateTexture(e),r&&!t.processedTexture){if(t.updateProcessedTexture(),!t.processedTexture)return void i.end(this.name);t.processed=!0}this._initBitmapCommonUniforms(t);const n=t.symbolizerParameters.type,o=Tt(n),{requestRender:l,allowDelayedRender:u}=e,{defines:h,program:m}=o.createProgram(e,t,t.projected&&r);if(u&&l!=null&&!m.compiled)return void l();a.useProgram(m);const c=this._getUniformInfos(n,a,m,h);this._quad||(this._quad=new te(a,[0,0,1,0,0,1,1,1])),o.bindTextureAndUniforms(e,m,t,c,r),this._quad.draw(),i.end(this.name)}_initBitmapCommonUniforms(e){if(!e.commonUniforms){const t=Qe(1,[0,0]),{transformGrid:r,width:i,height:a}=e,n=We(r,[i,a],[e.source.width,e.source.height],1,!1);e.commonUniforms={...t,...n,u_coordScale:e.coordScale}}}_getRasterFBO(e,t,r){const i=t===$&&r===$;return i?(this._fbo||(this._fbo=this._createNewFBO(e,t,r)),{isStandardRasterTileSize:i,fbo:this._fbo}):{isStandardRasterTileSize:i,fbo:this._createNewFBO(e,t,r)}}_createNewFBO(e,t,r){const i=me(e,t,r);return new Ke(e,i)}_initQuad(e){this._quad||(this._quad=new te(e,[0,0,1,0,0,1,1,1]))}_getUniformInfos(e,t,r,i){const a=i.length>0?e+"-"+i.join("-"):e;if(this._rendererUniformInfos.has(a))return this._rendererUniformInfos.get(a);const n=Ne(t,r);return this._rendererUniformInfos.set(a,n),n}}class Ls extends le{constructor(e,t,r,i,a,n,o=null){super(e,t,r,i,a,n),this.bitmap=null,this.bitmap=new lt(o,null,null),this.bitmap.coordScale=[a,n],this.bitmap.once("isReady",()=>this.ready())}destroy(){super.destroy(),this.bitmap.destroy(),this.bitmap=null,this.stage=null}set stencilRef(e){this.bitmap.stencilRef=e}get stencilRef(){return this.bitmap.stencilRef}setTransform(e){super.setTransform(e),this.bitmap.transforms.dvs=this.transforms.dvs}_createTransforms(){return{dvs:F(),tileMat3:F()}}onAttach(){this.bitmap.stage=this.stage}onDetach(){this.bitmap.stage=null}}let Gs=class extends ue{constructor(){super(...arguments),this.isCustomTilingScheme=!1}createTile(e){const t=this._getTileBounds(e),[r,i]=this._tileInfoView.tileInfo.size,a=this._tileInfoView.getTileResolution(e.level);return new Ls(e,a,t[0],t[3],r,i)}prepareRenderPasses(e){const t=e.registerRenderPass({name:"imagery (tile)",brushes:[Bs],target:()=>this.children.map(r=>r.bitmap),drawPhase:D.MAP});return[...super.prepareRenderPasses(e),t]}doRender(e){if(!this.visible||e.drawPhase!==D.MAP)return;const{rasterFunctionChain:t}=this;if(!t)return e.renderPass="raster-bitmap",void super.doRender(e);if(!t.hasFocalFunction){const[r,i]=this._tileInfoView.tileInfo.size;e.renderPass="raster",e.rasterFunction={name:"Reproject",parameters:{targetImageSize:[r,i],requireBilinear:!1},pixelType:"f32",id:0,isNoopProcess:!1},super.doRender(e)}if(t!=null&&t.functions.length){const{functions:r,hasBranches:i}=t;for(let a=0;a<r.length;a++){const n=r[a];n.name!=="Constant"&&n.name!=="Identity"&&(e.renderPass="raster",e.rasterFunction=n,e.hasBranches=i,super.doRender(e))}}e.rasterFunction=null,e.renderPass="bitmap",super.doRender(e)}_getTileBounds(e){const t=this._tileInfoView.getTileBounds(ne(),e);if(this.isCustomTilingScheme&&e.world){const{tileInfo:r}=this._tileInfoView,i=ye(r.spatialReference);if(i){const a=r.lodAt(e.level);if(!a)return t;const{resolution:n}=a,o=i/n%r.size[0],l=o?(r.size[0]-o)*n:0;t[0]-=l*e.world,t[2]-=l*e.world}}return t}};const ks=[0,0];let _=class extends xe{constructor(){super(...arguments),this._updatingHandles=new be,this._emptyTilePixelBlock=null,this._tileStrategy=null,this._tileInfoView=null,this._fetchQueue=null,this._blockCacheRegistryUrl=null,this._blockCacheRegistryId=null,this._srcResolutions=[],this.previousLOD=null,this._needBlockCacheUpdate=!1,this._globalSymbolizerParams=null,this._symbolizerParams=null,this._abortController=null,this._isCustomTilingScheme=!1,this._maxIndexedColormapSize=0,this._rasterFunctionState="na",this._globalUpdateRequested=!1,this.attached=!1,this.timeExtent=null,this.redrawOrRefetch=ve(async(s={})=>{if(!this.previousLOD||this.layerView.suspended)return;const e=this._rasterFunctionState;s.reprocess&&(await this._updatingHandles.addPromise(this.layer.updateRasterFunction()),this.updateRasterFunctionParameters());const t=this._rasterFunctionState,{type:r}=this;return s.refetch||r!=="raster"&&s.reprocess||t==="cpu"||e==="cpu"?this._updatingHandles.addPromise(this.doRefresh()):this._updatingHandles.addPromise(this._redrawImage(s.signal))})}destroy(){this._updatingHandles.destroy()}get useWebGLForProcessing(){return this._get("useWebGLForProcessing")??!0}set useWebGLForProcessing(s){this._set("useWebGLForProcessing",s)}get useProgressiveUpdate(){return this._get("useProgressiveUpdate")??!0}set useProgressiveUpdate(s){if(this._tileStrategy&&this.useProgressiveUpdate!==s){this._tileStrategy.destroy(),this.container.removeAllChildren();const e=this._getCacheSize(s);this._tileStrategy=new J({cachePolicy:"purge",acquireTile:t=>this.acquireTile(t),releaseTile:t=>this.releaseTile(t),cacheSize:e,tileInfoView:this._tileInfoView}),this._set("useProgressiveUpdate",s),this.layerView.requestUpdate()}}update(s){var a;this._fetchQueue.pause(),this._fetchQueue.state=s.state,this._tileStrategy.update(s),this._fetchQueue.resume();const{extent:e,resolution:t,scale:r}=s.state,i=this._tileInfoView.getClosestInfoForScale(r);if(this.layer.raster){if(!this.useProgressiveUpdate||this._needBlockCacheUpdate){const n=this._srcResolutions[i.level],o=e.toJSON?e:Te.fromJSON(e);se(this._blockCacheRegistryUrl,this._blockCacheRegistryId,o,t,n,this.layer.raster.ioConfig.sampling)}this._needBlockCacheUpdate=!1,((a=this.previousLOD)==null?void 0:a.level)!==i.level&&(this.previousLOD=i,this._symbolizerParams==null||this.layerView.hasTilingEffects||this._updateSymbolizerParams(),this._tileStrategy.updateCacheSize(0))}}moveEnd(){!this.layerView.hasTilingEffects&&this.useProgressiveUpdate||(this._abortController&&this._abortController.abort(),this._abortController=new AbortController,this._fetchQueue.length===0&&this._redrawImage(this._abortController.signal).then(()=>{this._globalUpdateRequested=!1,this.layerView.requestUpdate()}));const s=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy.updateCacheSize(s),this.layerView.requestUpdate()}get updating(){var s;return this._globalUpdateRequested||((s=this._updatingHandles)==null?void 0:s.updating)}attach(){const s=we("2d");this._maxIndexedColormapSize=4*(s.maxTextureSize||4096),s.supportsTextureFloat||(this.useWebGLForProcessing=!1),this._initializeTileInfo(),this._tileInfoView=new Pe(this.layerView.tileInfo,this.layerView.fullExtent);const e=this._computeFetchConcurrency();this._fetchQueue=new Se({tileInfoView:this._tileInfoView,concurrency:e,process:(r,i)=>this._fetchTile(r,i)});const t=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy=new J({cachePolicy:"purge",acquireTile:r=>this.acquireTile(r),releaseTile:r=>this.releaseTile(r),cacheSize:t,tileInfoView:this._tileInfoView}),this._updateBlockCacheRegistry()}detach(){this._tileStrategy.destroy(),this._fetchQueue.clear(),this.container.removeAllChildren(),this._fetchQueue=this._tileStrategy=this._tileInfoView=null,re(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryUrl=this._blockCacheRegistryId=null}acquireTile(s){const e=this.container.createTile(s);return this._updatingHandles.addPromise(this._enqueueTileFetch(e)),this.layerView.requestUpdate(),this._needBlockCacheUpdate=!0,this._globalUpdateRequested=this.layerView.hasTilingEffects||!this.useProgressiveUpdate,e}releaseTile(s){this._fetchQueue.abort(s.key.id),this.container.removeChild(s),s.once("detach",()=>{s.destroy(),this.layerView.requestUpdate()}),this.layerView.requestUpdate()}createEmptyTilePixelBlock(s=null){const e=s==null||s.join(",")===this._tileInfoView.tileInfo.size.join(",");if(e&&this._emptyTilePixelBlock!=null)return this._emptyTilePixelBlock;s=s||this._tileInfoView.tileInfo.size;const[t,r]=s,i=new Xe({width:t,height:r,pixels:[new Uint8Array(t*r)],mask:new Uint8Array(t*r),pixelType:"u8"});return e&&(this._emptyTilePixelBlock=i),i}_getBandIds(){if(!("rasterFunctionChain"in this.container)||!this.container.rasterFunctionChain)return this.layer.bandIds;const{bandIds:s,raster:e}=this.layer,t="rasterFunction"in e?e.rasterFunction.rawInputBandIds:null;return s!=null&&s.length&&(t!=null&&t.length)&&e.rasterInfo.bandCount!==1?s.map(r=>t[Math.min(r,t.length-1)]):s||t}updateRasterFunctionParameters(){}_fetchTile(s,e){const t=e!=null?e.signal:null,r=this.canUseWebGLForProcessing(),{layerView:i}=this,{tileInfo:a}=i,n=!a.isWrappable&&st(i.view.spatialReference)!=null,o=r&&this.layer.raster.hasUniqueSourceStorageInfo,l={allowPartialFill:!0,datumTransformation:i.datumTransformation,interpolation:r?"nearest":this.layer.interpolation,registryId:this._blockCacheRegistryId,requestRawData:o,skipRasterFunction:this.type==="raster"&&this.container.rasterFunctionChain!=null,signal:t,srcResolution:this._srcResolutions[s.level],timeExtent:i.timeExtent,tileInfo:a,disableWrapAround:n};return this.fetchTile(s,l)}_getCacheSize(s){return s?40:0}_initializeTileInfo(){const{layerView:s}=this,e=s.view.spatialReference;if(this._canUseLayerLODs()){const{origin:u,lods:h}=this.layer.tileInfo,m=h.map(({scale:f})=>f),c=Y.create({spatialReference:e,size:$,scales:m,origin:u});return s.set("tileInfo",c),void(this._srcResolutions=h.map(({resolution:f})=>({x:f,y:f})))}const{scales:t,srcResolutions:r,isCustomTilingScheme:i}=rt(this.layer.rasterInfo,e,{tileSize:$,alignGlobalDatasetWithAGOL:!0,limitToSrcResolution:!1}),a=Y.create({spatialReference:e,size:$,scales:t}),n=a.origin.x===0,{xmin:o,ymax:l}=s.fullExtent;(n||i&&a.origin.x>o)&&(a.origin=new Re({x:o,y:l,spatialReference:e})),this._isCustomTilingScheme=i,s.set("tileInfo",a),this._srcResolutions=r??[]}_canUseLayerLODs(){var i;const{layer:s,layerView:e}=this;if(s.raster.tileType!=="Map")return!1;const{lods:t}=s.tileInfo,r=(i=e.view.constraints)==null?void 0:i.effectiveLODs;return(r==null?void 0:r.length)===t.length&&r.every(({scale:a},n)=>Math.abs(a-t[n].scale)<.001)}_computeFetchConcurrency(){const{blockBoundary:s}=this.layer.rasterInfo.storageInfo,e=s[s.length-1];return(e.maxCol-e.minCol+1)*(e.maxRow-e.minRow+1)>64?2:10}async _enqueueTileFetch(s,e){var t;if(!this._fetchQueue.has(s.key.id)){try{const r=await this._fetchQueue.push(s.key),i=this._getBandIds();let a=!this.useProgressiveUpdate||this.layerView.hasTilingEffects&&!this._globalSymbolizerParams;if(this._globalUpdateRequested&&!this.layerView.moving&&this._fetchQueue.length===0){a=!1;try{await this._redrawImage((t=this._abortController)==null?void 0:t.signal)}catch(l){I(l)&&U.getLogger(this).error(l)}this._globalUpdateRequested=!1}!this.canUseWebGLForProcessing()&&this.type!=="rasterVF"||this.layerView.hasTilingEffects||this._symbolizerParams!=null||this._updateSymbolizerParams();const n=this._tileInfoView.getTileCoords(ks,s.key),o=this._tileInfoView.getTileResolution(s.key);await this.updateTileSource(s,{source:r,symbolizerParams:this._symbolizerParams,globalSymbolizerParams:this._globalSymbolizerParams,suspended:a,bandIds:i,coords:n,resolution:o}),s.once("attach",()=>this.layerView.requestUpdate()),this.container.addChild(s)}catch(r){I(r)||U.getLogger(this).error(r)}this.layerView.requestUpdate()}}async _redrawImage(s){if(this.container.children.length===0)return;await this.layer.updateRenderer(),this.layerView.hasTilingEffects?await this._updateGlobalSymbolizerParams(s):(this._updateSymbolizerParams(),this._globalSymbolizerParams=null);const e=this.container.children.map(async t=>this.updateTileSymbolizerParameters(t,{local:this._symbolizerParams,global:this._globalSymbolizerParams}));await Promise.allSettled(e),this.container.requestRender()}async _updateGlobalSymbolizerParams(s){const e={srcResolution:this._srcResolutions[this.previousLOD.level],registryId:this._blockCacheRegistryId,signal:s},t=await this.layer.fetchPixels(this.layerView.view.extent,this.layerView.view.width,this.layerView.view.height,e);if(!(t!=null&&t.pixelBlock))return;const{resolution:r}=this.previousLOD,i=this._getBandIds(),a=this.layer.symbolizer.generateWebGLParameters({pixelBlock:t.pixelBlock.extractBands(i),isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:r,y:r},bandIds:i});!this.canUseWebGLForProcessing()&&a&&a.type==="stretch"&&this.layer.renderer&&this.layer.renderer.type==="raster-stretch"&&(a.factor=a.factor.map(n=>255*n),a.outMin=Math.round(255*a.outMin),a.outMax=Math.round(255*a.outMax)),this._globalSymbolizerParams=a}_updateSymbolizerParams(){const{resolution:s}=this.previousLOD,e=this._getBandIds();this._symbolizerParams=this.layer.symbolizer.generateWebGLParameters({pixelBlock:null,isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:s,y:s},bandIds:e})}_updateBlockCacheRegistry(s=!1){const{layer:e,layerView:t}=this,{url:r,raster:i}=e,{multidimensionalDefinition:a}=e.normalizeRasterFetchOptions({multidimensionalDefinition:e.multidimensionalDefinition,timeExtent:t.timeExtent}),n=i.rasterInfo.multidimensionalInfo?i.getSliceIndex(a):null,o=tt(r,n);if(o!==this._blockCacheRegistryUrl){if(this._blockCacheRegistryUrl!=null&&re(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryId=et(o,i.rasterInfo),s){const{view:l}=t,u=this._tileInfoView.getClosestInfoForScale(l.scale),h=this._srcResolutions[u.level];se(o,this._blockCacheRegistryId,l.extent,l.resolution,h,i.ioConfig.sampling)}this._blockCacheRegistryUrl=o}}async doRefresh(){if(!this.attached)return;await this.layer.updateRenderer(),this.layerView.hasTilingEffects||this._updateSymbolizerParams(),this._updateBlockCacheRegistry(!0),this._fetchQueue.reset();const s=[];this._globalUpdateRequested=this.layerView.hasTilingEffects||!this.useProgressiveUpdate,this._tileStrategy.refresh(e=>s.push(this._enqueueTileFetch(e))),await this._updatingHandles.addPromise(Promise.allSettled(s))}};d([p()],_.prototype,"_globalUpdateRequested",void 0),d([p()],_.prototype,"attached",void 0),d([p()],_.prototype,"container",void 0),d([p()],_.prototype,"layer",void 0),d([p()],_.prototype,"layerView",void 0),d([p()],_.prototype,"type",void 0),d([p()],_.prototype,"useWebGLForProcessing",null),d([p()],_.prototype,"useProgressiveUpdate",null),d([p()],_.prototype,"timeExtent",void 0),d([p()],_.prototype,"updating",null),_=d([C("esri.views.2d.layers.imagery.BaseImageryTileSubView2D")],_);let w=class extends _{constructor(){super(...arguments),this.type="raster"}attach(){super.attach(),this.container=new Gs(this._tileInfoView),this.container.isCustomTilingScheme=this._isCustomTilingScheme,this.updateRasterFunctionParameters()}detach(){super.detach(),this.container.removeAllChildren(),this.container=null}canUseWebGLForProcessing(){var i,a;const{symbolizer:e}=this.layer,t=(a=(i=e.lookup)==null?void 0:i.colormapLut)==null?void 0:a.indexedColormap,r=t&&t.length>this._maxIndexedColormapSize;return this.useWebGLForProcessing&&e.canRenderInWebGL&&!r&&!(this.layer.interpolation==="majority"&&ce(this.layer))}fetchTile(e,t){return this.layer.fetchTile(e.level,e.row,e.col,t)}updateRasterFunctionParameters(){const{raster:e,type:t}=this.layer,{container:r}=this;if(e.datasetFormat!=="Function"||t==="wcs")return r.rasterFunctionChain=null,r.children.forEach(c=>{const{bitmap:f}=c;f&&(f.suspended=!0,f.processed=!1,f.projected&&(f.invalidateTexture(),f.rasterTexture=null))}),void(this._rasterFunctionState="na");const i=this._rasterFunctionState,{rasterFunction:a,primaryRasters:n}=e,o=a.supportsGPU&&(!n||n.rasters.length<=1),l=o?a.flatWebGLFunctionChain:null,{renderer:u}=this.layer,h=!o||!(l!=null&&l.functions.length)||(u==null?void 0:u.type)==="raster-stretch"&&u.dynamicRangeAdjustment||!this.canUseWebGLForProcessing();r.rasterFunctionChain=h?null:l;const m=a==null?"na":r.rasterFunctionChain?"gpu":"cpu";r.children.forEach(c=>{const{bitmap:f}=c;f&&(f.suspended=i!==m,f.processed=!1,f.processedTexture=null)}),this._rasterFunctionState=m}async updateTileSource(e,t){const r=this._getBandIds(),i=this._getLayerInterpolation(),a=this.canUseWebGLForProcessing(),{source:n,globalSymbolizerParams:o,suspended:l,coords:u,resolution:h}=t,m=this.layerView.hasTilingEffects?o:t.symbolizerParams,{bitmap:c}=e;if([c.x,c.y]=u,c.resolution=h,(n==null?void 0:n.pixelBlock)!=null){const f={extent:n.extent,pixelBlock:n.pixelBlock,srcPixelSize:n.srcTilePixelSize};if(c.rawPixelData=f,a)c.source=n.pixelBlock,c.isRendereredSource=!1;else{const z=await this.layer.applyRenderer(f,(o==null?void 0:o.type)==="stretch"?o:void 0);c.source=z,c.isRendereredSource=!0}c.symbolizerParameters=a?m:null,c.transformGrid=a?n.transformGrid:null}else{const f=this.createEmptyTilePixelBlock();c.source=f,c.symbolizerParameters=a?m:null,c.transformGrid=null}c.bandIds=a?r:null,c.width=this._tileInfoView.tileInfo.size[0],c.height=this._tileInfoView.tileInfo.size[1],c.interpolation=i,c.suspended=l,c.invalidateTexture()}async updateTileSymbolizerParameters(e,t){const{local:r,global:i}=t,a=this._getBandIds(),n=this._getLayerInterpolation(),o=this.canUseWebGLForProcessing(),{bitmap:l}=e,{rawPixelData:u}=l;o||u==null?(l.isRendereredSource&&u!=null&&(l.source=u.pixelBlock),l.isRendereredSource=!1):(l.source=await this.layer.applyRenderer(u,(i==null?void 0:i.type)==="stretch"?i:void 0),l.isRendereredSource=!0),l.symbolizerParameters=o?this.layerView.hasTilingEffects?i:r:null,l.bandIds=o?a:null,l.interpolation=n,l.suspended=!1}_getLayerInterpolation(){const{interpolation:e,renderer:t}=this.layer;if(!t)return e;const r=t.type;return r==="raster-colormap"||r==="unique-value"||r==="class-breaks"?"nearest":t.type==="raster-stretch"&&t.colorRamp!=null?e==="bilinear"||e==="cubic"?"bilinear":"nearest":e}};d([p()],w.prototype,"container",void 0),d([p()],w.prototype,"layer",void 0),d([p()],w.prototype,"type",void 0),w=d([C("esri.views.2d.layers.imagery.ImageryTileView2D")],w);const Ds=w;class Es extends le{constructor(e,t,r,i,a,n,o=null){super(e,t,r,i,a,n),this.tileData=new Ce(o),this.tileData.coordScale=[a,n],this.tileData.once("isReady",()=>this.ready())}destroy(){super.destroy(),this.tileData.destroy(),this.tileData=null,this.stage=null}set stencilRef(e){this.tileData.stencilRef=e}get stencilRef(){return this.tileData.stencilRef}_createTransforms(){return{dvs:F(),tileMat3:F()}}setTransform(e){super.setTransform(e);const t=this.resolution/(e.resolution*e.pixelRatio),r=this.transforms.tileMat3,[i,a]=this.tileData.offset,n=[this.x+i*this.resolution,this.y-a*this.resolution],[o,l]=e.toScreenNoRotation([0,0],n),{symbolTileSize:u}=this.tileData.symbolizerParameters,h=Math.round((this.width-this.tileData.offset[0])/u)*u,m=Math.round((this.height-this.tileData.offset[1])/u)*u,c=h/this.rangeX*t,f=m/this.rangeY*t;Ie(r,c,0,0,0,f,0,o,l,1),ae(this.transforms.dvs,e.displayViewMat3,r),this.tileData.transforms.dvs=this.transforms.dvs}onAttach(){this.tileData.stage=this.stage}onDetach(){this.tileData.stage=null}}class Os extends ue{constructor(){super(...arguments),this.isCustomTilingScheme=!1,this.symbolTypes=["triangle"]}createTile(e){const t=this._tileInfoView.getTileBounds(ne(),e),[r,i]=this._tileInfoView.tileInfo.size,a=this._tileInfoView.getTileResolution(e.level);return new Es(e,a,t[0],t[3],r,i)}prepareRenderPasses(e){const t=e.registerRenderPass({name:"imagery (vf tile)",brushes:[ze],target:()=>this.children.map(r=>r.tileData),drawPhase:D.MAP});return[...super.prepareRenderPasses(e),t]}doRender(e){this.visible&&e.drawPhase===D.MAP&&this.symbolTypes.forEach(t=>{e.renderPass=t,super.doRender(e)})}}let P=class extends _{constructor(){super(...arguments),this._handle=null,this.type="rasterVF"}canUseWebGLForProcessing(){return!1}async fetchTile(s,e){e={...e,interpolation:"nearest",requestProjectedLocalDirections:!0};const t=await this.layer.fetchTile(s.level,s.row,s.col,e);return this.layer.rasterInfo.dataType==="vector-magdir"&&(t!=null&&t.pixelBlock)&&(t.pixelBlock=await this.layer.convertVectorFieldData(t.pixelBlock,e)),t}updateTileSource(s,e){const t=e.symbolizerParams,{tileData:r}=s;r.key=s.key,r.width=this._tileInfoView.tileInfo.size[0],r.height=this._tileInfoView.tileInfo.size[1];const{symbolTileSize:i}=t,{source:a}=e;if(r.offset=this._getTileSymbolOffset(r.key,i),(a==null?void 0:a.pixelBlock)!=null){const n={extent:a.extent,pixelBlock:a.pixelBlock};r.rawPixelData=n,r.symbolizerParameters=t,r.source=this._sampleVectorFieldData(a.pixelBlock,t,r.offset)}else{const n=[Math.round((this._tileInfoView.tileInfo.size[0]-r.offset[0])/i),Math.round((this._tileInfoView.tileInfo.size[1]-r.offset[1])/i)],o=this.createEmptyTilePixelBlock(n);r.source=o,r.symbolizerParameters=t}return r.invalidateVAO(),Promise.resolve()}updateTileSymbolizerParameters(s,e){var o;const t=e.local,{symbolTileSize:r}=t,{tileData:i}=s;i.offset=this._getTileSymbolOffset(i.key,r);const a=i.symbolizerParameters.symbolTileSize;i.symbolizerParameters=t;const n=(o=i.rawPixelData)==null?void 0:o.pixelBlock;return n!=null&&a!==r&&(i.source=this._sampleVectorFieldData(n,i.symbolizerParameters,i.offset)),Promise.resolve()}attach(){super.attach(),this.container=new Os(this._tileInfoView),this.container.isCustomTilingScheme=this._isCustomTilingScheme,this._updateSymbolType(this.layer.renderer),this._handle=G(()=>this.layer.renderer,s=>this._updateSymbolType(s))}detach(){var s;super.detach(),this.container.removeAllChildren(),(s=this._handle)==null||s.remove(),this._handle=null,this.container=null}_getTileSymbolOffset(s,e){const t=s.col*this._tileInfoView.tileInfo.size[0]%e,r=s.row*this._tileInfoView.tileInfo.size[1]%e;return[t>e/2?e-t:-t,r>e/2?e-r:-r]}_sampleVectorFieldData(s,e,t){const{symbolTileSize:r}=e;return Ze(s,"vector-uv",r,t)}_updateSymbolType(s){s.type==="vector-field"&&(this.container.symbolTypes=s.style==="wind-barb"?["scalar","triangle"]:s.style==="simple-scalar"?["scalar"]:["triangle"])}};d([p()],P.prototype,"container",void 0),d([p()],P.prototype,"layer",void 0),d([p()],P.prototype,"type",void 0),P=d([C("esri.views.2d.layers.imagery.VectorFieldTileView2D")],P);const As=P,qs=s=>{let e=class extends s{constructor(){super(...arguments),this._rasterFieldPrefix="Raster.",this.layer=null,this.view=null,this.tileInfo=null}get fullExtent(){return this._getfullExtent()}_getfullExtent(){return ie(this.layer.rasterInfo,this.view.spatialReference)}get hasTilingEffects(){return!!(this.layer.renderer&&"dynamicRangeAdjustment"in this.layer.renderer&&this.layer.renderer.dynamicRangeAdjustment)}get datumTransformation(){return it(this.layer.fullExtent,this.view.spatialReference,!0)}supportsSpatialReference(t){return!!ie(this.layer.rasterInfo,t)}async fetchPopupFeatures(t,r){const{layer:i}=this;if(!t)throw new K("imageryTileLayerView:fetchPopupFeatures","Nothing to fetch without area",{layer:i});const{popupEnabled:a}=i,n=at(i,r);if(!a||n==null)throw new K("imageryTileLayerView:fetchPopupFeatures","Missing required popupTemplate or popupEnabled",{popupEnabled:a,popupTemplate:n});const o=[],{value:l,magdirValue:u,processedValue:h}=await i.identify(t,{timeExtent:this.timeExtent});let m="";if(l&&l.length){m=i.type==="imagery-tile"&&i.hasStandardTime()&&l[0]!=null?l.map(E=>i.getStandardTimeValue(E)).join(", "):l.join(", ");const c={ObjectId:0},f="Raster.ServicePixelValue";c[f]=(h==null?void 0:h.join(", "))??m,c[f+".Raw"]=m;const z=i.rasterInfo.attributeTable;if(z!=null){const{fields:E,features:pe}=z,Q=E.find(({name:v})=>v.toLowerCase()==="value"),V=Q?pe.find(v=>String(v.attributes[Q.name])===m):null;if(V)for(const v in V.attributes)V.attributes.hasOwnProperty(v)&&(c[this._rasterFieldPrefix+v]=V.attributes[v])}const N=i.rasterInfo.dataType;N!=="vector-magdir"&&N!=="vector-uv"||(c["Raster.Magnitude"]=u==null?void 0:u[0],c["Raster.Direction"]=u==null?void 0:u[1]);const M=new oe(this.fullExtent.clone(),null,c);M.layer=i,M.sourceLayer=M.layer,o.push(M)}return o}};return d([p()],e.prototype,"layer",void 0),d([p(Ue)],e.prototype,"timeExtent",void 0),d([p()],e.prototype,"view",void 0),d([p()],e.prototype,"fullExtent",null),d([p()],e.prototype,"tileInfo",void 0),d([p({readOnly:!0})],e.prototype,"hasTilingEffects",null),d([p()],e.prototype,"datumTransformation",null),e=d([C("esri.views.layers.ImageryTileLayerView")],e),e};let T=class extends qs(nt(Ve(Be))){constructor(){super(...arguments),this._useWebGLForProcessing=!0,this._useProgressiveUpdate=!0,this.subview=null}get useWebGLForProcessing(){return this._useWebGLForProcessing}set useWebGLForProcessing(s){this._useWebGLForProcessing=s,this.subview&&"useWebGLForProcessing"in this.subview&&(this.subview.useWebGLForProcessing=s)}get useProgressiveUpdate(){return this._useWebGLForProcessing}set useProgressiveUpdate(s){this._useProgressiveUpdate=s,this.subview&&"useProgressiveUpdate"in this.subview&&(this.subview.useProgressiveUpdate=s)}get displayParameters(){const{layer:s}=this,e=this._get("displayParameters");return s.renderer?{bandIds:s.bandIds,renderer:s.renderer,interpolation:s.interpolation,multidimensionalDefinition:s.multidimensionalDefinition,rasterFunction:s.type==="imagery-tile"?s.rasterFunction:null}:e}update(s){var e;(e=this.subview)==null||e.update(s),this.notifyChange("updating")}isUpdating(){return!this.subview||this.subview.updating}attach(){this.layer.increaseRasterJobHandlerUsage(),this._updateSubview(),this.addAttachHandles([G(()=>this.displayParameters,(s,e)=>{const t=s.interpolation!==(e==null?void 0:e.interpolation)&&(s.interpolation==="majority"||(e==null?void 0:e.interpolation)==="majority")&&ce(this.layer),r=s.renderer!==(e==null?void 0:e.renderer)&&this._getSubviewType(e==null?void 0:e.renderer)!==this._getSubviewType(s.renderer);r&&this._updateSubview();const i=s.multidimensionalDefinition!==(e==null?void 0:e.multidimensionalDefinition),a=s.rasterFunction!==(e==null?void 0:e.rasterFunction),n=a&&!this._useWebGLForProcessing,o=i||t||r||n;this.subview.redrawOrRefetch({refetch:o,reprocess:a}).catch(l=>{I(l)||U.getLogger(this).error(l)}),this.notifyChange("updating")}),G(()=>this.layer.multidimensionalSubset??null,(s,e)=>{const{multidimensionalDefinition:t}=this.layer;t!=null&&X(t,s)!==X(t,e)&&(this.subview.redrawOrRefetch({refetch:!0}).catch(r=>{I(r)||U.getLogger(this).error(r)}),this.notifyChange("updating"))},$e),G(()=>this.timeExtent,()=>{this.subview.timeExtent=this.timeExtent,this.subview.redrawOrRefetch({refetch:!0}).catch(s=>{I(s)||U.getLogger(this).error(s)})},Fe)])}detach(){var s;this.layer.decreaseRasterJobHandlerUsage(),this._detachSubview(this.subview),(s=this.subview)==null||s.destroy(),this.subview=null}moveStart(){this.requestUpdate()}viewChange(){this.requestUpdate()}moveEnd(){this.subview.moveEnd()}async hitTest(s,e){return[{type:"graphic",layer:this.layer,mapPoint:s,graphic:new oe({attributes:{},geometry:s.clone()})}]}doRefresh(){return this.subview?this.subview.doRefresh():Promise.resolve()}_updateSubview(){var i;const{renderer:s}=this.layer;if(!s)return;const e=this._getSubviewType(s);if(this.subview){if(this.subview.type===e)return void this._attachSubview(this.subview);this._detachSubview(this.subview),(i=this.subview)==null||i.destroy(),this.subview=null}const{layer:t}=this;let r;if(r=e==="rasterVF"?new As({layer:t,layerView:this}):e==="flow"?new Me({layer:t,layerView:this}):new Ds({layer:t,layerView:this}),"useWebGLForProcessing"in r&&(r.useWebGLForProcessing=this._useWebGLForProcessing),"useProgressiveUpdate"in r&&(r.useProgressiveUpdate=this._useProgressiveUpdate),"previousLOD"in r){const{subview:a}=this;r.previousLOD=a&&"previousLOD"in a?a.previousLOD:null}this._attachSubview(r),this.subview=r,this.requestUpdate()}_attachSubview(s){s&&!s.attached&&(s.attach(),s.attached=!0,this.container.addChildAt(s.container,0))}_detachSubview(s){s!=null&&s.attached&&(this.container.removeChild(s.container),s.detach(),s.attached=!1)}_getSubviewType(s){const e=s==null?void 0:s.type;return e==="vector-field"?"rasterVF":e==="flow"?"flow":"raster"}};d([p()],T.prototype,"subview",void 0),d([p()],T.prototype,"useWebGLForProcessing",null),d([p()],T.prototype,"useProgressiveUpdate",null),d([p({readOnly:!0})],T.prototype,"displayParameters",null),T=d([C("esri.views.2d.layers.ImageryTileLayerView2D")],T);const Pr=T;export{Pr as default};
|