@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.03 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{createScreenPointArray as e,createScreenPoint as t}from"../../core/screenUtils.js";import s from"../../geometry/Point.js";import r from"../../geometry/SpatialReference.js";import{makeDehydratedPoint as n}from"../../layers/graphics/dehydratedPoint.js";import{clonePoint as i}from"../../layers/graphics/hydratedFeatures.js";import{getConvertedElevation as o,getZForElevationMode as a}from"../../support/elevationInfoUtils.js";class c{constructor(e,t,s,r=null){this._elevationInfo=e,this.defaultZ=t,this._view=s,this._excludeGraphics=r}screenToMap(t){const{defaultZ:s,_view:r}=this,n=r.sceneIntersectionHelper.intersectElevationFromScreen(e(t.x,t.y),this._elevationInfo,s??0,this._excludeGraphics);return null==s&&null!=n&&(n.z=void 0),n}mapToScreen(e){const t=n(e.x,e.y,o(this._view,e,this._elevationInfo),e.spatialReference);return this._view.toScreen(t)}constrainZ(e){const{defaultZ:t}=this;return null!=t&&e.z!==t&&((e=i(e)).z=t),e}}class l{constructor(e,t,s=[]){this.view=e,this.elevationInfo=t,this.exclude=s}screenToMap(e){const t=this.view.toMap(e,{exclude:this.exclude,excludeLabels:!0});return null!=t&&(t.z=a(t,this.view,this.elevationInfo)),t}mapToScreen(e){let t=e;return null!=this.elevationInfo&&(t=n(e.x,e.y,o(this.view,e,this.elevationInfo),e.spatialReference)),this.view.toScreen(t)}constrainZ(e){return e}}class h{constructor(e,t=!1,s=0){this.view=e,this.hasZ=t,this.defaultZ=s,this.mapToScreen=t=>e.toScreen(t),this.screenToMap=t?t=>{const r=e.toMap(t);return r.z=s,r}:t=>e.toMap(t)}constrainZ(e){const{defaultZ:t}=this;return this.hasZ&&e.z!==t&&((e=i(e)).z=t),e}}class u{screenToMap(e){const{x:t,y:r}=e;return new s({x:t,y:r,spatialReference:u.spatialReference})}mapToScreen(e){return t(e.x,e.y)}constrainZ(e){return e}static{this.spatialReference=new r}}export{c as ElevationDrawSurface,h as MapDrawSurface,l as SceneDrawSurface,u as ScreenDrawSurface};