nmea_parser 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/nmea_parser.rb +46 -1
- metadata +1 -1
- metadata.gz.sig +0 -0
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 628a106e7d8005139a7c2bfc63fc3346715580b3
         | 
| 4 | 
            +
              data.tar.gz: 570de31b27695febccb16bb10bc8ab8c14408ba8
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: dbabfc1ce0be0f985658a670db797ff0d5569bb326cb4da36ec1819f4e9f0cd000a80689035b68c32292f9d8ad422b03ea32edaf9be26509b3e5c5033630cdb4
         | 
| 7 | 
            +
              data.tar.gz: de2cdc445c31b5afc18018ee781689d2dfa6d9c77a209ff33bfdb8bbeea0609b0bc53ecb33a0b44abd4ab9a3d307839f9e5880d7e87f5ee9da6d50ded91368fd
         | 
    
        checksums.yaml.gz.sig
    CHANGED
    
    | Binary file | 
    
        data.tar.gz.sig
    CHANGED
    
    | Binary file | 
    
        data/lib/nmea_parser.rb
    CHANGED
    
    | @@ -3,6 +3,7 @@ | |
| 3 3 | 
             
            # file: nmea_parser.rb
         | 
| 4 4 |  | 
| 5 5 | 
             
            require 'time'
         | 
| 6 | 
            +
            require 'date'
         | 
| 6 7 | 
             
            require 'immutable_struct'
         | 
| 7 8 |  | 
| 8 9 | 
             
            class NMEAParser
         | 
| @@ -22,16 +23,60 @@ class NMEAParser | |
| 22 23 | 
             
                a = raw_line.split(',')
         | 
| 23 24 |  | 
| 24 25 | 
             
                case msgcode
         | 
| 26 | 
            +
             | 
| 25 27 | 
             
                  when /GGA/
         | 
| 28 | 
            +
             | 
| 26 29 | 
             
                    _, raw_time, raw_lat, ns, raw_lon, ew = a
         | 
| 27 30 | 
             
                    @time, @latitude, @longitude = Time.parse(raw_time), 
         | 
| 28 31 | 
             
                                           decimalize(raw_lat, ns), decimalize(raw_lon, ew)
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                    # additional data captured 
         | 
| 34 | 
            +
                    #
         | 
| 35 | 
            +
                    # Fix quality, Number of satellites being tracked, Horizontal dilution
         | 
| 36 | 
            +
                    # of position, Altitude (Meters, above mean sea level), Height of 
         | 
| 37 | 
            +
                    # geoid, time in seconds since last DGPS update, DGPS station ID number
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                    @quality, @num_sat, @hdop, @altitude, @alt_unit, @height_geoid,
         | 
| 40 | 
            +
                    @height_geoid_unit, @last_dgps, @dgps = a[6..-2] << a[-1][/^[^\*]+/]
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                  when /RMC/
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                    _, raw_time, _, raw_lat, ns, raw_lon, ew = a
         | 
| 45 | 
            +
                    @time, @latitude, @longitude = Time.parse(raw_time), 
         | 
| 46 | 
            +
                                           decimalize(raw_lat, ns), decimalize(raw_lon, ew)
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                    # additional data captured 
         | 
| 49 | 
            +
                    #
         | 
| 50 | 
            +
                    # Speed over the ground in knots, Track angle in degrees True, 
         | 
| 51 | 
            +
                    # Date, Magnetic Variation, 
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                    @speed, @course = a[7..8]
         | 
| 54 | 
            +
                    @date, @variation = Date.parse(a[9]), a[10]
         | 
| 55 | 
            +
                    @var_direction =  a[-1][/^[^\*]+/]
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                  when /VTG/
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                    # data captured      
         | 
| 60 | 
            +
                  
         | 
| 61 | 
            +
                    # True track made good (degrees), Magnetic track made good, 
         | 
| 62 | 
            +
                    # Ground speed (knots), Ground speed (Kilometers per hour)
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                    @track, @mag_track, @speed, @speed_kph = a.values_at(1,3,5,7)
         | 
| 65 | 
            +
              
         | 
| 29 66 | 
             
                end
         | 
| 30 67 |  | 
| 31 68 | 
             
              end
         | 
| 32 69 |  | 
| 33 70 | 
             
              def to_h()  
         | 
| 34 | 
            -
                { | 
| 71 | 
            +
                {
         | 
| 72 | 
            +
                  time: @time, latitude: @latitude, longitude: @longitude, 
         | 
| 73 | 
            +
                  quality: @quality, num_sat: @num_sat, hdop: @hdop, altitude: @altitude,
         | 
| 74 | 
            +
                  alt_unit: @alt_unit, height_geoid: @height_geoid, 
         | 
| 75 | 
            +
                  height_geoid_unit: @height_geoid_unit, last_dgps: @last_dgps, 
         | 
| 76 | 
            +
                  dgps: @dgps, speed: @speed, course: @course, date: @date, 
         | 
| 77 | 
            +
                  variation: @variation, var_direction: @var_direction, track: @track, 
         | 
| 78 | 
            +
                  mag_track: @mag_track, speed: @speed, speed_kph: @speed_kph
         | 
| 79 | 
            +
                }
         | 
| 35 80 | 
             
              end
         | 
| 36 81 |  | 
| 37 82 | 
             
              def to_struct()
         | 
    
        metadata
    CHANGED
    
    
    
        metadata.gz.sig
    CHANGED
    
    | Binary file |