line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
require Exporter; |
2
|
|
|
|
|
|
|
package Geo::Constants; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
Geo::Constants - Package for standard Geo:: constants. |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 SYNOPSIS |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Geo::Constants qw{PI DEG RAD}; #import into namespace |
11
|
|
|
|
|
|
|
print "PI: ", PI(), "\n"; |
12
|
|
|
|
|
|
|
print "d/r: ", DEG(), "\n"; |
13
|
|
|
|
|
|
|
print "r/d: ", RAD(), "\n"; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use Geo::Constants; #Perl OO |
16
|
|
|
|
|
|
|
my $obj = Geo::Constants->new(); |
17
|
|
|
|
|
|
|
print "PI: ", $obj->PI, "\n"; |
18
|
|
|
|
|
|
|
print "d/r: ", $obj->DEG, "\n"; |
19
|
|
|
|
|
|
|
print "r/d: ", $obj->RAD, "\n"; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
13818
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
53
|
|
26
|
|
|
|
|
|
|
#use vars qw($VERSION $PACKAGE @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); |
27
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION @ISA @EXPORT_OK); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
476
|
|
28
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
29
|
|
|
|
|
|
|
@EXPORT_OK = (qw{PI DEG RAD KNOTS}); |
30
|
|
|
|
|
|
|
$VERSION = sprintf("%d.%02d", q{Revision: 0.06} =~ /(\d+)\.(\d+)/); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 new |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
The new() constructor |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $obj = Geo::Constants->new(); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub new { |
43
|
1
|
|
|
1
|
1
|
95
|
my $this = shift(); |
44
|
1
|
|
33
|
|
|
7
|
my $class = ref($this) || $this; |
45
|
1
|
|
|
|
|
1
|
my $self = {}; |
46
|
1
|
|
|
|
|
3
|
bless $self, $class; |
47
|
1
|
|
|
|
|
4
|
$self->initialize(@_); |
48
|
1
|
|
|
|
|
2
|
return $self; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 METHODS |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub initialize { |
56
|
1
|
|
|
1
|
0
|
1
|
my $self = shift(); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 PI |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
my $pi = $obj->PI; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
use Geo::Constants qw{PI}; |
64
|
|
|
|
|
|
|
my $pi = PI(); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub PI { |
69
|
6
|
|
|
6
|
1
|
62
|
return 4 * atan2(1,1); #Perl should complile this as a constant |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 DEG |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
my $degrees_per_radian = $obj->DEG; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
use Geo::Constants qw{DEG}; |
77
|
|
|
|
|
|
|
my $degrees_per_radian = DEG(); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub DEG { |
82
|
2
|
|
|
2
|
1
|
5
|
return 180 / PI(); #Degrees per radian |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 RAD |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my $radians_per_degree = $obj->RAD; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
use Geo::Constants qw{DEG}; |
90
|
|
|
|
|
|
|
my $radians_per_degree = RAD(); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub RAD { |
95
|
2
|
|
|
2
|
1
|
5
|
return PI() / 180; #Radians per degree |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 KNOTS |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1 nautical mile per hour = (1852/3600) m/s - United States Department of Commerce, National Institute of Standards and Technology, NIST Special Publication 330, 2001 Edition |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Returns 1852/3600 |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub KNOTS { |
107
|
2
|
|
|
2
|
1
|
5
|
return 1852/3600; #1 nautical mile per hour = (1852/3600) m/s |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
1; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
__END__ |