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