@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 5.26 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 r from"../PopupTemplate.js";import t from"../core/Clonable.js";import o from"../core/Error.js";import{MultiOriginJSONMixin as s}from"../core/MultiOriginJSONSupport.js";import{debounce as i,throwIfAbortError as a}from"../core/promiseUtils.js";import{property as p}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import{writer as l}from"../core/accessorSupport/decorators/writer.js";import m from"./Layer.js";import{ArcGISImageService as c}from"./mixins/ArcGISImageService.js";import{ArcGISService as u}from"./mixins/ArcGISService.js";import{BlendLayer as y}from"./mixins/BlendLayer.js";import{CustomParametersMixin as d}from"./mixins/CustomParametersMixin.js";import{OperationalLayer as f}from"./mixins/OperationalLayer.js";import{PortalLayer as h}from"./mixins/PortalLayer.js";import{RasterJobHandlerMixin as g}from"./mixins/RasterJobHandlerMixin.js";import{RasterPresetRendererMixin as v}from"./mixins/RasterPresetRendererMixin.js";import{RefreshableLayer as S}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as j}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as L}from"./mixins/TemporalLayer.js";import{legendEnabled as w,popupEnabled as I}from"./support/commonProperties.js";import{commonRasterFieldNames as b,rasterDimensionFieldPrefix as x,setDefaultRasterFieldFormats as P}from"./support/rasterFieldUtils.js";import{serviceSupportsSpatialReference as A}from"./support/versionUtils.js";import{createPopupTemplate as T}from"../support/popupUtils.js";import{SaveOperationType as _}from"../webdoc/interfaces.js";let C=class extends(y(L(j(f(h(v(c(g(S(d(u(s(t.ClonableMixin(m)))))))))))))){constructor(...e){super(...e),this.isReference=null,this.operationalLayerType="ArcGISImageServiceLayer",this.popupEnabled=!0,this.popupTemplate=null,this.type="imagery",this._debouncedSaveOperations=i((async(e,r,t)=>{const{save:o,saveAs:s}=await import("./save/imageryUtils.js");switch(e){case _.SAVE:return o(this,r);case _.SAVE_AS:return s(this,t,r)}}))}normalizeCtorArgs(e,r){return"string"==typeof e?{url:e,...r}:e}load(e){const r=null!=e?e.signal:null;return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Image Service"]},e).catch(a).then((()=>this._fetchService(r)))),Promise.resolve(this)}get legendEnabled(){return!this._isPreviewLayer&&(this._get("legendEnabled")??!0)}set legendEnabled(e){this._set("legendEnabled",e)}get listMode(){return this._isPreviewLayer?"hide":this._get("listMode")}set listMode(e){this._set("listMode",e)}writeOperationalLayerType(e,r,t){const o="vector-field"===this.renderer?.type;r[t]=o?"ArcGISImageServiceVectorLayer":"ArcGISImageServiceLayer"}get defaultPopupTemplate(){return this.createPopupTemplate()}get _isPreviewLayer(){return!(!this.raster||!this.url?.toLowerCase().includes("/rasterrendering/imageserver"))}createPopupTemplate(e){const{rasterFields:r}=this,t=new Set,o=b.itemPixelValue.toLowerCase(),s="raster-dataset"===this.sourceType,i=x.toLowerCase(),a=`${b.servicePixelValue.toLowerCase()}.`;for(const l of r){const e=l.name.toLowerCase();e===o||e.startsWith(a)||s&&e.startsWith(i)||t.add(l.name)}const p=T({fields:r,title:this.title},{...e,visibleFieldNames:t}),{rasterInfo:n}=this;return p?.fieldInfos&&n&&P(p.fieldInfos,n),p}queryFeatures(e,r){return this.queryRasters(e,r).then((e=>{if(e?.features)for(const r of e.features)r.layer=r.sourceLayer=this;return e}))}queryFeatureCount(e,r){return this.queryRasterCount(e,r)}redraw(){this.emit("redraw")}async save(e){return this._debouncedSaveOperations(_.SAVE,e)}async saveAs(e,r){return this._debouncedSaveOperations(_.SAVE_AS,r,e)}serviceSupportsSpatialReference(e){return A(this,e)}write(e,r){if(!this._isPreviewLayer)return super.write(e,r);if(r?.messages){const e=`${r.origin}/${r.layerContainerType||"operational-layers"}`;r.messages.push(new o("layer:unsupported",`Imagery preview layer (${this.title}, ${this.id}) of type '${this.declaredClass}' are not supported in the context of '${e}'`,{layer:this}))}return null}};e([p(w)],C.prototype,"legendEnabled",null),e([p({type:["show","hide"]})],C.prototype,"listMode",null),e([p({type:Boolean,json:{read:!1,write:{enabled:!0,overridePolicy:()=>({enabled:!1})}}})],C.prototype,"isReference",void 0),e([p({type:["ArcGISImageServiceLayer"],json:{origins:{"web-map":{type:["ArcGISImageServiceLayer","ArcGISImageServiceVectorLayer"],read:!1,write:{target:"layerType",ignoreOrigin:!0}}}}})],C.prototype,"operationalLayerType",void 0),e([l("web-map","operationalLayerType")],C.prototype,"writeOperationalLayerType",null),e([p(I)],C.prototype,"popupEnabled",void 0),e([p({type:r,json:{read:{source:"popupInfo"},write:{target:"popupInfo"}}})],C.prototype,"popupTemplate",void 0),e([p({readOnly:!0})],C.prototype,"defaultPopupTemplate",null),e([p({readOnly:!0,json:{read:!1}})],C.prototype,"type",void 0),e([p({readOnly:!0})],C.prototype,"_isPreviewLayer",null),C=e([n("esri.layers.ImageryLayer")],C);const E=C;export{E as default};