Autor Tema: Ayuda en codigo GPS  (Leído 1988 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado camolas

  • PIC10
  • *
  • Mensajes: 22
Ayuda en codigo GPS
« en: 04 de Julio de 2009, 16:31:58 »
Hola,

Soi mui newbi en vb6 perdon.
Tenho un problema meti los dados del gps latitude en una string GPS.Lat 41097854 agore necessitava de passarlos a 41'09.7854 podrias ayudar me el la corversion?
Perdon pelo mio mui malo Castellano.


Código: [Seleccionar]
'Reads GPS
Public Sub ReadGPSInfo(ByVal sData As String, Optional CommaSys As Boolean = True)
Static Ltry As Double   'Last Time we tried to reconnect GPS
Static Buff As String   'Buffer of Data
Dim Nb As Long          'Number of Bytes
Dim b() As Byte         'Array of Bytes
Dim DT() As String      'GPS Fields
Dim a As String

On Error Resume Next
    'If nothing to do
    If sData = "" Then
        Exit Sub
    Else
           
           
            'Process Line of Data
            If Left(sData, 1) = "$" Then
                DT = Split(sData, ",")
           
                'Save latest messages to Log in case somebody wants it later
                'NMEAMSGs.Remove DT(0)
                'NMEAMSGs.Add sData, DT(0)
               
       
                Select Case DT(0)
                    Case "$GPRMC"
                        'Get Lat, Long, Speed and Heading
                        GPS.Lat = CDbl(Left(DT(3), InStr(1, DT(3), ".") - 1))
                        GPS.Lat = GPS.Lat & CDbl(Right(DT(3), InStr(1, DT(3), ".") - 1))
           
                   
                   'GPS.Lat = word(sd, 1)
               
                    ' GPS.Lat = Left(sd, 2) + Left(sd, 3 - 3)
                     
                    ' GPS.Lat = GPS.Lat & Left(sd, 3 - 4)
                     
                       
                      GPS.Lon = CDbl(Left(DT(5), InStr(1, DT(5), ".") - 1))
                       GPS.Lon = GPS.Lon & CDbl(Right(DT(5), InStr(1, DT(5), ".") - 1))
                       
                        If DT(4) = "S" Then GPS.Lat = -GPS.Lat
                        If DT(6) = "W" Then GPS.Lon = -GPS.Lon
                        GPS.Speed = CDbl(DT(7))
                       
                        'If GPS.Speed > 3 Then GPS.Hdg = CInt(DT(8))
                        'If set time from GPS then
                        'If GPSTime And GPS.Valid Then
                        '    'Check for Inverted Date format (stupid GPSs in US date format -- nonstandard)
                        '    DT(0) = "": DT(0) = UseVars("gpsusadate")
                        '    If LCase(DT(0)) = "true" Then DT(9) = Mid(DT(9), 3, 2) + Left(DT(9), 2) + Mid(DT(9), 5)
                        '
                        '    'If time OR date is wrong, set it correctly from GPS
                        '    If Format(DateAdd("h", TimeZone, Now), "HHMM") <> Left(DT(1), 4) Or Format(DateAdd("h", TimeZone, Now), "DDMMYY") <> DT(9) Then
                        '        DT(1) = Format(DateAdd("h", -TimeZone, Mid(DT(9), 3, 2) + "/" + Left(DT(9), 2) + "/" + Mid(DT(9), 5, 2) + " " + Left(DT(1), 2) + ":" + Mid(DT(1), 3, 2) + ":" + Mid(DT(1), 5, 2)), "MM/DD/YY HH:MM:SS")
                        '        Date = Left(DT(1), 8)
                        '        Time = Mid(DT(1), 10)
                        '    End If
                        'End If
                    Case "$GPGGA"
                        'Get Altitude and Sat Count
                        If CommaSys Then DT(9) = Replace(DT(9), ".", ",")
                        GPS.Alt = CDbl(DT(9))
                        GPS.Sats = CInt(DT(7))
                        GPS.Valid = (Val(DT(6)) > 0)
                       
                End Select
            End If
End If
End Sub

Desconectado BrunoF

  • Administrador
  • DsPIC30
  • *******
  • Mensajes: 3865
Re: Ayuda en codigo GPS
« Respuesta #1 en: 16 de Julio de 2009, 02:48:33 »
Que formato utiliza?Si el formato es siempre del tipo XX'YY.ZZZZ, y teniendo en tu string GPS.Lat el valor, por ejemplo: 41097854, sólo te resta hacer:

Código: Visual Basic
  1. ..
  2. Dim StrOut as string
  3.  
  4. StrOut = Left(GPS.Lat, 2) & "'" & Mid(GPS.Lat, 3, 2) & "." & Right(GPS.Lat, 4)
"All of the books in the world contain no more information than is broadcast as video in a single large American city in a single year. Not all bits have equal value."  -- Carl Sagan

Sólo responderé a mensajes personales, por asuntos personales. El resto de las consultas DEBEN ser escritas en el foro público. Gracias.

Desconectado camolas

  • PIC10
  • *
  • Mensajes: 22
Re: Ayuda en codigo GPS
« Respuesta #2 en: 07 de Septiembre de 2009, 17:42:30 »
Gracias  :-/