define(["./Transforms-d13cc04e","./Matrix2-9aa31791","./RuntimeError-346a3079","./when-4bbc8319","./ComponentDatatype-93750d1a","./ArcType-98ec98bf","./arrayRemoveDuplicates-18786327","./EllipsoidGeodesic-dd8f2afb","./EllipsoidRhumbLine-30c47ff4","./EncodedCartesian3-f286cedc","./GeometryAttribute-43536dc0","./IntersectionTests-96a04219","./Plane-318d6937","./WebMercatorProjection-58801a11","./combine-83860057","./WebGLConstants-1c8239cc"],(function(e,a,t,n,i,r,s,o,l,u,c,C,p,d,h,g){"use strict";function f(t){t=n.defaultValue(t,n.defaultValue.EMPTY_OBJECT),this._ellipsoid=n.defaultValue(t.ellipsoid,a.Ellipsoid.WGS84),this._rectangle=n.defaultValue(t.rectangle,a.Rectangle.MAX_VALUE),this._projection=new e.GeographicProjection(this._ellipsoid),this._numberOfLevelZeroTilesX=n.defaultValue(t.numberOfLevelZeroTilesX,2),this._numberOfLevelZeroTilesY=n.defaultValue(t.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);var d=(s.north-e.latitude)/c|0;return d>=l&&(d=l-1),n.defined(r)?(r.x=p,r.y=d,r):new a.Cartesian2(p,d)}};var m=new a.Cartesian3,w=new a.Cartesian3,v=new a.Cartographic,y=new a.Cartesian3,M=new a.Cartesian3,T=new e.BoundingSphere,E=new f,_=[new a.Cartographic,new a.Cartographic,new a.Cartographic,new a.Cartographic],O=new a.Cartesian2,P={};function b(e){a.Cartographic.fromRadians(e.east,e.north,0,_[0]),a.Cartographic.fromRadians(e.west,e.north,0,_[1]),a.Cartographic.fromRadians(e.east,e.south,0,_[2]),a.Cartographic.fromRadians(e.west,e.south,0,_[3]);var t,n=0,i=0,r=0,s=0,o=P._terrainHeightsMaxLevel;for(t=0;t<=o;++t){for(var l=!1,u=0;u<4;++u){var c=_[u];if(E.positionToTileXY(c,t,O),0===u)r=O.x,s=O.y;else if(r!==O.x||s!==O.y){l=!0;break}}if(l)break;n=r,i=s}if(0!==t)return{x:n,y:i,level:t>o?o:t-1}}P.initialize=function(){var a=P._initPromise;return n.defined(a)||(a=e.Resource.fetchJson(e.buildModuleUrl("Assets/approximateTerrainHeights.json")).then((function(e){P._terrainHeights=e})),P._initPromise=a),a},P.getMinimumMaximumHeights=function(e,t){t=n.defaultValue(t,a.Ellipsoid.WGS84);var i=b(e),r=P._defaultMinTerrainHeight,s=P._defaultMaxTerrainHeight;if(n.defined(i)){var o=i.level+"-"+i.x+"-"+i.y,l=P._terrainHeights[o];n.defined(l)&&(r=l[0],s=l[1]),t.cartographicToCartesian(a.Rectangle.northeast(e,v),m),t.cartographicToCartesian(a.Rectangle.southwest(e,v),w),a.Cartesian3.midpoint(w,m,y);var u=t.scaleToGeodeticSurface(y,M);if(n.defined(u)){var c=a.Cartesian3.distance(y,u);r=Math.min(r,-c)}else r=P._defaultMinTerrainHeight}return{minimumTerrainHeight:r=Math.max(P._defaultMinTerrainHeight,r),maximumTerrainHeight:s}},P.getBoundingSphere=function(t,i){i=n.defaultValue(i,a.Ellipsoid.WGS84);var r=b(t),s=P._defaultMaxTerrainHeight;if(n.defined(r)){var o=r.level+"-"+r.x+"-"+r.y,l=P._terrainHeights[o];n.defined(l)&&(s=l[1])}var u=e.BoundingSphere.fromRectangle3D(t,i,0);return e.BoundingSphere.fromRectangle3D(t,i,s,T),e.BoundingSphere.union(u,T,u)},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)}}});var A=[e.GeographicProjection,d.WebMercatorProjection],k=A.length,L=Math.cos(i.CesiumMath.toRadians(30)),S=Math.cos(i.CesiumMath.toRadians(150));function x(e){var t=(e=n.defaultValue(e,n.defaultValue.EMPTY_OBJECT)).positions;this.width=n.defaultValue(e.width,1),this._positions=t,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=a.Ellipsoid.WGS84,this._projectionIndex=0,this._workerName="createGroundPolylineGeometry",this._scene3DOnly=!1}Object.defineProperties(x.prototype,{packedLength:{get:function(){return 1+3*this._positions.length+1+1+1+a.Ellipsoid.packedLength+1+1}}}),x.setProjectionAndEllipsoid=function(e,a){for(var t=0,n=0;n65535?new Uint32Array(T):new Uint16Array(T),_=new Float64Array(3*y),O=new Float32Array(M),b=new Float32Array(M),A=new Float32Array(M),k=new Float32Array(M),S=new Float32Array(M);C&&(h=new Float32Array(M),g=new Float32Array(M),f=new Float32Array(M),m=new Float32Array(2*y));var x=l.length/2,I=0,N=Me;N.height=0;var R=Te;R.height=0;var D=Ee,z=_e;if(C)for(d=0,p=1;pL?(ae=he(n,N,re,$,ze),te=he(n,R,Z,ee,He)):1===se?(te=he(n,R,Z,ee,He),ae.x=0,ae.y=i.CesiumMath.sign(N.longitude-Math.abs(R.longitude)),ae.z=0):(ae=he(n,N,re,$,ze),te.x=0,te.y=i.CesiumMath.sign(N.longitude-R.longitude),te.z=0)}var le=a.Cartesian3.distance(ie,U),ue=u.EncodedCartesian3.fromCartesian(ne,qe),Ce=a.Cartesian3.subtract(W,ne,Be),pe=a.Cartesian3.normalize(Ce,Ve),de=a.Cartesian3.subtract(ie,ne,je);de=a.Cartesian3.normalize(de,de);var ge=a.Cartesian3.cross(pe,de,Ve);ge=a.Cartesian3.normalize(ge,ge);var fe=a.Cartesian3.cross(de,re,Ye);fe=a.Cartesian3.normalize(fe,fe);var we=a.Cartesian3.subtract(U,W,Ge);we=a.Cartesian3.normalize(we,we);var ea=a.Cartesian3.cross(Z,we,Fe);ea=a.Cartesian3.normalize(ea,ea);var aa,ta,na,ia=le/j,ra=J/j,sa=0,oa=0,la=0;if(C){sa=a.Cartesian3.distance($,ee),aa=u.EncodedCartesian3.fromCartesian($,Xe),ta=a.Cartesian3.subtract(ee,$,We);var ua=(na=a.Cartesian3.normalize(ta,Ue)).x;na.x=na.y,na.y=-ua,oa=sa/I,la=Q/I}for(B=0;B<8;B++){var ca=q+4*B,Ca=V+2*B,pa=ca+3,da=B<4?1:-1,ha=2===B||3===B||6===B||7===B?1:-1;a.Cartesian3.pack(ue.high,O,ca),O[pa]=Ce.x,a.Cartesian3.pack(ue.low,b,ca),b[pa]=Ce.y,a.Cartesian3.pack(fe,A,ca),A[pa]=Ce.z,a.Cartesian3.pack(ea,k,ca),k[pa]=ia*da,a.Cartesian3.pack(ge,S,ca);var ga=ra*ha;0===ga&&ha<0&&(ga=9),S[pa]=ga,C&&(h[ca]=aa.high.x,h[ca+1]=aa.high.y,h[ca+2]=aa.low.x,h[ca+3]=aa.low.y,f[ca]=-ae.y,f[ca+1]=ae.x,f[ca+2]=te.y,f[ca+3]=-te.x,g[ca]=ta.x,g[ca+1]=ta.y,g[ca+2]=na.x,g[ca+3]=na.y,m[Ca]=oa*da,0===(ga=la*ha)&&ha<0&&(ga=9),m[Ca+1]=ga)}var fa=Ie,ma=Ne,wa=Se,va=xe,ya=a.Rectangle.fromCartographicArray(ke,Le),Ma=P.getMinimumMaximumHeights(ya,w),Ta=Ma.minimumTerrainHeight,Ea=Ma.maximumTerrainHeight;K+=Ta,K+=Ea,me(ne,ie,Ta,Ea,fa,wa),me(W,U,Ta,Ea,ma,va);var _a=a.Cartesian3.multiplyByScalar(ge,i.CesiumMath.EPSILON5,Ze);a.Cartesian3.add(fa,_a,fa),a.Cartesian3.add(ma,_a,ma),a.Cartesian3.add(wa,_a,wa),a.Cartesian3.add(va,_a,va),ve(fa,ma),ve(wa,va),a.Cartesian3.pack(fa,_,Y),a.Cartesian3.pack(ma,_,Y+3),a.Cartesian3.pack(va,_,Y+6),a.Cartesian3.pack(wa,_,Y+9),_a=a.Cartesian3.multiplyByScalar(ge,-2*i.CesiumMath.EPSILON5,Ze),a.Cartesian3.add(fa,_a,fa),a.Cartesian3.add(ma,_a,ma),a.Cartesian3.add(wa,_a,wa),a.Cartesian3.add(va,_a,va),ve(fa,ma),ve(wa,va),a.Cartesian3.pack(fa,_,Y+12),a.Cartesian3.pack(ma,_,Y+15),a.Cartesian3.pack(va,_,Y+18),a.Cartesian3.pack(wa,_,Y+21),G+=2,d+=3,V+=16,Y+=24,q+=32,J+=le,Q+=sa}d=0;var Oa=0;for(p=0;pL||li.CesiumMath.PI_OVER_TWO&&(u=!0,l=a.Cartesian3.subtract(o,n,de),C=c.cartesianToCartographic(l,Ce)),C.height=0;var p=e.project(C,s);return(s=a.Cartesian3.subtract(p,r,s)).z=0,s=a.Cartesian3.normalize(s,s),u&&a.Cartesian3.negate(s,s),s}var ge=new a.Cartesian3,fe=new a.Cartesian3;function me(e,t,n,i,r,s){var o=a.Cartesian3.subtract(t,e,ge);a.Cartesian3.normalize(o,o);var l=n-0,u=a.Cartesian3.multiplyByScalar(o,l,fe);a.Cartesian3.add(e,u,r);var c=i-1e3;u=a.Cartesian3.multiplyByScalar(o,c,fe),a.Cartesian3.add(t,u,s)}var we=new a.Cartesian3;function ve(e,t){var n=p.Plane.getPointDistance(Q,e),r=p.Plane.getPointDistance(Q,t),s=we;i.CesiumMath.equalsEpsilon(n,0,i.CesiumMath.EPSILON2)?(s=F(t,e,s),a.Cartesian3.multiplyByScalar(s,i.CesiumMath.EPSILON2,s),a.Cartesian3.add(e,s,e)):i.CesiumMath.equalsEpsilon(r,0,i.CesiumMath.EPSILON2)&&(s=F(e,t,s),a.Cartesian3.multiplyByScalar(s,i.CesiumMath.EPSILON2,s),a.Cartesian3.add(t,s,t))}function ye(e,a){var t=Math.abs(e.longitude),n=Math.abs(a.longitude);if(i.CesiumMath.equalsEpsilon(t,i.CesiumMath.PI,i.CesiumMath.EPSILON11)){var r=i.CesiumMath.sign(a.longitude);return e.longitude=r*(t-i.CesiumMath.EPSILON11),1}if(i.CesiumMath.equalsEpsilon(n,i.CesiumMath.PI,i.CesiumMath.EPSILON11)){var s=i.CesiumMath.sign(e.longitude);return a.longitude=s*(n-i.CesiumMath.EPSILON11),2}return 0}var Me=new a.Cartographic,Te=new a.Cartographic,Ee=new a.Cartesian3,_e=new a.Cartesian3,Oe=new a.Cartesian3,Pe=new a.Cartesian3,be=new a.Cartesian3,Ae=new a.Cartesian3,ke=[Me,Te],Le=new a.Rectangle,Se=new a.Cartesian3,xe=new a.Cartesian3,Ie=new a.Cartesian3,Ne=new a.Cartesian3,Re=new a.Cartesian3,De=new a.Cartesian3,ze=new a.Cartesian3,He=new a.Cartesian3,Be=new a.Cartesian3,je=new a.Cartesian3,Ge=new a.Cartesian3,Ve=new a.Cartesian3,Ye=new a.Cartesian3,Fe=new a.Cartesian3,qe=new u.EncodedCartesian3,Xe=new u.EncodedCartesian3,We=new a.Cartesian3,Ue=new a.Cartesian3,Ze=new a.Cartesian3,Je=[new e.BoundingSphere,new e.BoundingSphere],Qe=[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],Ke=Qe.length;function $e(e){return new c.GeometryAttribute({componentDatatype:i.ComponentDatatype.FLOAT,componentsPerAttribute:4,normalize:!1,values:e})}return x._projectNormal=he,function(e,a){return P.initialize().then((function(){return n.defined(a)&&(e=x.unpack(e,a)),x.createGeometry(e)}))}}));