define(["./BoundingSphere-9a3b5656","./Transforms-5b829630","./Cartesian2-bd414876","./Cartesian3-e0307675","./Check-741c5f3c","./defaultValue-81eec7ed","./GeographicTilingScheme-86cef90e","./Rectangle-cf3e0e3e","./Resource-8ae1a924","./ArcType-fc72c06c","./arrayRemoveDuplicates-cea3b206","./ComponentDatatype-aaeec80f","./EllipsoidGeodesic-e7a5ca44","./EllipsoidRhumbLine-592e8885","./EncodedCartesian3-aafcc30f","./GeographicProjection-c931c7fb","./GeometryAttribute-2b42a913","./IntersectionTests-80510c7b","./Math-e73894ab","./Matrix4-4c545f70","./Plane-bc8b6777","./WebMercatorProjection-44373a3d","./when-422ea0ae","./RuntimeError-26acdd3b","./combine-3c023bda","./WebGLConstants-508b9636","./Matrix2-dc0c61cc"],(function(e,a,t,n,i,r,s,o,c,l,u,C,p,d,h,g,m,f,w,y,E,M,T,S,k,P,_){"use strict";const b=new n.Cartesian3,O=new n.Cartesian3,A=new t.Cartographic,x=new n.Cartesian3,I=new n.Cartesian3,L=new e.BoundingSphere,N=new s.GeographicTilingScheme,R=[new t.Cartographic,new t.Cartographic,new t.Cartographic,new t.Cartographic],D=new t.Cartesian2,z={};function H(e){t.Cartographic.fromRadians(e.east,e.north,0,R[0]),t.Cartographic.fromRadians(e.west,e.north,0,R[1]),t.Cartographic.fromRadians(e.east,e.south,0,R[2]),t.Cartographic.fromRadians(e.west,e.south,0,R[3]);let a=0,n=0,i=0,r=0;const s=z._terrainHeightsMaxLevel;let o;for(o=0;o<=s;++o){let e=!1;for(let a=0;a<4;++a){const t=R[a];if(N.positionToTileXY(t,o,D),0===a)i=D.x,r=D.y;else if(i!==D.x||r!==D.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}}z.initialize=function(){let e=z._initPromise;return r.defined(e)||(e=c.Resource.fetchJson(a.buildModuleUrl("Assets/approximateTerrainHeights.json")).then((function(e){z._terrainHeights=e})),z._initPromise=e),e},z.getMinimumMaximumHeights=function(e,a){a=r.defaultValue(a,t.Ellipsoid.WGS84);const i=H(e);let s=z._defaultMinTerrainHeight,c=z._defaultMaxTerrainHeight;if(r.defined(i)){const t=`${i.level}-${i.x}-${i.y}`,l=z._terrainHeights[t];r.defined(l)&&(s=l[0],c=l[1]),a.cartographicToCartesian(o.Rectangle.northeast(e,A),b),a.cartographicToCartesian(o.Rectangle.southwest(e,A),O),n.Cartesian3.midpoint(O,b,x);const u=a.scaleToGeodeticSurface(x,I);if(r.defined(u)){const e=n.Cartesian3.distance(x,u);s=Math.min(s,-e)}else s=z._defaultMinTerrainHeight}return s=Math.max(z._defaultMinTerrainHeight,s),{minimumTerrainHeight:s,maximumTerrainHeight:c}},z.getBoundingSphere=function(a,n){n=r.defaultValue(n,t.Ellipsoid.WGS84);const i=H(a);let s=z._defaultMaxTerrainHeight;if(r.defined(i)){const e=`${i.level}-${i.x}-${i.y}`,a=z._terrainHeights[e];r.defined(a)&&(s=a[1])}const o=e.BoundingSphere.fromRectangle3D(a,n,0);return e.BoundingSphere.fromRectangle3D(a,n,s,L),e.BoundingSphere.union(o,L,o)},z._terrainHeightsMaxLevel=6,z._defaultMaxTerrainHeight=9e3,z._defaultMinTerrainHeight=-1e5,z._terrainHeights=void 0,z._initPromise=void 0,Object.defineProperties(z,{initialized:{get:function(){return r.defined(z._terrainHeights)}}});const B=[g.GeographicProjection,M.WebMercatorProjection],G=B.length,j=Math.cos(w.CesiumMath.toRadians(30)),V=Math.cos(w.CesiumMath.toRadians(150));function F(e){const a=(e=r.defaultValue(e,r.defaultValue.EMPTY_OBJECT)).positions;this.width=r.defaultValue(e.width,1),this._positions=a,this.granularity=r.defaultValue(e.granularity,9999),this.loop=r.defaultValue(e.loop,!1),this.arcType=r.defaultValue(e.arcType,l.ArcType.GEODESIC),this._ellipsoid=t.Ellipsoid.WGS84,this._projectionIndex=0,this._workerName="createGroundPolylineGeometry",this._scene3DOnly=!1}Object.defineProperties(F.prototype,{packedLength:{get:function(){return 1+3*this._positions.length+1+1+1+t.Ellipsoid.packedLength+1+1}}}),F.setProjectionAndEllipsoid=function(e,a){let t=0;for(let e=0;e65535?new Uint32Array(E):new Uint16Array(E),T=new Float64Array(3*f),S=new Float32Array(y),k=new Float32Array(y),P=new Float32Array(y),_=new Float32Array(y),b=new Float32Array(y);let O,A,x,I;l&&(O=new Float32Array(y),A=new Float32Array(y),x=new Float32Array(y),I=new Float32Array(2*f));const L=c.length/2;let N=0;const R=Ie;R.height=0;const D=Le;D.height=0;let H=Ne,B=Re;if(l)for(p=0,u=1;uj?(g=ke(t,R,f,u,Ye),m=ke(t,D,Q,C,$e)):1===e?(m=ke(t,D,Q,C,$e),g.x=0,g.y=w.CesiumMath.sign(R.longitude-Math.abs(D.longitude)),g.z=0):(g=ke(t,R,f,u,Ye),m.x=0,m.y=w.CesiumMath.sign(R.longitude-D.longitude),m.z=0)}const y=n.Cartesian3.distance(a,Z),E=h.EncodedCartesian3.fromCartesian(e,aa),M=n.Cartesian3.subtract($,e,Ze),L=n.Cartesian3.normalize(M,Je);let H=n.Cartesian3.subtract(a,e,Qe);H=n.Cartesian3.normalize(H,H);let B=n.Cartesian3.cross(L,H,Je);B=n.Cartesian3.normalize(B,B);let G=n.Cartesian3.cross(H,f,Ke);G=n.Cartesian3.normalize(G,G);let ae=n.Cartesian3.subtract(Z,$,Xe);ae=n.Cartesian3.normalize(ae,ae);let te=n.Cartesian3.cross(Q,ae,ea);te=n.Cartesian3.normalize(te,te);const ne=y/F,ie=X/F;let re,se,oe,ce=0,le=0,ue=0;if(l){ce=n.Cartesian3.distance(u,C),re=h.EncodedCartesian3.fromCartesian(u,ta),se=n.Cartesian3.subtract(C,u,na),oe=n.Cartesian3.normalize(se,ia);const e=oe.x;oe.x=oe.y,oe.y=-e,le=ce/N,ue=J/N}for(V=0;V<8;V++){const e=U+4*V,a=v+2*V,t=e+3,i=V<4?1:-1,r=2===V||3===V||6===V||7===V?1:-1;n.Cartesian3.pack(E.high,S,e),S[t]=M.x,n.Cartesian3.pack(E.low,k,e),k[t]=M.y,n.Cartesian3.pack(G,P,e),P[t]=M.z,n.Cartesian3.pack(te,_,e),_[t]=ne*i,n.Cartesian3.pack(B,b,e);let s=ie*r;0===s&&r<0&&(s=9),b[t]=s,l&&(O[e]=re.high.x,O[e+1]=re.high.y,O[e+2]=re.low.x,O[e+3]=re.low.y,x[e]=-g.y,x[e+1]=g.x,x[e+2]=m.y,x[e+3]=-m.x,A[e]=se.x,A[e+1]=se.y,A[e+2]=oe.x,A[e+3]=oe.y,I[a]=le*i,s=ue*r,0===s&&r<0&&(s=9),I[a+1]=s)}const Ce=qe,pe=ve,de=Ve,he=Fe,ge=o.Rectangle.fromCartographicArray(Ge,je),me=z.getMinimumMaximumHeights(ge,d),fe=me.minimumTerrainHeight,we=me.maximumTerrainHeight;K+=fe,K+=we,be(e,a,fe,we,Ce,de),be($,Z,fe,we,pe,he);let ye=n.Cartesian3.multiplyByScalar(B,w.CesiumMath.EPSILON5,ra);n.Cartesian3.add(Ce,ye,Ce),n.Cartesian3.add(pe,ye,pe),n.Cartesian3.add(de,ye,de),n.Cartesian3.add(he,ye,he),Ae(Ce,pe),Ae(de,he),n.Cartesian3.pack(Ce,T,W),n.Cartesian3.pack(pe,T,W+3),n.Cartesian3.pack(he,T,W+6),n.Cartesian3.pack(de,T,W+9),ye=n.Cartesian3.multiplyByScalar(B,-2*w.CesiumMath.EPSILON5,ra),n.Cartesian3.add(Ce,ye,Ce),n.Cartesian3.add(pe,ye,pe),n.Cartesian3.add(de,ye,de),n.Cartesian3.add(he,ye,he),Ae(Ce,pe),Ae(de,he),n.Cartesian3.pack(Ce,T,W+12),n.Cartesian3.pack(pe,T,W+15),n.Cartesian3.pack(he,T,W+18),n.Cartesian3.pack(de,T,W+21),q+=2,p+=3,v+=16,W+=24,U+=32,X+=y,J+=ce}p=0;let ae=0;for(u=0;uj||ow.CesiumMath.PI_OVER_TWO&&(l=!0,c=n.Cartesian3.subtract(o,i,Se),C=u.cartesianToCartographic(c,Me)),C.height=0;const p=e.project(C,s);return(s=n.Cartesian3.subtract(p,r,s)).z=0,s=n.Cartesian3.normalize(s,s),l&&n.Cartesian3.negate(s,s),s}const Pe=new n.Cartesian3,_e=new n.Cartesian3;function be(e,a,t,i,r,s){const o=n.Cartesian3.subtract(a,e,Pe);n.Cartesian3.normalize(o,o);const c=t-0;let l=n.Cartesian3.multiplyByScalar(o,c,_e);n.Cartesian3.add(e,l,r);const u=i-1e3;l=n.Cartesian3.multiplyByScalar(o,u,_e),n.Cartesian3.add(a,l,s)}const Oe=new n.Cartesian3;function Ae(e,a){const t=E.Plane.getPointDistance(oe,e),i=E.Plane.getPointDistance(oe,a);let r=Oe;w.CesiumMath.equalsEpsilon(t,0,w.CesiumMath.EPSILON2)?(r=ee(a,e,r),n.Cartesian3.multiplyByScalar(r,w.CesiumMath.EPSILON2,r),n.Cartesian3.add(e,r,e)):w.CesiumMath.equalsEpsilon(i,0,w.CesiumMath.EPSILON2)&&(r=ee(e,a,r),n.Cartesian3.multiplyByScalar(r,w.CesiumMath.EPSILON2,r),n.Cartesian3.add(a,r,a))}function xe(e,a){const t=Math.abs(e.longitude),n=Math.abs(a.longitude);if(w.CesiumMath.equalsEpsilon(t,w.CesiumMath.PI,w.CesiumMath.EPSILON11)){const n=w.CesiumMath.sign(a.longitude);return e.longitude=n*(t-w.CesiumMath.EPSILON11),1}if(w.CesiumMath.equalsEpsilon(n,w.CesiumMath.PI,w.CesiumMath.EPSILON11)){const t=w.CesiumMath.sign(e.longitude);return a.longitude=t*(n-w.CesiumMath.EPSILON11),2}return 0}const Ie=new t.Cartographic,Le=new t.Cartographic,Ne=new n.Cartesian3,Re=new n.Cartesian3,De=new n.Cartesian3,ze=new n.Cartesian3,He=new n.Cartesian3,Be=new n.Cartesian3,Ge=[Ie,Le],je=new o.Rectangle,Ve=new n.Cartesian3,Fe=new n.Cartesian3,qe=new n.Cartesian3,ve=new n.Cartesian3,We=new n.Cartesian3,Ue=new n.Cartesian3,Ye=new n.Cartesian3,$e=new n.Cartesian3,Ze=new n.Cartesian3,Qe=new n.Cartesian3,Xe=new n.Cartesian3,Je=new n.Cartesian3,Ke=new n.Cartesian3,ea=new n.Cartesian3,aa=new h.EncodedCartesian3,ta=new h.EncodedCartesian3,na=new n.Cartesian3,ia=new n.Cartesian3,ra=new n.Cartesian3,sa=[new e.BoundingSphere,new e.BoundingSphere],oa=[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],ca=oa.length;function la(e){return new m.GeometryAttribute({componentDatatype:C.ComponentDatatype.FLOAT,componentsPerAttribute:4,normalize:!1,values:e})}return F._projectNormal=ke,function(e,a){return z.initialize().then((function(){return r.defined(a)&&(e=F.unpack(e,a)),F.createGeometry(e)}))}}));