line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geo::Compass::Direction; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
140903
|
use 5.006; |
|
2
|
|
|
|
|
16
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
43
|
|
5
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
84
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
14
|
use Carp qw(croak); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
112
|
|
8
|
2
|
|
|
2
|
|
13
|
use Exporter qw(import); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
588
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.01'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
13
|
|
|
|
|
|
|
our @EXPORT_OK = qw(direction); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my @DIRECTIONS = qw( |
16
|
|
|
|
|
|
|
N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW NNW N |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub direction { |
20
|
1681
|
|
|
1681
|
1
|
661923
|
my ($deg) = @_; |
21
|
|
|
|
|
|
|
|
22
|
1681
|
100
|
|
|
|
3973
|
if (! defined $deg) { |
23
|
1
|
|
|
|
|
191
|
croak("direction() must have an integer or float as its only parameter"); |
24
|
|
|
|
|
|
|
} |
25
|
1680
|
100
|
100
|
|
|
10179
|
if ($deg !~ /^\d+$/ && $deg !~ /^\d+\.\d+$/) { |
26
|
1002
|
|
|
|
|
91412
|
croak("The degree parameter for direction() must be an int or float"); |
27
|
|
|
|
|
|
|
} |
28
|
678
|
100
|
66
|
|
|
2346
|
if ($deg < 0 || $deg > 360) { |
29
|
640
|
|
|
|
|
53281
|
croak("The degree parameter must be an int or float between 0-360"); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
38
|
|
|
|
|
92
|
my $calc = (($deg % 360) / 22.5) + .5; |
33
|
|
|
|
|
|
|
|
34
|
38
|
|
|
|
|
154
|
return $DIRECTIONS[$calc]; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
0
|
|
|
sub __placeholder {} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
__END__ |