define(["exports","./Cartographic-1d953166","./when-d186add7","./Check-2514d21d","./Rectangle-f841217d","./EllipsoidGeodesic-fc4b25bd","./EllipsoidRhumbLine-394d2834","./IntersectionTests-300d4352","./Math-7f5f2992","./FeatureDetection-4281d393","./Plane-d9914d3c"],(function(t,r,e,a,n,i,o,c,s,u,h){"use strict";var l={numberOfPoints:function(t,e,a){var n=r.t.distance(t,e);return Math.ceil(n/a)},numberOfPointsRhumbLine:function(t,r,e){var a=Math.pow(t.longitude-r.longitude,2)+Math.pow(t.latitude-r.latitude,2);return a=Math.max(a,s.e.EPSILON21),Math.ceil(Math.sqrt(a/(e*e)))}},f=new r.t$1;l.extractHeights=function(t,r){for(var e=t.length,a=new Array(e),n=0;n<e;n++){var i=t[n];a[n]=r.cartesianToCartographic(i,f).height}return a};var g=new u.y,p=new r.t,v=new r.t,d=new h.o(r.t.UNIT_X,0),m=new r.t,w=new h.o(r.t.UNIT_X,0),y=new r.t,T=new r.t,P=[];function A(t,r,e){var a,n=P;if(n.length=t,r===e){for(a=0;a<t;a++)n[a]=r;return n}var i=(e-r)/t;for(a=0;a<t;a++){var o=r+a*i;n[a]=o}return n}var C=new r.t$1,S=new r.t$1,E=new r.t,R=new r.t,b=new r.t,D=new i.E,N=new o.P;function G(t,e,a,n,i,o,c,s,u){var h=n.scaleToGeodeticSurface(t,R),f=n.scaleToGeodeticSurface(e,b),g=l.numberOfPoints(t,e,a),p=n.cartesianToCartographic(h,C),v=n.cartesianToCartographic(f,S),d=A(g,i,o);u>0&&(d=function(t,r){var e=P;e.length=t;for(var a=0;a<t;a++)e[a]+=r*Math.sin(Math.PI*a/t);return e}(g,u)),D.setEndPoints(p,v);var m=D.surfaceDistance/g,w=s;p.height=i;var y=n.cartographicToCartesian(p,E);r.t.pack(y,c,w),w+=3;for(var T=1;T<g;T++){var N=D.interpolateUsingSurfaceDistance(T*m,S);N.height=d[T],y=n.cartographicToCartesian(N,E),r.t.pack(y,c,w),w+=3}return w}function I(t,e,a,n,i,c,s,u){var h=n.scaleToGeodeticSurface(t,R),f=n.scaleToGeodeticSurface(e,b),g=n.cartesianToCartographic(h,C),p=n.cartesianToCartographic(f,S),v=l.numberOfPointsRhumbLine(g,p,a),d=A(v,i,c);N.ellipsoid.equals(n)||(N=new o.P(void 0,void 0,n)),N.setEndPoints(g,p);var m=N.surfaceDistance/v,w=u;g.height=i;var y=n.cartographicToCartesian(g,E);r.t.pack(y,s,w),w+=3;for(var T=1;T<v;T++){var P=N.interpolateUsingSurfaceDistance(T*m,S);P.height=d[T],y=n.cartographicToCartesian(P,E),r.t.pack(y,s,w),w+=3}return w}l.wrapLongitude=function(t,a){var n=[],i=[];if(e.e(t)&&t.length>0){a=e.u(a,u.y.IDENTITY);var o=u.y.inverseTransformation(a,g),s=u.y.multiplyByPoint(o,r.t.ZERO,p),l=r.t.normalize(u.y.multiplyByPointAsVector(o,r.t.UNIT_Y,v),v),f=h.o.fromPointNormal(s,l,d),P=r.t.normalize(u.y.multiplyByPointAsVector(o,r.t.UNIT_X,m),m),A=h.o.fromPointNormal(s,P,w),C=1;n.push(r.t.clone(t[0]));for(var S=n[0],E=t.length,R=1;R<E;++R){var b=t[R];if(h.o.getPointDistance(A,S)<0||h.o.getPointDistance(A,b)<0){var D=c.g.lineSegmentPlane(S,b,f,y);if(e.e(D)){var N=r.t.multiplyByScalar(l,5e-9,T);h.o.getPointDistance(f,S)<0&&r.t.negate(N,N),n.push(r.t.add(D,N,new r.t)),i.push(C+1),r.t.negate(N,N),n.push(r.t.add(D,N,new r.t)),C=1}}n.push(r.t.clone(t[R])),C++,S=b}i.push(C)}return{positions:n,lengths:i}},l.generateArc=function(t){e.e(t)||(t={});var i=t.positions;if(!e.e(i))throw new a.t("options.positions is required.");var o=i.length,c=e.u(t.ellipsoid,n.t.WGS84),u=e.u(t.height,0),h=Array.isArray(u);if(o<1)return[];if(1===o){var f=c.scaleToGeodeticSurface(i[0],R);if(0!==(u=h?u[0]:u)){var g=c.geodeticSurfaceNormal(f,E);r.t.multiplyByScalar(g,u,g),r.t.add(f,g,f)}return[f.x,f.y,f.z]}var p=t.minDistance;if(!e.e(p)){var v=e.u(t.granularity,s.e.RADIANS_PER_DEGREE);p=s.e.chordLength(v,c.maximumRadius)}var d,m=0;for(d=0;d<o-1;d++)m+=l.numberOfPoints(i[d],i[d+1],p);var w=t.hMax,y=3*(m+1),T=new Array(y),A=0;for(d=0;d<o-1;d++){A=G(i[d],i[d+1],p,c,h?u[d]:u,h?u[d+1]:u,T,A,w)}P.length=0;var S=i[o-1],b=c.cartesianToCartographic(S,C);b.height=h?u[o-1]:u;var D=c.cartographicToCartesian(b,E);return r.t.pack(D,T,y-3),T};var M=new r.t$1,k=new r.t$1;l.generateRhumbArc=function(t){e.e(t)||(t={});var i=t.positions;if(!e.e(i))throw new a.t("options.positions is required.");var o=i.length,c=e.u(t.ellipsoid,n.t.WGS84),u=e.u(t.height,0),h=Array.isArray(u);if(o<1)return[];if(1===o){var f=c.scaleToGeodeticSurface(i[0],R);if(0!==(u=h?u[0]:u)){var g=c.geodeticSurfaceNormal(f,E);r.t.multiplyByScalar(g,u,g),r.t.add(f,g,f)}return[f.x,f.y,f.z]}var p,v,d=e.u(t.granularity,s.e.RADIANS_PER_DEGREE),m=0,w=c.cartesianToCartographic(i[0],M);for(p=0;p<o-1;p++)v=c.cartesianToCartographic(i[p+1],k),m+=l.numberOfPointsRhumbLine(w,v,d),w=r.t$1.clone(v,M);var y=3*(m+1),T=new Array(y),A=0;for(p=0;p<o-1;p++){A=I(i[p],i[p+1],d,c,h?u[p]:u,h?u[p+1]:u,T,A)}P.length=0;var S=i[o-1],b=c.cartesianToCartographic(S,C);b.height=h?u[o-1]:u;var D=c.cartographicToCartesian(b,E);return r.t.pack(D,T,y-3),T},l.generateCartesianArc=function(t){for(var e=l.generateArc(t),a=e.length/3,n=new Array(a),i=0;i<a;i++)n[i]=r.t.unpack(e,3*i);return n},l.generateCartesianRhumbArc=function(t){for(var e=l.generateRhumbArc(t),a=e.length/3,n=new Array(a),i=0;i<a;i++)n[i]=r.t.unpack(e,3*i);return n},t.m=l}));
