Module: ADSB::Messages::Velocity

Defined in:
lib/adsb/messages/velocity.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(message) ⇒ Object



15
16
17
18
19
20
# File 'lib/adsb/messages/velocity.rb', line 15

def self.extended message
  west_east_velocity = signed_velocity(message.data[14..23].to_i(2), message.data[13].to_i(2))
  message.instance_variable_set(:@west_east_velocity, west_east_velocity)
  south_north_velocity = signed_velocity(message.data[25..34].to_i(2), message.data[24].to_i(2))
  message.instance_variable_set(:@south_north_velocity, south_north_velocity)
end

Instance Method Details

#headingObject

Get the reported heading.

Examples

message = ADSB::Message.new('8D485020994409940838175B284F')
heading = message.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

#velocityObject

Get the reported velocity.

Examples

message = ADSB::Message.new('8D485020994409940838175B284F')
velocity = message.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