12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.25/esri/copyright.txt for details.
- */
- import{_ as e}from"../chunks/tslib.es6.js";import r from"../request.js";import t from"../TimeExtent.js";import o from"../core/Error.js";import{HandleOwnerMixin as i}from"../core/HandleOwner.js";import{loadAll as s}from"../core/loadAll.js";import{isSome as a}from"../core/maybe.js";import{MultiOriginJSONMixin as p}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as n,isAbortError as m}from"../core/promiseUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import{Integer as c}from"../core/accessorSupport/ensureType.js";import{reader as y}from"../core/accessorSupport/decorators/reader.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import{writer as h}from"../core/accessorSupport/decorators/writer.js";import{nameToId as d,OriginId as f}from"../core/accessorSupport/PropertyOrigin.js";import g from"../geometry/Extent.js";import{getScale as b}from"../geometry/support/scaleUtils.js";import x from"./Layer.js";import{APIKeyMixin as j}from"./mixins/APIKeyMixin.js";import{ArcGISMapService as v}from"./mixins/ArcGISMapService.js";import{ArcGISService as S}from"./mixins/ArcGISService.js";import{BlendLayer as I}from"./mixins/BlendLayer.js";import{CustomParametersMixin as w}from"./mixins/CustomParametersMixin.js";import{OperationalLayer as O}from"./mixins/OperationalLayer.js";import{PortalLayer as E}from"./mixins/PortalLayer.js";import{RefreshableLayer as L}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as M}from"./mixins/ScaleRangeLayer.js";import{SublayersOwner as P}from"./mixins/SublayersOwner.js";import{TemporalLayer as T}from"./mixins/TemporalLayer.js";import{url as U}from"./support/commonProperties.js";import{ExportImageParameters as R}from"./support/ExportImageParameters.js";import N from"./support/Sublayer.js";import{shouldWriteSublayerStructure as A}from"./support/sublayerUtils.js";import{serviceSupportsSpatialReference as J}from"./support/versionUtils.js";let q=class extends(I(T(M(P(v(S(O(E(p(L(j(w(i(x)))))))))))))){constructor(...e){super(...e),this.datesInUnknownTimezone=!1,this.dpi=96,this.gdbVersion=null,this.imageFormat="png24",this.imageMaxHeight=2048,this.imageMaxWidth=2048,this.imageTransparency=!0,this.isReference=null,this.labelsVisible=!1,this.operationalLayerType="ArcGISMapServiceLayer",this.sourceJSON=null,this.sublayers=null,this.type="map-image",this.url=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:["Map Service"]},e).catch(n).then((()=>this._fetchService(r)))),Promise.resolve(this)}readImageFormat(e,r){const t=r.supportedImageFormatTypes;return t&&t.includes("PNG32")?"png32":"png24"}writeSublayers(e,r,t,o){if(!this.loaded||!e)return;const i=e.slice().reverse().flatten((({sublayers:e})=>e&&e.toArray().reverse())).toArray();let s=!1;if(this.capabilities&&this.capabilities.operations.supportsExportMap&&this.capabilities.exportMap.supportsDynamicLayers){const e=d(o.origin);if(e===f.PORTAL_ITEM){const e=this.createSublayersForOrigin("service").sublayers;s=A(i,e,f.SERVICE)}else if(e>f.PORTAL_ITEM){const e=this.createSublayersForOrigin("portal-item");s=A(i,e.sublayers,d(e.origin))}}const a=[],p={writeSublayerStructure:s,...o};let n=s;i.forEach((e=>{const r=e.write({},p);a.push(r),n=n||"user"===e.originOf("visible")}));a.some((e=>Object.keys(e).length>1))&&(r.layers=a),n&&(r.visibleLayers=i.filter((e=>e.visible)).map((e=>e.id)))}createExportImageParameters(e,r,t,o){const i=o&&o.pixelRatio||1;e&&this.version>=10&&(e=e.clone().shiftCentralMeridian());const s=new R({layer:this,floors:o?.floors,scale:b({extent:e,width:r})*i}),a=s.toJSON();s.destroy();const p=!o||!o.rotation||this.version<10.3?{}:{rotation:-o.rotation},n=e&&e.spatialReference,m=n.wkid||JSON.stringify(n.toJSON());a.dpi*=i;const l={};if(o?.timeExtent){const{start:e,end:r}=o.timeExtent.toJSON();l.time=e&&r&&e===r?""+e:`${e??"null"},${r??"null"}`}else this.timeInfo&&!this.timeInfo.hasLiveData&&(l.time="null,null");return{bbox:e&&e.xmin+","+e.ymin+","+e.xmax+","+e.ymax,bboxSR:m,imageSR:m,size:r+","+t,...a,...p,...l}}async fetchImage(e,r,t,o){return this._fetchImage("image",e,r,t,o)}async fetchImageBitmap(e,r,t,o){const i=await this._fetchImage("blob",e,r,t,o);return createImageBitmap(i)}async fetchRecomputedExtents(e={}){const o={...e,query:{returnUpdates:!0,f:"json",...this.customParameters,token:this.apiKey}},{data:i}=await r(this.url,o),{extent:s,fullExtent:a,timeExtent:p}=i,n=s||a;return{fullExtent:n&&g.fromJSON(n),timeExtent:p&&t.fromJSON({start:p[0],end:p[1]})}}loadAll(){return s(this,(e=>{e(this.allSublayers)}))}serviceSupportsSpatialReference(e){return J(this,e)}async _fetchImage(e,t,i,s,a){const p={responseType:e,signal:a?.signal??null,query:{...this.parsedUrl.query,...this.createExportImageParameters(t,i,s,a),f:"image",...this.refreshParameters,...this.customParameters,token:this.apiKey}},n=this.parsedUrl.path+"/export";if(null!=p.query.dynamicLayers&&!this.capabilities.exportMap.supportsDynamicLayers)throw new o("mapimagelayer:dynamiclayer-not-supported",`service ${this.url} doesn't support dynamic layers, which is required to be able to change the sublayer's order, rendering, labeling or source.`,{query:p.query});try{const{data:e}=await r(n,p);return e}catch(l){if(m(l))throw l;throw new o("mapimagelayer:image-fetch-error",`Unable to load image: ${n}`,{error:l})}}async _fetchService(e){if(this.sourceJSON)return void this.read(this.sourceJSON,{origin:"service",url:this.parsedUrl});const{data:t,ssl:o}=await r(this.parsedUrl.path,{query:{f:"json",...this.parsedUrl.query,...this.customParameters,token:this.apiKey},signal:e});o&&(this.url=this.url.replace(/^http:/i,"https:")),this.sourceJSON=t,this.read(t,{origin:"service",url:this.parsedUrl})}};e([l({type:Boolean})],q.prototype,"datesInUnknownTimezone",void 0),e([l()],q.prototype,"dpi",void 0),e([l()],q.prototype,"gdbVersion",void 0),e([l()],q.prototype,"imageFormat",void 0),e([y("imageFormat",["supportedImageFormatTypes"])],q.prototype,"readImageFormat",null),e([l({json:{origins:{service:{read:{source:"maxImageHeight"}}}}})],q.prototype,"imageMaxHeight",void 0),e([l({json:{origins:{service:{read:{source:"maxImageWidth"}}}}})],q.prototype,"imageMaxWidth",void 0),e([l()],q.prototype,"imageTransparency",void 0),e([l({type:Boolean,json:{read:!1,write:{enabled:!0,overridePolicy:()=>({enabled:!1})}}})],q.prototype,"isReference",void 0),e([l({json:{read:!1,write:!1}})],q.prototype,"labelsVisible",void 0),e([l({type:["ArcGISMapServiceLayer"]})],q.prototype,"operationalLayerType",void 0),e([l({json:{read:!1,write:!1}})],q.prototype,"popupEnabled",void 0),e([l()],q.prototype,"sourceJSON",void 0),e([l({json:{write:{ignoreOrigin:!0}}})],q.prototype,"sublayers",void 0),e([h("sublayers",{layers:{type:[N]},visibleLayers:{type:[c]}})],q.prototype,"writeSublayers",null),e([l({type:["show","hide","hide-children"]})],q.prototype,"listMode",void 0),e([l({json:{read:!1},readOnly:!0,value:"map-image"})],q.prototype,"type",void 0),e([l(U)],q.prototype,"url",void 0),q=e([u("esri.layers.MapImageLayer")],q);const F=q;export{F as default};
|