Class: Spektrum::Log::GPSRecord1

Inherits:
Record
  • Object
show all
Defined in:
lib/spektrum/log/records.rb

Instance Attribute Summary

Attributes inherited from Record

#timestamp

Instance Method Summary collapse

Methods inherited from Record

#raw_hex_string, #type

Constructor Details

#initialize(timestamp, raw_data) ⇒ GPSRecord1

Returns a new instance of GPSRecord1.



192
193
194
# File 'lib/spektrum/log/records.rb', line 192

def initialize(timestamp, raw_data)
  super timestamp, raw_data
end

Instance Method Details

#altitude(unit = :feet) ⇒ Float

Note:

This conversion has been verified via Spektrum STi

Gets the altitude, in desired unit.

Parameters:

  • unit (defaults to: :feet)

    one of :feet, :meters to define desired unit

Returns:

  • (Float)

    altitude in the desired unit



201
202
203
204
205
206
207
208
209
210
211
# File 'lib/spektrum/log/records.rb', line 201

def altitude(unit = :feet)
  @altitude ||= (hex_byte_field(3) * 100) + hex_byte_field(2)
  case unit
  when :feet
    @altitude * 0.32808399
  when :meters
    @altitude / 10.0
  else
    @altitude
  end
end

#coordinateArray

Gets a composite coordinate value, containing longitude, latitude and altitude in an array.

Parameters:

  • unit

    unit for altitude, see #altitude for options

Returns:



237
238
239
# File 'lib/spektrum/log/records.rb', line 237

def coordinate
  [longitude, latitude, altitude(:meters)]
end

#headingFloat

Note:

This conversion has been verified via Spektrum STi

Gets the current heading, in degrees.

Returns:

  • (Float)

    current heading



245
246
247
# File 'lib/spektrum/log/records.rb', line 245

def heading
  @heading ||= (hex_byte_field(13) * 10) + (hex_byte_field(12) / 10.0)
end

#latitudeFloat

Note:

This conversion has been verified via Spektrum STi

Note:

XXX Negative values are currently not supported!! XXX

Gets the latitude. Positive values indicate North latitudes, negative values indicate South.

Returns:

  • (Float)

    latitude in decimal-degress



219
220
221
# File 'lib/spektrum/log/records.rb', line 219

def latitude
  @latitude ||= build_latitude
end

#longitudeFloat

Note:

This conversion has been verified via Spektrum STi

Gets the longitude. Positive values indicate East longitudes, negative values indicate West.

Returns:

  • (Float)

    longitude in decimal-degress



228
229
230
# File 'lib/spektrum/log/records.rb', line 228

def longitude
  @lontitude ||= build_longitude
end

#valid?Boolean

Returns:

  • (Boolean)


249
250
251
# File 'lib/spektrum/log/records.rb', line 249

def valid?
  !(latitude == 0.0 && longitude == 0.0 && altitude == 0.0)
end