以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]甜老师现身!  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=52881)

--  作者:gaixuebo
--  发布时间:2014/6/25 9:08:00
--  [求助]甜老师现身!
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:gps产品名称.table

甜老师,你看下这段代码。(貌似很大一部分都是你写出来的)我想做成外部数据源,这个超过几万条就卡的要死啊!你看看能想想办法吗?
--  作者:有点甜
--  发布时间:2014/6/25 10:05:00
--  

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