@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 2.5 kB
JavaScript
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import r from"../../../../core/Handles.js";import{isNone as o}from"../../../../core/maybe.js";import{isAbortError as s}from"../../../../core/promiseUtils.js";import{watch as i,on as a}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 l}from"../../../../core/accessorSupport/decorators/subclass.js";import{c}from"../../../../chunks/vec3f64.js";import u from"../../../../geometry/Point.js";import{center as p}from"../../../../geometry/support/aaBoundingRect.js";let h=class extends t{get surface(){return this.view.map?.ground}get surfaceView(){return this.view.basemapTerrain}get renderLocation(){if(!this.location)return null;const e=c();return this.view.renderCoordsHelper.toRenderCoords(this.location,e),e}constructor(e){super(e),this.location=null,this._updateController=null,this._handles=new r}initialize(){this.view.state.isLocal&&(this._handles.add([i((()=>[this.surfaceView?.spatialReference,this.surfaceView?.extent]),(()=>this._update())),a((()=>this.surface?.layers),"change",(()=>this._update()))]),this._update())}destroy(){this._handles.destroy()}_update(){if(this._updateController&&(this._updateController.abort(),this._updateController=null),!this.surfaceView||o(this.surfaceView.extent)||o(this.surfaceView.spatialReference))return void this._set("location",null);const e=p(this.surfaceView.extent),t=new u({x:e[0],y:e[1],z:0,spatialReference:this.surfaceView.spatialReference});this.surface&&this.surface.layers.length>0?(this._set("location",null),this._updateController=new AbortController,this.surface.queryElevation(t,{noDataValue:0,signal:this._updateController.signal,cache:this.cache}).then((e=>{this._updateController=null,this._set("location",e.geometry)})).catch((e=>{s(e)||e&&"elevation-query:invalid-layer"===e.name||console.error("StableSurfaceCenter failed to update: ",e)}))):this._set("location",t)}};e([n({constructOnly:!0})],h.prototype,"view",void 0),e([n({constructOnly:!0})],h.prototype,"cache",void 0),e([n()],h.prototype,"surface",null),e([n()],h.prototype,"surfaceView",null),e([n({readOnly:!0})],h.prototype,"location",void 0),e([n({readOnly:!0})],h.prototype,"renderLocation",null),h=e([l("esri.views.3d.terrain.StableSurfaceCenter")],h);export{h as StableSurfaceCenter};