www.pudn.com > mo_gps.zip > GGA.cls


VERSION 1.0 CLASS 
BEGIN 
  MultiUse = -1  'True 
END 
Attribute VB_Name = "GPGGA" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = True 
Attribute VB_PredeclaredId = False 
Attribute VB_Exposed = False 
Attribute VB_Ext_KEY = "SavedWithClassBuilder" ,"Yes" 
Attribute VB_Ext_KEY = "Top_Level" ,"Yes" 
'Class name:    GGA.cls 
'Author:        Ray Bivens, Applications Prototype Lab, ESRI 
'Date:          Dec 98 
'Description:   Factors an NMEA (GPS) 'GPGGA' sentence to its string components. 
'Comments:      Create an instance of the class and assign a GPGGA string to the 
'               Sentence property. 
' 
'Revisions: 
 
Option Explicit 
 
'local variables to hold property values 
Private mvarSentence As String 
Private mvarUTC As String 
Private mvarLatitude As String 
Private mvarLatHemis As String 
Private mvarLongitude As String 
Private mvarLonHemis As String 
Private mvarQuality As String 
Private mvarSatsInUse As String 
Private mvarHDOP As String 
Private mvarAltitude As String 
Private mvarSeparationUnits As String 
Private mvarDiffAge As Single 
Private mvarStationID As String 
Private mvarSeparation As String 
Private mvarAltitudeUnits As String 
Private mvarChecksum As String 
 
Public Enum GPGGAError 
    InvalidOrCorruptGPGGA = vbObjectError + 512 + 1 
End Enum 
Public Property Get Checksum() As String 
Attribute Checksum.VB_Description = "Returns the checksum of the NMEA string." 
    Checksum = mvarChecksum 
End Property 
Public Property Get AltitudeUnits() As String 
Attribute AltitudeUnits.VB_Description = "Returns units of altitude (M = Meters)." 
    AltitudeUnits = mvarAltitudeUnits 
End Property 
 
Public Property Get Separation() As String 
Attribute Separation.VB_Description = "Returns geoidal separation (distance between WGS84 ellipsoid and mean sea level)." 
    Separation = mvarSeparation 
End Property 
 
Public Property Get StationID() As String 
Attribute StationID.VB_Description = "Returns differential reference station ID." 
    StationID = mvarStationID 
End Property 
 
Public Property Get DiffAge() As String 
Attribute DiffAge.VB_Description = "Returns the age in seconds since last update from differential reference station." 
    DiffAge = mvarDiffAge 
End Property 
 
Public Property Get SeparationUnits() As String 
Attribute SeparationUnits.VB_Description = "Returns units of geoidal separation (M = Meters)." 
    SeparationUnits = mvarSeparationUnits 
End Property 
 
Public Property Get Altitude() As String 
Attribute Altitude.VB_Description = "Returns the antenna altitude above/below mean sea level (geoid)." 
    Altitude = mvarAltitude 
End Property 
 
Public Property Get HDOP() As String 
Attribute HDOP.VB_Description = "Returns the Horizontal Dilution of Precision (HDOP)." 
    HDOP = mvarHDOP 
End Property 
 
 
Public Property Get SatsInUse() As String 
Attribute SatsInUse.VB_Description = "Returns the number of satellite vehicles (SVs) in use (not those in view)." 
    SatsInUse = mvarSatsInUse 
End Property 
 
Public Property Get Quality() As String 
Attribute Quality.VB_Description = "Returns a GPS quality indicator: 0 = invalid; 1 = GPS fix; 2 = Differential GPS fix. " 
    Quality = mvarQuality 
End Property 
 
Public Property Get LonHemis() As String 
Attribute LonHemis.VB_Description = "Returns a boolean type indicating east (true) or west (false) longitude." 
    LonHemis = mvarLonHemis 
End Property 
 
Public Property Get Longitude() As String 
Attribute Longitude.VB_Description = "Returns theLongitude of the object." 
    Longitude = mvarLongitude 
End Property 
 
Public Property Get LatHemis() As String 
Attribute LatHemis.VB_Description = "Returns a boolean type indicating north (true) or south (false) latitude." 
    LatHemis = mvarLatHemis 
End Property 
 
Public Property Get Latitude() As String 
Attribute Latitude.VB_Description = "Returns the Latitude of the object." 
    Latitude = mvarLatitude 
End Property 
 
Public Property Get UTC() As String 
Attribute UTC.VB_Description = "Returns the UTC from the object." 
    UTC = mvarUTC 
End Property 
 
Public Property Let Sentence(ByVal GGA_Sentence As String) 
Attribute Sentence.VB_Description = "Sets/Returns NMEA sentence for object." 
    Dim Utils As New CParseUtils 
     
        'check for correct header and number 
        'of place holders in sentence first... 
        If Utils.Parse(GGA_Sentence, 1) = "$GPGGA" And Utils.CountParts(GGA_Sentence) = 15 Then 
         
            Dim sUTC As String 
            Dim sLatitude As String 
            Dim sLatHemis As String 
            Dim sLongitude As String 
            Dim sLonHemis As String 
            Dim sQuality As String 
            Dim sSatsInUse As String 
            Dim sHDOP As String 
            Dim sAltitude As String 
            Dim sSeparationUnits As String 
            Dim sDiffAge As String 
            Dim sStationID As String 
            Dim sSeparation As String 
            Dim sAltitudeUnits As String 
            Dim sTempStationID As String 
            Dim sChecksum As String 
            Dim sTempChecksum As String 
             
            ' assign value to local variable... 
            mvarSentence = GGA_Sentence 
             
            ' parse NMEA sentence and check quality 
            ' if qc conditions not met, leave var as empty... 
            sUTC = Utils.Parse(mvarSentence, 2)             'UTC 
                If IsNumeric(sUTC) Then 
                    mvarUTC = sUTC 
                End If 
                 
            sLatitude = Utils.Parse(mvarSentence, 3)        'Latitude 
                If IsNumeric(sLatitude) Then 
                    mvarLatitude = sLatitude 
                End If 
                 
            sLatHemis = Utils.Parse(mvarSentence, 4)        'LatHemis 
                If sLatHemis = "N" Or sLatHemis = "S" Then 
                    mvarLatHemis = sLatHemis 
                End If 
                 
            sLongitude = Utils.Parse(mvarSentence, 5)       'Longitude 
                If IsNumeric(sLongitude) Then 
                    mvarLongitude = sLongitude 
                End If 
                 
            sLonHemis = Utils.Parse(mvarSentence, 6)        'LonHemis 
                If sLonHemis = "E" Or sLonHemis = "W" Then 
                    mvarLonHemis = sLonHemis 
                End If 
                 
            sQuality = Utils.Parse(mvarSentence, 7)         'Quality 
                If IsNumeric(sQuality) Then 
                    mvarQuality = sQuality 
                End If 
                 
            sSatsInUse = Utils.Parse(mvarSentence, 8)       'SatsInUse 
                If IsNumeric(sSatsInUse) Then 
                    mvarSatsInUse = sSatsInUse 
                End If 
                 
            sHDOP = Utils.Parse(mvarSentence, 9)            'HDOP 
                If IsNumeric(sHDOP) Then 
                    mvarHDOP = sHDOP 
                End If 
                 
            sAltitude = Utils.Parse(mvarSentence, 10)       'Altitude 
                If IsNumeric(sAltitude) Then 
                    mvarAltitude = sAltitude 
                End If 
                 
            sAltitudeUnits = Utils.Parse(mvarSentence, 11)  'AltitudeUnits 
            mvarAltitudeUnits = sAltitudeUnits 
                 
            sSeparation = Utils.Parse(mvarSentence, 12)     'Separation 
                If IsNumeric(sSeparation) Then 
                    mvarSeparation = sSeparation 
                End If 
                 
            sSeparationUnits = Utils.Parse(mvarSentence, 13) 'SeparationUnits 
            mvarSeparationUnits = sSeparationUnits 
                 
            sDiffAge = Utils.Parse(mvarSentence, 14)        'DiffAge 
                If IsNumeric(sDiffAge) Then 
                    mvarDiffAge = sDiffAge 
            End If 
                 
            sTempStationID = Utils.Parse(mvarSentence, 15)   'temp var 
            sStationID = Utils.Parse(sTempStationID, 1, "*") 'StationID 
            mvarStationID = sStationID 
                 
            sTempChecksum = Utils.Parse(mvarSentence, 15)   'temp var 
            sChecksum = Utils.Parse(sTempChecksum, 2, "*")  'Checksum 
            mvarChecksum = sChecksum 
                     
        Else 
            Err.Raise InvalidOrCorruptGPGGA, "GPGGA::Sentence", "Invalid or corrupt GPGGA sentence." 
        End If 
         
    Set Utils = Nothing 
End Property 
 
Public Property Get Sentence() As String 
    Sentence = mvarSentence 
End Property