UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 2.6 kB
/* 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 t from"../../../core/Logger.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{isAbortError as i}from"../../../core/promiseUtils.js";import{watch as s}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import n from"../../../geometry/Extent.js";import{BitmapContainer as p}from"../engine/BitmapContainer.js";import{LayerView2DMixin as m}from"./LayerView2D.js";import h from"./support/ExportStrategy.js";import c from"../../layers/LayerView.js";import d from"../../layers/RefreshableLayerView.js";import u from"../../layers/WMSLayerView.js";let g=class extends(u(d(m(c)))){constructor(){super(...arguments),this.bitmapContainer=new p}supportsSpatialReference(e){return this.layer.serviceSupportsSpatialReference(e)}update(e){this.strategy.update(e).catch((e=>{i(e)||t.getLogger(this).error(e)}))}attach(){const{layer:e}=this,{imageMaxHeight:t,imageMaxWidth:r}=e;this.bitmapContainer=new p,this.container.addChild(this.bitmapContainer),this.strategy=new h({container:this.bitmapContainer,fetchSource:this.fetchImage.bind(this),requestUpdate:this.requestUpdate.bind(this),imageMaxHeight:t,imageMaxWidth:r,imageRotationSupported:!1,imageNormalizationSupported:!1,hidpi:!1}),this.addAttachHandles(s((()=>this.exportImageVersion),(()=>this.requestUpdate())))}detach(){this.strategy=r(this.strategy),this.container.removeAllChildren()}viewChange(){}moveEnd(){this.requestUpdate()}createFetchPopupFeaturesQuery(e){const{view:t,bitmapContainer:r}=this,{x:i,y:s}=e,{spatialReference:a}=t;let o,p=0,m=0;if(r.children.some((e=>{const{width:t,height:r,resolution:h,x:c,y:d}=e,u=c+h*t,g=d-h*r;return i>=c&&i<=u&&s<=d&&s>=g&&(o=new n({xmin:c,ymin:g,xmax:u,ymax:d,spatialReference:a}),p=t,m=r,!0)})),!o)return null;const h=o.width/p,c=Math.round((i-o.xmin)/h),d=Math.round((o.ymax-s)/h);return{extent:o,width:p,height:m,x:c,y:d}}async doRefresh(){this.requestUpdate()}isUpdating(){return this.strategy.updating||this.updateRequested}fetchImage(e,t,r,i){return this.layer.fetchImageBitmap(e,t,r,{timeExtent:this.timeExtent,...i})}};e([a()],g.prototype,"strategy",void 0),e([a()],g.prototype,"updating",void 0),g=e([o("esri.views.2d.layers.WMSLayerView2D")],g);const y=g;export{y as default};