3秒左右。
DataTables("GPS产品名称").StopRedraw
DataTables("表C").StopRedraw
DataTables("表C").DataRows.Clear
Dim fdr As DataRow
Dim drs As List(Of DataRow) = DataTables("GPS产品名称").Select("", "GPS产品名称,日期")
Dim prev As String = ""
For i As Integer = 1 To drs.Count - 1
If prev <> drs(i)("GPS产品名称") Then
If i <> 0 Then
'fdr = DataTables("表C").Find("第一列 = '" & prev & "'")
'If fdr Is Nothing Then
fdr = DataTables("表C").AddNew
fdr("第一列") = prev
'End If
fdr("第三列") = drs(i-1)("距离累加值")
End If
prev = drs(i)("GPS产品名称")
drs(i)("距离累加值") = 0
Else
Dim x1 As Double = drs(i-1)("纬度")
Dim y1 As Double = drs(i-1)("经度")
Dim x2 As Double = drs(i)("纬度")
Dim y2 As Double = drs(i)("经度")
Dim rad As Double = 6371
Dim p1X As Double = X1 / 180 * Math.PI
Dim p1Y As Double = Y2 / 180 * Math.PI
Dim p2X As Double = X2 / 180 * Math.PI
Dim p2Y As Double = Y2 / 180 * Math.PI
Dim result As Double = Math.Acos(Math.Sin(p1Y) * Math.Sin(p2Y) + Math.Cos(p1Y) * Math.Cos(p2Y) * Math.Cos(p2X - p1X)) * rad
drs(i)("距离累加值") = drs(i-1)("距离累加值") + result
End If
Next
fdr = DataTables("表C").Find("第一列 = '" & drs(drs.Count-1)("GPS产品名称") & "'")
If fdr Is Nothing Then
fdr = DataTables("表C").AddNew
fdr("第一列") = drs(drs.Count-1)("GPS产品名称")
End If
fdr("第三列") = drs(drs.Count-1)("距离累加值")
DataTables("GPS产品名称").ResumeRedraw
DataTables("表C").ResumeRedraw