UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 3.78 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{valueInUnit as r}from"../../../../core/quantity.js";import{watch as i,syncAndInitial as o}from"../../../../core/reactiveUtils.js";import{getMetersPerVerticalUnitForSR as n}from"../../../../core/units.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{SceneDrawSurface as l,ElevationDrawSurface as c,MapDrawSurface as u}from"../../drawSurfaces.js";let f=class extends t{constructor(e){super(e),this._viewDrawSurface=null,this._elevationDrawSurface=null,this._firstPointZ=null,this.getContext=null,this.hasZ=!1,this.spatialReference=null,this.elevationInfo=null,this.excludedGraphicsLayer=null,this.view=null,this.defaultZ=null,this.snapToSceneEnabled=null}initialize(){super.initialize(),this._setupSurfaces(),this.addHandles(i(()=>({surface:this._elevationDrawSurface,defaultZ:this._effectiveDefaultZ}),({surface:e,defaultZ:t})=>{e&&(e.defaultZ=t)},o))}get _effectiveDrawSurface(){if(!this._elevationDrawSurface)return this._viewDrawSurface;const{hasZ:e,elevationInfo:t,_viewDrawSurface:r,_elevationDrawSurface:i,drawAtFixedElevation:o,constraintsEnabled:n,elevationConstraint:a,snapToSceneEnabled:s}=this;return!e||"on-the-ground"===t?.mode||o||!1===s||n&&a&&this.metersPerVerticalUnit?i:r}get _effectiveDefaultZ(){const{constraintsEnabled:e,elevationConstraint:t,drawAtFixedElevation:i,defaultZ:o}=this,{metersPerVerticalUnit:n}=this,a=t&&n?r(t,"meters")/n:null;return i||e&&null!=a?a??this._firstPointZ??o:null}get context(){return this.getContext()}get constraintsEnabled(){return this.context?.constraintsEnabled}get elevationConstraint(){return this.context?.elevationConstraint}get drawAtFixedElevation(){return this.context?.drawAtFixedElevation??!1}get metersPerVerticalUnit(){const e=this.spatialReference;return e?n(e):null}get test(){return{viewSurface:this._viewDrawSurface,elevationSurface:this._elevationDrawSurface,effectiveSurface:this._effectiveDrawSurface,setFirstPointZ:e=>this._firstPointZ=e}}screenToMap(e,t){this._firstPointZ=t.firstPointZ;const r=this._effectiveDrawSurface;return r?r?.screenToMap(e):this.view?.toMap(e)}mapToScreen(e,t){this._firstPointZ=t.firstPointZ;const r=this._effectiveDrawSurface;return r?r.mapToScreen(e):this.view?.toScreen(e)}_setupSurfaces(){const{view:e,elevationInfo:t,excludedGraphicsLayer:r,hasZ:i}=this;"3d"===e?.type?(this._viewDrawSurface=new l(e,t,r?[r]:void 0),this._elevationDrawSurface=new c(t??{mode:"absolute-height",offset:0},this.defaultZ,e,r??void 0)):"2d"===e?.type&&(this._viewDrawSurface??=new u(e,i,this.defaultZ??void 0))}};e([a()],f.prototype,"_viewDrawSurface",void 0),e([a()],f.prototype,"_elevationDrawSurface",void 0),e([a()],f.prototype,"_effectiveDrawSurface",null),e([a()],f.prototype,"_effectiveDefaultZ",null),e([a()],f.prototype,"_firstPointZ",void 0),e([a({constructOnly:!0})],f.prototype,"getContext",void 0),e([a()],f.prototype,"context",null),e([a({constructOnly:!0})],f.prototype,"hasZ",void 0),e([a({constructOnly:!0})],f.prototype,"spatialReference",void 0),e([a({constructOnly:!0})],f.prototype,"elevationInfo",void 0),e([a({constructOnly:!0})],f.prototype,"excludedGraphicsLayer",void 0),e([a({constructOnly:!0})],f.prototype,"view",void 0),e([a()],f.prototype,"constraintsEnabled",null),e([a()],f.prototype,"elevationConstraint",null),e([a()],f.prototype,"drawAtFixedElevation",null),e([a()],f.prototype,"defaultZ",void 0),e([a()],f.prototype,"snapToSceneEnabled",void 0),e([a()],f.prototype,"metersPerVerticalUnit",null),f=e([s("esri.views.draw.support.managers.SurfaceManager")],f);export{f as SurfaceManager};