0

我正在尝试 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";
}
4

1 回答 1

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 + "\"";
}
于 2012-09-25T08:48:18.347 回答