Skip to content

Commit

Permalink
'mergetle' can now sort by COSPAR (international) designation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill-Gray committed Mar 3, 2024
1 parent beddf05 commit 6c9a8d1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mergetle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ int tle_compare( const TLE *tle1, const TLE *tle2, const char sort_method)
for( i = 2; !rval && i < 8; i++)
rval = tle1->line1[i] - tle2->line1[i];
break;
case 'c': case 'C': /* sort by COSPAR (international) desig */
if( tle1->line1[9] >= '5' && tle2->line1[9] < '5')
rval = -1;
else if( tle2->line1[9] >= '5' && tle1->line1[9] < '5')
rval = 1;
else /* COSPAR IDs are from the same century */
rval = memcmp( tle1->line1 + 9, tle2->line1 + 9, 8);
break;
case 'm': case 'M': /* sort by mean motion */
rval = compare_doubles( tle1->line2 + 52, tle2->line2 + 52);
break;
Expand Down Expand Up @@ -180,6 +188,7 @@ static void error_exit( void)
printf( "in more than one .tle, the .tle from the first file on the command\n");
printf( "line is used. Options are:\n\n");
printf( "-sn, -sN Sort output by ascending/descending NORAD number\n");
printf( "-sc, -sC Sort output by ascending/descending COSPAR desig\n");
printf( "-sm, -sM Sort output by ascending/descending mean motion\n");
printf( "-se, -sE Sort output by ascending/descending eccentricity\n");
printf( "-sp, -sP Sort output by ascending/descending epoch\n");
Expand Down

0 comments on commit 6c9a8d1

Please sign in to comment.