define(["./buildModuleUrl-4e1b81e7","./Cartesian2-47311507","./Cartographic-3309dd0d","./Check-7b2a090c","./when-b60132fc","./Math-119be1a3","./ArcType-29cf2197","./arrayRemoveDuplicates-d2f048c5","./ComponentDatatype-c140a87d","./EllipsoidGeodesic-0f19ac62","./EllipsoidRhumbLine-ed1a6bf4","./EncodedCartesian3-f1396b05","./GeometryAttribute-3a88ba31","./IntersectionTests-7386ffbf","./PrimitiveType-a54dc62f","./Plane-7ae8294c","./WebMercatorProjection-01b1b5e7","./Event-16a2dfbf","./RuntimeError-4a5c8994","./WebGLConstants-4ae0db90","./FeatureDetection-c3b71206","./Cartesian4-3ca25aab"],(function(e,a,t,i,n,r,s,o,l,u,c,h,C,d,p,g,f,m,v,w,y,_){"use strict";function M(t){t=n.defaultValue(t,{}),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),this._customDPI=t.customDPI,this._scaleDenominators=t.scaleDenominators,this._tileWidth=n.defaultValue(t.tileWidth,256),this._tileHeight=n.defaultValue(t.tileHeight,256),this._beginLevel=n.defaultValue(t.beginLevel,0)}Object.defineProperties(M.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},rectangle:{get:function(){return this._rectangle}},projection:{get:function(){return this._projection}},beginLevel:{get:function(){return this._beginLevel}}}),M.prototype.getNumberOfXTilesAtLevel=function(e){if(n.defined(this._customDPI)&&n.defined(this._scaleDenominators)){var a=this.calculateResolution(e),t=this._tileWidth*a.x;return Math.ceil(this._rectangle.width/t)}return this._numberOfLevelZeroTilesX<=o&&(d=o-1);var p=(s.north-e.latitude)/c|0;return p>=l&&(p=l-1),n.defined(i)?(i.x=d,i.y=p,i):new a.Cartesian2(d,p)}},M.prototype.calculateResolution=function(e){var t=.0254*this._scaleDenominators[e-this._beginLevel]/this._customDPI.x,i=.0254*this._scaleDenominators[e-this._beginLevel]/this._customDPI.y,n=a.Ellipsoid.WGS84.maximumRadius;return new a.Cartesian2(t/n,i/n)};var T=new t.Cartesian3,E=new t.Cartesian3,b=new t.Cartographic,P=new t.Cartesian3,O=new t.Cartesian3,I=new e.BoundingSphere,L=new M,D=[new t.Cartographic,new t.Cartographic,new t.Cartographic,new t.Cartographic],S=new a.Cartesian2,k={};function A(e){t.Cartographic.fromRadians(e.east,e.north,0,D[0]),t.Cartographic.fromRadians(e.west,e.north,0,D[1]),t.Cartographic.fromRadians(e.east,e.south,0,D[2]),t.Cartographic.fromRadians(e.west,e.south,0,D[3]);var a,i=0,n=0,r=0,s=0,o=k._terrainHeightsMaxLevel;for(a=0;a<=o;++a){for(var l=!1,u=0;u<4;++u){var c=D[u];if(L.positionToTileXY(c,a,S),0===u)r=S.x,s=S.y;else if(r!==S.x||s!==S.y){l=!0;break}}if(l)break;i=r,n=s}if(0!==a)return{x:i,y:n,level:a>o?o:a-1}}k.initialize=function(){var a=k._initPromise;return n.defined(a)||(a=e.Resource.fetchJson(e.buildModuleUrl("Assets/approximateTerrainHeights.json")).then((function(e){k._terrainHeights=e})),k._initPromise=a),a},k.getMinimumMaximumHeights=function(e,i){i=n.defaultValue(i,a.Ellipsoid.WGS84);var r=A(e),s=k._defaultMinTerrainHeight,o=k._defaultMaxTerrainHeight;if(n.defined(r)){var l=r.level+"-"+r.x+"-"+r.y,u=k._terrainHeights[l];n.defined(u)&&(s=u[0],o=u[1]),i.cartographicToCartesian(a.Rectangle.northeast(e,b),T),i.cartographicToCartesian(a.Rectangle.southwest(e,b),E),t.Cartesian3.midpoint(E,T,P);var c=i.scaleToGeodeticSurface(P,O);if(n.defined(c)){var h=t.Cartesian3.distance(P,c);s=Math.min(s,-h)}else s=k._defaultMinTerrainHeight}return{minimumTerrainHeight:s=Math.max(k._defaultMinTerrainHeight,s),maximumTerrainHeight:o}},k.getBoundingSphere=function(t,i){i=n.defaultValue(i,a.Ellipsoid.WGS84);var r=A(t),s=k._defaultMaxTerrainHeight;if(n.defined(r)){var o=r.level+"-"+r.x+"-"+r.y,l=k._terrainHeights[o];n.defined(l)&&(s=l[1])}var u=e.BoundingSphere.fromRectangle3D(t,i,0);return e.BoundingSphere.fromRectangle3D(t,i,s,I),e.BoundingSphere.union(u,I,u)},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)}}});var x=[e.GeographicProjection,f.WebMercatorProjection],N=x.length,R=Math.cos(r.CesiumMath.toRadians(30)),H=Math.cos(r.CesiumMath.toRadians(150));function V(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,s.ArcType.GEODESIC),this._ellipsoid=n.defaultValue(e.ellipsoid,a.Ellipsoid.WGS84),this._projectionIndex=0,this._workerName="createGroundPolylineGeometry",this._scene3DOnly=!1}Object.defineProperties(V.prototype,{packedLength:{get:function(){return 1+3*this._positions.length+1+1+1+a.Ellipsoid.packedLength+1+1}}}),V.setProjectionAndEllipsoid=function(e,a){for(var t=0,i=0;i65535?new Uint32Array(E):new Uint16Array(E),P=new Float64Array(3*M),O=new Float32Array(T),I=new Float32Array(T),L=new Float32Array(T),D=new Float32Array(T),S=new Float32Array(T);d&&(f=new Float32Array(T),m=new Float32Array(T),v=new Float32Array(T),w=new Float32Array(2*M));var A=c.length/2,x=0,N=Ie;N.height=0;var H=Le;H.height=0;var V=De,z=Se;if(d)for(g=0,p=1;pR?(ie=_e(n,N,oe,ae,Fe),ne=_e(n,H,J,te,Ye)):1===le?(ne=_e(n,H,J,te,Ye),ie.x=0,ie.y=r.CesiumMath.sign(N.longitude-Math.abs(H.longitude)),ie.z=0):(ie=_e(n,N,oe,ae,Fe),ne.x=0,ne.y=r.CesiumMath.sign(N.longitude-H.longitude),ne.z=0)}var ce=t.Cartesian3.distance(se,Z),he=h.EncodedCartesian3.fromCartesian(re,Ke),Ce=t.Cartesian3.subtract(U,re,Xe),de=t.Cartesian3.normalize(Ce,Ze),pe=t.Cartesian3.subtract(se,re,qe);pe=t.Cartesian3.normalize(pe,pe);var ge=t.Cartesian3.cross(de,pe,Ze);ge=t.Cartesian3.normalize(ge,ge);var fe=t.Cartesian3.cross(pe,oe,Qe);fe=t.Cartesian3.normalize(fe,fe);var ve=t.Cartesian3.subtract(Z,U,Ue);ve=t.Cartesian3.normalize(ve,ve);var we=t.Cartesian3.cross(J,ve,Je);we=t.Cartesian3.normalize(we,we);var ye,Me,Te,be=ce/B,oa=K/B,la=0,ua=0,ca=0;if(d){la=t.Cartesian3.distance(ae,te),ye=h.EncodedCartesian3.fromCartesian(ae,$e),Me=t.Cartesian3.subtract(te,ae,ea);var ha=(Te=t.Cartesian3.normalize(Me,aa)).x;Te.x=Te.y,Te.y=-ha,ua=la/x,ca=$/x}for(G=0;G<8;G++){var Ca=X+4*G,da=F+2*G,pa=Ca+3,ga=G<4?1:-1,fa=2===G||3===G||6===G||7===G?1:-1;t.Cartesian3.pack(he.high,O,Ca),O[pa]=Ce.x,t.Cartesian3.pack(he.low,I,Ca),I[pa]=Ce.y,t.Cartesian3.pack(fe,L,Ca),L[pa]=Ce.z,t.Cartesian3.pack(we,D,Ca),D[pa]=be*ga,t.Cartesian3.pack(ge,S,Ca);var ma=oa*fa;0===ma&&fa<0&&(ma=Number.POSITIVE_INFINITY),S[pa]=ma,d&&(f[Ca]=ye.high.x,f[Ca+1]=ye.high.y,f[Ca+2]=ye.low.x,f[Ca+3]=ye.low.y,v[Ca]=-ie.y,v[Ca+1]=ie.x,v[Ca+2]=ne.y,v[Ca+3]=-ne.x,m[Ca]=Me.x,m[Ca+1]=Me.y,m[Ca+2]=Te.x,m[Ca+3]=Te.y,w[da]=ua*ga,0===(ma=ca*fa)&&fa<0&&(ma=Number.POSITIVE_INFINITY),w[da+1]=ma)}var va=je,wa=Ge,ya=Ve,_a=ze,Ma=a.Rectangle.fromCartographicArray(Re,He),Ta=k.getMinimumMaximumHeights(Ma,y),Ea=Ta.minimumTerrainHeight,ba=Ta.maximumTerrainHeight;ee+=Ea,ee+=ba,Ee(re,se,Ea,ba,va,ya),Ee(U,Z,Ea,ba,wa,_a);var Pa=t.Cartesian3.multiplyByScalar(ge,r.CesiumMath.EPSILON5,ta);t.Cartesian3.add(va,Pa,va),t.Cartesian3.add(wa,Pa,wa),t.Cartesian3.add(ya,Pa,ya),t.Cartesian3.add(_a,Pa,_a),Pe(va,wa),Pe(ya,_a),t.Cartesian3.pack(va,P,Y),t.Cartesian3.pack(wa,P,Y+3),t.Cartesian3.pack(_a,P,Y+6),t.Cartesian3.pack(ya,P,Y+9),Pa=t.Cartesian3.multiplyByScalar(ge,-2*r.CesiumMath.EPSILON5,ta),t.Cartesian3.add(va,Pa,va),t.Cartesian3.add(wa,Pa,wa),t.Cartesian3.add(ya,Pa,ya),t.Cartesian3.add(_a,Pa,_a),Pe(va,wa),Pe(ya,_a),t.Cartesian3.pack(va,P,Y+12),t.Cartesian3.pack(wa,P,Y+15),t.Cartesian3.pack(_a,P,Y+18),t.Cartesian3.pack(ya,P,Y+21),W+=2,g+=3,F+=16,Y+=24,X+=32,K+=ce,$+=la}g=0;var Oa=0;for(p=0;p<_;p++){for(G=0;GR||or.CesiumMath.PI_OVER_TWO&&(u=!0,l=t.Cartesian3.subtract(o,i,ye),h=c.cartesianToCartographic(l,ve)),h.height=0;var C=e.project(h,s);return(s=t.Cartesian3.subtract(C,n,s)).z=0,s=t.Cartesian3.normalize(s,s),u&&t.Cartesian3.negate(s,s),s}var Me=new t.Cartesian3,Te=new t.Cartesian3;function Ee(e,a,i,n,r,s){var o=t.Cartesian3.subtract(a,e,Me);t.Cartesian3.normalize(o,o);var l=i-0,u=t.Cartesian3.multiplyByScalar(o,l,Te);t.Cartesian3.add(e,u,r);var c=n-1e3;u=t.Cartesian3.multiplyByScalar(o,c,Te),t.Cartesian3.add(a,u,s)}var be=new t.Cartesian3;function Pe(e,a){var i=g.Plane.getPointDistance(ne,e),n=g.Plane.getPointDistance(ne,a),s=be;r.CesiumMath.equalsEpsilon(i,0,r.CesiumMath.EPSILON2)?(s=Q(a,e,s),t.Cartesian3.multiplyByScalar(s,r.CesiumMath.EPSILON2,s),t.Cartesian3.add(e,s,e)):r.CesiumMath.equalsEpsilon(n,0,r.CesiumMath.EPSILON2)&&(s=Q(e,a,s),t.Cartesian3.multiplyByScalar(s,r.CesiumMath.EPSILON2,s),t.Cartesian3.add(a,s,a))}function Oe(e,a){var t=Math.abs(e.longitude),i=Math.abs(a.longitude);if(r.CesiumMath.equalsEpsilon(t,r.CesiumMath.PI,r.CesiumMath.EPSILON11)){var n=r.CesiumMath.sign(a.longitude);return e.longitude=n*(t-r.CesiumMath.EPSILON11),1}if(r.CesiumMath.equalsEpsilon(i,r.CesiumMath.PI,r.CesiumMath.EPSILON11)){var s=r.CesiumMath.sign(e.longitude);return a.longitude=s*(i-r.CesiumMath.EPSILON11),2}return 0}var Ie=new t.Cartographic,Le=new t.Cartographic,De=new t.Cartesian3,Se=new t.Cartesian3,ke=new t.Cartesian3,Ae=new t.Cartesian3,xe=new t.Cartesian3,Ne=new t.Cartesian3,Re=[Ie,Le],He=new a.Rectangle,Ve=new t.Cartesian3,ze=new t.Cartesian3,je=new t.Cartesian3,Ge=new t.Cartesian3,Be=new t.Cartesian3,We=new t.Cartesian3,Fe=new t.Cartesian3,Ye=new t.Cartesian3,Xe=new t.Cartesian3,qe=new t.Cartesian3,Ue=new t.Cartesian3,Ze=new t.Cartesian3,Qe=new t.Cartesian3,Je=new t.Cartesian3,Ke=new h.EncodedCartesian3,$e=new h.EncodedCartesian3,ea=new t.Cartesian3,aa=new t.Cartesian3,ta=new t.Cartesian3,ia=[new e.BoundingSphere,new e.BoundingSphere],na=[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],ra=na.length;function sa(e){return new C.GeometryAttribute({componentDatatype:l.ComponentDatatype.FLOAT,componentsPerAttribute:4,normalize:!1,values:e})}return V._projectNormal=_e,function(e,a){return k.initialize().then((function(){return n.defined(a)&&(e=V.unpack(e,a)),V.createGeometry(e)}))}}));