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