我正在尝试GPS应用程序,我想将十进制数字转换为纬度/经度,但我没有达到确切的解决方案。我在下面尝试过
string decimalToLatLong(decimal lat,decimal refPoint)
{
bool isNeg = lat < 0;
int d = (int)lat;
int m = (int)((lat - d) * 60);
decimal s = ((((lat - d) * 60) - m) * 60);
return (d+m+s).ToString("00.000");
if (isLat)
direction = isNeg ? "S" : "N";
else
direction = isNeg ? "W" : "E";
}
答案 0 :(得分:2)
怎么样:
string decimalToLatLong(decimal dec)
{
int d = (int)dec;
int m = (int)((dec - d) * 60);
decimal s = ((((dec - d) * 60) - m) * 60);
return d + "° " + m + "' " + s + "\"";
}