function DDtoUTM(x,y){
inputLat=y;
inputLong=x;
Zone=(inputLong/6)+31;
inputZone=Math.floor(Zone);
phi=inputLat;
omega=(inputLong-(inputZone-30.5)*6);
A=_gProjectorEllipsoidA;
F=_gProjectorEllipsoidI;
K0=0.9996;
E=((2*F-1)/(F*F));
E1=(E/(1-E));
A0=((((-5)*E/256-3/64)*E-0.25)*E+1);
A2=(3/8*((15*E/128+0.25)*E+1)*E);
A4=(15/256*E*E*(1+0.75*E));
A6=(35*(E*E*E)/3072);
TP=(A/(1-1/F));
RCON=180/Math.PI;
phi=phi/RCON;
omega=omega/RCON;
S=Math.sin(phi);
C=Math.cos(phi);
T=S/C;
PSI=1+(E1*C*C);
T2=T*T;
T3=1-6*T2;
T4=(11-24*T2)*PSI;
T5=4*PSI*PSI;
WD=omega*omega*C*C;
ND=TP/Math.sqrt(PSI)*omega*C;
NTH=K0*((A*(A0*phi-A2*Math.sin(phi+phi)+A4*Math.sin(4*phi)-A6*Math.sin(6*phi)))+ND*S*omega/2*(1+((T5+PSI-T2+(((((T4*8-28*(T3))*PSI+(1-32*T2))*PSI-(T2+T2))*PSI+T2*T2+((((543-T2)*T2-3111)*T2+1385)*WD/56))*WD/30))*WD/12)))+10000000;
EST=K0*ND*(1+((PSI-T2+(((T3*T5+(1+8*T2)*PSI-(T2+T2))*PSI+T2*T2+((((179-T2)*T2-479)*T2+61)*WD/42))*WD/20))*WD/6))+500000;
return Array(EST,NTH,inputZone);
}
function UTMtoDD(x,y,z){
A=_gProjectorEllipsoidA;
F=_gProjectorEllipsoidI;
E=((2*F-1)/(F*F));
E1=(E/(1-E));
A0=((((-5)*E/256-3/64)*E-0.25)*E+1);
A2=(3/8*((15*E/128+0.25)*E+1)*E);
A4=(15/256*E*E*(1+0.75*E));
A6=(35*(E*E*E)/3072);
FALSEE=500000;
FALSEN=10000000;
K0=0.9996;
LONGCM=0;
INEST=x;
INNTH=y;
INZN=zone;
ET=INEST-500000;
NT=(INNTH-10000000)/(K0*A);
INTLAT=NT;
RCON=180/Math.PI;
for(I=1;I<11;I++){
INTOLD=INTLAT;
INTLAT=NT+(INTLAT-INTLAT*A0+A2*Math.sin(INTLAT+INTLAT)-A4*Math.sin(4*INTLAT)+A6*Math.sin(6*INTLAT));
diff=INTOLD-INTLAT;
VALUE=Math.abs(diff);
OK=false;
if(VALUE<5e-10){
OK=true;
break;
}
if(!OK){
LAT=0;
LONG=0;
CON=0;
PSF=0;
}
}
C=Math.cos(INTLAT);
T=Math.tan(INTLAT);
PSI=1+(E1*C*C);
TP=A/(1-1/F);
NU=TP/Math.sqrt(PSI);
RHO=NU/PSI;
T2=T*T;
T3=T2*T2;
T4=11-24*T2;
T5=K0*NU;
E2=ET*ET/(T5*T5);
LAT=(INTLAT+T/RHO*NU*((((((1575*T2+4095)*T2+3633)*T2+1385)/40320*E2-((((8*PSI*T4-12*(21-71*T2))*PSI+15*(15-98*T2+15*T3))*PSI+180*(5*T2-3*T3))*PSI+360*T3)/720)*E2+(((1-T2)*9-4*PSI)*PSI+12*T2)/24)*E2-0.5)*E2)*RCON;
LONG=((((((((9-68*T2)-4*PSI*(1-6*T2))*PSI+72*T2)*PSI+24*T3)/120-(((720*T2+1320)*T2+662)*T2+61)*E2/5040)*E2-(PSI+2*T2)/6)*E2+1)*ET/(T5*C))*RCON+(INZN-30.5)*6;
return Array(LONG,LAT);
}
function DMStoDD(_6,_7,_8){
var dd=-1;
if(_6<0){
dd=(Math.ceil(((_6*1)-(_7/60)-(_8/3600))*10000))/10000;
}else{
dd=(Math.floor(((_6*1)+(_7/60)+(_8/3600))*10000))/10000;
}
return dd;
}
function DDtoDMS(dd){
dec=Math.abs(dd);
deg=Math.floor(dec);
min=Math.floor((dec-deg)*60);
sec=((dec-deg-(min/60))*3600).toFixed(2);
if(dd<0){
deg=0-deg;
}
return Array(deg,min,sec);
}


