view release on metacpan or search on metacpan
lib/Astro/App/Satpass2.pm view on Meta::CPAN
} else {
$self->wail("Read-only attribute '$name'");
}
}
return;
}
sub _set_almanac_horizon {
my ( $self, $name, $value ) = @_;
my $parsed = $self->__parse_angle( { accept => 1 }, $value );
my $internal = looks_like_number( $parsed ) ? deg2rad( $parsed ) :
$parsed;
my $eci = Astro::Coord::ECI->new();
$eci->set( $name => $internal ); # To validate.
$self->{"_$name"} = $internal;
return( $self->{$name} = $parsed );
}
{
my $plus_or_minus_90 = sub { $_[0] >= -90 && $_[0] <= 90 };
my %validate = (
lib/Astro/App/Satpass2.pm view on Meta::CPAN
# in _frame_pop(), because we
# need to set {_twilight} as
# well.
sub _set_twilight {
my ($self, $name, $val) = @_;
if (my $key = $twilight_abbr{lc $val}) {
$self->{$name} = $key;
$self->{_twilight} = $twilight_def{$key};
} else {
my $angle = $self->__parse_angle( { accept => 1 }, $val );
looks_like_number( $angle )
or $self->wail( 'Twilight must be number or known keyword' );
$self->{$name} = $val;
$self->{_twilight} = deg2rad ($angle);
}
return $val;
}
sub _set_tz {
my ( $self, $name, $val ) = @_;
$self->_set_formatter_attribute( $name, $val );
lib/Astro/App/Satpass2.pm view on Meta::CPAN
$angle = _parse_angle_parts(
[ $deg => 360 ],
[ $min => 60 ],
[ $sec => 60 ],
);
$sgn and '-' eq $sgn and return -$angle;
return $angle;
}
$opt->{accept}
or looks_like_number( $angle )
or $self->wail( "Invalid angle '$angle'" );
return $angle;
}
# Documented in POD
{
my %units = (
au => AU,
ft => 0.0003048,
lib/Astro/App/Satpass2.pm view on Meta::CPAN
sub __parse_distance {
my ($self, $string, $dfdist) = @_;
defined $dfdist or $dfdist = 'km';
my $dfunits = $dfdist =~ s/ ( [[:alpha:]]+ ) \z //smx ? $1 : 'km';
my $units = lc (
$string =~ s/ \s* ( [[:alpha:]]+ ) \z //smx ? $1 : $dfunits );
$units{$units}
or $self->wail( "Units of '$units' are unknown" );
$string ne '' or $string = $dfdist;
looks_like_number ($string)
or $self->wail( "'$string' is not a number" );
return $string * $units{$units};
}
}
# Documented in POD
sub __parse_time {
my ($self, $time, $default) = @_;
my $pt = $self->{time_parser}
lib/Astro/App/Satpass2.pm view on Meta::CPAN
An attempt has been made to keep the requirements of this module
reasonably modest. But there are a number of optional modules which, if
installed, give you increased functionality. If you do not install these
initially and find you want the added functionality, you can always
install them later. The optional modules are:
=over
=item L<Astro::SIMBAD::Client|Astro::SIMBAD::Client>
This module looks up the positions of astronomical bodies in the SIMBAD
database at L<https://simbad.cds.unistra.fr/simbad/>. This is only used
by the C<lookup> subcommand of the L<sky()|/sky> method.
=item L<Astro::SpaceTrack|Astro::SpaceTrack>
This module retrieves satellite orbital elements from various sources.
Since you have to have these to predict satellite positions, this is the
least optional of the optional modules. Without it, you would have to
download orbital elements some other way and then use the
L<load()|/load> method to import them into C<Astro::App::Satpass2>.
lib/Astro/App/Satpass2.pm view on Meta::CPAN
The default is C<-noraw> if called interactively, and C<-raw> otherwise.
=back
=head2 geocode
$output = $satpass2->geocode('1600 Pennsylvania Ave, Washington DC');
satpass2> geocode '1600 Pennsylvania Ave, Washington DC'
This interactive method looks up its argument using the currently-set
L<geocoder|/geocoder>. It will fail if no geocoder is set.
If exactly one match is found, the location, latitude, and longitude
attributes are set accordingly.
If exactly one match is found and the L<autoheight|/autoheight>
attribute is true, the L<height()|/height> method will be called on the
resultant position. This operation may fail if the location is outside
the USA.
lib/Astro/App/Satpass2.pm view on Meta::CPAN
Nothing is returned.
=head3 list
This subcommand returns a string containing a list of the background
objects, in the format of the 'sky add' commands needed to re-create
them. If no subcommand at all is given, 'list' is assumed.
=head3 lookup
This subcommand takes as its argument a name, looks that name up in the
University of Strasbourg's SIMBAD database, and adds the object to the
background. An error occurs if the object can not be found. This
subcommand will fail if the
L<Astro::SIMBAD::Client|Astro::SIMBAD::Client> module can not be loaded.
Nothing is returned.
=head2 source
$output = $satpass2->source( $file_name );
satpass2> source file_name
lib/Astro/App/Satpass2/FormatValue.pm view on Meta::CPAN
$inx = $inx - $max + $size;
return ( $inx >= 0 && defined $wrapped->[$inx] ) ?
$wrapped->[$inx] :
$self->_format_string( '', $arg, $fmtr );
},
);
sub _do_title {
my ( $self, $arg, $fmtr ) = @_;
my $fmtr_name = $fmtr->{name};
# TODO this looks like a good place to insert localized title
# code. But see also _apply_defaults().
defined $arg->{title}
or $arg->{title} = '';
my $title = $arg->{title};
my $wrapped = $self->{internal}{$fmtr_name}{_title}{$title}{$arg->{width}}
||= $self->_do_title_wrap( $arg, $fmtr );
return $do_title{$self->{title_gravity}}->( $self, $wrapped,
$arg, $fmtr );
}
lib/Astro/App/Satpass2/FormatValue.pm view on Meta::CPAN
and $arg->{places} =~ RE_ALL_DIGITS
and $tplt .= ".$arg->{places}";
'%' eq $tplt
and return "$value";
my $buffer = sprintf $tplt . 'f', $value;
# The following line is because sprintf '%.1f', 0.04 produces
# '-0.0'. This may not be a bug, given what 'perldoc -f sprintf'
# says, but it sure looks like a wart to me.
$buffer =~ s/ \A ( \s* ) - ( 0* [.]? 0* \s* ) \z /$1 $2/smx;
$width or return $buffer;
if ($width && length $buffer > $width && $width >= 7) {
$arg->{places} = $width - 7;
return $self->_format_number_scientific( $value, $arg, $fmtr );
}
length $buffer <= $width
lib/Astro/App/Satpass2/ParseTime.pm view on Meta::CPAN
use warnings;
use parent qw{ Astro::App::Satpass2::Copier };
use Astro::App::Satpass2::FormatTime;
use Astro::App::Satpass2::Utils qw{
load_package
ARRAY_REF CODE_REF SCALAR_REF
@CARP_NOT
};
use Astro::Coord::ECI::Utils 0.059 qw{ looks_like_number };
our $VERSION = '0.056';
my %static = (
perltime => 0,
);
sub new {
my ( $class, %args ) = @_;
ref $class and $class = ref $class;
lib/Astro/App/Satpass2/ParseTime.pm view on Meta::CPAN
or $self->{absolute} = $self->base();
$string =~ s/ \A \s+ //smx;
$string =~ s/ \s+ \z //smx;
my $sign = substr $string, 0, 1;
substr( $string, 0, 1, '' );
my @delta = split qr{ \s* : \s* | \s+ }smx, $string;
@delta > 4 and return;
push @delta, ( 0 ) x ( 4 - @delta );
my $dt = 0;
foreach my $inx ( 0 .. 3 ) {
looks_like_number( $delta[$inx] ) or return;
$dt += $delta[$inx];
$dt *= $scale[$inx];
}
'-' eq $sign and $dt = - $dt;
return ( $self->{absolute} = $dt + $self->{absolute} );
} elsif ( $string =~
m/ \A epoch \s* ( [0-9]+ (?: [.] [0-9]* )? ) \z /smx ) {
my $time = $1 + 0;
lib/Astro/App/Satpass2/ParseTime/Date/Manip/v5.pm view on Meta::CPAN
package Astro::App::Satpass2::ParseTime::Date::Manip::v5;
use strict;
use warnings;
use Astro::Coord::ECI::Utils 0.112 qw{
looks_like_number greg_time_local };
use parent qw{ Astro::App::Satpass2::ParseTime::Date::Manip };
use Astro::App::Satpass2::Utils qw{ load_package @CARP_NOT };
our $VERSION = '0.056';
my $invalid;
BEGIN {
lib/Astro/App/Satpass2/ParseTime/Date/Manip/v5.pm view on Meta::CPAN
}
sub use_perltime {
return 1;
}
sub tz {
my ( $self, @args ) = @_;
$invalid and $self->wail( $invalid );
if ( @args ) {
if ( $args[0] || looks_like_number( $args[0] ) ) {
$ENV{TZ} = $args[0]; ## no critic (RequireLocalizedPunctuationVars)
$self->perltime() or Date_Init( "TZ=$args[0]" );
} else {
delete $ENV{TZ};
$self->perltime() or Date_Init( $default_zone );
}
}
return $self->SUPER::tz( @args );
}
lib/Astro/App/Satpass2/ParseTime/Date/Manip/v6.pm view on Meta::CPAN
package Astro::App::Satpass2::ParseTime::Date::Manip::v6;
use strict;
use warnings;
use Astro::Coord::ECI::Utils 0.112 qw{ looks_like_number };
use parent qw{ Astro::App::Satpass2::ParseTime::Date::Manip };
use Astro::App::Satpass2::Utils qw{ load_package @CARP_NOT };
our $VERSION = '0.056';
my $invalid;
BEGIN {
lib/Astro/App/Satpass2/ParseTime/ISO8601.pm view on Meta::CPAN
use strict;
use warnings;
use Astro::App::Satpass2::Utils qw{
back_end __back_end_class_name_of_record __parse_class_and_args
HAVE_DATETIME
@CARP_NOT
};
use Astro::Coord::ECI::Utils 0.112 qw{
looks_like_number SECSPERDAY greg_time_gm greg_time_local };
use parent qw{ Astro::App::Satpass2::ParseTime };
our $VERSION = '0.056';
my $package = __PACKAGE__;
sub attribute_names {
my ( $self ) = @_;
return ( $self->SUPER::attribute_names(), qw{ back_end } );
lib/Astro/App/Satpass2/Utils.pm view on Meta::CPAN
use strict;
use warnings;
use parent qw{ Exporter };
use Cwd ();
use File::HomeDir;
use File::Spec;
use Getopt::Long 2.33;
use Scalar::Util 1.26 qw{ blessed looks_like_number };
use Text::ParseWords ();
our $VERSION = '0.056';
our @CARP_NOT = qw{
Astro::App::Satpass2
Astro::App::Satpass2::Copier
Astro::App::Satpass2::Format
Astro::App::Satpass2::Format::Dump
Astro::App::Satpass2::Format::Template
lib/Astro/App/Satpass2/Utils.pm view on Meta::CPAN
sub quoter {
my @args = @_;
my @rslt = map { _quoter( $_ ) } @args;
return wantarray ? @rslt : join ' ', @rslt;
}
sub _quoter {
my ( $string ) = @_;
return 'undef' unless defined $string;
return $string if looks_like_number ($string);
return q{''} unless $string;
return $string unless $string =~ m/ [\s'"\$] /smx;
$string =~ s/ ( [\\'] ) /\\$1/smxg;
return qq{'$string'};
}
1;
__END__