define(["./Transforms-3e1dc9c2","./Matrix2-52f9f880","./RuntimeError-ac440aa5","./defaultValue-69ee94f4","./ComponentDatatype-a9820060","./ArcType-e1641d8d","./arrayRemoveDuplicates-fe254feb","./EllipsoidGeodesic-00b2a9dd","./EllipsoidRhumbLine-683f2cb5","./EncodedCartesian3-8ce94cd2","./GeometryAttribute-c774c37f","./IntersectionTests-088640d2","./Plane-e5b2f6e0","./WebMercatorProjection-6f83725a","./_commonjsHelpers-3aae1032-15991586","./combine-0259f56f","./PixelFormat-9ceadbf3","./WebGLConstants-f63312fc"],(function(e,t,a,n,i,r,s,o,l,c,u,C,d,h,p,f,g,m){"use strict";function w(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),this._tileInfo=a.tileInfo}Object.defineProperties(w.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},rectangle:{get:function(){return this._rectangle}},projection:{get:function(){return this._projection}}}),w.prototype.getNumberOfXTilesAtLevel=function(e){if(!n.defined(this._tileInfo))return this._numberOfLevelZeroTilesX<=o&&(d=o-1);let h=(s.north-e.latitude)/u|0;return h>=l&&(h=l-1),n.defined(r)?(r.x=d,r.y=h,r):new t.Cartesian2(d,h)};const y=new t.Cartesian3,M=new t.Cartesian3,T=new t.Cartographic,E=new t.Cartesian3,_=new t.Cartesian3,O=new e.BoundingSphere,P=new w,b=[new t.Cartographic,new t.Cartographic,new t.Cartographic,new t.Cartographic],A=new t.Cartesian2,k={};function I(e){t.Cartographic.fromRadians(e.east,e.north,0,b[0]),t.Cartographic.fromRadians(e.west,e.north,0,b[1]),t.Cartographic.fromRadians(e.east,e.south,0,b[2]),t.Cartographic.fromRadians(e.west,e.south,0,b[3]);let a=0,n=0,i=0,r=0;const s=k._terrainHeightsMaxLevel;let o;for(o=0;o<=s;++o){let e=!1;for(let t=0;t<4;++t){const a=b[t];if(P.positionToTileXY(a,o,A),0===t)i=A.x,r=A.y;else if(i!==A.x||r!==A.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}}k.initialize=function(){let t=k._initPromise;return n.defined(t)||(t=e.Resource.fetchJson(e.buildModuleUrl("Assets/approximateTerrainHeights.json")).then((function(e){k._terrainHeights=e})),k._initPromise=t),t},k.getMinimumMaximumHeights=function(e,a){a=n.defaultValue(a,t.Ellipsoid.WGS84);const i=I(e);let r=k._defaultMinTerrainHeight,s=k._defaultMaxTerrainHeight;if(n.defined(i)){const o=`${i.level}-${i.x}-${i.y}`,l=k._terrainHeights[o];n.defined(l)&&(r=l[0],s=l[1]),a.cartographicToCartesian(t.Rectangle.northeast(e,T),y),a.cartographicToCartesian(t.Rectangle.southwest(e,T),M),t.Cartesian3.midpoint(M,y,E);const c=a.scaleToGeodeticSurface(E,_);if(n.defined(c)){const e=t.Cartesian3.distance(E,c);r=Math.min(r,-e)}else r=k._defaultMinTerrainHeight}return r=Math.max(k._defaultMinTerrainHeight,r),{minimumTerrainHeight:r,maximumTerrainHeight:s}},k.getBoundingSphere=function(a,i){i=n.defaultValue(i,t.Ellipsoid.WGS84);const r=I(a);let s=k._defaultMaxTerrainHeight;if(n.defined(r)){const e=`${r.level}-${r.x}-${r.y}`,t=k._terrainHeights[e];n.defined(t)&&(s=t[1])}const o=e.BoundingSphere.fromRectangle3D(a,i,0);return e.BoundingSphere.fromRectangle3D(a,i,s,O),e.BoundingSphere.union(o,O,o)},k._terrainHeightsMaxLevel=6,k._defaultMaxTerrainHeight=9e3,k._defaultMinTerrainHeight=-1e5,k._terrainHeights=void 0,k._initPromise=void 0,Object.defineProperties(k,{initialized:{get:function(){return n.defined(k._terrainHeights)}}});const L=[e.GeographicProjection,h.WebMercatorProjection],S=L.length,x=Math.cos(i.CesiumMath.toRadians(30)),N=Math.cos(i.CesiumMath.toRadians(150));function R(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(R.prototype,{packedLength:{get:function(){return 1+3*this._positions.length+1+1+1+t.Ellipsoid.packedLength+1+1}}}),R.setProjectionAndEllipsoid=function(e,t){let a=0;for(let e=0;e65535?new Uint32Array(w):new Uint16Array(w),M=new Float64Array(3*g),T=new Float32Array(m),E=new Float32Array(m),_=new Float32Array(m),O=new Float32Array(m),P=new Float32Array(m);let b,A,I,L;C&&(b=new Float32Array(m),A=new Float32Array(m),I=new Float32Array(m),L=new Float32Array(2*g));const S=l.length/2;let N=0;const R=_e;R.height=0;const D=Oe;D.height=0;let v=Pe,z=be;if(C)for(h=0,d=1;dx?(f=ge(n,R,m,u,je),g=ge(n,D,Z,d,Be)):1===e?(g=ge(n,D,Z,d,Be),f.x=0,f.y=i.CesiumMath.sign(R.longitude-Math.abs(D.longitude)),f.z=0):(f=ge(n,R,m,u,je),g.x=0,g.y=i.CesiumMath.sign(R.longitude-D.longitude),g.z=0)}const w=t.Cartesian3.distance(a,U),y=c.EncodedCartesian3.fromCartesian(e,We),S=t.Cartesian3.subtract(W,e,Ve),v=t.Cartesian3.normalize(S,Fe);let z=t.Cartesian3.subtract(a,e,Ge);z=t.Cartesian3.normalize(z,z);let H=t.Cartesian3.cross(v,z,Fe);H=t.Cartesian3.normalize(H,H);let K=t.Cartesian3.cross(z,m,qe);K=t.Cartesian3.normalize(K,K);let ee=t.Cartesian3.subtract(U,W,Ye);ee=t.Cartesian3.normalize(ee,ee);let te=t.Cartesian3.cross(Z,ee,Xe);te=t.Cartesian3.normalize(te,te);const ae=w/B,ne=$/B;let ie,re,se,oe=0,le=0,ce=0;if(C){oe=t.Cartesian3.distance(u,d),ie=c.EncodedCartesian3.fromCartesian(u,Ue),re=t.Cartesian3.subtract(d,u,Ze),se=t.Cartesian3.normalize(re,$e);const e=se.x;se.x=se.y,se.y=-e,le=oe/N,ce=J/N}for(j=0;j<8;j++){const e=F+4*j,a=G+2*j,n=e+3,i=j<4?1:-1,r=2===j||3===j||6===j||7===j?1:-1;t.Cartesian3.pack(y.high,T,e),T[n]=S.x,t.Cartesian3.pack(y.low,E,e),E[n]=S.y,t.Cartesian3.pack(K,_,e),_[n]=S.z,t.Cartesian3.pack(te,O,e),O[n]=ae*i,t.Cartesian3.pack(H,P,e);let s=ne*r;0===s&&r<0&&(s=9),P[n]=s,C&&(b[e]=ie.high.x,b[e+1]=ie.high.y,b[e+2]=ie.low.x,b[e+3]=ie.low.y,I[e]=-f.y,I[e+1]=f.x,I[e+2]=g.y,I[e+3]=-g.x,A[e]=re.x,A[e+1]=re.y,A[e+2]=se.x,A[e+3]=se.y,L[a]=le*i,s=ce*r,0===s&&r<0&&(s=9),L[a+1]=s)}const ue=De,Ce=ve,he=Ne,pe=Re,fe=t.Rectangle.fromCartographicArray(Se,xe),me=k.getMinimumMaximumHeights(fe,p),we=me.minimumTerrainHeight,Me=me.maximumTerrainHeight;Q+=we,Q+=Me,ye(e,a,we,Me,ue,he),ye(W,U,we,Me,Ce,pe);let _e=t.Cartesian3.multiplyByScalar(H,i.CesiumMath.EPSILON5,Je);t.Cartesian3.add(ue,_e,ue),t.Cartesian3.add(Ce,_e,Ce),t.Cartesian3.add(he,_e,he),t.Cartesian3.add(pe,_e,pe),Te(ue,Ce),Te(he,pe),t.Cartesian3.pack(ue,M,Y),t.Cartesian3.pack(Ce,M,Y+3),t.Cartesian3.pack(pe,M,Y+6),t.Cartesian3.pack(he,M,Y+9),_e=t.Cartesian3.multiplyByScalar(H,-2*i.CesiumMath.EPSILON5,Je),t.Cartesian3.add(ue,_e,ue),t.Cartesian3.add(Ce,_e,Ce),t.Cartesian3.add(he,_e,he),t.Cartesian3.add(pe,_e,pe),Te(ue,Ce),Te(he,pe),t.Cartesian3.pack(ue,M,Y+12),t.Cartesian3.pack(Ce,M,Y+15),t.Cartesian3.pack(pe,M,Y+18),t.Cartesian3.pack(he,M,Y+21),V+=2,h+=3,G+=16,Y+=24,F+=32,$+=w,J+=oe}h=0;let K=0;for(d=0;dx||li.CesiumMath.PI_OVER_TWO&&(c=!0,l=t.Cartesian3.subtract(o,n,fe),C=u.cartesianToCartographic(l,he)),C.height=0;const d=e.project(C,s);return(s=t.Cartesian3.subtract(d,r,s)).z=0,s=t.Cartesian3.normalize(s,s),c&&t.Cartesian3.negate(s,s),s}const me=new t.Cartesian3,we=new t.Cartesian3;function ye(e,a,n,i,r,s){const o=t.Cartesian3.subtract(a,e,me);t.Cartesian3.normalize(o,o);const l=n-0;let c=t.Cartesian3.multiplyByScalar(o,l,we);t.Cartesian3.add(e,c,r);const u=i-1e3;c=t.Cartesian3.multiplyByScalar(o,u,we),t.Cartesian3.add(a,c,s)}const Me=new t.Cartesian3;function Te(e,a){const n=d.Plane.getPointDistance(K,e),r=d.Plane.getPointDistance(K,a);let s=Me;i.CesiumMath.equalsEpsilon(n,0,i.CesiumMath.EPSILON2)?(s=X(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=X(e,a,s),t.Cartesian3.multiplyByScalar(s,i.CesiumMath.EPSILON2,s),t.Cartesian3.add(a,s,a))}function Ee(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 _e=new t.Cartographic,Oe=new t.Cartographic,Pe=new t.Cartesian3,be=new t.Cartesian3,Ae=new t.Cartesian3,ke=new t.Cartesian3,Ie=new t.Cartesian3,Le=new t.Cartesian3,Se=[_e,Oe],xe=new t.Rectangle,Ne=new t.Cartesian3,Re=new t.Cartesian3,De=new t.Cartesian3,ve=new t.Cartesian3,ze=new t.Cartesian3,He=new t.Cartesian3,je=new t.Cartesian3,Be=new t.Cartesian3,Ve=new t.Cartesian3,Ge=new t.Cartesian3,Ye=new t.Cartesian3,Fe=new t.Cartesian3,qe=new t.Cartesian3,Xe=new t.Cartesian3,We=new c.EncodedCartesian3,Ue=new c.EncodedCartesian3,Ze=new t.Cartesian3,$e=new t.Cartesian3,Je=new t.Cartesian3,Qe=[new e.BoundingSphere,new e.BoundingSphere],Ke=[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],et=Ke.length;function tt(e){return new u.GeometryAttribute({componentDatatype:i.ComponentDatatype.FLOAT,componentsPerAttribute:4,normalize:!1,values:e})}return R._projectNormal=ge,function(e,t){return k.initialize().then((function(){return n.defined(t)&&(e=R.unpack(e,t)),R.createGeometry(e)}))}}));