UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

3 lines (2 loc) 5.5 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import t from"../PopupTemplate.js";import{ClonableMixin as r}from"../core/Clonable.js";import o from"../core/Error.js";import{MultiOriginJSONSupportMixin 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,subclass as p}from"../core/accessorSupport/decorators.js";import m from"../graphic/WCSGraphicOrigin.js";import d from"./Layer.js";import{BlendLayer as u}from"./mixins/BlendLayer.js";import{CustomParametersMixin as c}from"./mixins/CustomParametersMixin.js";import{OperationalLayer as h}from"./mixins/OperationalLayer.js";import{PortalLayer as f}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{TiledImagery as I}from"./mixins/TiledImagery.js";import w from"./raster/datasets/WCSRaster.js";import{legendEnabled as O,popupEnabled as b}from"./support/commonProperties.js";import S from"./support/Field.js";import{getServicePixelValueField as x,getMultidimensionalFields as P}from"./support/rasterFieldUtils.js";import{createPopupTemplate as R}from"../support/popupUtils.js";const T=new Set(["milliseconds","seconds","minutes","hours","days","weeks","months","years","decades","centuries"]);let C=class extends(u(g(h(f(c(I(y(j(v(s(r(d)))))))))))){constructor(...e){super(...e),this.coverageId=null,this.version=null,this.isReference=null,this.graphicOrigin=new m(this),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 0:return o(this,t);case 1: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 renderer(){return super.renderer}set renderer(e){super.renderer=e}get coverageInfo(){return this.raster.coverageInfo}get defaultPopupTemplate(){return this.createPopupTemplate()}get rasterFields(){const e=[x("Pixel Value")],t=this.raster?.rasterInfo??this.serviceRasterInfo,r=t?.multidimensionalInfo;if(r){const t=P(r);e.push(...t)}return e}createPopupTemplate(e){return R({fields:this.rasterFields,title:this.title},e)}async save(e){return this._debouncedSaveOperations(0,e)}async saveAs(e,t){return this._debouncedSaveOperations(1,t,e)}async _openRaster(e){const t=new w({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=T.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({readOnly:!0,clonable:!1})],C.prototype,"graphicOrigin",void 0),e([l(O)],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(b)],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:[S]})],C.prototype,"fields",void 0),e([l({readOnly:!0,type:[S]})],C.prototype,"rasterFields",null),C=e([p("esri.layers.WCSLayer")],C);const L=C;export{L as default};