ImageryTileLayer.js 7.3 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 r from"../PopupTemplate.js";import{read as t,rasterRendererTypes as o,websceneRasterRendererTypes as i}from"../rasterRenderers.js";import s from"../core/Error.js";import{isSome as a}from"../core/maybe.js";import{MultiOriginJSONMixin as n}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as l}from"../core/promiseUtils.js";import{watch as p}from"../core/reactiveUtils.js";import{property as d}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import{Integer as u}from"../core/accessorSupport/ensureType.js";import{enumeration as m}from"../core/accessorSupport/decorators/enumeration.js";import{reader as c}from"../core/accessorSupport/decorators/reader.js";import{subclass as y}from"../core/accessorSupport/decorators/subclass.js";import h from"./Layer.js";import{BlendLayer as f}from"./mixins/BlendLayer.js";import{CustomParametersMixin as v}from"./mixins/CustomParametersMixin.js";import{ImageryTileMixin as g}from"./mixins/ImageryTileMixin.js";import{OperationalLayer as j}from"./mixins/OperationalLayer.js";import{PortalLayer as b}from"./mixins/PortalLayer.js";import{RefreshableLayer as S}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as w}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as T}from"./mixins/TemporalLayer.js";import{legendEnabled as P}from"./support/commonProperties.js";import R from"./support/Field.js";import{interpolationKebab as O}from"./support/rasterEnums.js";import I from"./support/rasterDatasets/FunctionRaster.js";import x from"./support/rasterDatasets/RasterFactory.js";import{create as L}from"./support/rasterFunctions/rasterFunctionHelper.js";import{createPopupTemplate as F}from"../support/popupUtils.js";let N=class extends(f(w(j(b(v(g(T(S(n(h)))))))))){constructor(...e){super(...e),this.bandIds=null,this.interpolation=null,this.legendEnabled=!0,this.isReference=null,this.listMode="show",this.sourceJSON=null,this.version=null,this.title=null,this.type="imagery-tile",this.operationalLayerType="ArcGISTiledImageServiceLayer",this.popupEnabled=!0,this.popupTemplate=null,this.fields=null}normalizeCtorArgs(e,r){return"string"==typeof e?{url:e,...r}:e}load(e){const r=a(e)?e.signal:null;return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Image Service"]},e).catch(l).then((()=>this._openRaster(r)))),Promise.resolve(this)}get defaultPopupTemplate(){return this.createPopupTemplate()}get rasterFields(){let e=[new R({name:"Raster.ServicePixelValue",alias:"Pixel Value",domain:null,editable:!1,length:50,type:"string"})];const{rasterInfo:r}=this,{attributeTable:t}=r,o=a(t)?t.fields:null,i="Raster.";if(o){const r=o.filter((e=>"oid"!==e.type&&"value"!==e.name.toLowerCase())).map((e=>{const r=e.clone();return r.name=i+e.name,r}));e=e.concat(r)}const{dataType:s,multidimensionalInfo:n}=r;if(("vector-magdir"===s||"vector-uv"===s)&&a(n)){const r=n.variables[0].unit?.trim(),t="Magnitude"+(r?` (${r})`:"");e.push(new R({name:"Raster.Magnitude",alias:t,domain:null,editable:!1,type:"double"})),e.push(new R({name:"Raster.Direction",alias:"Direction (°)",domain:null,editable:!1,type:"double"}))}return e}set renderer(e){this._set("renderer",e),this.updateRenderer()}readRenderer(e,r,o){const i=r&&r.layerDefinition&&r.layerDefinition.drawingInfo&&r.layerDefinition.drawingInfo.renderer,s=t(i,o)||void 0;if(null!=s)return s}createPopupTemplate(e){return F({fields:this.rasterFields,title:this.title},e)}write(e,r){const{raster:t}=this;if(this.loaded?"RasterTileServer"===t.datasetFormat&&("Raster"===t.tileType||"Map"===t.tileType):this.url&&/\/ImageServer(\/|\/?$)/i.test(this.url))return super.write(e,r);if(r&&r.messages){const e=`${r.origin}/${r.layerContainerType||"operational-layers"}`;r.messages.push(new s("layer:unsupported",`Layers (${this.title}, ${this.id}) of type '${this.declaredClass}' are not supported in the context of '${e}'`,{layer:this}))}return null}async _openRaster(e){if(this.raster)this.raster.rasterInfo||await this.raster.open(),this.url=this.raster.url;else{const r=await x.open({url:this.url,sourceJSON:this.sourceJSON,ioConfig:{sampling:"closest",...this.ioConfig,customFetchParameters:this.customParameters},signal:e});if(this.rasterFunction){const e=L(this.rasterFunction.toJSON(),{raster:r}),t=new I({rasterFunction:e});await t.open(),this.raster=t}else this.raster=r}const{rasterInfo:r}=this.raster;if(!r)throw new s("imagery-tile-layer:load","cannot load resources on "+this.url);if(this.sourceJSON=this.sourceJSON||this.raster.sourceJSON,null!=this.sourceJSON){const e="Map"===this.raster.tileType&&null!=this.sourceJSON.minLOD&&null!=this.sourceJSON.maxLOD?this.sourceJSON:{...this.sourceJSON,minScale:0,maxScale:0};this.read(e,{origin:"service"})}null==this.title&&(this.title=this.raster.datasetName),"Map"===this.raster.tileType&&(this.popupEnabled=!1),this._configDefaultSettings(),this.addHandles(p((()=>this.customParameters),(e=>{this.raster.ioConfig.customFetchParameters=e})))}};e([d({type:[u],json:{write:{overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType||"0,1,2"!==this.bandIds?.join(",")}}}}})],N.prototype,"bandIds",void 0),e([d({json:{write:{overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType||"bilinear"!==this.interpolation}}}}}),m(O)],N.prototype,"interpolation",void 0),e([d({json:{write:!0}})],N.prototype,"multidimensionalDefinition",void 0),e([d(P)],N.prototype,"legendEnabled",void 0),e([d({type:Boolean,json:{read:!1,write:{enabled:!0,overridePolicy:()=>({enabled:!1})}}})],N.prototype,"isReference",void 0),e([d({type:["show","hide"]})],N.prototype,"listMode",void 0),e([d({json:{read:!0,write:!0}})],N.prototype,"blendMode",void 0),e([d()],N.prototype,"sourceJSON",void 0),e([d({readOnly:!0,json:{origins:{service:{read:{source:"currentVersion"}}}}})],N.prototype,"version",void 0),e([d()],N.prototype,"title",void 0),e([d({readOnly:!0,json:{read:!1}})],N.prototype,"type",void 0),e([d({type:["ArcGISTiledImageServiceLayer"]})],N.prototype,"operationalLayerType",void 0),e([d({type:Boolean,value:!0,json:{read:{source:"disablePopup",reader:(e,r)=>!r.disablePopup},write:{target:"disablePopup",overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType}},writer(e,r,t){r[t]=!e}}}})],N.prototype,"popupEnabled",void 0),e([d({type:r,json:{read:{source:"popupInfo"},write:{target:"popupInfo",overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType}}}}})],N.prototype,"popupTemplate",void 0),e([d({readOnly:!0})],N.prototype,"defaultPopupTemplate",null),e([d({readOnly:!0,type:[R]})],N.prototype,"fields",void 0),e([d({readOnly:!0,type:[R]})],N.prototype,"rasterFields",null),e([d({types:o,json:{name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy(){const e="raster-stretch"===this.renderer?.type&&"none"===this.renderer.stretchType&&!this.renderer.useGamma;return{enabled:!this.loaded||"Raster"===this.raster.tileType||!e}}},origins:{"web-scene":{types:i,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type&&"flow"!==e.type})}}}}})],N.prototype,"renderer",null),e([c("renderer")],N.prototype,"readRenderer",null),N=e([y("esri.layers.ImageryTileLayer")],N);const J=N;export{J as default};