Agriculture-front-end/public/Cesium/Workers/PolylinePipeline-11e50058.js
2023-04-16 22:33:44 +08:00

2 lines
5.3 KiB
JavaScript

define(["exports","./Cartographic-3309dd0d","./when-b60132fc","./Check-7b2a090c","./Cartesian2-47311507","./EllipsoidGeodesic-0f19ac62","./EllipsoidRhumbLine-ed1a6bf4","./IntersectionTests-7386ffbf","./Math-119be1a3","./PrimitiveType-a54dc62f","./Plane-7ae8294c"],(function(a,e,r,t,i,n,o,s,c,l,u){"use strict";var h={numberOfPoints:function(a,r,t){var i=e.Cartesian3.distance(a,r);return Math.ceil(i/t)},numberOfPointsRhumbLine:function(a,e,r){var t=Math.pow(a.longitude-e.longitude,2)+Math.pow(a.latitude-e.latitude,2);return Math.ceil(Math.sqrt(t/(r*r)))}},f=new e.Cartographic;h.extractHeights=function(a,e){for(var r=a.length,t=new Array(r),i=0;i<r;i++){var n=a[i];t[i]=e.cartesianToCartographic(n,f).height}return t};var g=new l.Matrix4,C=new e.Cartesian3,d=new e.Cartesian3,p=new u.Plane(e.Cartesian3.UNIT_X,0),v=new e.Cartesian3,m=new u.Plane(e.Cartesian3.UNIT_X,0),P=new e.Cartesian3,T=new e.Cartesian3,w=[];function y(a,e,r){var t,i=w;if(i.length=a,e===r){for(t=0;t<a;t++)i[t]=e;return i}var n=(r-e)/a;for(t=0;t<a;t++){var o=e+t*n;i[t]=o}return i}var A=new e.Cartographic,b=new e.Cartographic,E=new e.Cartesian3,M=new e.Cartesian3,S=new e.Cartesian3,R=new n.EllipsoidGeodesic,D=new o.EllipsoidRhumbLine;function x(a,r,t,i,n,o,s,c,l){var u=i.scaleToGeodeticSurface(a,M),f=i.scaleToGeodeticSurface(r,S),g=h.numberOfPoints(a,r,t),C=i.cartesianToCartographic(u,A),d=i.cartesianToCartographic(f,b),p=y(g,n,o);l>0&&(p=function(a,e){var r=w;r.length=a;for(var t=0;t<a;t++)r[t]+=e*Math.sin(Math.PI*t/a);return r}(g,l)),R.setEndPoints(C,d);var v=R.surfaceDistance/g,m=c;C.height=n;var P=i.cartographicToCartesian(C,E);e.Cartesian3.pack(P,s,m),m+=3;for(var T=1;T<g;T++){var D=R.interpolateUsingSurfaceDistance(T*v,b);D.height=p[T],P=i.cartographicToCartesian(D,E),e.Cartesian3.pack(P,s,m),m+=3}return m}function G(a,r,t,i,n,s,c,l){var u=i.scaleToGeodeticSurface(a,M),f=i.scaleToGeodeticSurface(r,S),g=i.cartesianToCartographic(u,A),C=i.cartesianToCartographic(f,b),d=h.numberOfPointsRhumbLine(g,C,t),p=y(d,n,s);D.ellipsoid.equals(i)||(D=new o.EllipsoidRhumbLine(void 0,void 0,i)),D.setEndPoints(g,C);var v=D.surfaceDistance/d,m=l;g.height=n;var P=i.cartographicToCartesian(g,E);e.Cartesian3.pack(P,c,m),m+=3;for(var T=1;T<d;T++){var w=D.interpolateUsingSurfaceDistance(T*v,b);w.height=p[T],P=i.cartographicToCartesian(w,E),e.Cartesian3.pack(P,c,m),m+=3}return m}h.wrapLongitude=function(a,t){var i=[],n=[];if(r.defined(a)&&a.length>0){t=r.defaultValue(t,l.Matrix4.IDENTITY);var o=l.Matrix4.inverseTransformation(t,g),c=l.Matrix4.multiplyByPoint(o,e.Cartesian3.ZERO,C),h=e.Cartesian3.normalize(l.Matrix4.multiplyByPointAsVector(o,e.Cartesian3.UNIT_Y,d),d),f=u.Plane.fromPointNormal(c,h,p),w=e.Cartesian3.normalize(l.Matrix4.multiplyByPointAsVector(o,e.Cartesian3.UNIT_X,v),v),y=u.Plane.fromPointNormal(c,w,m),A=1;i.push(e.Cartesian3.clone(a[0]));for(var b=i[0],E=a.length,M=1;M<E;++M){var S=a[M];if(u.Plane.getPointDistance(y,b)<0||u.Plane.getPointDistance(y,S)<0){var R=s.IntersectionTests.lineSegmentPlane(b,S,f,P);if(r.defined(R)){var D=e.Cartesian3.multiplyByScalar(h,5e-9,T);u.Plane.getPointDistance(f,b)<0&&e.Cartesian3.negate(D,D),i.push(e.Cartesian3.add(R,D,new e.Cartesian3)),n.push(A+1),e.Cartesian3.negate(D,D),i.push(e.Cartesian3.add(R,D,new e.Cartesian3)),A=1}}i.push(e.Cartesian3.clone(a[M])),A++,b=S}n.push(A)}return{positions:i,lengths:n}},h.generateArc=function(a){r.defined(a)||(a={});var t=a.positions,n=t.length,o=r.defaultValue(a.ellipsoid,i.Ellipsoid.WGS84),s=r.defaultValue(a.height,0),l=Array.isArray(s);if(n<1)return[];if(1===n){var u=o.scaleToGeodeticSurface(t[0],M);if(0!==(s=l?s[0]:s)){var f=o.geodeticSurfaceNormal(u,E);e.Cartesian3.multiplyByScalar(f,s,f),e.Cartesian3.add(u,f,u)}return[u.x,u.y,u.z]}var g=a.minDistance;if(!r.defined(g)){var C=r.defaultValue(a.granularity,c.CesiumMath.RADIANS_PER_DEGREE);g=c.CesiumMath.chordLength(C,o.maximumRadius)}var d,p=0;for(d=0;d<n-1;d++)p+=h.numberOfPoints(t[d],t[d+1],g);var v=a.hMax,m=3*(p+1),P=new Array(m),T=0;for(d=0;d<n-1;d++){T=x(t[d],t[d+1],g,o,l?s[d]:s,l?s[d+1]:s,P,T,v)}w.length=0;var y=t[n-1],b=o.cartesianToCartographic(y,A);b.height=l?s[n-1]:s;var S=o.cartographicToCartesian(b,E);return e.Cartesian3.pack(S,P,m-3),P};var I=new e.Cartographic,N=new e.Cartographic;h.generateRhumbArc=function(a){r.defined(a)||(a={});var t=a.positions,n=t.length,o=r.defaultValue(a.ellipsoid,i.Ellipsoid.WGS84),s=r.defaultValue(a.height,0),l=Array.isArray(s);if(n<1)return[];if(1===n){var u=o.scaleToGeodeticSurface(t[0],M);if(0!==(s=l?s[0]:s)){var f=o.geodeticSurfaceNormal(u,E);e.Cartesian3.multiplyByScalar(f,s,f),e.Cartesian3.add(u,f,u)}return[u.x,u.y,u.z]}var g,C,d=r.defaultValue(a.granularity,c.CesiumMath.RADIANS_PER_DEGREE),p=0,v=o.cartesianToCartographic(t[0],I);for(g=0;g<n-1;g++)C=o.cartesianToCartographic(t[g+1],N),p+=h.numberOfPointsRhumbLine(v,C,d),v=e.Cartographic.clone(C,I);var m=3*(p+1),P=new Array(m),T=0;for(g=0;g<n-1;g++){T=G(t[g],t[g+1],d,o,l?s[g]:s,l?s[g+1]:s,P,T)}w.length=0;var y=t[n-1],b=o.cartesianToCartographic(y,A);b.height=l?s[n-1]:s;var S=o.cartographicToCartesian(b,E);return e.Cartesian3.pack(S,P,m-3),P},h.generateCartesianArc=function(a){for(var r=h.generateArc(a),t=r.length/3,i=new Array(t),n=0;n<t;n++)i[n]=e.Cartesian3.unpack(r,3*n);return i},h.generateCartesianRhumbArc=function(a){for(var r=h.generateRhumbArc(a),t=r.length/3,i=new Array(t),n=0;n<t;n++)i[n]=e.Cartesian3.unpack(r,3*n);return i},a.PolylinePipeline=h}));