lib/OpenSky/API/Core/StateVector.pm

filter: Statementstmt 55.0% 11 / 20 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 40.0% 2 / 5 Podpod 100% 2 / 2 totaltotal 40.5% 15 / 37 CC 5 SCAR 23.7
CC
5
Cov
39%
category_name
20.0
position_source_name
6.0
_get_params
2.0
CRAP 10.7
« blib/lib/OpenSky/API.pm ↑ Summary blib/lib/OpenSky/API/Core/StateVector.pm »
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.002';
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 5 extends 'OpenSky::API::Core';
9  
10 5 my @PARAMS = qw(
11 icao24
12 callsign
13 origin_country
14 time_position
15 last_contact
16 longitude
17 latitude
18 baro_altitude
19 on_ground
20 velocity
21 true_track
22 vertical_rate
23 sensors
24 geo_altitude
25 squawk
26 spi
27 position_source
28 category
29 );
30  
31 5 has [@PARAMS] => ( is => 'ro', required => 1 );
32  
33 ▶sub _get_params ($class) {
Subroutine _get_params: not called CC=1 SCAR=6.9
34 0 return @PARAMS;
35 }
36  
37 ▶sub category_name ($self) {
Subroutine category_name: not called CC=4 SCAR=30.0
Pod documented
38 0 ▶ my $category = $self->category // 0;
Condition0%0/2
$self->category // 0
l!l
00
MC/DC0%0/1
$self->category // 0
$self->category
Truth table0%0/2
A
A= $self->category
Aresult
11
00
39 0 ▶ $category = 0 if $category > 20;
Branch: 1 branch
BranchTrueFalseTotal
if $category > 20 0 0 0
40 0 ▶ return '' unless $category;
Branch: 1 branch
BranchTrueFalseTotal
unless $category 0 0 0
41 0 my @names = (
42 'No information at all',
43 'No ADS-B Emitter Category Information',
44 'Light (< 15500 lbs)',
45 'Small (15500 to 75000 lbs)',
46 'Large (75000 to 300000 lbs)',
47 'High Vortex Large (aircraft such as B-757)',
48 'Heavy (> 300000 lbs)',
49 'High Performance (> 5g acceleration and 400 kts)',
50 'Rotorcraft',
51 'Glider / sailplane',
52 'Lighter-than-air',
53 'Parachutist / Skydiver',
54 'Ultralight / hang-glider / paraglider',
55 'Reserved',
56 'Unmanned Aerial Vehicle',
57 'Space / Trans-atmospheric vehicle',
58 'Surface Vehicle – Emergency Vehicle',
59 'Surface Vehicle – Service Vehicle',
60 'Point Obstacle (includes tethered balloons)',
61 'Cluster Obstacle',
62 'Line Obstacle',
63 );
64 0 return $names[$category];
65 }
66  
67 ▶sub position_source_name ($self) {
Subroutine position_source_name: not called CC=2 SCAR=17.9
Pod documented
68 0 ▶ my $source = $self->position_source // return 'Uknown';
Condition0%0/2
$self->position_source // (return "Uknown")
l!l
00
MC/DC0%0/1
$self->position_source // (return "Uknown")
$self->position_source
Truth table0%0/2
A
A= $self->position_source
Aresult
11
00
69 0 my @sources = (
70 'ADS-B',
71 'ASTERIX',
72 'MLAT',
73 'FLARM',
74 );
75 0 return $sources[$source];
76 }
77  
78 5 __PACKAGE__->meta->make_immutable;
79  
80 __END__
81  
82 =pod
83  
84 =encoding UTF-8
85  
86 =head1 NAME
87  
88 OpenSky::API::Core::StateVector - A class representing a state from the OpenSky Network API
89  
90 =head1 VERSION
91  
92 version 0.002
93  
94 =head1 SYNOPSIS
95  
96 use OpenSky::API;
97 my $opensky = OpenSky::API->new;
98 my $states = $opensky->get_states;
99 my $state = $states->[0];
100 say $state->callsign;
101  
102 =head1 DESCRIPTION
103  
104 This class is not to be instantiated directly. It is a read-only class representing an
105 L<OpenSky state vector|https://openskynetwork.github.io/opensky-api/index.html#state-vectors>.
106  
107 All attributes are read-only.
108  
109 =head2 C<icao24>
110  
111 Unique ICAO 24-bit address of the transponder in hex string representation.
112  
113 =head2 C<callsign>
114  
115 Callsign of the vehicle (8 chars). Can be null if no callsign has been received.
116  
117 =head2 C<origin_country>
118  
119 Country name inferred from the ICAO 24-bit address.
120  
121 =head2 C<time_position>
122  
123 Unix timestamp (seconds) for the last position update. Can be null if no position report was received by OpenSky within the past 15s.
124  
125 =head2 C<last_contact>
126  
127 Unix timestamp (seconds) for the last update in general. This field is updated for any new, valid message received from the transponder.
128  
129 =head2 C<longitude>
130  
131 WGS-84 longitude in decimal degrees. Can be null.
132  
133 =head2 C<latitude>
134  
135 WGS-84 latitude in decimal degrees. Can be null.
136  
137 =head2 C<baro_altitude>
138  
139 Barometric altitude in meters. Can be null.
140  
141 =head2 C<on_ground>
142  
143 Boolean value which indicates if the position was retrieved from a surface position report.
144  
145 =head2 C<velocity>
146  
147 Velocity over ground in m/s. Can be null.
148  
149 =head2 C<true_track>
150  
151 True track in decimal degrees clockwise from north (north=0°). Can be null.
152  
153 =head2 C<vertical_rate>
154  
155 Vertical rate in m/s. A positive value indicates that the airplane is climbing, a negative value indicates that it descends. Can be null.
156  
157 =head2 C<sensors>
158  
159 IDs of the receivers which contributed to this state vector. Is null if no filtering for sensor was used in the request.
160  
161 =head2 C<geo_altitude>
162  
163 Geometric altitude in meters. Can be null.
164  
165 =head2 C<squawk>
166  
167 The transponder code aka Squawk. Can be null.
168  
169 =head2 C<spi>
170  
171 Whether flight status indicates special purpose indicator.
172  
173 =head2 C<position_source_name>
174  
175 Returns the name of the position source. Can be an empty string.
176  
177 =head2 C<position_source>
178  
179 Integer. Origin of this state’s position:
180  
181 0 = ADS-B
182 1 = ASTERIX
183 2 = MLAT
184 3 = FLARM
185  
186 =head2 C<category_name>
187  
188 Returns the name of the aircraft category. Can be an empty string.
189  
190 If C<< $opensky->get_states >> is called without C<extended> set to true, this
191 method will always return an empty string.
192  
193 =head2 C<category>
194  
195 Integer. Aircraft category. Can be null.
196  
197 0 = No information at all
198 1 = No ADS-B Emitter Category Information
199 2 = Light (< 15500 lbs)
200 3 = Small (15500 to 75000 lbs)
201 4 = Large (75000 to 300000 lbs)
202 5 = High Vortex Large (aircraft such as B-757)
203 6 = Heavy (> 300000 lbs)
204 7 = High Performance (> 5g acceleration and 400 kts)
205 8 = Rotorcraft
206 9 = Glider / sailplane
207 10 = Lighter-than-air
208 11 = Parachutist / Skydiver
209 12 = Ultralight / hang-glider / paraglider
210 13 = Reserved
211 14 = Unmanned Aerial Vehicle
212 15 = Space / Trans-atmospheric vehicle
213 16 = Surface Vehicle – Emergency Vehicle
214 17 = Surface Vehicle – Service Vehicle
215 18 = Point Obstacle (includes tethered balloons)
216 19 = Cluster Obstacle
217 20 = Line Obstacle
218  
219 =head1 AUTHOR
220  
221 Curtis "Ovid" Poe <curtis.poe@gmail.com>
222  
223 =head1 COPYRIGHT AND LICENSE
224  
225 This software is Copyright (c) 2023 by Curtis "Ovid" Poe.
226  
227 This is free software, licensed under:
228  
229 The Artistic License 2.0 (GPL Compatible)
230  
231 =cut
« blib/lib/OpenSky/API.pm ↑ Summary blib/lib/OpenSky/API/Core/StateVector.pm »