line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Rinchi Common Image Generator Interface for Perl |
3
|
|
|
|
|
|
|
# Class Identifier: f78ae570-200e-11de-bdb3-001c25551abc |
4
|
|
|
|
|
|
|
# Author: Brian M. Ames |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Rinchi::CIGIPP::EarthReferenceModelDefinition; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
27
|
use 5.006; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
163
|
|
10
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
740
|
|
11
|
1
|
|
|
1
|
|
9
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
12
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2277
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
require Exporter; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
19
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
20
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# This allows declaration use Rinchi::CIGI::AtmosphereControl ':all'; |
23
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
24
|
|
|
|
|
|
|
# will save memory. |
25
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
) ] ); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
our @EXPORT = qw( |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Preloaded methods go here. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 NAME |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Rinchi::CIGIPP::EarthReferenceModelDefinition - Perl extension for the Common |
42
|
|
|
|
|
|
|
Image Generator Interface - Earth Reference Model Definition data packet. |
43
|
|
|
|
|
|
|
data packet. |
44
|
|
|
|
|
|
|
=head1 SYNOPSIS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
use Rinchi::CIGIPP::EarthReferenceModelDefinition; |
47
|
|
|
|
|
|
|
my $erm_def = Rinchi::CIGIPP::EarthReferenceModelDefinition->new(); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$packet_type = $erm_def->packet_type(); |
50
|
|
|
|
|
|
|
$packet_size = $erm_def->packet_size(); |
51
|
|
|
|
|
|
|
$custom_erm = $erm_def->custom_erm(Rinchi::CIGIPP->Enable); |
52
|
|
|
|
|
|
|
$equatorial_radius = $erm_def->equatorial_radius(6.458); |
53
|
|
|
|
|
|
|
$flattening = $erm_def->flattening(32.413); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 DESCRIPTION |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
The default Earth Reference Model (ERM) used for geodetic positioning is WGS |
58
|
|
|
|
|
|
|
84. The Host may define another ERM by sending an Earth Reference Model |
59
|
|
|
|
|
|
|
Definition packet to the IG. This packet defines the equatorial radius and the |
60
|
|
|
|
|
|
|
flattening of the new reference ellipsoid. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
When the IG receives an Earth Reference Model Definition packet, it should set |
63
|
|
|
|
|
|
|
the Earth Reference Model attribute of the Start of Frame packet to |
64
|
|
|
|
|
|
|
Host-Defined (1). If, for some reason, the IG cannot support the ERM defined by |
65
|
|
|
|
|
|
|
the Host, the attribute should be set to WGS 84 (0). |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 EXPORT |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
None by default. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
#============================================================================== |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item new $erm_def = Rinchi::CIGIPP::EarthReferenceModelDefinition->new() |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Constructor for Rinchi::EarthReferenceModelDefinition. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub new { |
80
|
1
|
|
|
1
|
1
|
245
|
my $class = shift; |
81
|
1
|
|
33
|
|
|
8
|
$class = ref($class) || $class; |
82
|
|
|
|
|
|
|
|
83
|
1
|
|
|
|
|
15
|
my $self = { |
84
|
|
|
|
|
|
|
'_Buffer' => '', |
85
|
|
|
|
|
|
|
'_ClassIdent' => 'f78ae570-200e-11de-bdb3-001c25551abc', |
86
|
|
|
|
|
|
|
'_Pack' => 'CCCCIdd', |
87
|
|
|
|
|
|
|
'_Swap1' => 'CCCCVVVVV', |
88
|
|
|
|
|
|
|
'_Swap2' => 'CCCCNNNNN', |
89
|
|
|
|
|
|
|
'packetType' => 19, |
90
|
|
|
|
|
|
|
'packetSize' => 24, |
91
|
|
|
|
|
|
|
'_bitfields1' => 0, # Includes bitfields unused31, and customERM. |
92
|
|
|
|
|
|
|
'customERM' => 0, |
93
|
|
|
|
|
|
|
'_unused32' => 0, |
94
|
|
|
|
|
|
|
'_unused33' => 0, |
95
|
|
|
|
|
|
|
'equatorialRadius' => 0, |
96
|
|
|
|
|
|
|
'flattening' => 0, |
97
|
|
|
|
|
|
|
}; |
98
|
|
|
|
|
|
|
|
99
|
1
|
50
|
|
|
|
13
|
if (@_) { |
100
|
0
|
0
|
|
|
|
0
|
if (ref($_[0]) eq 'ARRAY') { |
|
|
0
|
|
|
|
|
|
101
|
0
|
|
|
|
|
0
|
$self->{'_Buffer'} = $_[0][0]; |
102
|
|
|
|
|
|
|
} elsif (ref($_[0]) eq 'HASH') { |
103
|
0
|
|
|
|
|
0
|
foreach my $attr (keys %{$_[0]}) { |
|
0
|
|
|
|
|
0
|
|
104
|
0
|
0
|
|
|
|
0
|
$self->{"_$attr"} = $_[0]->{$attr} unless ($attr =~ /^_/); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
1
|
|
|
|
|
91
|
bless($self,$class); |
110
|
1
|
|
|
|
|
4
|
return $self; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
#============================================================================== |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item sub packet_type() |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
$value = $erm_def->packet_type(); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Data Packet Identifier. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This attribute identifies this data packet as the Earth Reference Model |
122
|
|
|
|
|
|
|
Definition packet. The value of this attribute must be 19. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub packet_type() { |
127
|
1
|
|
|
1
|
1
|
9
|
my ($self) = @_; |
128
|
1
|
|
|
|
|
9
|
return $self->{'packetType'}; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
#============================================================================== |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item sub packet_size() |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
$value = $erm_def->packet_size(); |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Data Packet Size. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
This attribute indicates the number of bytes in this data packet. The value of |
140
|
|
|
|
|
|
|
this attribute must be 24. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=cut |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub packet_size() { |
145
|
1
|
|
|
1
|
1
|
6
|
my ($self) = @_; |
146
|
1
|
|
|
|
|
4
|
return $self->{'packetSize'}; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
#============================================================================== |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item sub custom_erm([$newValue]) |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
$value = $erm_def->custom_erm($newValue); |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Custom ERM Enable. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
This attribute specifies whether the IG should use the Earth Reference Model |
158
|
|
|
|
|
|
|
(ERM) defined by this packet. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
If this attribute is set to Disable (0), the IG will use the WGS 84 reference |
161
|
|
|
|
|
|
|
model and all other attributes in this packet will be ignored. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Disable 0 |
164
|
|
|
|
|
|
|
Enable 1 |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub custom_erm() { |
169
|
1
|
|
|
1
|
1
|
3
|
my ($self,$nv) = @_; |
170
|
1
|
50
|
|
|
|
13
|
if (defined($nv)) { |
171
|
1
|
50
|
33
|
|
|
10
|
if (($nv==0) or ($nv==1)) { |
172
|
1
|
|
|
|
|
3
|
$self->{'customERM'} = $nv; |
173
|
1
|
|
|
|
|
3
|
$self->{'_bitfields1'} |= $nv &0x01; |
174
|
|
|
|
|
|
|
} else { |
175
|
0
|
|
|
|
|
0
|
carp "custom_erm must be 0 (Disable), or 1 (Enable)."; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
} |
178
|
1
|
|
|
|
|
13
|
return ($self->{'_bitfields1'} & 0x01); |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
#============================================================================== |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=item sub equatorial_radius([$newValue]) |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
$value = $erm_def->equatorial_radius($newValue); |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Equatorial Radius. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
This attribute specifies the semi-major axis of the ellipsoid. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=cut |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub equatorial_radius() { |
194
|
1
|
|
|
1
|
1
|
6
|
my ($self,$nv) = @_; |
195
|
1
|
50
|
|
|
|
6
|
if (defined($nv)) { |
196
|
1
|
|
|
|
|
3
|
$self->{'equatorialRadius'} = $nv; |
197
|
|
|
|
|
|
|
} |
198
|
1
|
|
|
|
|
4
|
return $self->{'equatorialRadius'}; |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
#============================================================================== |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=item sub flattening([$newValue]) |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
$value = $erm_def->flattening($newValue); |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Flattening. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
This attribute specifies the flattening of the ellipsoid. |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=cut |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
sub flattening() { |
214
|
1
|
|
|
1
|
1
|
6
|
my ($self,$nv) = @_; |
215
|
1
|
50
|
|
|
|
4
|
if (defined($nv)) { |
216
|
1
|
|
|
|
|
3
|
$self->{'flattening'} = $nv; |
217
|
|
|
|
|
|
|
} |
218
|
1
|
|
|
|
|
4
|
return $self->{'flattening'}; |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
#========================================================================== |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=item sub pack() |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
$value = $erm_def->pack(); |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
Returns the packed data packet. |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=cut |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
sub pack($) { |
232
|
1
|
|
|
1
|
1
|
6
|
my $self = shift ; |
233
|
|
|
|
|
|
|
|
234
|
1
|
|
|
|
|
9
|
$self->{'_Buffer'} = CORE::pack($self->{'_Pack'}, |
235
|
|
|
|
|
|
|
$self->{'packetType'}, |
236
|
|
|
|
|
|
|
$self->{'packetSize'}, |
237
|
|
|
|
|
|
|
$self->{'_bitfields1'}, # Includes bitfields unused31, and customERM. |
238
|
|
|
|
|
|
|
$self->{'_unused32'}, |
239
|
|
|
|
|
|
|
$self->{'_unused33'}, |
240
|
|
|
|
|
|
|
$self->{'equatorialRadius'}, |
241
|
|
|
|
|
|
|
$self->{'flattening'}, |
242
|
|
|
|
|
|
|
); |
243
|
|
|
|
|
|
|
|
244
|
1
|
|
|
|
|
6
|
return $self->{'_Buffer'}; |
245
|
|
|
|
|
|
|
} |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
#========================================================================== |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=item sub unpack() |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
$value = $erm_def->unpack(); |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
Unpacks the packed data packet. |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=cut |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
sub unpack($) { |
258
|
0
|
|
|
0
|
1
|
|
my $self = shift @_; |
259
|
|
|
|
|
|
|
|
260
|
0
|
0
|
|
|
|
|
if (@_) { |
261
|
0
|
|
|
|
|
|
$self->{'_Buffer'} = shift @_; |
262
|
|
|
|
|
|
|
} |
263
|
0
|
|
|
|
|
|
my ($a,$b,$c,$d,$e,$f,$g) = CORE::unpack($self->{'_Pack'},$self->{'_Buffer'}); |
264
|
0
|
|
|
|
|
|
$self->{'packetType'} = $a; |
265
|
0
|
|
|
|
|
|
$self->{'packetSize'} = $b; |
266
|
0
|
|
|
|
|
|
$self->{'_bitfields1'} = $c; # Includes bitfields unused31, and customERM. |
267
|
0
|
|
|
|
|
|
$self->{'_unused32'} = $d; |
268
|
0
|
|
|
|
|
|
$self->{'_unused33'} = $e; |
269
|
0
|
|
|
|
|
|
$self->{'equatorialRadius'} = $f; |
270
|
0
|
|
|
|
|
|
$self->{'flattening'} = $g; |
271
|
|
|
|
|
|
|
|
272
|
0
|
|
|
|
|
|
$self->{'customERM'} = $self->custom_erm(); |
273
|
|
|
|
|
|
|
|
274
|
0
|
|
|
|
|
|
return $self->{'_Buffer'}; |
275
|
|
|
|
|
|
|
} |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
#========================================================================== |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=item sub byte_swap() |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
$obj_name->byte_swap(); |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
Byte swaps the packed data packet. |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
=cut |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
sub byte_swap($) { |
288
|
0
|
|
|
0
|
1
|
|
my $self = shift @_; |
289
|
|
|
|
|
|
|
|
290
|
0
|
0
|
|
|
|
|
if (@_) { |
291
|
0
|
|
|
|
|
|
$self->{'_Buffer'} = shift @_; |
292
|
|
|
|
|
|
|
} else { |
293
|
0
|
|
|
|
|
|
$self->pack(); |
294
|
|
|
|
|
|
|
} |
295
|
0
|
|
|
|
|
|
my ($a,$b,$c,$d,$e,$f,$g,$h,$i) = CORE::unpack($self->{'_Swap1'},$self->{'_Buffer'}); |
296
|
|
|
|
|
|
|
|
297
|
0
|
|
|
|
|
|
$self->{'_Buffer'} = CORE::pack($self->{'_Swap2'},$a,$b,$c,$d,$e,$g,$f,$i,$h); |
298
|
0
|
|
|
|
|
|
$self->unpack(); |
299
|
|
|
|
|
|
|
|
300
|
0
|
|
|
|
|
|
return $self->{'_Buffer'}; |
301
|
|
|
|
|
|
|
} |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
1; |
304
|
|
|
|
|
|
|
__END__ |