NONGYESHUZIDIZUO/public/Cesium/Workers/PolygonGeometryLibrary-190f...

2 lines
7.5 KiB
JavaScript

define(["exports","./ArcType-198c1070","./arrayRemoveDuplicates-74caa2f4","./Cartesian2-2b41fabe","./Cartographic-1d953166","./ComponentDatatype-07894a2b","./when-d186add7","./Rectangle-f841217d","./EllipsoidRhumbLine-394d2834","./GeometryAttribute-95780fd1","./GeometryAttributes-9c67dd14","./GeometryPipeline-6f0b08bc","./IndexDatatype-61ffec74","./Math-7f5f2992","./FeatureDetection-4281d393","./PolygonPipeline-6809c3ce"],(function(e,t,r,n,i,o,a,s,u,h,c,l,f,p,v,d){"use strict";function g(){this._array=[],this._offset=0,this._length=0}Object.defineProperties(g.prototype,{length:{get:function(){return this._length}}}),g.prototype.enqueue=function(e){this._array.push(e),this._length++},g.prototype.dequeue=function(){if(0!==this._length){var e=this._array,t=this._offset,r=e[t];return e[t]=void 0,++t>10&&2*t>e.length&&(this._array=e.slice(t),t=0),this._offset=t,this._length--,r}},g.prototype.peek=function(){if(0!==this._length)return this._array[this._offset]},g.prototype.contains=function(e){return-1!==this._array.indexOf(e)},g.prototype.clear=function(){this._array.length=this._offset=this._length=0},g.prototype.sort=function(e){this._offset>0&&(this._array=this._array.slice(this._offset),this._offset=0),this._array.sort(e)};var y={computeHierarchyPackedLength:function(e){for(var t=0,r=[e];r.length>0;){var n=r.pop();if(a.e(n)){t+=2;var o=n.positions,s=n.holes;if(a.e(o)&&(t+=o.length*i.t.packedLength),a.e(s))for(var u=s.length,h=0;h<u;++h)r.push(s[h])}}return t},packPolygonHierarchy:function(e,t,r){for(var n=[e];n.length>0;){var o=n.pop();if(a.e(o)){var s=o.positions,u=o.holes;if(t[r++]=a.e(s)?s.length:0,t[r++]=a.e(u)?u.length:0,a.e(s))for(var h=s.length,c=0;c<h;++c,r+=3)i.t.pack(s[c],t,r);if(a.e(u))for(var l=u.length,f=0;f<l;++f)n.push(u[f])}}return r},unpackPolygonHierarchy:function(e,t){for(var r=e[t++],n=e[t++],o=new Array(r),a=n>0?new Array(n):void 0,s=0;s<r;++s,t+=i.t.packedLength)o[s]=i.t.unpack(e,t);for(var u=0;u<n;++u)a[u]=y.unpackPolygonHierarchy(e,t),t=a[u].startingIndex,delete a[u].startingIndex;return{positions:o,holes:a,startingIndex:t}}},m=new i.t;function b(e,t,r,n){return i.t.subtract(t,e,m),i.t.multiplyByScalar(m,r/n,m),i.t.add(e,m,m),[m.x,m.y,m.z]}y.subdivideLineCount=function(e,t,r){var n=i.t.distance(e,t)/r,o=Math.max(0,Math.ceil(p.e.log2(n)));return Math.pow(2,o)};var I=new i.t$1,w=new i.t$1,_=new i.t$1,L=new i.t;y.subdivideRhumbLineCount=function(e,t,r,n){var i=e.cartesianToCartographic(t,I),o=e.cartesianToCartographic(r,w),a=new u.P(i,o,e).surfaceDistance/n,s=Math.max(0,Math.ceil(p.e.log2(a)));return Math.pow(2,s)},y.subdivideLine=function(e,t,r,n){var o=y.subdivideLineCount(e,t,r),s=i.t.distance(e,t),u=s/o;a.e(n)||(n=[]);var h=n;h.length=3*o;for(var c=0,l=0;l<o;l++){var f=b(e,t,l*u,s);h[c++]=f[0],h[c++]=f[1],h[c++]=f[2]}return h},y.subdivideRhumbLine=function(e,t,r,n,i){var o=e.cartesianToCartographic(t,I),s=e.cartesianToCartographic(r,w),h=new u.P(o,s,e),c=h.surfaceDistance/n,l=Math.max(0,Math.ceil(p.e.log2(c))),f=Math.pow(2,l),v=h.surfaceDistance/f;a.e(i)||(i=[]);var d=i;d.length=3*f;for(var g=0,y=0;y<f;y++){var m=h.interpolateUsingSurfaceDistance(y*v,_),b=e.cartographicToCartesian(m,L);d[g++]=b.x,d[g++]=b.y,d[g++]=b.z}return d};var x=new i.t,E=new i.t,D=new i.t,S=new i.t;y.scaleToGeodeticHeightExtruded=function(e,t,r,n,o){n=a.u(n,s.t.WGS84);var u=x,h=E,c=D,l=S;if(a.e(e)&&a.e(e.attributes)&&a.e(e.attributes.position))for(var f=e.attributes.position.values,p=f.length/2,v=0;v<p;v+=3)i.t.fromArray(f,v,c),n.geodeticSurfaceNormal(c,u),l=n.scaleToGeodeticSurface(c,l),h=i.t.multiplyByScalar(u,r,h),h=i.t.add(l,h,h),f[v+p]=h.x,f[v+1+p]=h.y,f[v+2+p]=h.z,o&&(l=i.t.clone(c,l)),h=i.t.multiplyByScalar(u,t,h),h=i.t.add(l,h,h),f[v]=h.x,f[v+1]=h.y,f[v+2]=h.z;return e},y.polygonOutlinesFromHierarchy=function(e,t,n){var o,s,u,h=[],c=new g;for(c.enqueue(e);0!==c.length;){var l=c.dequeue(),f=l.positions;if(t)for(u=f.length,o=0;o<u;o++)n.scaleToGeodeticSurface(f[o],f[o]);if(!((f=r.D(f,i.t.equalsEpsilon,!0)).length<3)){var p=l.holes?l.holes.length:0;for(o=0;o<p;o++){var v=l.holes[o],d=v.positions;if(t)for(u=d.length,s=0;s<u;++s)n.scaleToGeodeticSurface(d[s],d[s]);if(!((d=r.D(d,i.t.equalsEpsilon,!0)).length<3)){h.push(d);var y=0;for(a.e(v.holes)&&(y=v.holes.length),s=0;s<y;s++)c.enqueue(v.holes[s])}}h.push(f)}}return h};var A=new i.t(6378137,6378137,6378137);y.polygonsFromHierarchy=function(e,t,n,o){var s=[],u=[],h=new g;for(h.enqueue(e);0!==h.length;){var c,l,f,v=h.dequeue(),y=v.positions,m=v.holes,b=y.slice();if(n)for(l=y.length,c=0;c<l;c++)o.scaleToGeodeticSurface(y[c],b[c]);if(a.e(o)&&!i.t.equals(o._radii,A)&&(f=p.e.EPSILON7),!((y=r.D(b,i.t.equalsEpsilon,!0,f)).length<3)){var I=t(y);if(a.e(I)){var w=[],_=d.A.computeWindingOrder2D(I);_===d.W.CLOCKWISE&&(I.reverse(),y=y.slice().reverse());var L,x=y.slice(),E=a.e(m)?m.length:0,D=[];for(c=0;c<E;c++){var S=m[c],T=S.positions;if(n)for(l=T.length,L=0;L<l;++L)o.scaleToGeodeticSurface(T[L],T[L]);if(!((T=r.D(T,i.t.equalsEpsilon,!0,p.e.EPSILON7)).length<3)){var C=t(T);if(a.e(C)){(_=d.A.computeWindingOrder2D(C))===d.W.CLOCKWISE&&(C.reverse(),T=T.slice().reverse()),D.push(T),w.push(x.length),x=x.concat(T),I=I.concat(C);var N=0;for(a.e(S.holes)&&(N=S.holes.length),L=0;L<N;L++)h.enqueue(S.holes[L])}}}s.push({outerRing:y,holes:D}),u.push({positions:x,positions2D:I,holes:w})}}}return{hierarchy:s,polygons:u}};var T=new n.o,C=new i.t,N=new h.n,G=new v.p;y.computeBoundingRectangle=function(e,t,r,n,o){for(var s=h.n.fromAxisAngle(e,n,N),u=v.p.fromQuaternion(s,G),c=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY,f=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY,d=r.length,g=0;g<d;++g){var y=i.t.clone(r[g],C);v.p.multiplyByVector(u,y,y);var m=t(y,T);a.e(m)&&(c=Math.min(c,m.x),l=Math.max(l,m.x),f=Math.min(f,m.y),p=Math.max(p,m.y))}return o.x=c,o.y=f,o.width=l-c,o.height=p-f,o},y.createGeometryFromPositions=function(e,r,n,i,a,s){var u=d.A.triangulate(r.positions2D,r.holes);u.length<3&&(u=[0,1,2]);var c=r.positions;if(i){for(var f=c.length,p=new Array(3*f),g=0,y=0;y<f;y++){var m=c[y];p[g++]=m.x,p[g++]=m.y,p[g++]=m.z}var b=new h.I({attributes:{position:new h.o({componentDatatype:o.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:p})},indices:u,primitiveType:v._0x12cc5d.TRIANGLES});return a.normal?l.k.computeNormal(b):b}return s===t.L.GEODESIC?d.A.computeSubdivision(e,c,u,n):s===t.L.RHUMB?d.A.computeRhumbLineSubdivision(e,c,u,n):void 0};var P=[],O=new i.t,M=new i.t;y.computeWallGeometry=function(e,r,n,a,s,u){var l,d,g,m,b,I=u?1:0,w=e.length,_=0;if(a)for(d=3*(w-I)*2,l=new Array(2*d),g=0;g<w-I;g++)m=e[g],b=e[(g+1)%w],l[_]=l[_+d]=m.x,l[++_]=l[_+d]=m.y,l[++_]=l[_+d]=m.z,l[++_]=l[_+d]=b.x,l[++_]=l[_+d]=b.y,l[++_]=l[_+d]=b.z,++_;else{var L=p.e.chordLength(n,r.maximumRadius),x=0;if(s===t.L.GEODESIC)for(g=0;g<w;g++)x+=y.subdivideLineCount(e[g],e[(g+1)%w],L);else if(s===t.L.RHUMB)for(g=0;g<w;g++)x+=y.subdivideRhumbLineCount(r,e[g],e[(g+1)%w],L);for(d=3*(x+w),l=new Array(2*d),g=0;g<w;g++){var E;m=e[g],b=e[(g+1)%w],s===t.L.GEODESIC?E=y.subdivideLine(m,b,L,P):s===t.L.RHUMB&&(E=y.subdivideRhumbLine(r,m,b,L,P));for(var D=E.length,S=0;S<D;++S,++_)l[_]=E[S],l[_+d]=E[S];l[_]=b.x,l[_+d]=b.x,l[++_]=b.y,l[_+d]=b.y,l[++_]=b.z,l[_+d]=b.z,++_}}w=l.length;var A=f.IndexDatatype.createTypedArray(w/3,w-6*(e.length-I)),T=0;for(w/=6,g=0;g<w;g++){var C=g,N=C+1,G=C+w,R=G+1;m=i.t.fromArray(l,3*C,O),b=i.t.fromArray(l,3*N,M),!i.t.equalsEpsilon(m,b,p.e.EPSILON10,p.e.EPSILON10)&&(A[T++]=C,A[T++]=G,A[T++]=N,A[T++]=N,A[T++]=G,A[T++]=R)}return new h.I({attributes:new c.a({position:new h.o({componentDatatype:o.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:l})}),indices:A,primitiveType:v._0x12cc5d.TRIANGLES})},e.y=y}));