Following code snippet will convert decimal latitude and longitude into degree, min and sec
1 2 3 4 5 6 7 8 9 10 11 12 |
function DECtoDMS(dd) { var vars = dd.split('.'); var deg = vars[0]; var tempma = "0."+vars[1]; tempma = tempma * 3600; var min = Math.floor(tempma / 60); var sec = tempma - (min * 60); return deg+"-"+min+"-"+sec; } var inDeg = DECtoDMS(72.8479400); |
To convert a latitude and longitude in degree min sec to decimal
1 2 3 4 5 6 |
function DMStoDEC(deg, min, sec) { return $deg+(((min*60)+(sec))/3600); } var res = DMStoDEC('72', '55', '52'); |