Module: ADSB::Messages::Velocity
- Defined in:
- lib/adsb/messages/velocity.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#heading ⇒ Object
Get the reported heading.
-
#velocity ⇒ Object
Get the reported velocity.
Class Method Details
.extended(message) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/adsb/messages/velocity.rb', line 15 def self.extended west_east_velocity = signed_velocity(.data[14..23].to_i(2), .data[13].to_i(2)) .instance_variable_set(:@west_east_velocity, west_east_velocity) south_north_velocity = signed_velocity(.data[25..34].to_i(2), .data[24].to_i(2)) .instance_variable_set(:@south_north_velocity, south_north_velocity) end |
Instance Method Details
#heading ⇒ Object
Get the reported heading.
Examples
= ADSB::Message.new('8D485020994409940838175B284F')
heading = .heading
10 11 12 13 |
# File 'lib/adsb/messages/velocity.rb', line 10 def heading heading = Math.atan2(@west_east_velocity, @south_north_velocity) * 360 / (2 * Math::PI) return heading < 0 ? heading + 360 : heading end |
#velocity ⇒ Object
Get the reported velocity.
Examples
= ADSB::Message.new('8D485020994409940838175B284F')
velocity = .velocity
27 28 29 |
# File 'lib/adsb/messages/velocity.rb', line 27 def velocity return Math.sqrt(@west_east_velocity ** 2 + @south_north_velocity ** 2) end |