Class: Spektrum::Log::GPSRecord1
- Defined in:
- lib/spektrum/log/records.rb
Instance Attribute Summary
Attributes inherited from Record
Instance Method Summary collapse
-
#altitude(unit = :feet) ⇒ Float
Gets the altitude, in desired unit.
-
#coordinate ⇒ Array
Gets a composite coordinate value, containing longitude, latitude and altitude in an array.
-
#heading ⇒ Float
Gets the current heading, in degrees.
-
#initialize(timestamp, raw_data) ⇒ GPSRecord1
constructor
A new instance of GPSRecord1.
-
#latitude ⇒ Float
Gets the latitude.
-
#longitude ⇒ Float
Gets the longitude.
- #valid? ⇒ Boolean
Methods inherited from Record
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(, raw_data) super , raw_data end |
Instance Method Details
#altitude(unit = :feet) ⇒ Float
This conversion has been verified via Spektrum STi
Gets the altitude, in 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 |
#coordinate ⇒ Array
Gets a composite coordinate value, containing longitude, latitude and altitude in an array.
237 238 239 |
# File 'lib/spektrum/log/records.rb', line 237 def coordinate [longitude, latitude, altitude(:meters)] end |
#heading ⇒ Float
This conversion has been verified via Spektrum STi
Gets the current heading, in degrees.
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 |
#latitude ⇒ Float
This conversion has been verified via Spektrum STi
XXX Negative values are currently not supported!! XXX
Gets the latitude. Positive values indicate North latitudes, negative values indicate South.
219 220 221 |
# File 'lib/spektrum/log/records.rb', line 219 def latitude @latitude ||= build_latitude end |
#longitude ⇒ Float
This conversion has been verified via Spektrum STi
Gets the longitude. Positive values indicate East longitudes, negative values indicate West.
228 229 230 |
# File 'lib/spektrum/log/records.rb', line 228 def longitude @lontitude ||= build_longitude end |
#valid? ⇒ Boolean
249 250 251 |
# File 'lib/spektrum/log/records.rb', line 249 def valid? !(latitude == 0.0 && longitude == 0.0 && altitude == 0.0) end |