blib/lib/GPS/OID.pm

filter: Statementstmt 100% 53 / 53 Branchbran 91.6% 11 / 12 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 11 / 11 Podpod 100% 9 / 9 totaltotal 94.4% 85 / 90 CC 8 SCAR 7.0
CC
8
Cov
96%
overload
3.0
data
3.0
new
2.0
CRAP 2.0
↑ Summary
1 package GPS::OID;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $VERSION = '0.07';
6  
7 =head1 NAME
8  
9 GPS::OID - Package for GPS PRN - Object ID conversions.
10  
11 =head1 SYNOPSIS
12  
13 use GPS::OID;
14 my $obj = GPS::OID->new();
15 print "PRN: ", $obj->prn_oid(22231), "\n";
16 print "OID: ", $obj->oid_prn(1), "\n";
17  
18 =head1 DESCRIPTION
19  
20 This module maps GPS PRN number to Satellite OID and vice versa.
21  
22 =head2 Object Identification Number (OID)
23  
24 The catalog number assigned to the object by the US Air Force. The numbers are assigned sequentially as objects are cataloged. This is the most common way to search for TLE data on this site.
25  
26 Object numbers less then 10000 are always aligned to the right, and padded with zeros or spaces to the left.
27  
28 =head2 Pseudo Random Numbers (PRNs)
29  
30 GPS satellites are identified by the receiver by means of PRN-numbers. Real GPS satellites are numbered from 1 - 32. WAAS/EGNOS satellites and other pseudolites are assigned higher numbers. The PRN-numbers of the satellites appear on the satellite view screens of many GPS receivers.
31  
32 =head1 CONVENTIONS
33  
34 Function naming convention is "format of the return" underscore "format of the parameters."
35  
36 =head1 CONSTRUCTOR
37  
38 =head2 new
39  
40 The new() constructor
41  
42 my $obj = GPS::OID->new();
43  
44 =cut
45  
46 1 ▶sub new {
Subroutine new: called CC=2 SCAR=7.1
Pod documented
47 1 my $this = shift();
48 1 ▶ my $class = ref($this) || $this;
Condition33%1/3
ref $this || $this
l!l&&r!l&&!r
010
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table33%1/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
49 1 my $self = {};
50 1 bless $self, $class;
51 1 $self->initialize(@_);
52 1 return $self;
53 }
54  
55 =head1 METHODS
56  
57 =head2 initialize
58  
59 =cut
60  
61 1 ▶sub initialize {
Subroutine initialize: called CC=1 SCAR=0.0
Pod documented
62 1 my $self=shift;
63 1 %$self=@_;
64 }
65  
66 =head2 prn_oid
67  
68 PRN given Object ID.
69  
70 my $prn=prn_oid(22231);
71  
72 =cut
73  
74 7 ▶sub prn_oid {
Subroutine prn_oid: called CC=1 SCAR=0.0
Pod documented
75 7 my $self=shift();
76 7 my $param=int(shift());
77 7 my $data=$self->data;
78 7 return $data->{$param};
79 }
80  
81 =head2 oid_prn
82  
83 Object ID given PRN.
84  
85 my $oid=oid_prn(1);
86  
87 =cut
88  
89 7 ▶sub oid_prn {
Subroutine oid_prn: called CC=1 SCAR=0.0
Pod documented
90 7 my $self=shift();
91 7 my $param=int(shift());
92 7 my $data=$self->data;
93 7 $data={map {int($data->{$_}), $_} keys %$data};
94 7 return $data->{$param};
95 }
96  
97 =head2 listprn
98  
99 List all known PRNs.
100  
101 my @prn=$obj->listprn;
102 my $prn=$obj->listprn;
103  
104 =cut
105  
106 2 ▶sub listprn {
Subroutine listprn: called CC=2 SCAR=6.9
Pod documented
107 2 my $self=shift();
108 2 my %list=$self->data;
109 2 my @list=sort {$a <=> $b} values %list;
110 2 ▶ return wantarray ? @list : \@list;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 1 2
111 }
112  
113 =head2 listoid
114  
115 List all known OIDs.
116  
117 my @oid=$obj->listoid;
118 my $oid=$obj->listoid;
119  
120 =cut
121  
122 2 ▶sub listoid {
Subroutine listoid: called CC=2 SCAR=6.9
Pod documented
123 2 my $self=shift();
124 2 my %list=$self->data;
125 2 my @list=sort {$a <=> $b} keys %list;
126 2 ▶ return wantarray ? @list : \@list;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 1 2
127 }
128  
129 =head2 data
130  
131 OID to PRN hash reference
132  
133 my $data=$self->data;
134  
135 =cut
136  
137 20 ▶sub data {
Subroutine data: called CC=3 SCAR=11.0
Pod documented
138 20 my $self=shift();
139 20 ▶ unless (defined($self->{'data'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"data"}) 2 18 20
140 2 my %data=(
141 22231 => q{01},
142 28474 => q{02},
143 23833 => q{03},
144 22877 => q{04},
145 22779 => q{05},
146 23027 => q{06},
147 22657 => q{07},
148 25030 => q{08},
149 22700 => q{09},
150 23953 => q{10},
151 25933 => q{11},
152 29601 => q{12},
153 24876 => q{13},
154 26605 => q{14},
155 20830 => q{15},
156 27663 => q{16},
157 28874 => q{17},
158 26690 => q{18},
159 28190 => q{19},
160 26360 => q{20},
161 27704 => q{21},
162 28129 => q{22},
163 28361 => q{23},
164 21552 => q{24},
165 21890 => q{25},
166 22014 => q{26},
167 22108 => q{27},
168 26407 => q{28},
169 22275 => q{29},
170 24320 => q{30},
171 29486 => q{31},
172 24307 => q{120}, #EGNOS Inmarsat 3F2 AOR-E 15.5°W Garmin 33
173 28899 => q{121}, # Inmarsat 4F2 AOR-E 53.0°W Garmin 34
174 24819 => q{122}, #WAAS Inmarsat 3F4 AOR-W 142.0°W Garmin 35
175 26863 => q{124}, #EGNOS ARTEMIS 21.5°E Garmin 37
176 #23839 => q{126}, # Inmarsat 3F1 IOR-W 64.0°E Garmin 39
177 25153 => q{126}, #EGNOS Inmarsat 3F5 IOR-W 25.0°E Garmin 39
178 28622 => q{129}, #MSAS MTSAT-1 140.0°E Garmin 42
179 #00000 => q{131}, #ESTB Inmarsat-III IOR-E 65.5°E Garmin 44
180 24674 => q{134}, #WAAS Inmarsat 3F3 POR 178.0°E Garmin 47
181 28884 => q{135}, #WAAS Galaxy 15 (PanAm) 133.0°W Garmin 48
182 28937 => q{137}, #MSAS MTSAT-2 Garmin 50
183 28868 => q{138}, #WAAS Anik F1R (Telsat) 107.3°W Garmin 51
184 );
185 2 $self->{'data'}=\%data;
186 }
187 20 ▶ return wantarray ? %{$self->{'data'}} : $self->{'data'};
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 4 16 20
188 }
189  
190 =head2 overload
191  
192 Adds or overloads new OID/PRN pairs.
193  
194 $obj->overload($oid=>$prn);
195  
196 =cut
197  
198 2 ▶sub overload {
Subroutine overload: called CC=3 SCAR=11.0
Pod documented
199 2 my $self=shift();
200 2 my $oid=shift();
201 2 my $prn=shift();
202 2 my $data=$self->data;
203 2 my $return=q{added};
204 2 ▶ if (exists($data->{$oid})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $data->{$oid}) 1 1 2
205 1 $return='overloaded';
206 }
207 2 $data->{$oid}=$prn;
208 2 ▶ return defined($data->{$oid}) ? $return : undef();
Branch: 1 branch
BranchTrueFalseTotal
defined $data->{$oid} ? : 2 0 2
209 }
210  
211 =head2 reset
212  
213 Resets overloaded OID/PRN pairs to package defaults.
214  
215 $obj->reset;
216  
217 =cut
218  
219 1 ▶sub reset {
Subroutine reset: called CC=1 SCAR=0.0
Pod documented
220 1 my $self=shift();
221 1 undef($self->{'data'});
222 }
223  
224 1 1;
225  
226 __END__
↑ Summary