| 1 | package Astro::Coord::ECI::VSOP87D::_Inferior; | ||||||||||||
| 2 | |||||||||||||
| 3 | 5 | ▶ | use 5.008; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | |||||||||||||
| 5 | 5 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 5 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | 5 | ▶ | use base qw{ Astro::Coord::ECI }; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | |||||||||||||
| 10 | 5 | ▶ | use Astro::Coord::ECI::Mixin qw{ | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | almanac almanac_hash | ||||||||||||
| 12 | next_quarter_hash | ||||||||||||
| 13 | 5 | }; | |||||||||||
| 14 | 5 | ▶ | use Astro::Coord::ECI::Utils qw{ PI find_first_true mod2pi }; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 15 | 5 | ▶ | use Astro::Coord::ECI::VSOP87D qw{ :mixin }; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 16 | 5 | ▶ | use Carp; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 17 | |||||||||||||
| 18 | 5 | our $VERSION = '0.008'; | |||||||||||
| 19 | |||||||||||||
| 20 | 5 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 21 | 5 | my ( $class, %arg ) = @_; | |||||||||||
| 22 | 5 | $class->__default( \%arg ); | |||||||||||
| 23 | 5 | return $class->SUPER::new( %arg ); | |||||||||||
| 24 | } | ||||||||||||
| 25 | |||||||||||||
| 26 | 0 | ▶ | sub __almanac_event_type_iterator { | ||||||||||
|
Subroutine
__almanac_event_type_iterator: not called CC=1 SCAR=6.9
| |||||||||||||
| 27 | 0 | my ( $self, $station ) = @_; | |||||||||||
| 28 | |||||||||||||
| 29 | 0 | my $inx = 0; | |||||||||||
| 30 | |||||||||||||
| 31 | 0 | my $horizon = $station->__get_almanac_horizon(); | |||||||||||
| 32 | |||||||||||||
| 33 | 0 | my @events = ( | |||||||||||
| 34 | [ $station, next_elevation => [ $self, $horizon, 1 ], | ||||||||||||
| 35 | horizon => '__horizon_name' ], | ||||||||||||
| 36 | [ $station, next_meridian => [ $self ], | ||||||||||||
| 37 | transit => '__transit_name' ], | ||||||||||||
| 38 | [ $self, next_quarter => [], 'quarter', '__quarter_name' ], | ||||||||||||
| 39 | ); | ||||||||||||
| 40 | |||||||||||||
| 41 | 0 | ▶ | return sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||
| 42 | $inx < @events | ||||||||||||
| 43 | 0 | ▶ | and return @{ $events[$inx++] }; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 44 | 0 | return; | |||||||||||
| 45 | 0 | }; | |||||||||||
| 46 | } | ||||||||||||
| 47 | |||||||||||||
| 48 | { | ||||||||||||
| 49 | 1177 | ▶ | my $get = sub { | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 50 | 1177 | my ( $self, $name ) = @_; | |||||||||||
| 51 | 1177 | return $self->__get_attr()->{$name}; | |||||||||||
| 52 | 5 | }; | |||||||||||
| 53 | |||||||||||||
| 54 | 5 | my %accessor = ( | |||||||||||
| 55 | elongation_in_longitude => $get, | ||||||||||||
| 56 | model_cutoff => $get, | ||||||||||||
| 57 | nutation_cutoff => $get, | ||||||||||||
| 58 | ); | ||||||||||||
| 59 | |||||||||||||
| 60 | 0 | ▶ | sub attribute { | ||||||||||
|
Subroutine
attribute: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 61 | 0 | my ( $self, $name ) = @_; | |||||||||||
| 62 | 0 | ▶ | exists $accessor{$name} | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 63 | and return __PACKAGE__; | ||||||||||||
| 64 | 0 | return $self->SUPER::attribute( $name ); | |||||||||||
| 65 | } | ||||||||||||
| 66 | |||||||||||||
| 67 | 2661 | ▶ | sub get { | ||||||||||
|
Subroutine
get: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||
| 68 | 2661 | my ( $self, @arg ) = @_; | |||||||||||
| 69 | 2661 | my @rslt; | |||||||||||
| 70 | 2661 | foreach my $name ( @arg ) { | |||||||||||
| 71 | 2661 | ▶ | if ( my $code = $accessor{$name} ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 72 | 1177 | push @rslt, $code->( $self, $name ); | |||||||||||
| 73 | } else { | ||||||||||||
| 74 | 1484 | push @rslt, $self->SUPER::get( $name ); | |||||||||||
| 75 | } | ||||||||||||
| 76 | wantarray | ||||||||||||
| 77 | 2661 | ▶ | or return $rslt[0]; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 78 | } | ||||||||||||
| 79 | 16 | return @rslt; | |||||||||||
| 80 | } | ||||||||||||
| 81 | } | ||||||||||||
| 82 | |||||||||||||
| 83 | # NOTE that the %opt arguments are UNSUPPORTED and can be changed or | ||||||||||||
| 84 | # removed without notice. Caveat codor. | ||||||||||||
| 85 | 5 | ▶ | sub next_quarter { | ||||||||||
|
Subroutine
next_quarter: called CC=11 SCAR=24.0
Pod
documented
| |||||||||||||
| 86 | 10 | my ( $self, $quarter, %opt ) = @_; | |||||||||||
| 87 | |||||||||||||
| 88 | 10 | my $time = $self->universal(); | |||||||||||
| 89 | |||||||||||||
| 90 | 10 | ▶ | my $elong_method = $self->get( 'elongation_in_longitude' ) ? | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 91 | '__longitude_from_sun' : | ||||||||||||
| 92 | '__angle_subtended_from_earth'; | ||||||||||||
| 93 | |||||||||||||
| 94 | 10 | my $increment = $self->synodic_period() / 16; | |||||||||||
| 95 | |||||||||||||
| 96 | my @checker = ( | ||||||||||||
| 97 | 130 | ▶ | sub { # 0 = superior conjunction | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||
| 98 | 130 | my ( $time ) = @_; | |||||||||||
| 99 | 130 | ▶ | $self->__longitude_from_sun( $time ) > 0 ? 4 : 0; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 100 | }, | ||||||||||||
| 101 | 66 | ▶ | sub { # 1 = elongaton east | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||
| 102 | 66 | my ( $time ) = @_; | |||||||||||
| 103 | 66 | ▶ | return $self->$elong_method( $time ) < | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 104 | $self->$elong_method( $time - 1 ) ? 1 : 0; | ||||||||||||
| 105 | }, | ||||||||||||
| 106 | 58 | ▶ | sub { # 2 = inferior conjunction | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||
| 107 | 58 | my ( $time ) = @_; | |||||||||||
| 108 | 58 | ▶ | $self->__longitude_from_sun( $time ) < 0 ? 2 : 0; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 109 | }, | ||||||||||||
| 110 | 55 | ▶ | sub { # 3 = elongaton west | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||
| 111 | 55 | my ( $time ) = @_; | |||||||||||
| 112 | 55 | ▶ | return $self->$elong_method( $time ) > | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 113 | $self->$elong_method( $time - 1 ) ? 3 : 0; | ||||||||||||
| 114 | }, | ||||||||||||
| 115 | 10 | ); | |||||||||||
| 116 | |||||||||||||
| 117 | 10 | ▶ | if ( defined $opt{checker_result} ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 118 | 0 | return $checker[$opt{checker_result}]->( $time ); | |||||||||||
| 119 | } | ||||||||||||
| 120 | |||||||||||||
| 121 | 10 | my $test; | |||||||||||
| 122 | 10 | ▶ | if ( defined $quarter ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 123 | 2 | $test = $checker[$quarter]; | |||||||||||
| 124 | 2 | ▶ | while ( $test->( $time ) ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 125 | 3 | $time += $increment; | |||||||||||
| 126 | } | ||||||||||||
| 127 | 2 | ▶ | while ( ! $test->( $time ) ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 128 | 15 | $time += $increment; | |||||||||||
| 129 | } | ||||||||||||
| 130 | } else { | ||||||||||||
| 131 | 8 | ▶ | my @chk = grep { ! $_->( $time ) } @checker | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 132 | or confess 'Programming error - no false checks'; | ||||||||||||
| 133 | 8 | my $rslt; | |||||||||||
| 134 | 8 | ▶ | while ( ! $rslt ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 135 | 27 | $time += $increment; | |||||||||||
| 136 | 27 | foreach my $c ( @chk ) { | |||||||||||
| 137 | 48 | ▶ | $rslt = $c->( $time ) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 138 | and last; | ||||||||||||
| 139 | } | ||||||||||||
| 140 | } | ||||||||||||
| 141 | 8 | $quarter = $rslt % 4; | |||||||||||
| 142 | 8 | $test = $checker[$quarter]; | |||||||||||
| 143 | } | ||||||||||||
| 144 | |||||||||||||
| 145 | 10 | my $rslt = find_first_true( $time - $increment, $time, $test ); | |||||||||||
| 146 | |||||||||||||
| 147 | 10 | $self->universal( $rslt ); | |||||||||||
| 148 | |||||||||||||
| 149 | wantarray | ||||||||||||
| 150 | 10 | ▶ | or return $rslt; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 151 | 10 | return( $rslt, $quarter, $self->__quarter_name( $quarter ) ); | |||||||||||
| 152 | } | ||||||||||||
| 153 | |||||||||||||
| 154 | 10 | ▶ | sub __quarter_name { | ||||||||||
|
Subroutine
__quarter_name: called CC=2 SCAR=7.1
| |||||||||||||
| 155 | 10 | my ( $self, $event, $name ) = @_; | |||||||||||
| 156 | 10 | ▶ | $name ||= [ | ||||||||||
|
Condition50%1/2
$name ||= ["%s superior conjunction", "%s elongation east", "%s inferior conjunction", "%s elongation west"]
MC/DC0%0/1
$name ||= ["%s superior conjunction", "%s elongation east", "%s inferior conjunction", "%s elongation west"]
$name
Truth table50%1/2
A
A= $name
| |||||||||||||
| 157 | '%s superior conjunction', | ||||||||||||
| 158 | '%s elongation east', | ||||||||||||
| 159 | '%s inferior conjunction', | ||||||||||||
| 160 | '%s elongation west', | ||||||||||||
| 161 | ]; | ||||||||||||
| 162 | 10 | return sprintf $name->[$event], $self->get( 'name' ); | |||||||||||
| 163 | } | ||||||||||||
| 164 | |||||||||||||
| 165 | { | ||||||||||||
| 166 | 2 | ▶ | my $set = sub { | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 167 | 2 | my ( $self, $name, $value ) = @_; | |||||||||||
| 168 | 2 | $self->__get_attr()->{$name} = $value; | |||||||||||
| 169 | 2 | return $self; | |||||||||||
| 170 | 5 | }; | |||||||||||
| 171 | |||||||||||||
| 172 | 5 | my %mutator = ( | |||||||||||
| 173 | elongation_in_longitude => $set, | ||||||||||||
| 174 | model_cutoff => \&__mutate_model_cutoff, | ||||||||||||
| 175 | nutation_cutoff => \&__mutate_nutation_cutoff, | ||||||||||||
| 176 | ); | ||||||||||||
| 177 | |||||||||||||
| 178 | 10 | ▶ | sub set { | ||||||||||
|
Subroutine
set: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||
| 179 | 10 | my ( $self, @arg ) = @_; | |||||||||||
| 180 | 10 | ▶ | while ( @arg ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 181 | 34 | my ( $name, $value ) = splice @arg, 0, 2; | |||||||||||
| 182 | 34 | ▶ | if ( my $code = $mutator{$name} ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 183 | 12 | $code->( $self, $name, $value ); | |||||||||||
| 184 | } else { | ||||||||||||
| 185 | 22 | $self->SUPER::set( $name, $value ); | |||||||||||
| 186 | } | ||||||||||||
| 187 | } | ||||||||||||
| 188 | 10 | return $self; | |||||||||||
| 189 | } | ||||||||||||
| 190 | } | ||||||||||||
| 191 | |||||||||||||
| 192 | 5 | 1; | |||||||||||
| 193 | |||||||||||||
| 194 | __END__ | ||||||||||||