【发布时间】:2014-01-05 22:40:43
【问题描述】:
目前,我在 VB.NET 中将 DMS 转换为 DD 非常困难,经过无休止的搜索并且没有运气,我打开了这个 Q,希望其他用户遇到这个问题并希望在过去!
我正在尝试将 N51°4.212'、E0°12.905' 的 DMS 转换为 DD。
阅读此问答后: Convert GPS Degrees Minutes Seconds to Decimal Degrees
我有这个函数,它抛出了完全不正确的 DD 坐标(50.9298,-0.215083333333333):
Private Function DMS_To_DD(ByVal Degrees As String, ByVal Mins As String, ByVal Secs As String) As String
Dim TmpMins As String = CStr(Mins) & "." & Secs
Return CInt(Degrees) + (CDbl(TmpMins) / 60) * -1
End Function
&然后阅读此页面:http://simoncodersoftware.wordpress.com/2013/04/09/convert-dms-to-dd-using-vb-net/
这让我想到了这个功能:
Private Function DMS_To_DD(ByVal Degrees As String, ByVal Mins As String, ByVal Secs As String) As String
Dim TotalSecs As Integer = CInt(Mins) * 60 + Secs
Dim Total_2 As Double = TotalSecs / 3600
Dim X1 As String = CStr(CInt(Degrees) & CStr(Total_2))
If X1.StartsWith("-") Then
Return X1.Substring(0, 3) & X1.Substring(4, 5)
Else
Return X1.Substring(0, 2) & X1.Substring(3, 5)
End If
End Function
返回无效坐标:51.1255, 0045138
调用这两个函数: DMS_To_DD(51, 4, 212) DMS_To_DD(0, 12, 905)
我在这里出错的任何想法?这个问题快把我逼疯了!
【问题讨论】:
标签: vb.net coordinates geography