// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://@sbaseurl@/jsapi/jsapi/esri/copyright.txt and http://www.arcgis.com/apps/webappbuilder/copyright.txt for details.

//>>built
define("esri/geometry/Point esri/geometry/Polyline esri/geometry/Polygon esri/geometry/webMercatorUtils dojo/Deferred dojo/_base/array dojo/_base/lang esri/geometry/geometryEngine esri/SpatialReference esri/geometry/scaleUtils".split(" "),function(B,w,y,l,C,D,z,g,m,E){var f={getProjectedGeometry:function(b,a,c){var e,d;e=new C;l.canProject(b,a)?(d=l.project(b,a),e.resolve(d)):c.project([b],a,function(a){d=a[0];e.resolve(d)});return e.promise},getDestinationPoint:function(b,a,c){var e=b.x*Math.PI/
180,d=a*Math.PI/180;a=Math.sin(d);var d=Math.cos(d),k=.9966471893352243*Math.tan(b.y*Math.PI/180);b=1/Math.sqrt(1+k*k);var f=k*b,g=Math.atan2(k,d),k=b*a,q=1-k*k,h=2.7233160610984375E11*q/4.040829998465916E13,A=1+h/16384*(4096+h*(-768+h*(320-175*h))),x=h/1024*(256+h*(-128+h*(74-47*h))),r,t,p,u=c/(6356752.314245*A),n,l=0;do h=Math.cos(2*g+u),r=Math.sin(u),t=Math.cos(u),p=x*r*(h+x/4*(t*(-1+2*h*h)-x/6*h*(-3+4*r*r)*(-3+4*h*h))),n=u,u=c/(6356752.314245*A)+p;while(1E-12<Math.abs(u-n)&&200>++l);if(200<=l)return console.error("Formula failed to converge"),
null;c=f*r-b*t*d;c=Math.atan2(f*t+b*r*d,.9966471893352243*Math.sqrt(k*k+c*c));q=2.0955066654848088E-4*q*(4+.003352810664775694*(4-3*q));e=(e+(Math.atan2(r*a,b*t-f*r*d)-.003352810664775694*(1-q)*k*(u+q*r*(h+q*t*(-1+2*h*h))))+3*Math.PI)%(2*Math.PI)-Math.PI;c=180*c/Math.PI;e=180*e/Math.PI;return new B(e,c,new m(4326))},getInverseCalculations:function(b,a){var c=a.x*Math.PI/180-b.x*Math.PI/180,e=.9966471893352243*Math.tan(b.y*Math.PI/180),d=1/Math.sqrt(1+e*e),e=e*d,k=.9966471893352243*Math.tan(a.y*Math.PI/
180),f=1/Math.sqrt(1+k*k),k=k*f,g,q,h,l,m,r,t,p,u,n=c,w,v=0;do{g=Math.sin(n);q=Math.cos(n);h=f*g*f*g+(d*k-e*f*q)*(d*k-e*f*q);h=Math.sqrt(h);if(0==h)return 0;l=e*k+d*f*q;m=Math.atan2(h,l);r=d*f*g/h;t=1-r*r;p=l-2*e*k/t;isNaN(p)&&(p=0);u=2.0955066654848088E-4*t*(4+.003352810664775694*(4-3*t));w=n;n=c+.003352810664775694*(1-u)*r*(m+u*h*(p+u*l*(-1+2*p*p)))}while(1E-12<Math.abs(n-w)&&200>++v);if(200<=v)return null;n=2.7233160610984375E11*t/4.040829998465916E13;v=n/1024*(256+n*(-128+n*(74-47*n)));c=Math.atan2(f*
g,d*k-e*f*q);d=Math.atan2(d*g,-e*f+d*k*q);c=(c+2*Math.PI)%(2*Math.PI);d=(d+2*Math.PI)%(2*Math.PI);e=Number((6356752.314245*(1+n/16384*(4096+n*(-768+n*(320-175*n))))*(m-v*h*(p+v/4*(l*(-1+2*p*p)-v/6*p*(-3+4*h*h)*(-3+4*p*p))))).toFixed(3));c=180*c/Math.PI;d=180*d/Math.PI;return{distance:e,initialBearing:c,finalBearing:d}},getLineBetweenPoints:function(b){var a,c=[];D.forEach(b,z.hitch(this,function(a){c.push([a.x,a.y])}));0<c.length&&(a=new w({paths:[c],spatialReference:{wkid:4326}}));return a},getAngleBetweenPoints:function(b,
a){var c=f.getInverseCalculations(b,a);return null===c?0:c.initialBearing},getDistanceBetweenPoints:function(b,a){var c=f.getInverseCalculations(b,a);return null===c?0:c.distance},getLengthOfGeometry:function(b){var a,c;a={};(c=g.simplify(b))?b.spatialReference.isWebMercator()||4326===b.spatialReference.wkid?(a.meters=g.geodesicLength(c,"meters"),a.miles=g.geodesicLength(c,"miles"),a.kilometers=g.geodesicLength(c,"kilometers")):(a.meters=g.planarLength(c,"meters"),a.miles=g.planarLength(c,"miles"),
a.kilometers=g.planarLength(c,"kilometers")):(a.meters=0,a.miles=0,a.kilometers=0);return a},getAreaOfGeometry:function(b){var a,c;a=g.simplify(b);c={};a?b.spatialReference.isWebMercator()||4326===b.spatialReference.wkid?(c.acres=g.geodesicArea(a,"acres"),c.squareMeters=g.geodesicArea(a,"square-meters"),c.squareFeet=g.geodesicArea(a,"square-feet"),c.squareUsFeet=g.geodesicArea(a,109406),c.squareKilometer=g.geodesicArea(a,"square-kilometers")):(c.acres=g.planarArea(a,"acres"),c.squareMeters=g.planarArea(a,
"square-meters"),c.squareFeet=g.planarArea(a,"square-feet"),c.squareUsFeet=g.planarArea(a,109406),c.squareKilometer=g.planarArea(a,"square-kilometers")):(c.acres=0,c.squareMeters=0,c.squareFeet=0,c.squareUsFeet=0,c.squareKilometer=0);return c},getPolyLineFromPaths:function(b){var a,c;a=new w(new m({wkid:4326}));for(c=0;c<b.length;c++)a.addPath(b[c]);return a},getPolygonFromPolyLines:function(b,a,c,e){var d,f,g;d=[];e=e?new y(new m(e)):new y(new m({wkid:4326}));for(f=0;f<b.length;f++)for(g=0;g<b[f].length;g++)d.push(b[f][g]);
a?d.push(z.clone(d[0])):c&&(d[d.length-1][0]=d[0][0],d[d.length-1][1]=d[0][1]);e.isClockwise(d)||d.reverse();e.addRing(d);return e},getPointsForArc:function(b,a,c,e){var d,g=[],l,m;d=a-b;a=parseInt(d,10);0>=a&&(a=1);l=Math.abs(d)/Math.abs(a);if(0<l)for(d=0;d<Math.abs(a)+1;d++)m=b+l*d,(m=f.getDestinationPoint(c,m,Math.abs(e)))&&g.push(m);return g},getArcParam:function(b){var a;a={};0>b.distance?0>b.radius?(a.bearing=b.initBearing+90,a.centerPoint=f.getDestinationPoint(b.chordMidPoint,a.bearing,b.centerAndChordDistance),
a.startAngle=f.getAngleBetweenPoints(a.centerPoint,b.chordEndPoint),a.endAngle=f.getAngleBetweenPoints(a.centerPoint,b.chordStartPoint)):(a.bearing=b.initBearing-90,a.centerPoint=f.getDestinationPoint(b.chordMidPoint,a.bearing,b.centerAndChordDistance),a.startAngle=f.getAngleBetweenPoints(a.centerPoint,b.chordStartPoint),a.endAngle=f.getAngleBetweenPoints(a.centerPoint,b.chordEndPoint)):0<b.radius?(a.bearing=b.initBearing+90,a.centerPoint=f.getDestinationPoint(b.chordMidPoint,a.bearing,b.centerAndChordDistance),
a.startAngle=f.getAngleBetweenPoints(a.centerPoint,b.chordStartPoint),a.endAngle=f.getAngleBetweenPoints(a.centerPoint,b.chordEndPoint)):(a.bearing=b.initBearing-90,a.centerPoint=f.getDestinationPoint(b.chordMidPoint,a.bearing,b.centerAndChordDistance),a.startAngle=f.getAngleBetweenPoints(a.centerPoint,b.chordEndPoint),a.endAngle=f.getAngleBetweenPoints(a.centerPoint,b.chordStartPoint));return a},removeNegativeExponents:function(b){return 1<b.toString().toLowerCase().split("e-").length?0:b},getChordLengthFromArcLength:function(b,
a){var c,e;b=Math.abs(b);e=Math.PI*Math.abs(a);c=Math.abs(a)*Math.sin(Math.abs(b)/Math.abs(a)/2);return b<=e?2*c:-2*c},getArcLengthFromChordLength:function(b,a){var c;c=Math.abs(b);a=Math.abs(a);c=2*Math.asin(c/(2*a))*a;0>b&&(c=2*Math.PI*a-c);return c},chordBearingToTangentBearing:function(b,a,c){var e;e=180/Math.PI*Math.acos(Math.abs(c)/2/Math.abs(a));a/=Math.abs(a);b=b+90*a-c/Math.abs(c)*a*e;return f.removeNegativeExponents(0>b?b+360:360<=b?b%360:b)},tangentBearingToChordBearing:function(b,a,c){var e;
e=180/Math.PI*Math.acos(Math.abs(c)/2/Math.abs(a));a/=Math.abs(a);b=b+90*a-c/Math.abs(c)*a*e;return f.removeNegativeExponents(0>b?b+360:360<=b?b%360:b)},getUnitValueForSR:function(b){switch(E.getUnitValueForSR(b)){case 1:return"meters";case 111194.87428468118:return"meters";case .3048:return"feet";case .3048006096:case .3048006096012192:return"uSSurveyFeet"}},getRotationAngleBetweenPoints:function(b,a){var c,e,d,g;b=l.project(b,new m(102100));a=l.project(a,new m(102100));c=a.x-b.x;e=a.y-b.y;d=180*
Math.atan2(Math.abs(c),Math.abs(e))/Math.PI;g=180*Math.atan2(Math.abs(e),Math.abs(c))/Math.PI;c=f.removeNegativeExponents(c);e=f.removeNegativeExponents(e);d=f.removeNegativeExponents(d);g=f.removeNegativeExponents(g);if(0===e){if(0===c)return 0;if(0<c)return 90;if(0>c)return 270}else if(0<e){if(0===c)return 0;if(0<c)return d;if(0>c)return 270+g}else if(0>e){if(0===c)return 180;if(0<c)return 90+g;if(0>c)return 180+d}},getScaleDistanceBetweenPoints:function(b,a){b=l.project(b,new m(102100));a=l.project(a,
new m(102100));var c=g.distance(b,a,9001);return f.removeNegativeExponents(c)}};return f});