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