后面还有:Public Sub Inite()
Dim Foxdb As DAO.Database
Dim RdTb As DAO.Recordset
Dim RdTurnTb As DAO.Recordset
Dim I As Long
Set Foxdb = OpenDatabase(MDBpath & "/" & ShpTit & ".Mdb", False, False)
Set RdTb = Foxdb.OpenRecordset("select * from NetP Order By Idx", dbOpenDynaset)RdTb.MoveLast
RdTb.MoveFirst
ReDim Csgrow(RdTb.RecordCount - 1 + 2) As NodeCol
I = 0
Do Until RdTb.EOF
Csgrow(I).Node_ = RdTb!Node_
Csgrow(I).Node_Point = RdTb!TurnIdx
I = I + 1
RdTb.MoveNext
Loop
RdTb.MoveFirstSet RdTurnTb = Foxdb.OpenRecordset("select * from Net0 Order By Idx", dbOpenDynaset)
RdTurnTb.MoveLast
RdTurnTb.MoveFirst
ReDim ArrayRdTurn(RdTurnTb.RecordCount - 1 + 400) As NodeTurn
I = 0
Do Until RdTurnTb.EOF
ArrayRdTurn(I).Fnode_ = Trim(Str(RdTurnTb!Fnode_))
ArrayRdTurn(I).TNode_ = Trim(Str(RdTurnTb!TNode_))
ArrayRdTurn(I).UseTime_ = RdTurnTb!Length
' ArrayRdTurn(I).TurnConnectIdx = Get_RdIndex(ArrayRdTurn(I).TNode_, 0)
ArrayRdTurn(I).TurnConnectIdx = RdTurnTb!TurnIdx
I = I + 1
RdTurnTb.MoveNext
Loop
ArrayRdTurn_Long = ICsgrow(UBound(Csgrow) - 1).Node_ = "From_"
Csgrow(UBound(Csgrow) - 1).Node_Point = ArrayRdTurn_Long
Csgrow(UBound(Csgrow)).Node_ = "To_"
Csgrow(UBound(Csgrow)).Node_Point = -1RdTurnTb.Close
RdTb.Close
Foxdb.Close
Set From_Strs = New MapObjects2.Strings
Set To_Strs = New MapObjects2.Strings
'For I = 0 To UBound(Csgrow)
' Csgrow(I).Node_Point = Get_RdTurnIndex(Csgrow(I).Node_, "", 0)
'Next
End SubPrivate Function Get_RdIndex(V_Node_ As String, InitIndex) As Long
Dim J As Long
Get_RdIndex = -1
For J = InitIndex To UBound(Csgrow)
If Csgrow(J).Node_ = V_Node_ Then
Get_RdIndex = J
Exit For
End If
Next
End FunctionPrivate Function Get_RdTurnIndex(Fun_Fnode_ As String, Fun_Tnode_ As String, Fun_InitIndex) As Long
Dim J As Long '取出与 Fun_Fnode_, Fun_Tode_位置相同的指针
Get_RdTurnIndex = -1
If Fun_Tnode_ <> "" Then
For J = Fun_InitIndex To UBound(ArrayRdTurn)
If (ArrayRdTurn(J).Fnode_ = Fun_Fnode_) And (ArrayRdTurn(J).TNode_ = Fun_Tnode_) Then
Get_RdTurnIndex = J
Exit For
End If
Next
Else
For J = Fun_InitIndex To UBound(ArrayRdTurn)
If ArrayRdTurn(J).Fnode_ = Fun_Fnode_ Then
Get_RdTurnIndex = J
Exit For
End If
Next
End If
End FunctionPrivate Function Get_SgrowIndex(V_Node_ As String) As Long
Dim J As Long
Get_SgrowIndex = -1
For J = 0 To UBound(Csgrow)
If Csgrow(J).Node_ = V_Node_ Then
Get_SgrowIndex = J
Exit For
End If
Next
End FunctionPrivate Sub Put_Ord(Idx As Long, ChgVal As Double)
Dim C_Beg As Long
Dim C_Idx As Long
Dim Ibeg As Long
Dim Imid As Long
Dim Iend As Long
Dim Ik As LongIf ChgVal >= 0 Then
Csgrow(Idx).T = ChgVal
Select Case Csgrow_Count
Case 0
MsgBox "Great error"
End
Case 1
Exit Sub
Csgrow_Above = -1
Csgrow_Bellow = -1
Case Else
If Csgrow_Above = Idx Then
'-----------
If Csgrow(Idx).T <= Csgrow(Csgrow(Idx).Next_Point).T Then Exit Sub
'-----------
Csgrow_Above = Csgrow(Idx).Next_Point
Else
If Csgrow_Bellow = Idx Then
'-----------
If Csgrow(Idx).T >= Csgrow(Csgrow(Idx).Above_Point).T Then Exit Sub
'-----------
Csgrow_Bellow = Csgrow(Idx).Above_Point
Else
'-----------
If Csgrow(Csgrow(Idx).Above_Point).T <= Csgrow(Idx).T And Csgrow(Idx).T <= Csgrow(Csgrow(Idx).Next_Point).T Then Exit Sub
'-----------
Csgrow(Csgrow(Idx).Above_Point).Next_Point = Csgrow(Idx).Next_Point
Csgrow(Csgrow(Idx).Next_Point).Above_Point = Csgrow(Idx).Above_Point
End If
End If
End Select
Csgrow_Count = Csgrow_Count - 1
End IfSelect Case Csgrow_Count
Case 0
Csgrow_Above = Idx
Csgrow_Bellow = Idx
Case 1
If Csgrow(Csgrow_Above).T >= Csgrow(Idx).T Then
Csgrow(Idx).Next_Point = Csgrow_Above
Csgrow(Csgrow_Above).Above_Point = Idx
Csgrow_Bellow = Csgrow_Above
Csgrow_Above = Idx
Else
Csgrow(Csgrow_Above).Next_Point = Idx
Csgrow(Idx).Above_Point = Csgrow_Above
Csgrow_Bellow = Idx
End If
Case 2
C_Idx = Csgrow(Csgrow_Above).Next_Point
If Csgrow(Csgrow_Above).T >= Csgrow(Idx).T Then
Csgrow(Idx).Next_Point = Csgrow_Above
Csgrow(Csgrow_Above).Above_Point = Idx
Csgrow_Above = Idx
Else
If Csgrow(C_Idx).T <= Csgrow(Idx).T Then
Csgrow(C_Idx).Next_Point = Idx
Csgrow(Idx).Above_Point = C_Idx
Csgrow_Bellow = Idx
Else
Csgrow(Csgrow_Above).Next_Point = Idx
Csgrow(Idx).Above_Point = Csgrow_Above
Csgrow(Idx).Next_Point = C_Idx
Csgrow(C_Idx).Above_Point = Idx
End If
End If
Case Else
Ibeg = 1
Iend = Csgrow_Count
C_Beg = Csgrow_Above
Do Until Iend <= 1 + Ibeg
Imid = Int((Iend - Ibeg + 2) / 2)
C_Idx = C_Beg
For Ik = 1 To Imid - 1
C_Idx = Csgrow(C_Idx).Next_Point
Next Ik
If Csgrow(C_Idx).T > Csgrow(Idx).T Then
Iend = Imid + Ibeg - 1
End If
If Csgrow(C_Idx).T < Csgrow(Idx).T Then
Ibeg = Imid + Ibeg - 1
C_Beg = C_Idx
End If
If Csgrow(C_Idx).T = Csgrow(Idx).T Then
Ik = Csgrow(C_Idx).Next_Point
Csgrow(C_Idx).Next_Point = Idx
Csgrow(Idx).Above_Point = C_Idx
Csgrow(Idx).Next_Point = Ik
Csgrow(Ik).Above_Point = Idx
C_Beg = -1
Exit Do
End If
Loop If C_Beg >= 0 Then
C_Idx = Csgrow(C_Beg).Next_Point
If Csgrow(C_Beg).T >= Csgrow(Idx).T Then
Csgrow(Idx).Next_Point = C_Beg
Csgrow(C_Beg).Above_Point = Idx
If C_Beg = Csgrow_Above Then
Csgrow_Above = Idx
End If
Else
If Csgrow(C_Idx).T <= Csgrow(Idx).T Then
Csgrow(C_Idx).Next_Point = Idx
Csgrow(Idx).Above_Point = C_Idx
' If C_Beg = Csgrow_Bellow Then
Csgrow_Bellow = Idx
' End If
Else
Csgrow(C_Beg).Next_Point = Idx
Csgrow(Idx).Above_Point = C_Beg
Csgrow(Idx).Next_Point = C_Idx
Csgrow(C_Idx).Above_Point = Idx
End If
End If
End If
End Select
Csgrow_Count = Csgrow_Count + 1
End SubPrivate Sub Class_Initialize()End SubPrivate Sub Class_Terminate()End Sub
结构:
Option Explicit
Public Type NodeTurn
Fnode_ As String
TNode_ As String
TurnConnectIdx As Long
UseTime_ As Double
End TypePublic Type NodeCol
Node_ As String
Node_Point As Long '指向NodeTurn的第一个指针
P As Double
T As Double
Prev As String
Above_Point As Long
Next_Point As Long
End Type
两个数据表结构为:
Net0:
Id FNODE_ TNODE_ LENGTH F_T TURNIDX IDX
NetP:
Id NODE_ IDX TURNIDX
Dim Foxdb As DAO.Database
Dim RdTb As DAO.Recordset
Dim RdTurnTb As DAO.Recordset
Dim I As Long
Set Foxdb = OpenDatabase(MDBpath & "/" & ShpTit & ".Mdb", False, False)
Set RdTb = Foxdb.OpenRecordset("select * from NetP Order By Idx", dbOpenDynaset)RdTb.MoveLast
RdTb.MoveFirst
ReDim Csgrow(RdTb.RecordCount - 1 + 2) As NodeCol
I = 0
Do Until RdTb.EOF
Csgrow(I).Node_ = RdTb!Node_
Csgrow(I).Node_Point = RdTb!TurnIdx
I = I + 1
RdTb.MoveNext
Loop
RdTb.MoveFirstSet RdTurnTb = Foxdb.OpenRecordset("select * from Net0 Order By Idx", dbOpenDynaset)
RdTurnTb.MoveLast
RdTurnTb.MoveFirst
ReDim ArrayRdTurn(RdTurnTb.RecordCount - 1 + 400) As NodeTurn
I = 0
Do Until RdTurnTb.EOF
ArrayRdTurn(I).Fnode_ = Trim(Str(RdTurnTb!Fnode_))
ArrayRdTurn(I).TNode_ = Trim(Str(RdTurnTb!TNode_))
ArrayRdTurn(I).UseTime_ = RdTurnTb!Length
' ArrayRdTurn(I).TurnConnectIdx = Get_RdIndex(ArrayRdTurn(I).TNode_, 0)
ArrayRdTurn(I).TurnConnectIdx = RdTurnTb!TurnIdx
I = I + 1
RdTurnTb.MoveNext
Loop
ArrayRdTurn_Long = ICsgrow(UBound(Csgrow) - 1).Node_ = "From_"
Csgrow(UBound(Csgrow) - 1).Node_Point = ArrayRdTurn_Long
Csgrow(UBound(Csgrow)).Node_ = "To_"
Csgrow(UBound(Csgrow)).Node_Point = -1RdTurnTb.Close
RdTb.Close
Foxdb.Close
Set From_Strs = New MapObjects2.Strings
Set To_Strs = New MapObjects2.Strings
'For I = 0 To UBound(Csgrow)
' Csgrow(I).Node_Point = Get_RdTurnIndex(Csgrow(I).Node_, "", 0)
'Next
End SubPrivate Function Get_RdIndex(V_Node_ As String, InitIndex) As Long
Dim J As Long
Get_RdIndex = -1
For J = InitIndex To UBound(Csgrow)
If Csgrow(J).Node_ = V_Node_ Then
Get_RdIndex = J
Exit For
End If
Next
End FunctionPrivate Function Get_RdTurnIndex(Fun_Fnode_ As String, Fun_Tnode_ As String, Fun_InitIndex) As Long
Dim J As Long '取出与 Fun_Fnode_, Fun_Tode_位置相同的指针
Get_RdTurnIndex = -1
If Fun_Tnode_ <> "" Then
For J = Fun_InitIndex To UBound(ArrayRdTurn)
If (ArrayRdTurn(J).Fnode_ = Fun_Fnode_) And (ArrayRdTurn(J).TNode_ = Fun_Tnode_) Then
Get_RdTurnIndex = J
Exit For
End If
Next
Else
For J = Fun_InitIndex To UBound(ArrayRdTurn)
If ArrayRdTurn(J).Fnode_ = Fun_Fnode_ Then
Get_RdTurnIndex = J
Exit For
End If
Next
End If
End FunctionPrivate Function Get_SgrowIndex(V_Node_ As String) As Long
Dim J As Long
Get_SgrowIndex = -1
For J = 0 To UBound(Csgrow)
If Csgrow(J).Node_ = V_Node_ Then
Get_SgrowIndex = J
Exit For
End If
Next
End FunctionPrivate Sub Put_Ord(Idx As Long, ChgVal As Double)
Dim C_Beg As Long
Dim C_Idx As Long
Dim Ibeg As Long
Dim Imid As Long
Dim Iend As Long
Dim Ik As LongIf ChgVal >= 0 Then
Csgrow(Idx).T = ChgVal
Select Case Csgrow_Count
Case 0
MsgBox "Great error"
End
Case 1
Exit Sub
Csgrow_Above = -1
Csgrow_Bellow = -1
Case Else
If Csgrow_Above = Idx Then
'-----------
If Csgrow(Idx).T <= Csgrow(Csgrow(Idx).Next_Point).T Then Exit Sub
'-----------
Csgrow_Above = Csgrow(Idx).Next_Point
Else
If Csgrow_Bellow = Idx Then
'-----------
If Csgrow(Idx).T >= Csgrow(Csgrow(Idx).Above_Point).T Then Exit Sub
'-----------
Csgrow_Bellow = Csgrow(Idx).Above_Point
Else
'-----------
If Csgrow(Csgrow(Idx).Above_Point).T <= Csgrow(Idx).T And Csgrow(Idx).T <= Csgrow(Csgrow(Idx).Next_Point).T Then Exit Sub
'-----------
Csgrow(Csgrow(Idx).Above_Point).Next_Point = Csgrow(Idx).Next_Point
Csgrow(Csgrow(Idx).Next_Point).Above_Point = Csgrow(Idx).Above_Point
End If
End If
End Select
Csgrow_Count = Csgrow_Count - 1
End IfSelect Case Csgrow_Count
Case 0
Csgrow_Above = Idx
Csgrow_Bellow = Idx
Case 1
If Csgrow(Csgrow_Above).T >= Csgrow(Idx).T Then
Csgrow(Idx).Next_Point = Csgrow_Above
Csgrow(Csgrow_Above).Above_Point = Idx
Csgrow_Bellow = Csgrow_Above
Csgrow_Above = Idx
Else
Csgrow(Csgrow_Above).Next_Point = Idx
Csgrow(Idx).Above_Point = Csgrow_Above
Csgrow_Bellow = Idx
End If
Case 2
C_Idx = Csgrow(Csgrow_Above).Next_Point
If Csgrow(Csgrow_Above).T >= Csgrow(Idx).T Then
Csgrow(Idx).Next_Point = Csgrow_Above
Csgrow(Csgrow_Above).Above_Point = Idx
Csgrow_Above = Idx
Else
If Csgrow(C_Idx).T <= Csgrow(Idx).T Then
Csgrow(C_Idx).Next_Point = Idx
Csgrow(Idx).Above_Point = C_Idx
Csgrow_Bellow = Idx
Else
Csgrow(Csgrow_Above).Next_Point = Idx
Csgrow(Idx).Above_Point = Csgrow_Above
Csgrow(Idx).Next_Point = C_Idx
Csgrow(C_Idx).Above_Point = Idx
End If
End If
Case Else
Ibeg = 1
Iend = Csgrow_Count
C_Beg = Csgrow_Above
Do Until Iend <= 1 + Ibeg
Imid = Int((Iend - Ibeg + 2) / 2)
C_Idx = C_Beg
For Ik = 1 To Imid - 1
C_Idx = Csgrow(C_Idx).Next_Point
Next Ik
If Csgrow(C_Idx).T > Csgrow(Idx).T Then
Iend = Imid + Ibeg - 1
End If
If Csgrow(C_Idx).T < Csgrow(Idx).T Then
Ibeg = Imid + Ibeg - 1
C_Beg = C_Idx
End If
If Csgrow(C_Idx).T = Csgrow(Idx).T Then
Ik = Csgrow(C_Idx).Next_Point
Csgrow(C_Idx).Next_Point = Idx
Csgrow(Idx).Above_Point = C_Idx
Csgrow(Idx).Next_Point = Ik
Csgrow(Ik).Above_Point = Idx
C_Beg = -1
Exit Do
End If
Loop If C_Beg >= 0 Then
C_Idx = Csgrow(C_Beg).Next_Point
If Csgrow(C_Beg).T >= Csgrow(Idx).T Then
Csgrow(Idx).Next_Point = C_Beg
Csgrow(C_Beg).Above_Point = Idx
If C_Beg = Csgrow_Above Then
Csgrow_Above = Idx
End If
Else
If Csgrow(C_Idx).T <= Csgrow(Idx).T Then
Csgrow(C_Idx).Next_Point = Idx
Csgrow(Idx).Above_Point = C_Idx
' If C_Beg = Csgrow_Bellow Then
Csgrow_Bellow = Idx
' End If
Else
Csgrow(C_Beg).Next_Point = Idx
Csgrow(Idx).Above_Point = C_Beg
Csgrow(Idx).Next_Point = C_Idx
Csgrow(C_Idx).Above_Point = Idx
End If
End If
End If
End Select
Csgrow_Count = Csgrow_Count + 1
End SubPrivate Sub Class_Initialize()End SubPrivate Sub Class_Terminate()End Sub
结构:
Option Explicit
Public Type NodeTurn
Fnode_ As String
TNode_ As String
TurnConnectIdx As Long
UseTime_ As Double
End TypePublic Type NodeCol
Node_ As String
Node_Point As Long '指向NodeTurn的第一个指针
P As Double
T As Double
Prev As String
Above_Point As Long
Next_Point As Long
End Type
两个数据表结构为:
Net0:
Id FNODE_ TNODE_ LENGTH F_T TURNIDX IDX
NetP:
Id NODE_ IDX TURNIDX
第一次做广告,实在是很急。
http://www.csdn.net/expert/topic/561/561652.xml?temp=.5516931