地理经纬度(度)与经纬度(度分秒)之间互转
1 public static double Dms2Degree(CoordDms dms) 2 { 3 if (null != dms) 4 { 5 decimal decD = new decimal(dms.Degree); 6 decimal decM = new decimal(dms.Minute); 7 decimal decS = new decimal(dms.Second); 8 decimal dec60 = new decimal(60.0); 9 10 decimal decDDouble = decD + (decM / dec60) + (decS / dec60 / dec60); 11 return decimal.ToDouble(decDDouble); 12 } 13 14 return 0; 15 } 16 17 public static CoordDms Degree2Dms(double d) 18 { 19 decimal dec = new decimal(d); 20 Decimal dec60 = new decimal(60.0); 21 CoordDms cd = new CoordDms(); 22 cd.Degree = decimal.ToInt32(dec); 23 decimal min = decimal.Multiply(dec - new decimal(cd.Degree), dec60); 24 cd.Minute = decimal.ToInt32(min); 25 decimal sec = min - new decimal(cd.Minute); 26 cd.Second = decimal.ToDouble(decimal.Multiply(sec, dec60)); 27 28 return cd; 29 } 30 public class CoordDms 31 { 32 public int Degree { get; set; } 33 public int Minute { get; set; } 34 public Double Second { get; set; } 35 }
@小七de尾巴