PolygonGeometryLibrary-7c66403e.js 7.5 KB

1
  1. define(["exports","./ArcType-31298545","./arrayRemoveDuplicates-f7eaafa2","./Cartesian2-6033fa5d","./Cartographic-67e73ef9","./ComponentDatatype-81047f82","./when-92c6cf3c","./Rectangle-bab7abf0","./EllipsoidRhumbLine-8847d1a1","./GeometryAttribute-ef657318","./GeometryAttributes-7f66ea53","./GeometryPipeline-f4eddf07","./IndexDatatype-4c0e98b8","./Math-92c3b5f7","./PrimitiveType-cdfe443e","./PolygonPipeline-b86e8785","./WindingOrder-1b9c8a87"],(function(e,t,r,n,i,a,o,s,u,h,l,c,f,p,v,g,y){"use strict";function d(){this._array=[],this._offset=0,this._length=0}Object.defineProperties(d.prototype,{length:{get:function(){return this._length}}}),d.prototype.enqueue=function(e){this._array.push(e),this._length++},d.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}},d.prototype.peek=function(){if(0!==this._length)return this._array[this._offset]},d.prototype.contains=function(e){return-1!==this._array.indexOf(e)},d.prototype.clear=function(){this._array.length=this._offset=this._length=0},d.prototype.sort=function(e){this._offset>0&&(this._array=this._array.slice(this._offset),this._offset=0),this._array.sort(e)};var m={computeHierarchyPackedLength:function(e){for(var t=0,r=[e];r.length>0;){var n=r.pop();if(o.e(n)){t+=2;var a=n.positions,s=n.holes;if(o.e(a)&&(t+=a.length*i.t.packedLength),o.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 a=n.pop();if(o.e(a)){var s=a.positions,u=a.holes;if(t[r++]=o.e(s)?s.length:0,t[r++]=o.e(u)?u.length:0,o.e(s))for(var h=s.length,l=0;l<h;++l,r+=3)i.t.pack(s[l],t,r);if(o.e(u))for(var c=u.length,f=0;f<c;++f)n.push(u[f])}}return r},unpackPolygonHierarchy:function(e,t){for(var r=e[t++],n=e[t++],a=new Array(r),o=n>0?new Array(n):void 0,s=0;s<r;++s,t+=i.t.packedLength)a[s]=i.t.unpack(e,t);for(var u=0;u<n;++u)o[u]=m.unpackPolygonHierarchy(e,t),t=o[u].startingIndex,delete o[u].startingIndex;return{positions:a,holes:o,startingIndex:t}}},b=new i.t;function I(e,t,r,n){return i.t.subtract(t,e,b),i.t.multiplyByScalar(b,r/n,b),i.t.add(e,b,b),[b.x,b.y,b.z]}m.subdivideLineCount=function(e,t,r){var n=i.t.distance(e,t)/r,a=Math.max(0,Math.ceil(p.e.log2(n)));return Math.pow(2,a)};var w=new i.t$1,_=new i.t$1,L=new i.t$1,x=new i.t;m.subdivideRhumbLineCount=function(e,t,r,n){var i=e.cartesianToCartographic(t,w),a=e.cartesianToCartographic(r,_),o=new u.P(i,a,e).surfaceDistance/n,s=Math.max(0,Math.ceil(p.e.log2(o)));return Math.pow(2,s)},m.subdivideLine=function(e,t,r,n){var a=m.subdivideLineCount(e,t,r),s=i.t.distance(e,t),u=s/a;o.e(n)||(n=[]);var h=n;h.length=3*a;for(var l=0,c=0;c<a;c++){var f=I(e,t,c*u,s);h[l++]=f[0],h[l++]=f[1],h[l++]=f[2]}return h},m.subdivideRhumbLine=function(e,t,r,n,i){var a=e.cartesianToCartographic(t,w),s=e.cartesianToCartographic(r,_),h=new u.P(a,s,e),l=h.surfaceDistance/n,c=Math.max(0,Math.ceil(p.e.log2(l))),f=Math.pow(2,c),v=h.surfaceDistance/f;o.e(i)||(i=[]);var g=i;g.length=3*f;for(var y=0,d=0;d<f;d++){var m=h.interpolateUsingSurfaceDistance(d*v,L),b=e.cartographicToCartesian(m,x);g[y++]=b.x,g[y++]=b.y,g[y++]=b.z}return g};var E=new i.t,S=new i.t,T=new i.t,A=new i.t;m.scaleToGeodeticHeightExtruded=function(e,t,r,n,a){n=o.u(n,s.t.WGS84);var u=E,h=S,l=T,c=A;if(o.e(e)&&o.e(e.attributes)&&o.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,l),n.geodeticSurfaceNormal(l,u),c=n.scaleToGeodeticSurface(l,c),h=i.t.multiplyByScalar(u,r,h),h=i.t.add(c,h,h),f[v+p]=h.x,f[v+1+p]=h.y,f[v+2+p]=h.z,a&&(c=i.t.clone(l,c)),h=i.t.multiplyByScalar(u,t,h),h=i.t.add(c,h,h),f[v]=h.x,f[v+1]=h.y,f[v+2]=h.z;return e},m.polygonOutlinesFromHierarchy=function(e,t,n){var a,s,u,h=[],l=new d;for(l.enqueue(e);0!==l.length;){var c=l.dequeue(),f=c.positions;if(t)for(u=f.length,a=0;a<u;a++)n.scaleToGeodeticSurface(f[a],f[a]);if(!((f=r.D(f,i.t.equalsEpsilon,!0)).length<3)){var p=c.holes?c.holes.length:0;for(a=0;a<p;a++){var v=c.holes[a],g=v.positions;if(t)for(u=g.length,s=0;s<u;++s)n.scaleToGeodeticSurface(g[s],g[s]);if(!((g=r.D(g,i.t.equalsEpsilon,!0)).length<3)){h.push(g);var y=0;for(o.e(v.holes)&&(y=v.holes.length),s=0;s<y;s++)l.enqueue(v.holes[s])}}h.push(f)}}return h};var D=new i.t(6378137,6378137,6378137);m.polygonsFromHierarchy=function(e,t,n,a){var s=[],u=[],h=new d;for(h.enqueue(e);0!==h.length;){var l,c,f,v=h.dequeue(),m=v.positions,b=v.holes,I=m.slice();if(n)for(c=m.length,l=0;l<c;l++)a.scaleToGeodeticSurface(m[l],I[l]);if(o.e(a)&&!i.t.equals(a._radii,D)&&(f=p.e.EPSILON7),!((m=r.D(I,i.t.equalsEpsilon,!0,f)).length<3)){var w=t(m);if(o.e(w)){var _=[],L=g.A.computeWindingOrder2D(w);L===y.W.CLOCKWISE&&(w.reverse(),m=m.slice().reverse());var x,E=m.slice(),S=o.e(b)?b.length:0,T=[];for(l=0;l<S;l++){var A=b[l],C=A.positions;if(n)for(c=C.length,x=0;x<c;++x)a.scaleToGeodeticSurface(C[x],C[x]);if(!((C=r.D(C,i.t.equalsEpsilon,!0,p.e.EPSILON7)).length<3)){var N=t(C);if(o.e(N)){(L=g.A.computeWindingOrder2D(N))===y.W.CLOCKWISE&&(N.reverse(),C=C.slice().reverse()),T.push(C),_.push(E.length),E=E.concat(C),w=w.concat(N);var P=0;for(o.e(A.holes)&&(P=A.holes.length),x=0;x<P;x++)h.enqueue(A.holes[x])}}}s.push({outerRing:m,holes:T}),u.push({positions:E,positions2D:w,holes:_})}}}return{hierarchy:s,polygons:u}};var C=new n.o,N=new i.t,P=new h.n,G=new v.p;m.computeBoundingRectangle=function(e,t,r,n,a){for(var s=h.n.fromAxisAngle(e,n,P),u=v.p.fromQuaternion(s,G),l=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,f=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY,g=r.length,y=0;y<g;++y){var d=i.t.clone(r[y],N);v.p.multiplyByVector(u,d,d);var m=t(d,C);o.e(m)&&(l=Math.min(l,m.x),c=Math.max(c,m.x),f=Math.min(f,m.y),p=Math.max(p,m.y))}return a.x=l,a.y=f,a.width=c-l,a.height=p-f,a},m.createGeometryFromPositions=function(e,r,n,i,o,s){var u=g.A.triangulate(r.positions2D,r.holes);u.length<3&&(u=[0,1,2]);var l=r.positions;if(i){for(var f=l.length,p=new Array(3*f),y=0,d=0;d<f;d++){var m=l[d];p[y++]=m.x,p[y++]=m.y,p[y++]=m.z}var b=new h.I({attributes:{position:new h.o({componentDatatype:a.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:p})},indices:u,primitiveType:v._0x29ba75.TRIANGLES});return o.normal?c.k.computeNormal(b):b}return s===t.L.GEODESIC?g.A.computeSubdivision(e,l,u,n):s===t.L.RHUMB?g.A.computeRhumbLineSubdivision(e,l,u,n):void 0};var O=[],M=new i.t,R=new i.t;m.computeWallGeometry=function(e,r,n,o,s,u){var c,g,y,d,b,I=u?1:0,w=e.length,_=0;if(o)for(g=3*(w-I)*2,c=new Array(2*g),y=0;y<w-I;y++)d=e[y],b=e[(y+1)%w],c[_]=c[_+g]=d.x,c[++_]=c[_+g]=d.y,c[++_]=c[_+g]=d.z,c[++_]=c[_+g]=b.x,c[++_]=c[_+g]=b.y,c[++_]=c[_+g]=b.z,++_;else{var L=p.e.chordLength(n,r.maximumRadius),x=0;if(s===t.L.GEODESIC)for(y=0;y<w;y++)x+=m.subdivideLineCount(e[y],e[(y+1)%w],L);else if(s===t.L.RHUMB)for(y=0;y<w;y++)x+=m.subdivideRhumbLineCount(r,e[y],e[(y+1)%w],L);for(g=3*(x+w),c=new Array(2*g),y=0;y<w;y++){var E;d=e[y],b=e[(y+1)%w],s===t.L.GEODESIC?E=m.subdivideLine(d,b,L,O):s===t.L.RHUMB&&(E=m.subdivideRhumbLine(r,d,b,L,O));for(var S=E.length,T=0;T<S;++T,++_)c[_]=E[T],c[_+g]=E[T];c[_]=b.x,c[_+g]=b.x,c[++_]=b.y,c[_+g]=b.y,c[++_]=b.z,c[_+g]=b.z,++_}}w=c.length;var A=f.IndexDatatype.createTypedArray(w/3,w-6*(e.length-I)),D=0;for(w/=6,y=0;y<w;y++){var C=y,N=C+1,P=C+w,G=P+1;d=i.t.fromArray(c,3*C,M),b=i.t.fromArray(c,3*N,R),!i.t.equalsEpsilon(d,b,p.e.EPSILON10,p.e.EPSILON10)&&(A[D++]=C,A[D++]=P,A[D++]=N,A[D++]=N,A[D++]=P,A[D++]=G)}return new h.I({attributes:new l.a({position:new h.o({componentDatatype:a.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:c})}),indices:A,primitiveType:v._0x29ba75.TRIANGLES})},e.y=m}));