UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 3.58 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{rad2deg as t}from"../../../core/mathUtils.js";import{getMetersPerUnitForSR as e,getMetersPerCartesianUnitForSR as o}from"../../../core/unitUtils.js";import{set as r}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{c as i}from"../../../chunks/vec32.js";import{getReferenceEllipsoid as s}from"../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as n}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectPointToVector as a}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPoint as m}from"../../../geometry/projection/projectVectorToPoint.js";import{projectVectorToVector as c}from"../../../geometry/projection/projectVectorToVector.js";import{create as l}from"../../../geometry/support/aaBoundingRect.js";import{Axis as p}from"../../../geometry/support/Axis.js";import{create as d,setExtent as h,getExtent as u,altitudeAt as f,setAltitudeAt as y,setAltitudeOfTransformation as g,normalAt as j,axisAt as S,elevate as _,intersectRayClosestSilhouette as w,intersectRay as A,createGlobal as P,createLocal as C}from"../../../geometry/support/coordinateSystem.js";import{intersectRay as R}from"../../../geometry/support/plane.js";import{angleAroundAxis as M}from"../../../geometry/support/vector.js";import{sv3d as U}from"../../../geometry/support/vectorStacks.js";import{isDehydratedPoint as v}from"../../../layers/graphics/dehydratedFeatureUtils.js";import{ViewingMode as x}from"../../ViewingMode.js";class B{constructor(t,e,o,r){this.viewingMode=t,this.spatialReference=e,this.unitInMeters=o,this._coordinateSystem=r,this._tmpCoordinateSystem=d(r),this.referenceEllipsoid=s(e),this.sphericalPCPF=n(e)}set extent(t){t&&h(this._coordinateSystem,t,this._coordinateSystem)}get extent(){return u(this._coordinateSystem,l())}getAltitude(t){return f(this._coordinateSystem,t)}setAltitude(t,e,o=t){return y(this._coordinateSystem,o,e,t)}setAltitudeOfTransformation(t,e){g(this._coordinateSystem,e,t,e)}worldUpAtPosition(t,e){return j(this._coordinateSystem,t,e)}worldBasisAtPosition(t,e,o){return S(this._coordinateSystem,t,e,o)}basisMatrixAtPosition(t,e){const o=this.worldBasisAtPosition(t,p.X,U.get()),i=this.worldBasisAtPosition(t,p.Y,U.get()),s=this.worldBasisAtPosition(t,p.Z,U.get());return r(e,o[0],o[1],o[2],0,i[0],i[1],i[2],0,s[0],s[1],s[2],0,0,0,0,1),e}headingAtPosition(e,o){const r=this.worldUpAtPosition(e,U.get()),i=this.worldBasisAtPosition(e,p.Y,U.get()),s=M(o,i,r);return t(s)}intersectManifoldClosestSilhouette(t,e,o){return _(this._coordinateSystem,e,this._tmpCoordinateSystem),w(this._tmpCoordinateSystem,t,o),o}intersectManifold(t,e,o){_(this._coordinateSystem,e,this._tmpCoordinateSystem);const r=U.get();return A(this._tmpCoordinateSystem,t,r)?i(o,r):null}intersectInfiniteManifold(t,e,o){if(this.viewingMode===x.Global)return this.intersectManifold(t,e,o);_(this._coordinateSystem,e,this._tmpCoordinateSystem);const r=this._tmpCoordinateSystem.value,s=U.get();return R(r.plane,t,s)?i(o,s):null}toRenderCoords(t,e,o){return v(t)?a(t,e,this.spatialReference):c(t,e,o,this.spatialReference)}fromRenderCoords(t,e,o=null){return v(e)?(null!=o&&(e.spatialReference=o),m(t,this.spatialReference,e)?e:null):c(t,this.spatialReference,e,o)?e:null}static create(t,o){switch(t){case x.Local:return new B(x.Local,o,e(o),C());case x.Global:return new B(x.Global,o,1,P(o))}}static renderUnitScaleFactor(t,e){return o(t)/o(e)}}export{B as RenderCoordsHelper};