line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Zodiac::Angle; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
311174
|
use strict; |
|
5
|
|
|
|
|
49
|
|
|
5
|
|
|
|
|
120
|
|
4
|
5
|
|
|
5
|
|
20
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
115
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
1938
|
use Class::Utils qw(set_params); |
|
5
|
|
|
|
|
104250
|
|
|
5
|
|
|
|
|
88
|
|
7
|
5
|
|
|
5
|
|
325
|
use Error::Pure qw(err); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
167
|
|
8
|
5
|
|
|
5
|
|
24
|
use List::MoreUtils qw(none); |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
18
|
|
9
|
5
|
|
|
5
|
|
2540
|
use Readonly; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
160
|
|
10
|
5
|
|
|
5
|
|
1287
|
use Unicode::UTF8 qw(decode_utf8); |
|
5
|
|
|
|
|
1246
|
|
|
5
|
|
|
|
|
3251
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Readonly::Array our @SIGN_TYPES => qw(sign ascii); |
13
|
|
|
|
|
|
|
Readonly::Hash our %ZODIAC => ( |
14
|
|
|
|
|
|
|
1 => { |
15
|
|
|
|
|
|
|
'sign' => decode_utf8('♈'), # Aries/Beran |
16
|
|
|
|
|
|
|
'ascii' => 'ar', |
17
|
|
|
|
|
|
|
}, |
18
|
|
|
|
|
|
|
2 => { |
19
|
|
|
|
|
|
|
'sign' => decode_utf8('♉'), # Taurus/Býk |
20
|
|
|
|
|
|
|
'ascii' => 'ta', |
21
|
|
|
|
|
|
|
}, |
22
|
|
|
|
|
|
|
3 => { |
23
|
|
|
|
|
|
|
'sign' => decode_utf8('♊'), # Gemini/Blíženci |
24
|
|
|
|
|
|
|
'ascii' => 'ge', |
25
|
|
|
|
|
|
|
}, |
26
|
|
|
|
|
|
|
4 => { |
27
|
|
|
|
|
|
|
'sign' => decode_utf8('♋'), # Cancer/Rak |
28
|
|
|
|
|
|
|
'ascii' => 'cn', |
29
|
|
|
|
|
|
|
}, |
30
|
|
|
|
|
|
|
5 => { |
31
|
|
|
|
|
|
|
'sign' => decode_utf8('♌'), # Leo/Lev |
32
|
|
|
|
|
|
|
'ascii' => 'le', |
33
|
|
|
|
|
|
|
}, |
34
|
|
|
|
|
|
|
6 => { |
35
|
|
|
|
|
|
|
'sign' => decode_utf8('♍'), # Virgo/Panna |
36
|
|
|
|
|
|
|
'ascii' => 'vi', |
37
|
|
|
|
|
|
|
}, |
38
|
|
|
|
|
|
|
7 => { |
39
|
|
|
|
|
|
|
'sign' => decode_utf8('♎'), # Libra/Váhy |
40
|
|
|
|
|
|
|
'ascii' => 'li', |
41
|
|
|
|
|
|
|
}, |
42
|
|
|
|
|
|
|
8 => { |
43
|
|
|
|
|
|
|
'sign' => decode_utf8('♏'), # Scorpio/Štír |
44
|
|
|
|
|
|
|
'ascii' => 'sc', |
45
|
|
|
|
|
|
|
}, |
46
|
|
|
|
|
|
|
9 => { |
47
|
|
|
|
|
|
|
'sign' => decode_utf8('♐'), # Sagittarius/Střelec |
48
|
|
|
|
|
|
|
'ascii' => 'sa', |
49
|
|
|
|
|
|
|
}, |
50
|
|
|
|
|
|
|
10 => { |
51
|
|
|
|
|
|
|
'sign' => decode_utf8('♑'), # Capricorn/Kozoroh |
52
|
|
|
|
|
|
|
'ascii' => 'cp', |
53
|
|
|
|
|
|
|
}, |
54
|
|
|
|
|
|
|
11 => { |
55
|
|
|
|
|
|
|
'sign' => decode_utf8('♒'), # Aquarius/Vodnář |
56
|
|
|
|
|
|
|
'ascii' => 'aq', |
57
|
|
|
|
|
|
|
}, |
58
|
|
|
|
|
|
|
12 => { |
59
|
|
|
|
|
|
|
'sign' => decode_utf8('♓'), # Pisces/Ryby |
60
|
|
|
|
|
|
|
'ascii' => 'pi', |
61
|
|
|
|
|
|
|
}, |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
Readonly::Scalar our $SPACE => ' '; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
our $VERSION = 0.04; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Constructor. |
68
|
|
|
|
|
|
|
sub new { |
69
|
2
|
|
|
2
|
1
|
151
|
my ($class, @params) = @_; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# Create object. |
72
|
2
|
|
|
|
|
7
|
my $self = bless {}, $class; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# Process parameters. |
75
|
2
|
|
|
|
|
11
|
set_params($self, @params); |
76
|
|
|
|
|
|
|
|
77
|
2
|
|
|
|
|
16
|
return $self; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub angle2zodiac { |
81
|
17
|
|
|
17
|
1
|
7255
|
my ($self, $angle, $opts_hr) = @_; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# Options. |
84
|
17
|
100
|
100
|
|
|
52
|
if (! defined $opts_hr || ! exists $opts_hr->{'minute'}) { |
85
|
13
|
|
|
|
|
25
|
$opts_hr->{'minute'} = 1; |
86
|
|
|
|
|
|
|
} |
87
|
17
|
100
|
|
|
|
32
|
if (! exists $opts_hr->{'second'}) { |
88
|
15
|
|
|
|
|
22
|
$opts_hr->{'second'} = 0; |
89
|
|
|
|
|
|
|
} |
90
|
17
|
50
|
|
|
|
28
|
if (! exists $opts_hr->{'second_round'}) { |
91
|
17
|
|
|
|
|
19
|
$opts_hr->{'second_round'} = 4; |
92
|
|
|
|
|
|
|
} |
93
|
17
|
100
|
|
|
|
40
|
if (! exists $opts_hr->{'sign_type'}) { |
94
|
15
|
|
|
|
|
20
|
$opts_hr->{'sign_type'} = 'sign'; |
95
|
|
|
|
|
|
|
} |
96
|
17
|
100
|
|
19
|
|
80
|
if (none { $opts_hr->{'sign_type'} eq $_ } @SIGN_TYPES) { |
|
19
|
|
|
|
|
244
|
|
97
|
1
|
|
|
|
|
4
|
err "Parameter 'sign_type' is bad. Possible values are 'sign' and 'ascii'."; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
16
|
|
|
|
|
53
|
my $ret = {}; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# Full angle degree. |
103
|
16
|
|
|
|
|
30
|
my $full_angle_degree = int($angle); |
104
|
16
|
|
|
|
|
23
|
$angle -= $full_angle_degree; |
105
|
16
|
|
|
|
|
22
|
$angle *= 60; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# Angle minute. |
108
|
16
|
100
|
|
|
|
27
|
if ($opts_hr->{'minute'}) { |
109
|
15
|
|
|
|
|
24
|
$ret->{'angle_minute'} = int($angle); |
110
|
15
|
|
|
|
|
16
|
$angle -= $ret->{'angle_minute'}; |
111
|
15
|
|
|
|
|
18
|
$angle *= 60; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# Angle second. |
115
|
16
|
100
|
|
|
|
27
|
if ($opts_hr->{'second'}) { |
116
|
2
|
|
|
|
|
6
|
my $print_format = '%0.'.$opts_hr->{'second_round'}.'f'; |
117
|
2
|
|
|
|
|
15
|
$ret->{'angle_second'} = sprintf($print_format, $angle); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# Angle sign. |
121
|
16
|
|
|
|
|
27
|
$ret->{'sign'} = int($full_angle_degree / 30); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# Angle degree in sign. |
124
|
16
|
|
|
|
|
22
|
$ret->{'angle_degree'} = $full_angle_degree - ($ret->{'sign'} * 30); |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# Output. |
127
|
16
|
|
|
|
|
18
|
my $zodiac_angle; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
# Output with sign (UTF-8). |
130
|
16
|
100
|
|
|
|
36
|
if ($opts_hr->{'sign_type'} eq 'sign') { |
131
|
|
|
|
|
|
|
$zodiac_angle = $ret->{'angle_degree'}.decode_utf8('°'). |
132
|
15
|
|
|
|
|
85
|
$ZODIAC{$ret->{'sign'} + 1}->{'sign'}; |
133
|
15
|
100
|
|
|
|
163
|
if ($opts_hr->{'minute'}) { |
134
|
14
|
|
|
|
|
31
|
$zodiac_angle .= $ret->{'angle_minute'}.decode_utf8("′"); |
135
|
14
|
100
|
|
|
|
23
|
if ($opts_hr->{'second'}) { |
136
|
1
|
|
|
|
|
4
|
$zodiac_angle .= $ret->{'angle_second'}.decode_utf8("′′"); |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# Output with ascii. |
141
|
|
|
|
|
|
|
} else { |
142
|
|
|
|
|
|
|
$zodiac_angle = $ret->{'angle_degree'}.$SPACE. |
143
|
1
|
|
|
|
|
6
|
$ZODIAC{$ret->{'sign'} + 1}->{'ascii'}; |
144
|
1
|
50
|
|
|
|
13
|
if ($opts_hr->{'minute'}) { |
145
|
1
|
|
|
|
|
3
|
$zodiac_angle .= $SPACE.$ret->{'angle_minute'}."'"; |
146
|
1
|
50
|
|
|
|
3
|
if ($opts_hr->{'second'}) { |
147
|
1
|
|
|
|
|
3
|
$zodiac_angle .= $ret->{'angle_second'}."''"; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
16
|
|
|
|
|
47
|
return $zodiac_angle; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub zodiac2angle { |
156
|
0
|
|
|
0
|
1
|
|
my ($self, $zodiac_angle) = @_; |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
# TODO |
159
|
0
|
|
|
|
|
|
my $angle; |
160
|
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
return $angle; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
1; |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
__END__ |