UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 4.18 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{rad2deg as e}from"../../core/mathUtils.js";import{subtract as t,add as r,transformMat4 as n,copy as i,min as o,max as s,sub as m}from"../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as h,create as l}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{WGS84ECEFSpatialReferenceLike as a}from"../../geometry/ellipsoidUtils.js";import c from"../../geometry/Extent.js";import g from"../../geometry/HeightModelInfo.js";import f from"../../geometry/SpatialReference.js";import{projectBuffer as u}from"../../geometry/projection/projectBuffer.js";const x=new f({wkid:4326,vcsWkid:115700}),d=new c(-180,-90,180,90,x);function S(e,t){if(!Array.isArray(e)||e.length<t)return!1;for(const r of e)if("number"!=typeof r)return!1;return!0}const p=7645211,R={xmin:-180,ymin:-90,zmin:-450,xmax:180,ymax:90,zmax:8850},_=new Map([[5773,new g({heightModel:"gravity-related-height",heightUnit:"meters",vertCRS:"EGM96_Geoid"})],[3855,new g({heightModel:"gravity-related-height",heightUnit:"meters",vertCRS:"EGM2008_Geoid"})],[115700,new g({heightModel:"ellipsoidal",heightUnit:"meters",vertCRS:"WGS_1984"})],[115701,new g({heightModel:"ellipsoidal",heightUnit:"meters",vertCRS:"ETRS_1989"})],[6360,new g({heightModel:"gravity-related-height",heightUnit:"us-feet",vertCRS:"NAVD88_height_(ftUS)"})],[7837,new g({heightModel:"gravity-related-height",heightUnit:"meters",vertCRS:"DHHN2016_(height)"})],[5709,new g({heightModel:"gravity-related-height",heightUnit:"meters",vertCRS:"NAP"})]]);function w(e){let t=null;return e?(_.forEach((r,n)=>{t||r.vertCRS!==e.vertCRS||r.heightUnit!==e.heightUnit||(t=n)}),t):t}function E(e){if(!e)return null;const t=e.vcsWkid||e.latestVcsWkid;return t?_.get(t):null}function b(e){return!(!(e.extensions?.ESRI_crs?.wkid||e.extensions?.ESRI_crs?.latestWkid||e.extensions?.ESRI_crs?.wkt)||!e.root?.extensions?.ESRI_crs?.boundingVolume?.box&&!e.root?.extensions?.ESRI_crs?.boundingVolume?.sphere)}function y(g,x=!1){let d=new f({wkid:4326,vcsWkid:115700}),_=g.root?.boundingVolume,w=!1,E=g?.root?.transform;if(x&&(g.extensions?.ESRI_crs?.wkid||g.extensions?.ESRI_crs?.latestWkid||g.extensions?.ESRI_crs?.wkt)&&(g.root?.extensions?.ESRI_crs?.boundingVolume?.box||g.root?.extensions?.ESRI_crs?.boundingVolume?.sphere))d=new f(g.extensions?.ESRI_crs),_=g.root?.extensions?.ESRI_crs?.boundingVolume,E=g.root?.transform,w=!0;else if(!_)return new c(-180,-90,180,90,d);if(_.box){const e=_?.box;if(e[3]>p&&e[7]>p&&e[11]>p)return new c({...R,spatialReference:d})}const b=l();if(!w&&_.region&&S(_.region,6)){const t=_.region,r=e(t[0]),n=e(t[1]),i=t[4],o=e(t[2]),s=e(t[3]),m=t[5];return new c({xmin:r,ymin:n,zmin:i,xmax:o,ymax:s,zmax:m,spatialReference:d})}if(_.sphere&&S(_.sphere,4)){const e=_.sphere,m=h(e[0],e[1],e[2]),g=e[3]/Math.sqrt(3),x=l();t(x,m,h(g,g,g));const p=l();if(r(p,m,h(g,g,g)),E&&S(E,16)){const e=E;n(b,x,e),i(x,b),n(b,p,e),i(p,b)}w||(u(x,a,0,x,f.WGS84,0),u(p,a,0,p,f.WGS84,0));const R=l(),y=l();return o(R,x,p),s(y,x,p),new c({xmin:R[0],ymin:R[1],zmin:R[2],xmax:y[0],ymax:y[1],zmax:y[2],spatialReference:d})}if(_.box&&S(_.box,12)){const e=_.box,t=h(e[0],e[1],e[2]),i=h(e[3],e[4],e[5]),g=h(e[6],e[7],e[8]),x=h(e[9],e[10],e[11]),p=[];for(let r=0;r<8;++r)p.push(l());if(r(p[0],t,i),r(p[0],p[0],g),r(p[0],p[0],x),m(p[1],t,i),r(p[1],p[1],g),r(p[1],p[1],x),r(p[2],t,i),m(p[2],p[2],g),r(p[2],p[2],x),m(p[3],t,i),m(p[3],p[3],g),r(p[3],p[3],x),r(p[4],t,i),r(p[4],p[4],g),m(p[4],p[4],x),m(p[5],t,i),r(p[5],p[5],g),m(p[5],p[5],x),r(p[6],t,i),m(p[6],p[6],g),m(p[6],p[6],x),m(p[7],t,i),m(p[7],p[7],g),m(p[7],p[7],x),E&&S(E,16)){const e=E;for(let t=0;t<8;++t)n(p[t],p[t],e)}const R=h(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),b=h(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE);for(let r=0;r<8;++r)w||u(p[r],a,0,p[r],f.WGS84,0),o(b,b,p[r]),s(R,R,p[r]);return new c({xmin:b[0],ymin:b[1],zmin:b[2],xmax:R[0],ymax:R[1],zmax:R[2],spatialReference:d})}return new c(-180,-90,180,90,d)}export{d as default3DTilesFullExtent,x as default3DTilesSpatialReference,E as getHeightModelInfoFromVCS,w as getVCSFromHeightModelInfo,b as hasEsriCrs,y as initFullExtent,S as verifyArray};