Astro-SpaceTrack
view release on metacpan or search on metacpan
tools/modeldef view on Meta::CPAN
}
defined $opt{username}
or defined $opt{password}
or $st->set( identity => 1 );
}
my $title = 'Space Track Model Definitions';
print
# $cgi->header( -charset => 'utf-8' ),
$cgi->start_html( -title => $title, -style => { src => 'trw.css' } ),
$cgi->h1( $title ), $cgi->p( <<"EOD" );
This is an expansion on the model definitions provided by version 2 of
the Space Track interface. It is generated by
@{[ Cwd::abs_path( $0 ) ]}
EOD
foreach my $class ( qw{ boxscore launch_site satcat gp_history gp } ) {
my $model;
if ( $opt{files} ) {
local $/ = undef; # Slurp mode.
open my $fh, '<:encoding(utf-8)', "$class.got"
or die "Failed to open $class.got: $!\n";
$model = $json->decode( <$fh> );
close $fh;
} else {
my $resp = $st->spacetrack_query_v2(
basicspacedata => 'modeldef',
class => $class,
format => 'json',
);
$resp->is_success()
or die $resp->status_line();
$model = $json->decode( $resp->content_decoded() );
}
print $cgi->h2( "Class $class" ), $cgi->start_dl();
foreach my $field (
sort { $a->{Field} cmp $b->{Field} }
@{ $model->{data} }
) {
my $name = $field->{Field};
print $cgi->dt( $name );
my $blurb = defined $desc{$class}{$name} ? $desc{$class}{$name} :
defined $desc{_}{$name} ? $desc{_}{$name} : 'Unknown.';
$blurb =~ s/ \s* \n / /smxg;
print $cgi->dd( $blurb, interpret_type( $field ) );
}
print $cgi->end_dl();
}
print $cgi->p( <<'EOD' );
The descriptions of the data types should be pretty much
self-explanatory. However:
EOD
print $cgi->ul(
map { $cgi->li( $_ ) } <<'EOD',
<code>date</code> by itself means a calendar date (GMT), without a time
of day. The date is expressed as a numeric <code>year-month-day</code>
with the year being a four-digit Gregorian year, and the month and day
being two digits.
EOD
<<'EOD',
<code>date and time</code> means both calendar date (GMT) and optional
time of day. The time of day is expressed as
<code>hour:minute:second</code>, with each field having two digits, and
separated from the date by a single space.
EOD
);
print $cgi->table(
{
class => 'nopadding',
summary => 'revision information',
},
$cgi->Tr(
$cgi->td( { class => 'right' }, 'Last revision:' ),
$cgi->td( strftime( '%d-%b-%Y', localtime ) ),
),
);
print $cgi->end_html();
{
my %interp;
BEGIN {
%interp = (
bigint => sub {
return 'integer of 8 bytes';
},
char => sub {
my ( $type, $width ) = @_;
return "string of $width characters";
},
date => sub {
return 'date';
},
datetime => sub {
return 'date and time';
},
decimal => sub {
my ( $type, $width ) = @_;
( $width, my $decimal ) = split qr{ , }smx, $width;
return "decimal number of $width digits with $decimal after the decimal";
},
double => sub {
return 'double-precision number';
},
enum => sub {
my ( $type, $width ) = @_;
return "enumeration of $width";
},
float => sub {
return 'floating-point number';
},
int => sub {
return 'integer of 4 bytes';
},
mediumint => sub {
return 'integer of 3 bytes';
},
smallint => sub {
return 'integer of 2 bytes';
( run in 1.825 second using v1.01-cache-2.11-cpan-39bf76dae61 )