@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 4.2 kB
JavaScript
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import i from"../../../core/Collection.js";import{watch as r,syncAndInitial as s,sync as a}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{GraphicsCollection as n}from"../../../support/GraphicsCollection.js";import l from"../engine/flow/FlowView2D.js";import{LayerView2DMixin as c}from"./LayerView2D.js";import w from"./graphics/GraphicsView2D.js";import p from"./graphics/HighlightGraphicContainer.js";import u from"./imagery/ImageryView2D.js";import d from"./imagery/VectorFieldView2D.js";import m from"../../layers/ImageryLayerView.js";import y from"../../layers/LayerView.js";import v from"../../layers/RefreshableLayerView.js";let g=class extends(m(v(c(y)))){constructor(){super(...arguments),this._exportImageVersion=-1,this._highlightGraphics=new n,this._highlightView=void 0,this.layer=null,this.subview=null}get pixelData(){const{subview:e}=this;return this.updating||!e?null:"getPixelData"in e?e.getPixelData():null}async hitTest(e,t){return this.subview?[{type:"graphic",graphic:this.subview.hitTest(e),layer:this.layer,mapPoint:e}]:null}update(e){this.subview?.update(e)}attach(){this.layer.increaseRasterJobHandlerUsage(),this._setSubView(),this.view&&(this._highlightView=new w({view:this.view,graphics:this._highlightGraphics,requestUpdateCallback:()=>this.requestUpdate(),container:new p(this.view.featuresTilingScheme)}),this.container.addChild(this._highlightView.container)),this.addAttachHandles([r((()=>this.layer.blendMode??"normal"),(e=>this.subview&&(this.subview.container.blendMode=e)),s),r((()=>this.layer.effect??null),(e=>this.subview&&(this.subview.container.effect=e)),s),r((()=>this.layer.exportImageServiceParameters.version),(e=>{e&&this._exportImageVersion!==e&&(this._exportImageVersion=e,this.requestUpdate())}),a),r((()=>this.timeExtent),(e=>{const{subview:t}=this;t&&(t.timeExtent=e,"redraw"in t?this.requestUpdate():t.redrawOrRefetch())}),a),this.layer.on("redraw",(()=>{const{subview:e}=this;e&&("redraw"in e?e.redraw():e.redrawOrRefetch())})),r((()=>this.layer.renderer),(()=>this._setSubView()))])}detach(){this.layer.decreaseRasterJobHandlerUsage(),this.container.removeAllChildren(),this._detachSubview(this.subview),this.subview?.destroy(),this.subview=null,this._highlightView?.destroy(),this._exportImageVersion=-1}moveStart(){}viewChange(){}moveEnd(){this.requestUpdate()}highlight(e,r){if(!((Array.isArray(e)?e[0]:i.isCollection(e)?e.getItemAt(0):e)instanceof t))return{remove:()=>{}};let s=[];return Array.isArray(e)||i.isCollection(e)?s=e.map((e=>e.clone())):e instanceof t&&(s=[e.clone()]),this._highlightGraphics.addMany(s),{remove:()=>{this._highlightGraphics.removeMany(s)}}}async doRefresh(){this.requestUpdate()}isUpdating(){return!this.subview||this.subview.updating}_setSubView(){if(!this.view)return;const e=this.layer.renderer?.type;let t="imagery";if("vector-field"===e?t="imageryVF":"flow"===e&&(t="flow"),this.subview){const{type:e}=this.subview;if(e===t)return this._attachSubview(this.subview),void("flow"===e?this.subview.redrawOrRefetch():"imagery"===e&&"lerc"===this.layer.format?this.subview.redraw():this.requestUpdate());this._detachSubview(this.subview),this.subview?.destroy()}this.subview="imagery"===t?new u({layer:this.layer,view:this.view,timeExtent:this.timeExtent}):"imageryVF"===t?new d({layer:this.layer,view:this.view,timeExtent:this.timeExtent}):new l({layer:this.layer,layerView:this}),this._attachSubview(this.subview),this.requestUpdate()}_attachSubview(e){e&&!e.attached&&(e.attach(),e.attached=!0,this.container.addChildAt(e.container,0),e.container.blendMode=this.layer.blendMode,e.container.effect=this.layer.effect)}_detachSubview(e){e?.attached&&(this.container.removeChild(e.container),e.detach(),e.attached=!1)}};e([h()],g.prototype,"pixelData",null),e([h()],g.prototype,"subview",void 0),g=e([o("esri.views.2d.layers.ImageryLayerView2D")],g);const b=g;export{b as default};