<HTML>
<!--THIS HTML FILE AND ACCOMPANING SCRIPTS WILL CONVERT UTM COORDINATES TO 
DEGREES, MINUTES, SECOND(DMS) AND/OR DMS TO UTM -->
<HEAD>
<TITLE>COORDINATE CONVERSTION</TITLE>
<META name="author" content="Nicholas M. Gilbert">
<META name="description" content="This website will convert coordinated from UTM to DMS or from
DMS to UTM">
<META name="keywords" content="coordinate conversion, universal tranverse mercator, degrees minuters seconds, dms, utm, UTM, GPS, navigation, declination, topos, maps, orienteering, rogaine, rogaining, land nav, orienteer, adventure racing, extreme, extreme adventures, extreme sports">
<!--style sheet-->
<STYLE>
<!--


A:link {text-decoration: none;
font-family: Arial, Helvetica, Swiss, sans-serif;
font-weight: bold;
color: #0000cc}

A:visited {text-decoration: none;
font-family: Arial, Helvetica, Swiss, sans-serif;
font-weight: bold;
color: #0000cc}

A:active {text-decoration: none;
font-family: Arial, Helvetica, Swiss, sans-serif;
font-weight: bold;
color: #0000cc}

A:hover {color: #ff0000}

-->
</STYLE>
</HEAD>
<BODY BGCOLOR="beige">
<H1 align="center"><B>UTM & DMS COORDINATE CONVERTER</B></H1>
<HR>
This website will convert coordinates from Universal Transverse Mercator(UTM) style coordinates to Degrees, Minutes, and seconds(DMS). To convert from UTM to DMS, enter a latitude(north or south) coordinate in the top box on the left side, then enter the longitude(east or west) UTM coordinate in the box directly below. To convert from DMS to UTM, enter a value for degrees(&#176;) in the first box on the right hand side, enter minutes(') in the box rigth next to it, then enter seconds (") in the box next to minutes, repeat in boxes below using the longitude values. 

<HR>
<CENTER>
<TABLE>
<TR><TD>

<FORM>
<!--INPUT BOXES FOR UTM COORDINTATES-->
<TABLE>
<TR>
<TD COLSPAN="2"><big>Enter the UTM coodinates here:</big><br></TD>
</TR>
</TABLE>
<TABLE>
<TR>
<TD><INPUT TYPE="TEXT" NAME="nsCoord" SIZE="15" MAXLENGTH="20" onChange="valNsLatDeg(this.form)">&nbsp;&#176;&nbsp;&nbsp;<b>Latitude</b></TD>
</TR>
<TR>
<TD><INPUT TYPE="TEXT" NAME="ewCoord" SIZE="15" MAXLENGTH="20" onChange="valEwLatDeg(this.form)">&nbsp;&#176;&nbsp;&nbsp;<b>Longitude</b></TD>
</TR>
</TABLE>
<TABLE>
<TR>
<TD><INPUT TYPE="BUTTON" VALUE="Convert to DMS" NAME="convert" onClick="convUtm(this.form)"></TD>
<TD><INPUT TYPE="RESET" VALUE="Clear" NAME="reset"></TD>
</TR> 
</TABLE>
<!--boxes for converted coords-->
<TABLE>
<TR>
<TD><INPUT TYPE="TEXT" SIZE="3" MAXLENGTH="2" NAME="nsDeg" onChange="useRight(this.form)">&nbsp;&#176;&nbsp</TD>
<TD><INPUT TYPE="TEXT" SIZE="2" MAXLENGTH="2" NAME="nsMin" onChange="useRight(this.form)">&nbsp;'&nbsp;</TD>
<TD><INPUT TYPE="TEXT" SIZE="10" MAXLENGTH="10" NAME="nsSec" onChange="useRight(this.form)">&nbsp;"&nbsp;&nbsp;<b>Latitude</b></TD>
</TR>
<TR>
<TD><INPUT TYPE="TEXT" SIZE="3" MAXLENGTH="3" NAME="ewDeg" onChange="useRight(this.form)">&nbsp;&#176;&nbsp;</TD>
<TD><INPUT TYPE="TEXT" SIZE="2" MAXLENGTH="2" NAME="ewMin" onChange="useRight(this.form)">&nbsp;'&nbsp;</TD>
<TD><INPUT TYPE="TEXT" SIZE="10" MAXLENGTH="10" NAME="ewSec" onChange="useRight(this.form)">&nbsp;"&nbsp;&nbsp;<b>Longitude</b></TD>
</TR>
</TABLE>
</FORM>
</TD>
<TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>

<TD>
<FORM>

<TABLE>
<TR>
<TD COLSPAN="3"><big>Enter the DMS coodinates here:</big><br></TD>
</TR>
</TABLE>
<!--input boxes for dms coords-->
<TABLE>
<TR>
<TD><INPUT TYPE="TEXT" SIZE="3" MAXLENGTH="2" NAME="nDeg" onChange="valNsDmsDeg(this.form)">&nbsp;&#176;&nbsp;</TD>
<TD><INPUT TYPE="TEXT" SIZE="2" MAXLENGTH="2" NAME="nMin" onChange="valNsDmsMin(this.form)">&nbsp;'&nbsp;</TD>
<TD><INPUT TYPE="TEXT" SIZE="10" MAXLENGTH="10" NAME="nSec" onChange="valNsDmsSec(this.form)" >&nbsp;"&nbsp;&nbsp;<b>Latitude</b></TD>
</TR>
<TR>
<TD><INPUT TYPE="TEXT" SIZE="3" MAXLENGTH="3" NAME="eDeg" onChange="valEwDmsDeg(this.form)">&nbsp;&#176;&nbsp;</TD>
<TD><INPUT TYPE="TEXT" SIZE="2" MAXLENGTH="2" NAME="eMin" onChange="valEwDmsMin(this.form)">&nbsp;'&nbsp;</TD>
<TD><INPUT TYPE="TEXT" SIZE="10" MAXLENGTH="10" NAME="eSec" onChange="valEwDmsSec(this.form)">&nbsp;"&nbsp;&nbsp;<b>Longitude</b></TD>
</TR>
</TABLE>
<TABLE>
<TR>
<TD><INPUT TYPE="BUTTON" VALUE="Convert to UTM" NAME="convert" onClick="convDMS(this.form)"></TD>
<TD><INPUT TYPE="RESET" VALUE="Clear" NAME="reset"></TD>
</TR> 
</TABLE>
<!--boxes for result of dms to utm conversion-->
<TABLE>
<TR>
<TD><INPUT TYPE="TEXT" NAME="nsUTM" SIZE="15" onChange="valLon(this.form)">&nbsp;&#176;&nbsp;&nbsp;<b>Latitude</b></TD>
</TR>
<TR>
<TD><INPUT TYPE="TEXT" NAME="ewUTM" SIZE="15" onChange="valLon(this.form)">&nbsp;&#176;&nbsp;&nbsp;<b>Longitude</b></TD>
</TR>
</TABLE>
</FORM>
</TD></TR>
</TABLE>
<HR>
</CENTER>
<!--these links may be of interest to those who view this page-->
<H2>Related Links</H2>
<ul>
<li><a href="http://www.topozone.com">TopoZone</a>-Topo maps of the entire US</li>
<li><a href="http://www.ngdc.noaa.gov/cgi-bin/seg/gmag/fldsnth1.pl">Declination Calculator</a>-Calculates declination based on date, elevation, and coordiants</li>
<li><a href="http://www.census.gov/cgi-bin/gazetteer">U.S. Gazetteer</a>-Gives coordinates, population, and a map of your home town</li>
<li><a href="http://www.beastoftheeast.com">Odyessy Adventure Racing</a>-America's largest adventure racing organizer</li>
<li><a href="http://www.ocad.com/gps.htm">OCAD</a>-Orienteering Computer Aided Drafting</li>
<li><a href="http://www.terraserver.com">Terra Server</a>-Relief,topo, and arial images</li>
</ul>
<br>


<hr>
<a href="coordSource.html"><font color="#0000cc"><u><small>View the source code of this website</small></u></font></a>-<small>you are free and encouraged to, use, and/or share with others, any or all of the html source code or javascripts from this site</small><br>
<a href="mailto:cat1racer@hotmail.com?subject=bug_report"><font color="#0000cc"><u><small>Bug Report</small></u></font></a>-<small>if you notice a bug in the html or script coding, please let me know, also if you have comments or suggestions on how to make the scripts or website better, let me know too.</small>

<hr>
<center><small>Copyright <big>&copy;</big> 2000, <a href="mailto:cat1racer@hotmail.com?subject=webmaster_coord_converter"><font color="#000000"><small>Nicholas M. Gilbert</small></small></a></center>
<center><small><small>Note: this website may not be 100% accurate</small></small>
</BODY>
</HTML>


<SCRIPT>
<!--
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// This function does computation and error checking for the DMS to UTM converstion //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function convDMS(form)
{


var utm //UTM value to be returned

//Degree, minute, and second values entered in by user
var deg = parseInt(form.nDeg.value) 
var min = parseInt(form.nMin.value)
var sec = parseFloat(form.nSec.value)
var stop //do not return anything if all fields left blank
var star //return stars if invalid input
//test for blanks
if(form.nDeg.value == "" || form.nMin.value == "" || form.nSec.value == "")
{
if(form.nDeg.value == "" && form.nMin.value == "" && form.nSec.value == "")
{
var stop = 1
}
//if one or two boxes are left empty make them zero
else
{
if(form.nDeg.value == "")
{
deg = 0
}
if(form.nMin.value == "")
{
min = 0
}
if(form.nSec.value == "")
{
sec = 0
}
}
}
//test for valid numbers entered
if(isNaN(deg) || isNaN(min) || isNaN(sec))
{
star = 1
}
if(deg > 90 || deg < 0)
{
star = 1
}
if(min > 59 || min < 0)
{
star = 1
}
if(sec >= 60 || sec < 0)
{
star = 1
}
if(deg == 90 && min > 0)
{
star = 1
}
if(deg == 90 && sec > 0)
{
star = 1
}
//does the calculation
utm = calcUTM(deg, min, sec)
//Return converted value to screen
printUTMns(utm, stop, star)

//Degree, minute, and second values entered in by user; same as above but for east west value
deg = parseInt(form.eDeg.value)
min = parseInt(form.eMin.value)
sec = parseFloat(form.eSec.value)
//check to see if blank
if(form.eDeg.value == "" || form.eMin.value == "" || form.eSec.value == "")
{
if(form.eDeg.value == "" && form.eMin.value == "" && form.eSec.value == "")
{
stop = 1
}
else
//if one or two value is entered make the boxes left empty zero
{
if(form.eDeg.value == "")
{
deg = 0
}
if(form.eMin.value == "")
{
min = 0
}
if(form.eSec.value == "")
{
sec = 0
}
}
}
//return star if invalid input
if(isNaN(deg) || isNaN(min) || isNaN(sec))
{
star = 1
}
if(deg > 180 || deg < 0)
{
star = 1
}
if(min > 59 || min < 0)
{
star = 1
}
if(sec >= 60 || sec < 0)
{
star = 1
}
if(deg == 180 && min > 0)
{
star = 1
}
if(deg == 180 && sec > 0)
{
star = 1
}
//Convert DMS to UTM
utm = calcUTM(deg, min, sec)
//Return converted value to screen
printUTMew(utm,stop, star)

}

//Converts DMS to UTM

function calcUTM(deg, min, sec)
{

var utm = 0
utm = deg + (min/60) + (sec/3600)
//round down to 1/100000000
utm = Math.floor(utm*100000000)/100000000
return (utm)

}

//Returns NS UTM coordinate to screen or does nothing or prints stars
function printUTMns(utm, stop, star)
{

if (star !=1 )
{
if (stop != 1)
{
document.forms[1].nsUTM.value = utm
}}
else
{
document.forms[1].nsUTM.value = "********"
}
}

//Returns EW UTM coordinate to screen, same as above
function printUTMew(utm, stop, star)
{

if (star != 1)
{
if (stop != 1)
{
document.forms[1].ewUTM.value = utm
}}
else
{
document.forms[1].ewUTM.value = "********"
}
}





//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// This function does computation and error checking for the UTM to DMS converstion //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function convUtm(form)
{

var utm //UTM VALUEN ENTERED IN BY USERS
var deg //AMOUNT OF DEGREES OF THE UTM VALUE
var min //AMOUNT OF MINUTES OF THE UTM VALUE
var sec //AMOUNT OF SECONDS OF THE UTM VALUE


//CALCULATE AND RETURN NORTH OR SOUTH COORD IN DMS
utm = parseFloat(form.nsCoord.value)


deg = calcDeg(utm)
min = calcMin(utm,deg)
sec = calcSec(utm,deg,min)

//make blanks if nothing entered
var chr = String(utm) 
if (chr.length == 3 && chr == 'NaN')
{
deg = ''
min = ''
sec = ''
}
else{
//returned stars if invalid
if (isNaN(utm))
{
deg = '*'
min = '*'
sec = '*'
}
if (utm < 0 || utm > 90)
{
deg = '*'
min = '*'
sec = '*'
}

//prints converted values to appropriate box
printNS(deg,min,sec)

//CALCULATE EAST OR WEST COORD IN DMS
utm = parseFloat(form.ewCoord.value)
deg = calcDeg(utm)
min = calcMin(utm,deg)
sec = calcSec(utm,deg,min)

//like above, check for blanks
chr = String(utm) 
if (chr.length == 3 && isNaN(utm))
{
deg = ''
min = ''
sec = ''
}
//return stars if invalid
else{
if (isNaN(utm))
{
deg = '*'
min = '*'
sec = '*'
}
if (utm < 0 || utm > 180)
{
deg = '*'
min = '*'
sec = '*'
}
}
printEW(deg,min,sec)
}


//COMPUTE DEGREES
function calcDeg(utm)
{

if(utm >= 1)
{var deg = Math.floor(utm)}
else
{var deg = 0}
return (deg)
}

//COMPUTE MINUTES
function calcMin(utm,deg)
{
min = 0
var n = utm - deg
while(n >= (1/60))
{
n -= (1/60)
min++
}
return (min)
}

// COMPUTE SECONDS
function calcSec(utm,deg,min)

sec = 0
var n = utm - (deg + (min/60))
while(n >= (1/3600))
{
n -= (1/3600)
sec++
}
//round to nearest 1/10000000
decimal = 10000000*(n*3600)
decimal = Math.floor(decimal)/10000000
//sec += n*3600 //check this equation
sec += decimal
return (sec)


//RETURN NORTH OR SOUTH VALUES TO FORM
function printNS(deg, min, sec)

document.forms[0].nsDeg.value = deg
document.forms[0].nsMin.value = min
document.forms[0].nsSec.value = sec
}

//RETURN EAST OR WEST VALUES TO FORM
function printEW(deg, min, sec)
{
//RETURN VALUES TO FORM 
document.forms[0].ewDeg.value = deg
document.forms[0].ewMin.value = min
document.forms[0].ewSec.value = sec
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// This function does on the fly checking for values entered on the utm side //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////


function valNsLatDeg(form)
{
var coor = parseFloat(form.nsCoord.value)
//checks for a number
if (isNaN(coor))
{
window.alert('You must enter a number.')
document.forms[0].nsCoord.value = ''
}
else{
//check to see if coord is valid
if (coor > 90 || coor < 0)
{
window.alert('You must enter a coordinate between 0 - 90 degrees')
document.forms[0].nsCoord.value = ''
}
}

}

//like above but for east/west
function valEwLatDeg(form)
{
//check for valid input
var coor = parseFloat(form.ewCoord.value)
if (isNaN(coor))
{
window.alert('You must enter a number.')
document.forms[0].ewCoord.value = ''
}
else{
if (coor > 180 || coor < 0)
{
window.alert('You must enter a coordinate between 0 - 180 degrees')
document.forms[0].ewCoord.value = ''
}
}

}

//if values entered in the lower boxes tell user to use appropriated side
function useRight()
{
window.alert('To convert from DMS, please use the right hand side')

document.forms[0].nsDeg.value = '' 
document.forms[0].nsMin.value = ''
document.forms[0].nsSec.value = ''

document.forms[0].ewDeg.value = ''
document.forms[0].ewMin.value = ''
document.forms[0].ewSec.value = ''
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// This function does on the fly checking for values entered on the dms side //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////



function valNsDmsDeg(form)
{
var deg = parseFloat(form.nDeg.value)
var min = parseFloat(form.nMin.value)
var sec = parseFloat(form.nSec.value)
//checks for a number
if (isNaN(deg) && form.nDeg.value !="")
{
window.alert('You must enter a number.')
document.forms[1].nDeg.value = ''
}
//checks for valid num
else{
if (deg > 90 || deg < 0)
{
window.alert('You must enter an integer for degree between 0 - 90')
document.forms[1].nDeg.value = ''
}
}
//if deg is 90 then min and sec must be zero
if (deg == 90)
{

if (min > 0 || sec > 0)
{
window.alert('If degress is 90, then seconds and minutes must be 0')
document.forms[1].nDeg.value = ''

}
}

}

//check the min inputed value
function valNsDmsMin(form)
{
var deg = parseFloat(form.nDeg.value)
var min = parseFloat(form.nMin.value)
if (isNaN(min)){
window.alert('You must enter a number.')
document.forms[1].nMin.value = ''
}
else{
if (min > 59 || min < 0)
{
window.alert('You must enter a postive integer for minute between 0 - 59')
document.forms[1].nMin.value = ''
}
}
//if min is greater than 0 deg must be less than 90
if ( min > 0 && deg == 90)
{
window.alert('If degrees is 90, then minutes must be 0')
document.forms[1].nMin.value = 0
}

}

//checks values for second inputed value
function valNsDmsSec(form)
{
var deg = parseFloat(form.nDeg.value)
var sec = parseFloat(form.nSec.value)
if (isNaN(sec) && form.nSec.value !="")
{
window.alert('You must enter a number.')
document.forms[1].nSec.value = ''
}
else{
if (sec >= 60 || sec < 0)
{
window.alert('You must enter a second between 0 and up to but not including 60')
document.forms[1].nSec.value = ''
}
}
//if sec is 0 then deg must be less than 90
if ( sec > 0 && deg == 90)
{
window.alert('If degrees is 90, then seconds must be 0')
document.forms[1].nSec.value = 0
}

}

//like above but for east and west coords
function valEwDmsDeg(form)
{
var deg = parseFloat(form.eDeg.value)
var min = parseFloat(form.eMin.value)
var sec = parseFloat(form.eSec.value)
if (isNaN(deg) && form.eDeg.value !="")
{
window.alert('You must enter a number.')
document.forms[1].eDeg.value = ''
}
else{
//this time deg must be less than 180
if (deg > 180 || deg < 0)
{
window.alert('You must enter an integer for degree between 0 - 180')
document.forms[1].eDeg.value = ''
}
}

if (deg == 180)
{
if (min > 0 || sec > 0)
{
window.alert('If degress is 180, then seconds and minutes must be 0')
document.forms[1].eMin.value = 0
document.forms[1].eSec.value = 0
}
}

}

function valEwDmsMin(form)
{
var deg = parseFloat(form.eDeg.value)
var min = parseFloat(form.eMin.value)
if (isNaN(min) && form.eMin.value !="")
{
window.alert('You must enter a number.')
document.forms[1].eMin.value = ''
}
else{
if (min > 59 || min < 0)
{
window.alert('You must enter a positive integer for minute between 0 - 59')
document.forms[1].eMin.value = ''
}
}

if ( min > 0 && deg == 180)
{
window.alert('If degrees is 180, then minutes must be 0')
document.forms[1].eMin.value = 0
}
}


function valEwDmsSec(form)
{
var deg = parseFloat(form.eDeg.value)
var sec = parseFloat(form.eSec.value)
if (isNaN(sec) && form.eSec.value !="")
{
window.alert('You must enter a number.')
document.forms[1].eSec.value = ''
}
else{
if (sec >= 60 || sec < 0)
{
window.alert('You must enter a positive number for second between 0 and up to but not including 60')
document.forms[1].eSec.value = ''
}
}

if ( sec > 0 && deg == 180)
{
window.alert('If degrees is 180, then seconds must be 0')
document.forms[1].eSec.value = 0
}
}


//if values are entered into either of the lower two boxes tell user to use left side
function valLon()
{
window.alert('To convert from UTM, please use the left hand side')

document.forms[1].nsUTM.value = '' 

document.forms[1].ewUTM.value = ''


}

/////////////////////////////////////////////////////////////////////////////
// BREAK FREE IF OPENED IN A FRAME!!! //
////////////////////////////////////////////////////////////////////////////

if (top !=self) {
window.alert('This page may not be viewed in a frame')
top.location = location
}
-->
</SCRIPT>
<!-- the end -->