@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 5.98 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */
import{clamp as n,rad2deg as l,deg2rad as e,asinClamped as t}from"../../core/mathUtils.js";import{getMetersPerUnitForSR as r}from"../../core/units.js";import{isSphericalECEF as u,WGS84ECEFSpatialReferenceLike as a,SphericalPCPFMarsLike as c,SphericalPCPFMoonLike as s,isMars as o,isMoon as i}from"../ellipsoidUtils.js";import{moon as f,mars as p,earth as h}from"../support/Ellipsoid.js";import{earthEllipsoidConstants as M}from"../support/geodesicConstants.js";import{equals as d,isWGS84 as E,isWebMercator as R,isPlateCarree as m}from"../support/spatialReferenceUtils.js";const w={2:{5:F,7:null,9:null,10:F,1:H,6:null,8:null,0:null,3:W,11:b,2:F,4:X},5:{5:F,7:null,9:null,10:F,1:H,6:null,8:null,0:null,3:W,11:b,2:F,4:X},7:{5:null,7:F,9:null,10:F,1:null,6:D,8:null,0:null,3:null,11:null,2:null,4:null},9:{5:null,7:null,9:F,10:F,1:null,6:null,8:B,0:null,3:null,11:null,2:null,4:null},3:{5:S,7:null,9:null,10:S,1:j,6:null,8:null,0:null,3:F,11:U,2:S,4:q},4:{5:Y,7:null,9:null,10:Y,1:Z,6:null,8:null,0:null,3:$,11:G,2:Y,4:F},1:{5:N,7:null,9:null,10:N,1:F,6:null,8:null,0:null,3:O,11:x,2:N,4:Q},6:{5:null,7:L,9:null,10:L,1:null,6:F,8:null,0:null,3:null,11:null,2:null,4:null},8:{5:null,7:null,9:K,10:K,1:null,6:null,8:F,0:null,3:null,11:null,2:null,4:null},0:{5:null,7:null,9:null,10:null,1:null,6:null,8:null,0:F,3:null,11:null,2:null,4:null},10:{5:F,7:F,9:F,10:F,1:H,6:D,8:B,0:null,3:W,11:b,2:F,4:X},11:{5:k,7:null,9:null,10:k,1:y,6:null,8:null,0:null,3:A,11:F,2:k,4:v}};function C(n,l){return I(n,l)?.projector}function I(n,l){if(null==n||null==l)return null;if(_.source.spatialReference===n&&_.dest.spatialReference===l)return _;const e=T(n,_.source),t=T(l,_.dest);return 0===e&&0===t?d(n,l)?_.projector=F:_.projector=null:_.projector=w[e][t],_}function P(n,l){switch(C(n,l)){case F:return"copy3";case H:return"wgs84ToSphericalECEF";case W:return"wgs84ToWebMercator";case b:return"wgs84ToPlateCarree";case X:return"wgs84ToWGS84ECEF";case S:return"webMercatorToWGS84";case j:return"webMercatorToSphericalECEF";case q:return"webMercatorToWGS84ECEF";case U:return"webMercatorToPlateCarree";case Y:return"wgs84ECEFToWGS84";case Z:return"wgs84ECEFToSphericalECEF";case $:return"wgs84ECEFToWebMercator";case N:return"sphericalECEFToWGS84";case O:return"sphericalECEFToWebMercator";case L:return"sphericalMarsPCPFToMars2000";case K:return"sphericalMoonPCPFToMoon2000";case Q:return"sphericalECEFToWGS84ECEF";case D:return"mars2000ToSphericalPCPF";case B:return"moon2000ToSphericalPCPF";default:return null}}function T(n,l){return n?l.spatialReference===n?l.spatialReferenceId:(l.spatialReference=n,"metersPerUnit"in l&&(l.metersPerUnit=r(n,1)),u(n)?l.spatialReferenceId=1:E(n)?l.spatialReferenceId=2:R(n)?l.spatialReferenceId=3:m(n)?l.spatialReferenceId=11:n.wkt===a.wkt?l.spatialReferenceId=4:4490===n.wkid?l.spatialReferenceId=5:n.wkt===c.wkt?l.spatialReferenceId=6:n.wkt===s.wkt?l.spatialReferenceId=8:o(n)?l.spatialReferenceId=7:i(n)?l.spatialReferenceId=9:l.spatialReferenceId=0):0}function F(n,l,e,t){n!==e&&(e[t++]=n[l++],e[t++]=n[l++],e[t]=n[l]??0)}function S(n,l,e,t){e[t]=ln*(n[l]/tn),e[t+1]=ln*(en-2*Math.atan(Math.exp(-n[l+1]/tn))),e[t+2]=n[l+2]??0}function j(n,l,e,t){const r=n[l]/tn,u=en-2*Math.atan(Math.exp(-n[l+1]/tn)),a=tn+(n[l+2]??0),c=Math.cos(u)*a;e[t]=Math.cos(r)*c,e[t+1]=Math.sin(r)*c,e[t+2]=Math.sin(u)*a}function q(n,l,e,t){S(n,l,e,t),X(e,t,e,t)}function g(l,e,t,r,u){const a=.4999999*Math.PI,c=n(nn*l[e+1],-a,a),s=Math.sin(c);t[r++]=nn*l[e]*u.radius,t[r++]=u.halfSemiMajorAxis*Math.log((1+s)/(1-s)),t[r]=l[e+2]??0}function W(n,l,e,t){g(n,l,e,t,h)}function b(n,l,e,t){e[t]=n[l]*rn,e[t+1]=n[l+1]*rn,e[t+2]=n[l+2]??0}function k(n,l,e,t){e[t]=n[l]*un,e[t+1]=n[l+1]*un,e[t+2]=n[l+2]??0}function U(n,l,e,t){S(n,l,e,t),b(e,t,e,t)}function G(n,l,e,t){Y(n,l,e,t),b(e,t,e,t)}function x(n,l,e,t){N(n,l,e,t),b(e,t,e,t)}function y(n,l,e,t){k(n,l,e,t),H(e,t,e,t)}function A(n,l,e,t){k(n,l,e,t),W(e,t,e,t)}function v(n,l,e,t){k(n,l,e,t),X(e,t,e,t)}function z(n,l,e,t,r){const u=r+(n[l+2]??0),a=nn*n[l],c=nn*n[l+1],s=Math.cos(c)*u;e[t]=Math.cos(a)*s,e[t+1]=Math.sin(a)*s,e[t+2]=Math.sin(c)*u}function B(n,l,e,t){z(n,l,e,t,f.radius)}function D(n,l,e,t){z(n,l,e,t,p.radius)}function H(n,l,e,t){z(n,l,e,t,h.radius)}function J(n,l,e,r,u){const a=n[l],c=n[l+1],s=n[l+2]??0,o=Math.sqrt(a*a+c*c+s*s),i=t(s/(0===o?1:o)),f=Math.atan2(c,a);e[r++]=ln*f,e[r++]=ln*i,e[r]=o-u}function K(n,l,e,t){J(n,l,e,t,f.radius)}function L(n,l,e,t){J(n,l,e,t,p.radius)}function N(n,l,e,t){J(n,l,e,t,h.radius)}function O(n,l,e,t){N(n,l,e,t),W(e,t,e,t)}function Q(n,l,e,t){N(n,l,e,t),X(e,t,e,t)}function V(n,l,e,t,r){const u=nn*n[l],a=nn*n[l+1],c=n[l+2]??0,s=Math.sin(a),o=Math.cos(a),i=r.radius/Math.sqrt(1-r.eccentricitySquared*s*s);e[t++]=(i+c)*o*Math.cos(u),e[t++]=(i+c)*o*Math.sin(u),e[t++]=(i*(1-r.eccentricitySquared)+c)*s}function X(n,l,e,t){V(n,l,e,t,h)}function Y(n,l,e,t){const r=M,u=n[l],a=n[l+1],c=n[l+2]??0;let s,o,i,f,p,d,E,R,m,w,C,I,P,T,F,S,j,q,g,W,b;s=Math.abs(c),o=u*u+a*a,i=Math.sqrt(o),f=o+c*c,p=Math.sqrt(f),W=Math.atan2(a,u),d=c*c/f,E=o/f,T=r.a2/p,F=r.a3-r.a4/p,E>.3?(R=s/p*(1+E*(r.a1+T+d*F)/p),g=Math.asin(R),w=R*R,m=Math.sqrt(1-w)):(m=i/p*(1-d*(r.a5-T-E*F)/p),g=Math.acos(m),w=1-m*m,R=Math.sqrt(w)),C=1-h.eccentricitySquared*w,I=h.radius/Math.sqrt(C),P=r.a6*I,T=i-I*m,F=s-P*R,j=m*T+R*F,S=m*F-R*T,q=S/(P/C+j),g+=q,b=j+S*q/2,c<0&&(g=-g),e[t++]=ln*W,e[t++]=ln*g,e[t]=b}function Z(n,l,e,t){Y(n,l,e,t),H(e,t,e,t)}function $(n,l,e,t){Y(n,l,e,t),W(e,t,e,t)}const _={source:{spatialReference:null,spatialReferenceId:0,metersPerUnit:1},dest:{spatialReference:null,spatialReferenceId:0,metersPerUnit:1},projector:F},nn=e(1),ln=l(1),en=.5*Math.PI,tn=h.radius,rn=tn*Math.PI/180,un=180/(tn*Math.PI);export{F as copy3,C as getProjector,I as getProjectorClassification,P as getProjectorName,un as invPlateCarreeScale,g as lonLatToWebMercatorComparable,w as projectionTable,J as sphericalPCPFtoLonLatElevation,W as wgs84ToWebMercator};