//度分秒转小数,如输入333527.9(表示33度35分27.9秒),返回33.59108333
private double convDMStoDecimal(double temp)
{
double d = temp / 10000; //33.35279
int degree = (int)Math.Floor(d); //33 返回小于或等于指定数字的最大整数
temp -= degree * 10000; //3527.9
int minute = (int)Math.Floor(temp/100);//35
double m = minute / 60.0;
temp -= minute * 100; //27.9
double s = temp / 60.0 / 60.0;
double result = degree + m + s;
return (result);
}
//小数转度分秒,如输入33.59108333,返回33.35279(表示33度35分27.9秒)
private double convDecimaltoDMS(double temp)
{
int d = (int)Math.Floor(temp); //33 //返回小于或等于指定数字的最大整数
double x = (temp - d) * 60; //0.59108333*60=35.464998(分)
int m = (int)Math.Floor(x); //35
double s = (x - m) * 60; //0.464998*60=27.89988
double result = (double)d + (double)m / 100 + (double)s / 10000;
return result;
}