// \param degs Degrees in float format // \return List with (degrees, minutes, seconds) DMS grad_min_sec(double degs) { //Avoiding operations with negative values bool to_neg = false; if (degs < 0) { degs = Math.Abs((double)degs); to_neg = true; } double d = Math.Floor((double)degs); double degs_m = (degs - d) * 60.0; double m = Math.Floor(degs_m); double s = (degs_m - m) * 60.0; //Avoiding the .60 values if (s >= 59.99) { s = 0; m += 1; } if (m >= 60.0) { m = 60.0 - m; d += 1; } if (to_neg) { d = -d; } DMS dms = new DMS(); dms.Degre = (int)d; dms.Minute = (int)m; dms.Seconde = s; return dms; }
double ConvertDeg(DMS dms) { double deg = dms.Degre; deg = Math.Abs(deg); deg += dms.Minute / 60.0; deg += dms.Seconde / 3600.0; if (dms.Degre < 0) deg = -deg; return deg; }