| 1 | # ABSTRACT: A class representing a state from the OpenSky Network API | ||||||||||||
| 2 | |||||||||||||
| 3 | package OpenSky::API::Core::StateVector; | ||||||||||||
| 4 | |||||||||||||
| 5 | 5 | our $VERSION = '0.005'; | |||||||||||
| 6 | 5 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 5 | ▶ | use experimental qw(signatures); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | |||||||||||||
| 9 | 5 | my @PARAMS = qw( | |||||||||||
| 10 | icao24 | ||||||||||||
| 11 | callsign | ||||||||||||
| 12 | origin_country | ||||||||||||
| 13 | time_position | ||||||||||||
| 14 | last_contact | ||||||||||||
| 15 | longitude | ||||||||||||
| 16 | latitude | ||||||||||||
| 17 | baro_altitude | ||||||||||||
| 18 | on_ground | ||||||||||||
| 19 | velocity | ||||||||||||
| 20 | true_track | ||||||||||||
| 21 | vertical_rate | ||||||||||||
| 22 | sensors | ||||||||||||
| 23 | geo_altitude | ||||||||||||
| 24 | squawk | ||||||||||||
| 25 | spi | ||||||||||||
| 26 | position_source | ||||||||||||
| 27 | category | ||||||||||||
| 28 | ); | ||||||||||||
| 29 | |||||||||||||
| 30 | 0 | ▶ | around 'BUILDARGS' => sub ( $orig, $class, $state ) { | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 31 | 0 | my %value_for; | |||||||||||
| 32 | 0 | @value_for{ $class->_get_params } = @$state; | |||||||||||
| 33 | 0 | return $class->$orig(%value_for); | |||||||||||
| 34 | 5 | }; | |||||||||||
| 35 | |||||||||||||
| 36 | 5 | has [@PARAMS] => ( is => 'ro', required => 1 ); | |||||||||||
| 37 | |||||||||||||
| 38 | 0 | ▶ | sub _get_params ($class) { | ||||||||||
|
Subroutine
_get_params: not called CC=1 SCAR=6.9
| |||||||||||||
| 39 | 0 | return @PARAMS; | |||||||||||
| 40 | } | ||||||||||||
| 41 | |||||||||||||
| 42 | 0 | ▶ | sub category_name ($self) { | ||||||||||
|
Subroutine
category_name: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||
| 43 | 0 | ▶ | my $category = $self->category // 0; | ||||||||||
|
Condition0%0/2
$self->category // 0
MC/DC0%0/1
$self->category // 0
$self->category
Truth table0%0/2
A
A= $self->category
| |||||||||||||
| 44 | 0 | ▶ | $category = 0 if $category > 20; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 45 | 0 | ▶ | return '' unless $category; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 46 | 0 | my @names = ( | |||||||||||
| 47 | 'No information at all', | ||||||||||||
| 48 | 'No ADS-B Emitter Category Information', | ||||||||||||
| 49 | 'Light (< 15500 lbs)', | ||||||||||||
| 50 | 'Small (15500 to 75000 lbs)', | ||||||||||||
| 51 | 'Large (75000 to 300000 lbs)', | ||||||||||||
| 52 | 'High Vortex Large (aircraft such as B-757)', | ||||||||||||
| 53 | 'Heavy (> 300000 lbs)', | ||||||||||||
| 54 | 'High Performance (> 5g acceleration and 400 kts)', | ||||||||||||
| 55 | 'Rotorcraft', | ||||||||||||
| 56 | 'Glider / sailplane', | ||||||||||||
| 57 | 'Lighter-than-air', | ||||||||||||
| 58 | 'Parachutist / Skydiver', | ||||||||||||
| 59 | 'Ultralight / hang-glider / paraglider', | ||||||||||||
| 60 | 'Reserved', | ||||||||||||
| 61 | 'Unmanned Aerial Vehicle', | ||||||||||||
| 62 | 'Space / Trans-atmospheric vehicle', | ||||||||||||
| 63 | 'Surface Vehicle – Emergency Vehicle', | ||||||||||||
| 64 | 'Surface Vehicle – Service Vehicle', | ||||||||||||
| 65 | 'Point Obstacle (includes tethered balloons)', | ||||||||||||
| 66 | 'Cluster Obstacle', | ||||||||||||
| 67 | 'Line Obstacle', | ||||||||||||
| 68 | ); | ||||||||||||
| 69 | 0 | return $names[$category]; | |||||||||||
| 70 | } | ||||||||||||
| 71 | |||||||||||||
| 72 | 0 | ▶ | sub position_source_name ($self) { | ||||||||||
|
Subroutine
position_source_name: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 73 | 0 | ▶ | my $source = $self->position_source // return 'Uknown'; | ||||||||||
|
Condition0%0/2
$self->position_source // (return "Uknown")
MC/DC0%0/1
$self->position_source // (return "Uknown")
$self->position_source
Truth table0%0/2
A
A= $self->position_source
| |||||||||||||
| 74 | 0 | my @sources = ( | |||||||||||
| 75 | 'ADS-B', | ||||||||||||
| 76 | 'ASTERIX', | ||||||||||||
| 77 | 'MLAT', | ||||||||||||
| 78 | 'FLARM', | ||||||||||||
| 79 | ); | ||||||||||||
| 80 | 0 | return $sources[$source]; | |||||||||||
| 81 | } | ||||||||||||
| 82 | |||||||||||||
| 83 | 5 | __PACKAGE__->meta->make_immutable; | |||||||||||
| 84 | |||||||||||||
| 85 | __END__ | ||||||||||||