UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 3.03 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{cyclicalDegrees as e,Cyclical as r}from"../../core/Cyclical.js";import{convertRotationType as t,createAngle as o}from"../../core/quantity.js";import{convertUnit as i}from"../../core/units.js";import{angle as n}from"../../core/libs/gl-matrix-2/math/vec2.js";import{create as a,UNIT_Y as c}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as s,exactEquals as l,copy as u}from"../../core/libs/gl-matrix-2/math/vec3.js";import{create as f}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{geodesicCompatibleSpatialReference as m,inverseGeodeticSolver as g,InverseGeodeticSolverResult as p,directGeodeticSolver as d}from"../../geometry/geodesicUtils.js";import{projectVectorToVector as h}from"../../geometry/projection/projectVectorToVector.js";import{equals as v}from"../../geometry/support/spatialReferenceUtils.js";function j(e,r){if(null==e||null==r)return;const t=b(e,r);return null!=t?o(t,"radians","geographic"):void 0}const b=(()=>{const e=f(),r=f();return(t,o)=>(s(e,t.x,t.y,t.z??0),s(r,o.x,o.y,o.z??0),y(e,r,t.spatialReference,o.spatialReference))})(),y=(()=>{const e=a(),r=f(),t=f();return(o,a,s,u)=>{if(l(o,a))return;const f=m(s),p=m(u);if(f&&p&&v(f,p)&&h(o,s,r,f)&&h(a,u,t,p)){const{azimuth:e}=g(C,r,t,f);return null!=e?i(e,"degrees","radians"):void 0}e[0]=a[0]-o[0],e[1]=a[1]-o[1];let d=n(c,e);return e[0]<0&&(d=I-d),d}})();function x(e,r,t,o="absolute"){if(r&&t)switch(o){case"absolute":return j(r,t);case"relative":return w(z(e,r,t),"relative");case"relative-bilateral":return w(z(e,r,t),"relative-bilateral")}}function z(e,r,t){if(!e||!r||!t)return;const i=b(e,r),n=b(r,t);return null!=i&&null!=n?o(n-i,"radians","geographic"):void 0}function w(e,r){if(null!=e)switch(r){case"absolute":return M(e);case"relative":{const r=U(e);let t=k.normalize(r,0,!0);return-180===t&&(t=180),o(t,"degrees","geographic")}case"relative-bilateral":{const r=U(e),t=Math.abs(k.normalize(r,0,!0));return o(t,"degrees","geographic")}}}function M(e){const r=U(e),t=P.normalize(r,0,!0);return o(t,"degrees","geographic")}function T(e,r,n){let a=i(e.value,e.unit,"degrees");return a=t(a,e.rotationType,n),a=i(a,"degrees",r),o(a,r,n)}const R=(()=>{const e=f();return(r,o,n,a,c,l="geodesic")=>{u(e,o);const f=U(c);if("geodesic"===l){const t=m(n);if(t&&h(e,n,e,t))return d(r,e,f,a,t),r[2]=o[2],!!h(r,t,r,n)}const g=t(f,"geographic","arithmetic"),p=i(g,"degrees","radians"),v=o[0]+a*Math.cos(p),j=o[1]+a*Math.sin(p),b=o[2];return s(r,v,j,b),!0}})();function U(e){if(null!=e)return t(q(e),e.rotationType,"geographic")}function V(e){if(null!=e)return t(q(e),e.rotationType,"arithmetic")}function q(e){return i(e.value,e.unit,"degrees")}const C=new p,I=2*Math.PI,P=e,k=new r(-180,180);export{T as convertAngle,j as directionBetweenPoints,x as directionForVertices,V as getDegreesArithmetic,U as getDegreesGeographic,w as getNormalizedDirection,M as getNormalizedGeographicOrientation,R as pointFromDistanceAlongAzimuth,y as radiansGeographicBetweenVec};