UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 4.82 kB
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Collection.js";import{referenceSetter as s}from"../../../core/collectionUtils.js";import i from"../../../core/Error.js";import{watch as r,syncAndInitial as a,on as o}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import{Container as h}from"../engine/Container.js";import c from"../support/HighlightOptions.js";import l from"../../layers/support/ClipRect.js";import d from"../../layers/support/Geometry.js";import u from"../../layers/support/Path.js";const y=t.ofType({key:"type",base:null,typeMap:{rect:l,path:u,geometry:d}}),f=t=>{let l=class extends t{constructor(){super(...arguments),this.attached=!1,this.clips=new y,this.lastUpdateId=-1,this.moving=!1,this.updateRequested=!1,this.visibleAtCurrentScale=!1,this.highlightOptions=null}initialize(){const e=this.view?.spatialReferenceLocked??!0,t=this.view?.spatialReference;t&&e&&!this.spatialReferenceSupported?this.addResolvingPromise(Promise.reject(new i("layerview:spatial-reference-incompatible","The spatial reference of this layer does not meet the requirements of the view",{layer:this.layer}))):(this.container||(this.container=new h),this.container.fadeTransitionEnabled=!0,this.container.visible=!1,this.container.endTransitions(),this.addHandles([r((()=>this.suspended),(e=>{this.container&&(this.container.visible=!e),this.view&&!e&&this.updateRequested&&this.view.requestUpdate()}),a),r((()=>this.layer?.opacity??1),(e=>{this.container&&(this.container.opacity=e)}),a),r((()=>this.layer&&"blendMode"in this.layer?this.layer.blendMode:"normal"),(e=>{this.container&&(this.container.blendMode=e)}),a),r((()=>this.layer&&"effect"in this.layer?this.layer.effect:null),(e=>{this.container&&(this.container.effect=e)}),a),r((()=>this.highlightOptions),(e=>this.container.highlightOptions=e),a),o((()=>this.clips),"change",(()=>{this.container&&(this.container.clips=this.clips)}),a),r((()=>({scale:this.view?.scale,scaleRange:this.layer&&"effectiveScaleRange"in this.layer?this.layer.effectiveScaleRange:null})),(({scale:e})=>{const t=null!=e&&this.isVisibleAtScale(e);t!==this.visibleAtCurrentScale&&this._set("visibleAtCurrentScale",t)}),a)],"constructor"),this.view?.whenLayerView?this.view.whenLayerView(this.layer).then((e=>{e===this&&this.processAttach()}),(()=>{})):this.when().then((()=>{this.processAttach()}),(()=>{})))}destroy(){this.processDetach(),this.updateRequested=!1}get spatialReferenceSupported(){const e=this.view?.spatialReference;return null==e||this.supportsSpatialReference(e)}get updating(){return this.spatialReferenceSupported&&(!this.attached||!this.suspended&&(this.updateRequested||this.isUpdating())||!!this.updatingHandles?.updating)}processAttach(){this.isResolved()&&!this.attached&&!this.destroyed&&this.spatialReferenceSupported&&(this.attach(),this.attached=!0,this.requestUpdate())}processDetach(){this.attached&&(this.attached=!1,this.removeHandles("attach"),this.detach(),this.updateRequested=!1)}isVisibleAtScale(e){const t=this.layer&&"effectiveScaleRange"in this.layer?this.layer.effectiveScaleRange:null;if(!t)return!0;const{minScale:s,maxScale:i}=t;return(0===s||e<=s)&&(0===i||e>=i)}requestUpdate(){this.destroyed||this.updateRequested||(this.updateRequested=!0,this.suspended||this.view.requestUpdate())}processUpdate(e){!this.isFulfilled()||this.isResolved()?(this._set("updateParameters",e),this.updateRequested&&!this.suspended&&(this.updateRequested=!1,this.update(e))):this.updateRequested=!1}hitTest(e,t){return Promise.resolve(null)}supportsSpatialReference(e){return!0}canResume(){return!!this.spatialReferenceSupported&&(!!super.canResume()&&this.visibleAtCurrentScale)}getSuspendInfo(){const e=super.getSuspendInfo(),t=!this.spatialReferenceSupported,s=this.visibleAtCurrentScale;return t&&(e.spatialReferenceNotSupported=t),s&&(e.outsideScaleRange=s),e}addAttachHandles(e){this.addHandles(e,"attach")}};return e([n()],l.prototype,"attached",void 0),e([n({type:y,set(e){const t=s(e,this._get("clips"),y);this._set("clips",t)}})],l.prototype,"clips",void 0),e([n()],l.prototype,"container",void 0),e([n()],l.prototype,"moving",void 0),e([n({readOnly:!0})],l.prototype,"spatialReferenceSupported",null),e([n({readOnly:!0})],l.prototype,"updateParameters",void 0),e([n()],l.prototype,"updateRequested",void 0),e([n()],l.prototype,"updating",null),e([n()],l.prototype,"view",void 0),e([n({readOnly:!0})],l.prototype,"visibleAtCurrentScale",void 0),e([n({type:c})],l.prototype,"highlightOptions",void 0),l=e([p("esri.views.2d.layers.LayerView2D")],l),l};export{f as LayerView2DMixin};