blib/lib/Geo/Constants.pm

filter: Statementstmt 100% 24 / 24 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 6 / 6 totaltotal 97.5% 40 / 41 CC 2 SCAR 1.8
CC
2
Cov
96%
new
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
↑ Summary
1 package Geo::Constants;
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 1 ▶use base qw{Exporter};
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '0.07';
7 1 our @EXPORT_OK = qw{PI DEG RAD KNOTS};
8  
9 =head1 NAME
10  
11 Geo::Constants - Package for standard Geo:: constants.
12  
13 =head1 SYNOPSIS
14  
15 use Geo::Constants qw{PI DEG RAD}; #import into namespace
16 print "PI: ", PI(), "\n";
17 print "d/r: ", DEG(), "\n";
18 print "r/d: ", RAD(), "\n";
19  
20 use Geo::Constants; #Perl OO
21 my $obj = Geo::Constants->new();
22 print "PI: ", $obj->PI, "\n";
23 print "d/r: ", $obj->DEG, "\n";
24 print "r/d: ", $obj->RAD, "\n";
25  
26 =head1 DESCRIPTION
27  
28 =head1 CONSTRUCTOR
29  
30 =head2 new
31  
32 The new() constructor
33  
34 my $obj = Geo::Constants->new();
35  
36 =cut
37  
38 1 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod documented
39 1 my $this = shift;
40 1 ▶ my $class = ref($this) ? ref($this) : $this;
Branch: 1 branch
BranchTrueFalseTotal
ref $this ? : 0 1 1
41 1 my $self = {};
42 1 bless $self, $class;
43 1 $self->initialize(@_);
44 1 return $self;
45 }
46  
47 =head2 initialize
48  
49 =cut
50  
51 1 ▶sub initialize {
Subroutine initialize: called CC=1 SCAR=0.0
Pod documented
52 1 my $self=shift;
53 1 %$self=@_;
54 }
55  
56 =head1 FUNCTIONS
57  
58 =head2 PI
59  
60 my $pi = $obj->PI;
61  
62 use Geo::Constants qw{PI};
63 my $pi = PI();
64  
65 =cut
66  
67 6 ▶sub PI {
Subroutine PI: called CC=1 SCAR=0.0
Pod documented
68 6 return 4 * atan2(1,1); #Perl should complile this as a constant
69 }
70  
71 =head2 DEG
72  
73 my $degrees_per_radian = $obj->DEG;
74  
75 use Geo::Constants qw{DEG};
76 my $degrees_per_radian = DEG();
77  
78 UOM: degrees/radian
79  
80 =cut
81  
82 2 ▶sub DEG {
Subroutine DEG: called CC=1 SCAR=0.0
Pod documented
83 2 return 180 / PI(); #Degrees per radian
84 }
85  
86 =head2 RAD
87  
88 my $radians_per_degree = $obj->RAD;
89  
90 use Geo::Constants qw{DEG};
91 my $radians_per_degree = RAD();
92  
93 UOM: radians/degree
94  
95 =cut
96  
97 2 ▶sub RAD {
Subroutine RAD: called CC=1 SCAR=0.0
Pod documented
98 2 return PI() / 180; #Radians per degree
99 }
100  
101 =head2 KNOTS
102  
103 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
104  
105 Returns 1852/3600 m/s/knot
106  
107 UOM: meters/second per knot
108  
109 =cut
110  
111 2 ▶sub KNOTS {
Subroutine KNOTS: called CC=1 SCAR=0.0
Pod documented
112 2 return 1852/3600; #1 nautical mile per hour = (1852/3600) m/s
113 }
114  
115 =head1 AUTHOR
116  
117 Michael R. Davis
118  
119 =head1 LICENSE
120  
121 Copyright (c) 2006-2025 Michael R. Davis
122  
123 This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
124  
125 =head1 SEE ALSO
126  
127 L<Geo::Functions>, L<Geo::Ellipsoids>, L<Astro::Constants>
128  
129 =cut
130  
131 1 1;
↑ Summary