line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Zodiac::Angle; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
312300
|
use strict; |
|
5
|
|
|
|
|
41
|
|
|
5
|
|
|
|
|
107
|
|
4
|
5
|
|
|
5
|
|
18
|
use warnings; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
105
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
1810
|
use Class::Utils qw(set_params); |
|
5
|
|
|
|
|
103143
|
|
|
5
|
|
|
|
|
77
|
|
7
|
5
|
|
|
5
|
|
279
|
use Error::Pure qw(err); |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
144
|
|
8
|
5
|
|
|
5
|
|
22
|
use List::MoreUtils qw(none); |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
15
|
|
9
|
5
|
|
|
5
|
|
2333
|
use Readonly; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
140
|
|
10
|
5
|
|
|
5
|
|
1190
|
use Unicode::UTF8 qw(decode_utf8); |
|
5
|
|
|
|
|
1216
|
|
|
5
|
|
|
|
|
3656
|
|
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.05; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Constructor. |
68
|
|
|
|
|
|
|
sub new { |
69
|
2
|
|
|
2
|
1
|
126
|
my ($class, @params) = @_; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# Create object. |
72
|
2
|
|
|
|
|
6
|
my $self = bless {}, $class; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# Process parameters. |
75
|
2
|
|
|
|
|
8
|
set_params($self, @params); |
76
|
|
|
|
|
|
|
|
77
|
2
|
|
|
|
|
14
|
return $self; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub angle2zodiac { |
81
|
17
|
|
|
17
|
1
|
6161
|
my ($self, $angle, $opts_hr) = @_; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# Options. |
84
|
17
|
100
|
100
|
|
|
43
|
if (! defined $opts_hr || ! exists $opts_hr->{'minute'}) { |
85
|
13
|
|
|
|
|
24
|
$opts_hr->{'minute'} = 1; |
86
|
|
|
|
|
|
|
} |
87
|
17
|
100
|
|
|
|
25
|
if (! exists $opts_hr->{'second'}) { |
88
|
15
|
|
|
|
|
18
|
$opts_hr->{'second'} = 0; |
89
|
|
|
|
|
|
|
} |
90
|
17
|
50
|
|
|
|
39
|
if (! exists $opts_hr->{'second_round'}) { |
91
|
17
|
|
|
|
|
20
|
$opts_hr->{'second_round'} = 4; |
92
|
|
|
|
|
|
|
} |
93
|
17
|
100
|
|
|
|
48
|
if (! exists $opts_hr->{'sign_type'}) { |
94
|
15
|
|
|
|
|
19
|
$opts_hr->{'sign_type'} = 'sign'; |
95
|
|
|
|
|
|
|
} |
96
|
17
|
100
|
|
19
|
|
71
|
if (none { $opts_hr->{'sign_type'} eq $_ } @SIGN_TYPES) { |
|
19
|
|
|
|
|
205
|
|
97
|
1
|
|
|
|
|
4
|
err "Parameter 'sign_type' is bad. Possible values are 'sign' and 'ascii'."; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
16
|
|
|
|
|
45
|
my $ret = {}; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# Full angle degree. |
103
|
16
|
|
|
|
|
23
|
my $full_angle_degree = int($angle); |
104
|
16
|
|
|
|
|
22
|
$angle -= $full_angle_degree; |
105
|
16
|
|
|
|
|
19
|
$angle *= 60; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# Angle minute. |
108
|
16
|
100
|
|
|
|
22
|
if ($opts_hr->{'minute'}) { |
109
|
15
|
|
|
|
|
18
|
$ret->{'angle_minute'} = int($angle); |
110
|
15
|
|
|
|
|
17
|
$angle -= $ret->{'angle_minute'}; |
111
|
15
|
|
|
|
|
18
|
$angle *= 60; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# Angle second. |
115
|
16
|
100
|
|
|
|
26
|
if ($opts_hr->{'second'}) { |
116
|
2
|
|
|
|
|
4
|
my $print_format = '%0.'.$opts_hr->{'second_round'}.'f'; |
117
|
2
|
|
|
|
|
14
|
$ret->{'angle_second'} = sprintf($print_format, $angle); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# Angle sign. |
121
|
16
|
|
|
|
|
20
|
$ret->{'sign'} = int($full_angle_degree / 30); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# Angle degree in sign. |
124
|
16
|
|
|
|
|
19
|
$ret->{'angle_degree'} = $full_angle_degree - ($ret->{'sign'} * 30); |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# Output. |
127
|
16
|
|
|
|
|
17
|
my $zodiac_angle; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
# Output with sign (UTF-8). |
130
|
16
|
100
|
|
|
|
26
|
if ($opts_hr->{'sign_type'} eq 'sign') { |
131
|
|
|
|
|
|
|
$zodiac_angle = $ret->{'angle_degree'}.decode_utf8('°'). |
132
|
15
|
|
|
|
|
114
|
$ZODIAC{$ret->{'sign'} + 1}->{'sign'}; |
133
|
15
|
100
|
|
|
|
179
|
if ($opts_hr->{'minute'}) { |
134
|
14
|
|
|
|
|
28
|
$zodiac_angle .= $ret->{'angle_minute'}.decode_utf8("′"); |
135
|
14
|
100
|
|
|
|
29
|
if ($opts_hr->{'second'}) { |
136
|
1
|
|
|
|
|
3
|
$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
|
|
|
|
|
5
|
$ZODIAC{$ret->{'sign'} + 1}->{'ascii'}; |
144
|
1
|
50
|
|
|
|
10
|
if ($opts_hr->{'minute'}) { |
145
|
1
|
|
|
|
|
3
|
$zodiac_angle .= $SPACE.$ret->{'angle_minute'}."'"; |
146
|
1
|
50
|
|
|
|
3
|
if ($opts_hr->{'second'}) { |
147
|
1
|
|
|
|
|
2
|
$zodiac_angle .= $ret->{'angle_second'}."''"; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
16
|
|
|
|
|
44
|
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__ |