/*  
 *  - - - - - - - - - - - 
 *   g a l _ t l e d e c  
 *  - - - - - - - - - - - 
 *  
 *  This routine is part of the General Astrodynamics Library  
 *
 *  Description:
 *
 *     This routine decodes the packed two line element cards into the tle structure
 *  
 *  Status: 
 *  
 *     support routine.  
 *  
 *  Given:  
 *
 *     *card1         c[70]         First Card
 *     *card2         c[70]         Second Card
 *  
 *  Returned:  
 *  
 *     *tle         gal_tle_t       Unpacked data
 *     gal_tledec       i           GAL_SUCCESS if success
 *                                  GAL_FAILURE if failure
 *  
 *  Notes:
 *
 *  1) Standard Two-Line Elements (TLE) Format
 *     
 *     1 25107U 97082D   98151.26839894 -.00007632  00000-0 -27359-2 0  1321
 *     2 25107  86.3970 282.3520 0003565  65.4476 294.7132 14.34205441 23251
 *     
 *     Breakdown of a Two Line Element Set
 *     
 *     !>Line Number 1
 *     !   !>Catalog Number (NORAD)
 *     !   !  !>Security Classification for this Element Set
 *     !   !  !    !>International Identification for this Object (COSPAR)
 *     !   !  !    !     !>Two Digit Year
 *     !   !  !    !     !  !>Day of Year
 *     !   !  !    !     !  !     !>Fraction of 24 Hour Day
 *     !   !  !    !     !  !     !     !>Sign of 1st Time Derivative
 *     !   !  !    !     !  !     !     !    !>1st Time Derivative
 *     !   !  !    !     !  !     !     !    !     !>Sign of 2nd Time Derivative
 *     !   !  !    !     !  !     !     !    !     !  !>2nd Time Derivative
 *     !   !  !    !     !  !     !     !    !     !  !  !>Sign of exponent
 *     !   !  !    !     !  !     !     !    !     !  !   !>Exponent 2ndTimeDerivative
 *     !   !  !    !     !  !     !     !    !     !  !     !>Sign of BSTAR drag term
 *     !   !  !    !     !  !     !     !    !     !  !     !  !>BSTAR/Drag Term
 *     !   !  !    !     !  !     !     !    !     !  !     !  !  !>Sign of Exponent
 *     !   !  !    !     !  !     !     !    !     !  !     !  !  !!>Exponent BstarDrg
 *     !   !  !    !     !  !     !     !    !     !  !     !  !  !! !>Ephemeris Type
 *     !   !  !    !     ! ---    !     !    !     !  !     !  !  !! ! !>Element No.
 *     ! -----! -------- --|||--------- !--------- !-----   !-----!! ! ----!>Checksum
 *     1 25107U 97082D   98151.26839894 -.00007632  00000-0 -27359-2 0  1321 = Line 1
 *     2 25107 086.3970 282.3520 0003565 065.4476 294.7132 14.34205441 23251 = Line 2
 *     123456789012345678901234567890123456789012345678901234567890123456789 = columns
 *     ! ----- ---.---- ---.---- ------- ---.---- ---.---- --.--------|||||!>Checksum
 *     !   !   Incl     RAAN     Ecc     AoP      MA       RpD        -----
 *     !   !   !        !        !       !        !        !          !>Rev # @ Epoch
 *     !   !   !        !        !       !        !        !>MeanMotion(Revolutions/Day)
 *     !   !   !        !        !       !        !>Mean Anomaly
 *     !   !   !        !        !       !>Argument of Perigee
 *     !   !   !        !        !>Eccentricity, with assumed decimal point leading
 *     !   !   !        !>Right Ascension of Ascending Node
 *     !   !   !>Inclination
 *     !   !>Catalog Number (NORAD)
 *     !>Line Number 2
 *     
 *     Line 1
 *     
 *        Column Numbers     Number of
 *        First     Last     Characters     Description
 *        -----     ----     ----------     -----------
 *          1        1           1          Line No. Identification
 *          3        7           5          Catalog No.
 *          8        8           1          Security Classification
 *         10       17           8          International Designator (COSPAR/WDC-A-R&S)
 *         19       32          14          YRDOY.FODddddd
 *         34       34           1          Sign of first time derivative
 *         35       43           9          1st Time Derative
 *         45       45           1          Sign of 2nd Time Derivative
 *         46       50           5          2nd Time Derivative
 *         51       51           1          Sign of 2nd Time Derivative Exponent
 *         52       52           1          Exponent of 2nd Time Derivative
 *         54       54           1          Sign of Bstar/Drag Term
 *         55       59           5          Bstar/Drag Term
 *         60       60           1          Sign of Exponent of Bstar/Drag Term
 *         61       61           1          Exponent of Bstar/Drag Term
 *         63       63           1          Ephemeris Type
 *         65       68           4          Element Number
 *         69       69           1          Check Sum, Modulo 10
 *     
 *     Line 2
 *     
 *        Column Numbers     Number of
 *        First     Last     Characters     Description
 *        -----     ----     ----------     -----------
 *          1        1           1          Line No. Identification
 *          3        7           5          Catalog No.
 *          9       16           8          Inclination
 *         18       25           8          Right Ascension of Ascending Node
 *         27       33           7          Eccentricity with assumed leading decimal
 *         35       42           8          Argument of the Perigee
 *         44       51           8          Mean Anomaly
 *         53       63          11          Revolutions per Day (Mean Motion)
 *         64       68           5          Revolution Number at Epoch
 *         69       69           1          Check Sum Modulo 10
 *     
 *  Called:
 *
 *     gal_tlechksum                        Calculate NORAD TLE checksum character
 *     gal_trim                             Trim whitespace from ends of string
 *     gal_replace                          Find and replace substring in string
 *
 *  References:
 *  
 *     Revisting Spacetrack Report #3
 *     Vallado, David, Crawford, Paul, Hujsak, Richard, Kelso, T.S.
 *     AIAA 2006-6753
 *  
 *  This revision:  
 * 
 *     2008 March 30 
 *  
 *  Copyright (C) 2008 Paul C. L. Willmott. See notes at end. 
 *  
 *-----------------------------------------------------------------------  
 */  

#ifndef _GAL_TLEDEC_H_  
#define _GAL_TLEDEC_H_ 1  
 
#include "gal_tle.h"

#undef  __BEGIN_DECLS  
#undef  __END_DECLS  
#ifdef  __cplusplus  
#define __BEGIN_DECLS extern "C" {  
#define __END_DECLS }  
#else  
#define __BEGIN_DECLS /* empty */  
#define __END_DECLS   /* empty */  
#endif
  
__BEGIN_DECLS  
  
int
gal_tledec
  (
    char *card1,
    char *card2,
    gal_tle_t *tle
  ) ;
   
__END_DECLS  
  
#endif /* !_GAL_TLEDEC_ */ 

/*
 *  gal - General Astrodynamics Library  
 *  Copyright (C) 2008 Paul C. L. Willmott  
 *  
 *  This program is free software; you can redistribute it and/or modify  
 *  it under the terms of the GNU General Public License as published by  
 *  the Free Software Foundation; either version 2 of the License, or  
 *  (at your option) any later version.  
 *  
 *  This program is distributed in the hope that it will be useful,  
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of  
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
 *  GNU General Public License for more details.  
 *  
 *  You should have received a copy of the GNU General Public License along  
 *  with this program; if not, write to the Free Software Foundation, Inc.,  
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.  
 *    
 *  Contact:  
 *    
 *  Paul Willmott  
 *  vp9mu@amsat.org  
 */  
  
