@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 5.63 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 t from"../PopupTemplate.js";import r from"../core/Clonable.js";import o from"../core/Error.js";import{MultiOriginJSONMixin as s}from"../core/MultiOriginJSONSupport.js";import{debounce as i,throwIfAbortError as n}from"../core/promiseUtils.js";import{watch as a}from"../core/reactiveUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import m from"./Layer.js";import{BlendLayer as c}from"./mixins/BlendLayer.js";import{CustomParametersMixin as d}from"./mixins/CustomParametersMixin.js";import{ImageryTileMixin as u}from"./mixins/ImageryTileMixin.js";import{OperationalLayer as f}from"./mixins/OperationalLayer.js";import{PortalLayer as h}from"./mixins/PortalLayer.js";import{RasterJobHandlerMixin as y}from"./mixins/RasterJobHandlerMixin.js";import{RefreshableLayer as v}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as g}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as j}from"./mixins/TemporalLayer.js";import{legendEnabled as I,popupEnabled as S}from"./support/commonProperties.js";import w from"./support/Field.js";import{getServicePixelValueField as b,getMultidimensionalFields as x}from"./support/rasterFieldUtils.js";import A from"./support/rasterDatasets/WCSRaster.js";import{createPopupTemplate as P}from"../support/popupUtils.js";import{SaveOperationType as O}from"../webdoc/interfaces.js";const R=new Set(["milliseconds","seconds","minutes","hours","days","weeks","months","years","decades","centuries"]);let C=class extends(c(g(f(h(d(u(y(j(v(s(r.ClonableMixin(m)))))))))))){constructor(...e){super(...e),this.coverageId=null,this.version=null,this.isReference=null,this.legendEnabled=!0,this.noData=0,this.operationalLayerType="WCS",this.type="wcs",this.popupEnabled=!0,this.popupTemplate=null,this.fields=null,this._debouncedSaveOperations=i((async(e,t,r)=>{const{save:o,saveAs:s}=await import("./save/imageryUtils.js");switch(e){case O.SAVE:return o(this,t);case O.SAVE_AS:return s(this,r,t)}}))}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}load(e){const t=null!=e?e.signal:null;return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["WCS"]},e).catch(n).then((()=>this._openRaster(t)))),Promise.resolve(this)}get coverageInfo(){return this.raster.coverageInfo}get defaultPopupTemplate(){return this.createPopupTemplate()}get rasterFields(){const e=[b("Pixel Value")],t=this.raster?.rasterInfo??this.serviceRasterInfo,r=t?.multidimensionalInfo;if(r){const t=x(r);e.push(...t)}return e}createPopupTemplate(e){return P({fields:this.rasterFields,title:this.title},e)}async save(e){return this._debouncedSaveOperations(O.SAVE,e)}async saveAs(e,t){return this._debouncedSaveOperations(O.SAVE_AS,t,e)}async _openRaster(e){const t=new A({url:this.url,version:this.version,coverageId:this.coverageId,ioConfig:{sampling:"closest",...this.ioConfig,customFetchParameters:this.customParameters}});if(await t.open({signal:e}),!t.rasterInfo)throw t.destroy(),new o("wcs-layer:load","cannot load resources on "+this.url);const{rasterInfo:r}=t;null==r.noDataValue&&(r.noDataValue=this.noData),this._set("serviceRasterInfo",r),this._set("spatialReference",r.spatialReference),null==this.title&&this.setAtOrigin("title",t.datasetName,"service"),null==this.coverageId&&this.setAtOrigin("coverageId",t.coverageInfo.id,"service"),null==this.version&&t.version&&this.setAtOrigin("version",t.version,"service"),this.setAtOrigin("tileInfo",t.rasterInfo.storageInfo.tileInfo,"service");const{multidimensionalInfo:s}=r;if(null!=s){const e=s.variables[0].dimensions.find((({name:e})=>"StdTime"===e));if(e){let t=e.extent?.[0]??e.values[0];Array.isArray(t)&&(t=t[0]);let r=e.extent?.[1]??e.values[e.values.length-1];Array.isArray(r)&&(r=r[1]);const o=R.has(e.intervalUnit?.toLowerCase())?e.intervalUnit?.toLowerCase():null;this.set("timeInfo",{startField:"StdTime",fullTimeExtent:{start:t,end:r},timeZone:null,interval:o?{value:e.interval,unit:o}:null})}}this.raster=t,this._configDefaultSettings(),this.addHandles(a((()=>this.customParameters),(e=>this.raster.ioConfig.customFetchParameters=e)))}};e([l({type:String,nonNullable:!0,json:{name:"wcsInfo.coverageId",write:{isRequired:!0,ignoreOrigin:!0}}})],C.prototype,"coverageId",void 0),e([l()],C.prototype,"coverageInfo",null),e([l({type:["1.0.0","1.1.0","1.1.1","1.1.2","2.0.1"],nonNullable:!0,json:{name:"wcsInfo.version",write:{isRequired:!0,ignoreOrigin:!0}}})],C.prototype,"version",void 0),e([l({type:Boolean,json:{read:!1,write:{enabled:!0,overridePolicy:()=>({enabled:!1})}}})],C.prototype,"isReference",void 0),e([l({json:{read:!0,write:!0}})],C.prototype,"blendMode",void 0),e([l(I)],C.prototype,"legendEnabled",void 0),e([l({type:["show","hide"]})],C.prototype,"listMode",void 0),e([l()],C.prototype,"noData",void 0),e([l({type:["WCS"]})],C.prototype,"operationalLayerType",void 0),e([l()],C.prototype,"raster",void 0),e([l({readOnly:!0})],C.prototype,"type",void 0),e([l(S)],C.prototype,"popupEnabled",void 0),e([l({type:t,json:{name:"popupInfo",write:!0}})],C.prototype,"popupTemplate",void 0),e([l({readOnly:!0})],C.prototype,"defaultPopupTemplate",null),e([l({readOnly:!0,type:[w]})],C.prototype,"fields",void 0),e([l({readOnly:!0,type:[w]})],C.prototype,"rasterFields",null),C=e([p("esri.layers.WCSLayer")],C);const T=C;export{T as default};