WCSLayer.js 3.8 KB

12345
  1. /*
  2. All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. See https://js.arcgis.com/4.25/esri/copyright.txt for details.
  4. */
  5. import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Error.js";import{isSome as r}from"../core/maybe.js";import{MultiOriginJSONMixin as s}from"../core/MultiOriginJSONSupport.js";import{watch as o}from"../core/reactiveUtils.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/accessorSupport/ensureType.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import n from"./Layer.js";import{BlendLayer as l}from"./mixins/BlendLayer.js";import{CustomParametersMixin as p}from"./mixins/CustomParametersMixin.js";import{ImageryTileMixin as m}from"./mixins/ImageryTileMixin.js";import{OperationalLayer as u}from"./mixins/OperationalLayer.js";import{PortalLayer as c}from"./mixins/PortalLayer.js";import{RefreshableLayer as d}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as f}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as y}from"./mixins/TemporalLayer.js";import{popupEnabled as h}from"./support/commonProperties.js";import v from"./support/Field.js";import g from"./support/rasterDatasets/WCSRaster.js";import{createPopupTemplate as j}from"../support/popupUtils.js";const x=new Set(["milliseconds","seconds","minutes","hours","days","weeks","months","years","decades","centuries"]);let I=class extends(l(f(u(c(p(m(y(d(s(n)))))))))){constructor(...e){super(...e),this.coverageId=null,this.version=null,this.isReference=null,this.type="wcs",this.popupEnabled=!0,this.popupTemplate=null,this.fields=null}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}load(e){const t=r(e)?e.signal:null;return this.addResolvingPromise(this._openRaster(t)),Promise.resolve(this)}get coverageInfo(){return this.raster.coverageInfo}get defaultPopupTemplate(){return this.createPopupTemplate()}get rasterFields(){return[new v({name:"Raster.ServicePixelValue",alias:"Pixel Value",domain:null,editable:!1,length:50,type:"string"})]}createPopupTemplate(e){return j({fields:this.rasterFields,title:this.title},e)}async _openRaster(e){const s=new g({url:this.url,version:this.version,coverageId:this.coverageId,ioConfig:{sampling:"closest",...this.ioConfig,customFetchParameters:this.customParameters}});if(await s.open({signal:e}),!s.rasterInfo)throw s.destroy(),new t("wcs-layer:load","cannot load resources on "+this.url);null==this.title&&this.setAtOrigin("title",s.datasetName,"service"),null==this.coverageId&&this.setAtOrigin("coverageId",s.coverageInfo.id,"service");const{multidimensionalInfo:i}=s.rasterInfo;if(r(i)){const e=i.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 s=x.has(e.intervalUnit?.toLowerCase())?e.intervalUnit.toLowerCase():null;this.set("timeInfo",{startField:"StdTime",fullTimeExtent:{start:t,end:r},timeReference:null,interval:s?{value:e.interval,unit:s}:null})}}this.raster=s,this._configDefaultSettings(),this.addHandles(o((()=>this.customParameters),(e=>this.raster.ioConfig.customFetchParameters=e)))}};e([i({type:String,nonNullable:!0,json:{write:!0}})],I.prototype,"coverageId",void 0),e([i()],I.prototype,"coverageInfo",null),e([i()],I.prototype,"version",void 0),e([i()],I.prototype,"isReference",void 0),e([i()],I.prototype,"raster",void 0),e([i({readOnly:!0})],I.prototype,"type",void 0),e([i(h)],I.prototype,"popupEnabled",void 0),e([i()],I.prototype,"popupTemplate",void 0),e([i({readOnly:!0})],I.prototype,"defaultPopupTemplate",null),e([i({readOnly:!0,type:[v]})],I.prototype,"fields",void 0),e([i({readOnly:!0,type:[v]})],I.prototype,"rasterFields",null),I=e([a("esri.layers.WCSLayer")],I);const P=I;export{P as default};