@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 1.98 kB
JavaScript
import{isSome as r}from"../../../../../core/maybe.js";import e from"./aspectProcessor.js";import o from"./bandArithmeticProcessor.js";import t from"./compositeBandProcessor.js";import s from"./convolutionProcessor.js";import n from"./extractBandProcessor.js";import i from"./localProcessor.js";import c from"./maskProcessor.js";import m from"./ndviProcessor.js";import a from"./remapProcessor.js";import p from"./reprojectProcessor.js";import f from"./slopeProcessor.js";import u from"./stretchProcessor.js";import{ContextType as l}from"../../../../webgl/context-util.js";import{TextureType as d,PixelFormat as j,SizedPixelFormat as h,TextureSamplingMode as P,PixelType as w,TextureWrapMode as x}from"../../../../webgl/enums.js";import{Texture as T}from"../../../../webgl/Texture.js";const b=new Map;function g(r,e,o){const t={width:e,height:o,target:d.TEXTURE_2D,pixelFormat:j.RGBA,internalFormat:r.type===l.WEBGL2?h.RGBA32F:j.RGBA,samplingMode:P.NEAREST,dataType:w.FLOAT,isImmutable:r.type===l.WEBGL2,wrapMode:x.CLAMP_TO_EDGE,flipped:!1};return new T(r,t)}function A(e,o,t,s){const{context:n,requestRender:i,allowDelayedRender:c}=e,m=s.createProgram(e,t);if(c&&r(i)&&!m.compiled)return i(),null;const{width:a,height:p}=t;return n.bindFramebuffer(o),n.setViewport(0,0,a,p),n.useProgram(m),m}function B(r){return b.get(r.toLowerCase())}function E(r,e,o,t){const s=r.rasterFunction.name.toLowerCase(),n="reproject"===s?p:B(s);if(null==n)return;const i=A(r,o,t,n);if(!i)return;n.bindTextureAndUniforms(r,i,t),e.draw();const{width:c,height:m}=t,a=g(r.context,c,m);if(o.copyToTexture(0,0,c,m,0,0,a),"reproject"===s)t.rasterTexture=a,t.projected=!0;else{const e=r.hasBranches?r.rasterFunction.id:0;t.functionTextures[e]=a}}b.set("aspect",e),b.set("bandarithmetic",o),b.set("compositeband",t),b.set("convolution",s),b.set("extractband",n),b.set("local",i),b.set("mask",c),b.set("ndvi",m),b.set("remap",a),b.set("slope",f),b.set("stretch",u);export{g as createTexture,E as process};