📄 frmgps.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 6480
ClientLeft = 60
ClientTop = 450
ClientWidth = 9195
LinkTopic = "Form1"
ScaleHeight = 6480
ScaleWidth = 9195
StartUpPosition = 3 '窗口缺省
Begin VB.Timer Timer1
Interval = 2000
Left = 2385
Top = 5295
End
Begin MSCommLib.MSComm MSComm1
Left = 1005
Top = 5190
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
CommPort = 4
DTREnable = -1 'True
BaudRate = 4800
End
Begin VB.Frame Frame1
Caption = "GPS实时定位图"
Height = 4215
Left = 165
TabIndex = 0
Top = 510
Width = 5625
Begin VB.CommandButton cmdfz
Caption = "参考点赋值"
Enabled = 0 'False
Height = 345
Left = 1890
TabIndex = 11
Top = 3675
Width = 1725
End
Begin VB.TextBox Text2
Enabled = 0 'False
Height = 285
Left = 165
TabIndex = 4
Top = 2925
Width = 1515
End
Begin VB.TextBox Text5
Enabled = 0 'False
Height = 285
Left = 165
TabIndex = 3
Top = 2190
Width = 1170
End
Begin VB.TextBox Text6
Enabled = 0 'False
Height = 285
Left = 165
TabIndex = 2
Top = 1335
Width = 975
End
Begin VB.TextBox Text7
Enabled = 0 'False
Height = 285
Left = 180
TabIndex = 1
Top = 555
Width = 975
End
Begin VB.Label Label4
Caption = "日期:"
Height = 315
Left = 225
TabIndex = 8
Top = 2685
Width = 795
End
Begin VB.Label Label5
Caption = "时间:"
Height = 315
Left = 285
TabIndex = 7
Top = 1875
Width = 795
End
Begin VB.Label Label6
Caption = "向东:"
Height = 315
Left = 270
TabIndex = 6
Top = 1035
Width = 795
End
Begin VB.Label Label7
Caption = "向北:"
Height = 315
Left = 285
TabIndex = 5
Top = 255
Width = 795
End
Begin VB.Shape Shape3
FillColor = &H0000C000&
FillStyle = 0 'Solid
Height = 120
Left = 3390
Shape = 2 'Oval
Top = 1800
Width = 120
End
Begin VB.Shape Shape1
FillColor = &H000000FF&
FillStyle = 0 'Solid
Height = 135
Left = 2700
Top = 870
Visible = 0 'False
Width = 120
End
Begin VB.Shape Shape2
FillStyle = 0 'Solid
Height = 3195
Left = 1875
Shape = 3 'Circle
Top = 240
Width = 3195
End
End
Begin VB.Label LabGps
Caption = " "
Height = 330
Left = 1500
TabIndex = 10
Top = 135
Width = 6600
WordWrap = -1 'True
End
Begin VB.Label Label8
Caption = "定位原始信息:"
Height = 315
Left = 225
TabIndex = 9
Top = 135
Width = 1305
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim strgps As String, strgps1 As String, strgps2 As String, strgps3 As String, strgps4 As String
Dim w, k, j As Long
Dim cosb, cosl, sinb, sinl As Double
Dim le, ln, lu As Double
Dim ll, bb, hh As Double
Dim X As Double, Y As Double, Z As Double
Dim H As Double, L As Double, B As Double, N As Double
Dim RelativeX As Double, RelativeY As Double, RelativeZ As Double
Dim b1 As String, h1 As String, l1 As String
Dim ReferenceX As Double, ReferenceY As Double, ReferenceZ As Double
Dim Referencee As Double, Referencen As Double, Referenceu As Double
Dim e2 As Double
Dim lrene, lrenn, lrenu As Double
Dim str1(20) As String
Dim publicl, publicb, publich As Double
Private Sub Command1_Click()
Dim lll, bbb, hhh As Double
Dim cosll, sinll, cosbb, sinbb As Double
If Shape1.Visible = True And (Val(Text6.Text) * Val(Text6.Text) + Val(Text7.Text) * Val(Text7.Text)) < 200 Then
lll = publicl
bbb = publicb
hhh = publich
cosl = Cos(lll * 3.1415926 / 180)
sinl = Sin(lll * 3.1415926 / 180)
cosb = Cos(bbb * 3.1415926 / 180)
sinb = Sin(bbb * 3.1415926 / 180)
L = ll
B = bb
H = hh
N = 6378137 / Sqr(1 - e2 * Sin(B * 3.1415926 / 180) * Sin(B * 3.1415926 / 180))
X = (N + H) * Cos(B * 3.1415926 / 180) * Cos(L * 3.1415926 / 180)
Y = (N + H) * Cos(B * 3.1415926 / 180) * Sin(L * 3.1415926 / 180)
Z = (N * (1 - e2) + H) * Sin(B * 3.1415926 / 180)
ReferenceX = X
ReferenceY = Y
ReferenceZ = Z
lrene = ReferenceY * cosl - ReferenceX * sinl
lrenn = ReferenceZ * cosb - ReferenceX * sinb * cosl - ReferenceY * sinb * sinl
lrenu = ReferenceX * cosb * cosl + ReferenceY * cosb * sinl + ReferenceZ * sinb
End If
End Sub
Private Sub Form_Load()
MSComm1.PortOpen = True
ll = 118.856853333333
bb = 32.03116
hh = 12.6
e2 = 2 / 298.257223563 - 1 / 298.257223563 / 298.257223563
cosl = Cos(ll * 3.1415926 / 180)
sinl = Sin(ll * 3.1415926 / 180)
cosb = Cos(bb * 3.1415926 / 180)
sinb = Sin(bb * 3.1415926 / 180)
L = ll
B = bb
H = hh
N = 6378137 / Sqr(1 - e2 * Sin(B * 3.1415926 / 180) * Sin(B * 3.1415926 / 180))
X = (N + H) * Cos(B * 3.1415926 / 180) * Cos(L * 3.1415926 / 180)
Y = (N + H) * Cos(B * 3.1415926 / 180) * Sin(L * 3.1415926 / 180)
Z = (N * (1 - e2) + H) * Sin(B * 3.1415926 / 180)
ReferenceX = X
ReferenceY = Y
ReferenceZ = Z
lrene = ReferenceY * cosl - ReferenceX * sinl
lrenn = ReferenceZ * cosb - ReferenceX * sinb * cosl - ReferenceY * sinb * sinl
lrenu = ReferenceX * cosb * cosl + ReferenceY * cosb * sinl + ReferenceZ * sinb
End Sub
Private Sub Timer1_Timer()
Dim i, t As Integer
strgps = MSComm1.Input
Debug.Print strgps
w = InStr(1, strgps, "$GPGGA")
If w = 0 Then Exit Sub
k = InStr(w, strgps, Chr(13) & Chr(10))
If k = 0 Then Exit Sub
LabGps.Caption = strgps
t = 1
For j = 1 To 12
strgps2 = Mid(strgps, t)
For i = 1 To 100
If Mid(strgps2, i, 1) = "," Then
str1(j) = Mid(strgps2, 1, i - 1)
Exit For
End If
Next i
t = t + i
Next j
If str1(7) <> "1" Then
Shape1.Visible = False
Else
Shape1.Visible = True
Text5.Text = Format(Time, "hh时mm分ss秒")
Text2.Text = Format(Date, "YYYY年MM月DD日")
b1 = Val(str1(3))
l1 = Val(str1(5))
L = (l1 \ 100 + (l1 / 100 - l1 \ 100) * 100 / 60)
B = (b1 \ 100 + (b1 / 100 - b1 \ 100) * 100 / 60)
ll = L
bb = B
hh = Val(str1(10)) - Val(str1(12))
publicl = ll
publicb = bb
publich = hh
e2 = 2 / 298.257223563 - 1 / 298.257223563 / 298.257223563
L = ll
B = bb
H = hh
N = 6378137 / Sqr(1 - e2 * Sin(B * 3.1415926 / 180) * Sin(B * 3.1415926 / 180))
X = (N + H) * Cos(B * 3.1415926 / 180) * Cos(L * 3.1415926 / 180)
Y = (N + H) * Cos(B * 3.1415926 / 180) * Sin(L * 3.1415926 / 180)
Z = (N * (1 - e2) + H) * Sin(B * 3.1415926 / 180)
ReferenceX = X
ReferenceY = Y
ReferenceZ = Z
Text6.Text = ReferenceY * cosl - ReferenceX * sinl - lrene
Text7.Text = ReferenceZ * cosb - ReferenceX * sinb * cosl - ReferenceY * sinb * sinl - lrenn
End If
If Shape1.Visible = True And (Val(Text6.Text) * Val(Text6.Text) + Val(Text7.Text) * Val(Text7.Text)) < 200 Then
cmdfz.Enabled = True
Else
cmdfz.Enabled = False
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -