line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geo::Compass::Direction; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
143244
|
use 5.006; |
|
2
|
|
|
|
|
15
|
|
4
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
41
|
|
5
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
81
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
12
|
use Carp qw(croak); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
111
|
|
8
|
2
|
|
|
2
|
|
12
|
use Exporter qw(import); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
591
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
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
|
596138
|
my ($deg) = @_; |
21
|
|
|
|
|
|
|
|
22
|
1681
|
100
|
|
|
|
4680
|
if (! defined $deg) { |
23
|
1
|
|
|
|
|
232
|
croak("direction() must have an integer or float as its only parameter"); |
24
|
|
|
|
|
|
|
} |
25
|
1680
|
100
|
100
|
|
|
9870
|
if ($deg !~ /^\d+$/ && $deg !~ /^\d+\.\d+$/) { |
26
|
1002
|
|
|
|
|
86154
|
croak("The degree parameter for direction() must be an int or float"); |
27
|
|
|
|
|
|
|
} |
28
|
678
|
100
|
66
|
|
|
2824
|
if ($deg < 0 || $deg > 360) { |
29
|
640
|
|
|
|
|
54919
|
croak("The degree parameter must be an int or float between 0-360"); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
38
|
|
|
|
|
100
|
my $calc = (($deg % 360) / 22.5) + .5; |
33
|
|
|
|
|
|
|
|
34
|
38
|
|
|
|
|
208
|
return $DIRECTIONS[$calc]; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
0
|
|
|
sub __placeholder {} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
__END__ |