define(["./Transforms-f15de320","./Matrix2-c6c16658","./RuntimeError-5b082e8f","./when-4bbc8319","./ComponentDatatype-3d0a0aac","./ArcType-fc72c06c","./arrayRemoveDuplicates-80a91d16","./EllipsoidGeodesic-2e7ba57d","./EllipsoidRhumbLine-c6741351","./EncodedCartesian3-b1495e46","./GeometryAttribute-8350368e","./IntersectionTests-a4e54d9a","./Plane-26e67b94","./WebMercatorProjection-baa60d8a","./combine-e9466e32","./WebGLConstants-508b9636"],(function(e,t,a,n,i,r,s,o,l,c,u,C,p,d,h,g){"use strict";function f(a){a=n.defaultValue(a,n.defaultValue.EMPTY_OBJECT),this._ellipsoid=n.defaultValue(a.ellipsoid,t.Ellipsoid.WGS84),this._rectangle=n.defaultValue(a.rectangle,t.Rectangle.MAX_VALUE),this._projection=new e.GeographicProjection(this._ellipsoid),this._numberOfLevelZeroTilesX=n.defaultValue(a.numberOfLevelZeroTilesX,2),this._numberOfLevelZeroTilesY=n.defaultValue(a.numberOfLevelZeroTilesY,1)}Object.defineProperties(f.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},rectangle:{get:function(){return this._rectangle}},projection:{get:function(){return this._projection}}}),f.prototype.getNumberOfXTilesAtLevel=function(e){return this._numberOfLevelZeroTilesX<=o&&(p=o-1);let d=(s.north-e.latitude)/u|0;return d>=l&&(d=l-1),n.defined(r)?(r.x=p,r.y=d,r):new t.Cartesian2(p,d)};const m=new t.Cartesian3,w=new t.Cartesian3,y=new t.Cartographic,M=new t.Cartesian3,T=new t.Cartesian3,E=new e.BoundingSphere,_=new f,O=[new t.Cartographic,new t.Cartographic,new t.Cartographic,new t.Cartographic],b=new t.Cartesian2,P={};function A(e){t.Cartographic.fromRadians(e.east,e.north,0,O[0]),t.Cartographic.fromRadians(e.west,e.north,0,O[1]),t.Cartographic.fromRadians(e.east,e.south,0,O[2]),t.Cartographic.fromRadians(e.west,e.south,0,O[3]);let a=0,n=0,i=0,r=0;const s=P._terrainHeightsMaxLevel;let o;for(o=0;o<=s;++o){let e=!1;for(let t=0;t<4;++t){const a=O[t];if(_.positionToTileXY(a,o,b),0===t)i=b.x,r=b.y;else if(i!==b.x||r!==b.y){e=!0;break}}if(e)break;a=i,n=r}if(0!==o)return{x:a,y:n,level:o>s?s:o-1}}P.initialize=function(){let t=P._initPromise;return n.defined(t)||(t=e.Resource.fetchJson(e.buildModuleUrl("Assets/approximateTerrainHeights.json")).then((function(e){P._terrainHeights=e})),P._initPromise=t),t},P.getMinimumMaximumHeights=function(e,a){a=n.defaultValue(a,t.Ellipsoid.WGS84);const i=A(e);let r=P._defaultMinTerrainHeight,s=P._defaultMaxTerrainHeight;if(n.defined(i)){const o=`${i.level}-${i.x}-${i.y}`,l=P._terrainHeights[o];n.defined(l)&&(r=l[0],s=l[1]),a.cartographicToCartesian(t.Rectangle.northeast(e,y),m),a.cartographicToCartesian(t.Rectangle.southwest(e,y),w),t.Cartesian3.midpoint(w,m,M);const c=a.scaleToGeodeticSurface(M,T);if(n.defined(c)){const e=t.Cartesian3.distance(M,c);r=Math.min(r,-e)}else r=P._defaultMinTerrainHeight}return r=Math.max(P._defaultMinTerrainHeight,r),{minimumTerrainHeight:r,maximumTerrainHeight:s}},P.getBoundingSphere=function(a,i){i=n.defaultValue(i,t.Ellipsoid.WGS84);const r=A(a);let s=P._defaultMaxTerrainHeight;if(n.defined(r)){const e=`${r.level}-${r.x}-${r.y}`,t=P._terrainHeights[e];n.defined(t)&&(s=t[1])}const o=e.BoundingSphere.fromRectangle3D(a,i,0);return e.BoundingSphere.fromRectangle3D(a,i,s,E),e.BoundingSphere.union(o,E,o)},P._terrainHeightsMaxLevel=6,P._defaultMaxTerrainHeight=9e3,P._defaultMinTerrainHeight=-1e5,P._terrainHeights=void 0,P._initPromise=void 0,Object.defineProperties(P,{initialized:{get:function(){return n.defined(P._terrainHeights)}}});const k=[e.GeographicProjection,d.WebMercatorProjection],L=k.length,S=Math.cos(i.CesiumMath.toRadians(30)),x=Math.cos(i.CesiumMath.toRadians(150));function I(e){const a=(e=n.defaultValue(e,n.defaultValue.EMPTY_OBJECT)).positions;this.width=n.defaultValue(e.width,1),this._positions=a,this.granularity=n.defaultValue(e.granularity,9999),this.loop=n.defaultValue(e.loop,!1),this.arcType=n.defaultValue(e.arcType,r.ArcType.GEODESIC),this._ellipsoid=t.Ellipsoid.WGS84,this._projectionIndex=0,this._workerName="createGroundPolylineGeometry",this._scene3DOnly=!1}Object.defineProperties(I.prototype,{packedLength:{get:function(){return 1+3*this._positions.length+1+1+1+t.Ellipsoid.packedLength+1+1}}}),I.setProjectionAndEllipsoid=function(e,t){let a=0;for(let e=0;e65535?new Uint32Array(w):new Uint16Array(w),M=new Float64Array(3*f),T=new Float32Array(m),E=new Float32Array(m),_=new Float32Array(m),O=new Float32Array(m),b=new Float32Array(m);let A,k,L,x;C&&(A=new Float32Array(m),k=new Float32Array(m),L=new Float32Array(m),x=new Float32Array(2*f));const I=l.length/2;let N=0;const R=Te;R.height=0;const D=Ee;D.height=0;let v=_e,z=Oe;if(C)for(d=0,p=1;pS?(g=he(n,R,m,u,ze),f=he(n,D,Z,p,He)):1===e?(f=he(n,D,Z,p,He),g.x=0,g.y=i.CesiumMath.sign(R.longitude-Math.abs(D.longitude)),g.z=0):(g=he(n,R,m,u,ze),f.x=0,f.y=i.CesiumMath.sign(R.longitude-D.longitude),f.z=0)}const w=t.Cartesian3.distance(a,U),y=c.EncodedCartesian3.fromCartesian(e,qe),I=t.Cartesian3.subtract(W,e,Be),v=t.Cartesian3.normalize(I,Ve);let z=t.Cartesian3.subtract(a,e,je);z=t.Cartesian3.normalize(z,z);let H=t.Cartesian3.cross(v,z,Ve);H=t.Cartesian3.normalize(H,H);let K=t.Cartesian3.cross(z,m,Ye);K=t.Cartesian3.normalize(K,K);let ee=t.Cartesian3.subtract(U,W,Ge);ee=t.Cartesian3.normalize(ee,ee);let te=t.Cartesian3.cross(Z,ee,Fe);te=t.Cartesian3.normalize(te,te);const ae=w/j,ne=$/j;let ie,re,se,oe=0,le=0,ce=0;if(C){oe=t.Cartesian3.distance(u,p),ie=c.EncodedCartesian3.fromCartesian(u,Xe),re=t.Cartesian3.subtract(p,u,We),se=t.Cartesian3.normalize(re,Ue);const e=se.x;se.x=se.y,se.y=-e,le=oe/N,ce=J/N}for(B=0;B<8;B++){const e=q+4*B,a=V+2*B,n=e+3,i=B<4?1:-1,r=2===B||3===B||6===B||7===B?1:-1;t.Cartesian3.pack(y.high,T,e),T[n]=I.x,t.Cartesian3.pack(y.low,E,e),E[n]=I.y,t.Cartesian3.pack(K,_,e),_[n]=I.z,t.Cartesian3.pack(te,O,e),O[n]=ae*i,t.Cartesian3.pack(H,b,e);let s=ne*r;0===s&&r<0&&(s=9),b[n]=s,C&&(A[e]=ie.high.x,A[e+1]=ie.high.y,A[e+2]=ie.low.x,A[e+3]=ie.low.y,L[e]=-g.y,L[e+1]=g.x,L[e+2]=f.y,L[e+3]=-f.x,k[e]=re.x,k[e+1]=re.y,k[e+2]=se.x,k[e+3]=se.y,x[a]=le*i,s=ce*r,0===s&&r<0&&(s=9),x[a+1]=s)}const Ce=Ne,pe=Re,de=xe,ge=Ie,fe=t.Rectangle.fromCartographicArray(Le,Se),we=P.getMinimumMaximumHeights(fe,h),Te=we.minimumTerrainHeight,Ee=we.maximumTerrainHeight;Q+=Te,Q+=Ee,me(e,a,Te,Ee,Ce,de),me(W,U,Te,Ee,pe,ge);let $e=t.Cartesian3.multiplyByScalar(H,i.CesiumMath.EPSILON5,Ze);t.Cartesian3.add(Ce,$e,Ce),t.Cartesian3.add(pe,$e,pe),t.Cartesian3.add(de,$e,de),t.Cartesian3.add(ge,$e,ge),ye(Ce,pe),ye(de,ge),t.Cartesian3.pack(Ce,M,Y),t.Cartesian3.pack(pe,M,Y+3),t.Cartesian3.pack(ge,M,Y+6),t.Cartesian3.pack(de,M,Y+9),$e=t.Cartesian3.multiplyByScalar(H,-2*i.CesiumMath.EPSILON5,Ze),t.Cartesian3.add(Ce,$e,Ce),t.Cartesian3.add(pe,$e,pe),t.Cartesian3.add(de,$e,de),t.Cartesian3.add(ge,$e,ge),ye(Ce,pe),ye(de,ge),t.Cartesian3.pack(Ce,M,Y+12),t.Cartesian3.pack(pe,M,Y+15),t.Cartesian3.pack(ge,M,Y+18),t.Cartesian3.pack(de,M,Y+21),G+=2,d+=3,V+=16,Y+=24,q+=32,$+=w,J+=oe}d=0;let K=0;for(p=0;pS||li.CesiumMath.PI_OVER_TWO&&(c=!0,l=t.Cartesian3.subtract(o,n,de),C=u.cartesianToCartographic(l,Ce)),C.height=0;const p=e.project(C,s);return(s=t.Cartesian3.subtract(p,r,s)).z=0,s=t.Cartesian3.normalize(s,s),c&&t.Cartesian3.negate(s,s),s}const ge=new t.Cartesian3,fe=new t.Cartesian3;function me(e,a,n,i,r,s){const o=t.Cartesian3.subtract(a,e,ge);t.Cartesian3.normalize(o,o);const l=n-0;let c=t.Cartesian3.multiplyByScalar(o,l,fe);t.Cartesian3.add(e,c,r);const u=i-1e3;c=t.Cartesian3.multiplyByScalar(o,u,fe),t.Cartesian3.add(a,c,s)}const we=new t.Cartesian3;function ye(e,a){const n=p.Plane.getPointDistance(J,e),r=p.Plane.getPointDistance(J,a);let s=we;i.CesiumMath.equalsEpsilon(n,0,i.CesiumMath.EPSILON2)?(s=F(a,e,s),t.Cartesian3.multiplyByScalar(s,i.CesiumMath.EPSILON2,s),t.Cartesian3.add(e,s,e)):i.CesiumMath.equalsEpsilon(r,0,i.CesiumMath.EPSILON2)&&(s=F(e,a,s),t.Cartesian3.multiplyByScalar(s,i.CesiumMath.EPSILON2,s),t.Cartesian3.add(a,s,a))}function Me(e,t){const a=Math.abs(e.longitude),n=Math.abs(t.longitude);if(i.CesiumMath.equalsEpsilon(a,i.CesiumMath.PI,i.CesiumMath.EPSILON11)){const n=i.CesiumMath.sign(t.longitude);return e.longitude=n*(a-i.CesiumMath.EPSILON11),1}if(i.CesiumMath.equalsEpsilon(n,i.CesiumMath.PI,i.CesiumMath.EPSILON11)){const a=i.CesiumMath.sign(e.longitude);return t.longitude=a*(n-i.CesiumMath.EPSILON11),2}return 0}const Te=new t.Cartographic,Ee=new t.Cartographic,_e=new t.Cartesian3,Oe=new t.Cartesian3,be=new t.Cartesian3,Pe=new t.Cartesian3,Ae=new t.Cartesian3,ke=new t.Cartesian3,Le=[Te,Ee],Se=new t.Rectangle,xe=new t.Cartesian3,Ie=new t.Cartesian3,Ne=new t.Cartesian3,Re=new t.Cartesian3,De=new t.Cartesian3,ve=new t.Cartesian3,ze=new t.Cartesian3,He=new t.Cartesian3,Be=new t.Cartesian3,je=new t.Cartesian3,Ge=new t.Cartesian3,Ve=new t.Cartesian3,Ye=new t.Cartesian3,Fe=new t.Cartesian3,qe=new c.EncodedCartesian3,Xe=new c.EncodedCartesian3,We=new t.Cartesian3,Ue=new t.Cartesian3,Ze=new t.Cartesian3,$e=[new e.BoundingSphere,new e.BoundingSphere],Je=[0,2,1,0,3,2,0,7,3,0,4,7,0,5,4,0,1,5,5,7,4,5,6,7,5,2,6,5,1,2,3,6,2,3,7,6],Qe=Je.length;function Ke(e){return new u.GeometryAttribute({componentDatatype:i.ComponentDatatype.FLOAT,componentsPerAttribute:4,normalize:!1,values:e})}return I._projectNormal=he,function(e,t){return P.initialize().then((function(){return n.defined(t)&&(e=I.unpack(e,t)),I.createGeometry(e)}))}}));