@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.89 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{_ as e}from"../../chunks/tslib.es6.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as t}from"../../core/accessorSupport/decorators/subclass.js";import n from"../support/RasterJobHandler.js";import{convertVectorFieldData as o}from"../support/rasterFunctions/vectorFieldUtils.js";import{normalizeRendererJSON as s}from"../../renderers/support/rasterRendererHelper.js";import{createFlowMesh as a}from"../../views/2d/engine/flow/dataUtils.js";const i=i=>{let l=class extends i{constructor(){super(...arguments),this._rasterJobHandlerConfig={instance:null,refCount:0,connectionPromise:null}}get _rasterJobHandler(){return this._rasterJobHandlerConfig.instance}increaseRasterJobHandlerUsage(){this._rasterJobHandlerConfig.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandlerConfig.refCount--,this._rasterJobHandlerConfig.refCount<=0&&this._shutdownJobHandler()}async convertVectorFieldData(e,r,t){if(null==e)return null;const n=this._rasterJobHandler;return n?n.convertVectorFieldData({pixelBlock:e,dataType:r},t):o(e,r)}async createFlowMesh(e,r){const t=this._rasterJobHandler;return t?t.createFlowMesh(e,r):a(e.meshType,e.simulationSettings,e.flowData,null!=r.signal?r.signal:(new AbortController).signal)}_initJobHandler(){const{_rasterJobHandlerConfig:e}=this;if(e.connectionPromise)return e.connectionPromise;const r=new n;return e.connectionPromise=r.initialize().then((()=>{e.instance=r,this.notifyChange("_rasterJobHandler")}),(()=>{})),e.connectionPromise}_shutdownJobHandler(){const{_rasterJobHandlerConfig:e}=this;e.instance?.destroy(),e.instance=null,e.connectionPromise=null,e.refCount=0,this.notifyChange("_rasterJobHandler"),this._cachedRendererJson=void 0}async _updateSymbolizer(e,r,t,n){const o=this._rasterJobHandlerConfig.instance;if(!o)return;const a=s({...r.toJSON(),variableName:t});JSON.stringify(this._cachedRendererJson)!==JSON.stringify(a)&&(n&&(e.rasterInfo=n),e.rendererJSON=a,e.bind(),await o.updateSymbolizer(e),this._cachedRendererJson=r.toJSON())}async _symbolize(e,r){const{pixelData:t,bandIds:n,simpleStretchParams:o}=e,s=this._rasterJobHandler;if(s){const e=await s.symbolize({...t,simpleStretchParams:o,bandIds:n},r);return{extent:t.extent,pixelBlock:e}}const a=e.symbolizer.symbolize({...t,simpleStretchParams:o,bandIds:n});return{extent:t.extent,pixelBlock:a}}};return e([r({clonable:!1})],l.prototype,"_rasterJobHandler",null),e([r({clonable:!1})],l.prototype,"_cachedRendererJson",void 0),e([r({clonable:!1})],l.prototype,"_rasterJobHandlerConfig",void 0),l=e([t("esri.layers.mixins.RasterJobHandlerMixin")],l),l};export{i as RasterJobHandlerMixin};