kerosan 0 Report post Posted February 27, 2013 assalamualaikum warga putera.. skang ni ak dh pening kepala buat bnda ni.. nk tanya..mcm mana nk convert data gps yg gprmc ke decimal dalam vb.net sbb kalau amik sebiji data gprmc dan terus masuk ke google map..memang coordinate tak brape betul.. ak try google..jmpe satu cara..ak kena convert data gprmc ke decimal.. mcm cnth: Latitude = 2 degrees 8.6038 minutes = 2 + (8.6038/60) degrees = 2.1433967 degrees tapi yang menjadi masalah kat aku.. ak dh buat mcm2 tapi still tak jadi.. balik2 keluar data gprmc..memang coordinate dia akan lari jauh.. ni coding vb.net ak.. Imports System Imports System.IO.Ports Public Class Form1 '1. Define (create) the delegate type we want to use. It will be ' a SUB with one argument (a string) Delegate Sub SetReceivedText(ByVal ReceivedData As String) '2. Declare a variable of the correct type Dim d As SetReceivedText 'define a string Dim data_received As String Private Sub get_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles get_btn.Click 'if port is open If SerialPort1.IsOpen Then SerialPort1.RtsEnable = False SerialPort1.DtrEnable = False SerialPort1.Close() Application.DoEvents() End If 'set port setting SerialPort1.PortName = "COM16" SerialPort1.BaudRate = 9600 SerialPort1.DataBits = 8 SerialPort1.Parity = 0 SerialPort1.StopBits = IO.Ports.StopBits.One SerialPort1.WriteTimeout = 2000 Try 'open port SerialPort1.Open() Catch ex As Exception 'give alert any problem MsgBox(ex.Message) End Try If SerialPort1.IsOpen Then SerialPort1.RtsEnable = True End If lblStatus.Text = "GPS connected" End Sub Private Sub SerialPort1_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived 'get data from serial port data_received = SerialPort1.ReadLine 'give an alert when data received 'MsgBox(data_received) Me.Invoke(New EventHandler(AddressOf DoUpdate)) End Sub Public Sub DoUpdate(ByVal sender As Object, ByVal e As System.EventArgs) Dim str As String Dim strArr() As String Dim position, Lposition As Integer Dim nPosition, LnPosition As Double Dim myString, LmyString As String Dim ldString, LldString Dim minutestr, degreestr As String Dim minutes, degree As Double 'Dim count As Integer str = data_received strArr = str.Split(",") 'For count = 0 To strArr.Length - 1 'MsgBox(strArr(count)) 'Next If strArr(0) = "$GPRMC" Then ListBox1.Items.Add(data_received) txtReceived.Text = data_received position = strArr(3).IndexOf(".") nPosition = degree myString = strArr(3).Replace(".", "") minutestr = myString.Substring(position - 2) minutes = Double.Parse(minutestr, New System.Globalization.CultureInfo("en-US")) degreestr = myString.Substring(0, position - 2) degree = Convert.ToDouble(degreestr) + minutes / 60 ldString = myString.Insert(nPosition, ".") txtLadtitute.Text = ldString Lposition = strArr(5).IndexOf(".") LnPosition = Lposition - 2 LmyString = strArr(5).Replace(".", "") LldString = LmyString.Insert(LnPosition, ".") txtLongitude.Text = LldString WebBrowser1.Navigate("http://maps.google.com/?q=" & txtLadtitute.Text & "," & txtLongitude.Text) End If End Sub harap sgt otai2 putera dapat beri bantuan.. Quote Share this post Link to post Share on other sites
NeoLogy 74 Report post Posted February 27, 2013 Ni maybe problem dengan parsing ni..bleh tak ko bagi satu contoh raw data dan apa converted data yang ko expected daripada raw data tu.. Quote Share this post Link to post Share on other sites