From 94bb87481b4bc03253905e5086d05947dd19ff80 Mon Sep 17 00:00:00 2001 From: Tom Wyant Date: Fri, 26 Apr 2024 10:38:04 -0400 Subject: [PATCH] Track changes in Kelso data set names. He renamed the data sets for the Chinese and Russian ASAT test debris. The old names are retained as synonyms. The data supporting the synonyms etc got refactired from the test into Astro::SpaceTrack so I could display the notes in names->( 'celestrak' ) --- lib/Astro/SpaceTrack.pm | 60 ++++++++++++++++++++++++---------- xt/author/celestrak_datasets.t | 20 ++++-------- 2 files changed, 49 insertions(+), 31 deletions(-) diff --git a/lib/Astro/SpaceTrack.pm b/lib/Astro/SpaceTrack.pm index 647a57f..b27504d 100644 --- a/lib/Astro/SpaceTrack.pm +++ b/lib/Astro/SpaceTrack.pm @@ -308,11 +308,29 @@ my %catalogs = ( # Catalog names (and other info) for each source. oneweb => { name => 'OneWeb' }, swarm => { name => 'Swarm' }, gnss => { name => 'GNSS navigational satellites' }, - '1982-092' => { name => 'Russian ASAT Test Debris (COSMOS 1408)' }, - '1999-025' => { name => 'Fengyun 1C debris' }, + '1982-092' => { + name => 'Russian ASAT Test Debris (COSMOS 1408)', + note => q/'cosmos-1408-debris' as of April 26 2024/, + ignore => 1, # Ignore in xt/author/celestrak_datasets.t + }, + 'cosmos-1408-debris' => { + name => 'Russian ASAT Test Debris (COSMOS 1408)', + }, + '1999-025' => { + name => 'Fengyun 1C debris', + note => q/'fengyun-1c-debris' as of April 26 2024/, + ignore => 1, # Ignore in xt/author/celestrak_datasets.t + }, + 'fengyun-1c-debris' => { + name => 'Fengyun 1C debris', + }, 'cosmos-2251-debris' => { name => 'Cosmos 2251 debris' }, 'iridium-33-debris' => { name => 'Iridium 33 debris' }, - '2012-044' => { name => 'BREEZE-M R/B Breakup (2012-044C)' }, + '2012-044' => { + name => 'BREEZE-M R/B Breakup (2012-044C)', + note => 'Fetchable as of November 16 2021, but not on web page', + ignore => 1, # Ignore in xt/author/celestrak_datasets.t + }, # Removed 2022-05-12 # '2019-006' => { name => 'Indian ASAT Test Debris' }, }, @@ -342,12 +360,13 @@ my %catalogs = ( # Catalog names (and other info) for each source. rms => 1, match => 1, }, - ses => { - name => 'SES', - # source => 'SES-11P', - rms => 1, - match => 1, - }, + # Removed 2024-04-26 + #ses => { + # name => 'SES', + # # source => 'SES-11P', + # rms => 1, + # match => 1, + #}, telesat => { name => 'Telesat', # source => 'Telesat-E', @@ -1092,14 +1111,17 @@ There are no arguments. } } +# Given a catalog name, return the catalog, which MUST NOT be modified. # UNSUPPORTED AND SUBJECT TO CHANGE OR REMOVAL WITHOUT NOTICE! # If you have a use for this information, please let me know and I will # see about putting together something I believe I can support. sub __catalog { - my ( undef, $name ) = @_; - $catalogs{$name} - or Carp::confess "Bug - catalog $name does not exist"; - return $catalogs{$name}; + my ( $self, $name ) = @_; + $name = lc $name; + my $src = $catalogs{$name}; + $name eq 'spacetrack' + and $src = $src->[ $self->getv( 'space_track_version' ) ]; + return $src; } =for html @@ -2983,19 +3005,19 @@ since all it is doing is returning data kept by this module. sub names { my ( $self, $name ) = @_; - $name = lc $name; delete $self->{_pragmata}; - $catalogs{$name} or return HTTP::Response->new( + my $src = $self->__catalog( $name ) + or return HTTP::Response->new( HTTP_NOT_FOUND, "Data source '$name' not found."); - my $src = $catalogs{$name}; - $name eq 'spacetrack' - and $src = $src->[ $self->getv( 'space_track_version' ) ]; + my @list; foreach my $cat (sort keys %$src) { push @list, defined ($src->{$cat}{number}) ? "$cat ($src->{$cat}{number}): $src->{$cat}{name}\n" : "$cat: $src->{$cat}{name}\n"; + defined $src->{$cat}{note} + and $list[-1] .= " $src->{$cat}{note}\n"; } my $resp = HTTP::Response->new (HTTP_OK, undef, undef, join ('', @list)); return $resp unless wantarray; @@ -3003,6 +3025,8 @@ sub names { foreach my $cat (sort {$src->{$a}{name} cmp $src->{$b}{name}} keys %$src) { push @list, [$src->{$cat}{name}, $cat]; + defined $src->{$cat}{note} + and push @{ $list[-1] }, $src->{$cat}{note}; } return ($resp, \@list); } diff --git a/xt/author/celestrak_datasets.t b/xt/author/celestrak_datasets.t index 7ea1251..9fac443 100644 --- a/xt/author/celestrak_datasets.t +++ b/xt/author/celestrak_datasets.t @@ -24,14 +24,7 @@ my %got = parse_string( $rslt->content(), source => 'celestrak' ); my $st = Astro::SpaceTrack->new(); -(undef, my $names) = $st->names( 'celestrak' ); -my %expect; -foreach (@$names) { - $expect{$_->[1]} = { - name => $_->[0], - ignore => 0, - }; -} +my %expect = %{ $st->__catalog( 'celestrak' ) }; =begin comment @@ -59,28 +52,29 @@ $expect{'2019-006'} = { }; # Removed October 23, 2008 - $expect{'usa-193-debris'} = { name => 'USA 193 Debris', note => 'Not actually provided as a fetchable data set.', ignore => 1, }; -=end comment - -=cut - +# Keys relocated to Astro::SpaceTrack April 26 2024. $expect{'2012-044'} = { name => 'BREEZE-M R/B Breakup (2012-044C)', note => 'Fetchable as of November 16 2021, but not on web page', ignore => 1, }; +# Removed April 26 2024 if ($expect{sts}) { $expect{sts}{note} = 'Only available when a mission is in progress.'; $expect{sts}{ignore} = 1; # What it says. } +=end comment + +=cut + foreach my $key (sort keys %expect) { if ($expect{$key}{ignore}) { my $presence = delete $got{$key} ? 'present' : 'not present';