diff --git a/fakeiod.c b/fakeiod.c index 0a39b85..7318316 100644 --- a/fakeiod.c +++ b/fakeiod.c @@ -6,7 +6,7 @@ #include "sgdp4h.h" #include -#define LIM 80 +#define LIM 128 #define NMAX 256 #define D2R M_PI/180.0 #define R2D 180.0/M_PI diff --git a/satorbit.c b/satorbit.c index 547a396..e10eadb 100644 --- a/satorbit.c +++ b/satorbit.c @@ -376,7 +376,6 @@ void plot_xyz(void) while (fgetline(fp,line,LIM)>0) { // Get satellite position sscanf(line,"%lf %lf %lf %lf",&mjd,&satpos.x,&satpos.y,&satpos.z); - printf("%lf %f %f %f\n",mjd,satpos.x,satpos.y,satpos.z); // Get positions sunpos_xyz(m.mjd,&sunpos,&sra,&sde); diff --git a/satutl.c b/satutl.c index 53ad47f..88ed863 100644 --- a/satutl.c +++ b/satutl.c @@ -47,51 +47,46 @@ int read_twoline(FILE *fp, long search_satno, orbit_t *orb) int found; double bm, bx; + // Set defaults + strcpy(orb->desig,""); + st1 = line1; st2 = line2; do { - if(fgets(line1, ST_SIZE-1, fp) == NULL) return -1; + if(fgets(line1, ST_SIZE-1, fp) == NULL) + return -1; st1 = st_start(line1); } while(st1[0] != '1'); - if(search_satno > 0) - { + if(search_satno > 0) { found = 0; - } - else - { - found = 1; - search_satno = atol(st1+2); - } - + } else { + found = 1; + search_satno = atol(st1+2); + } sprintf(search, "1 %05ld", search_satno); do { st1 = st_start(line1); - if(strncmp(st1, search, 7) == 0) - { - found = 1; - break; - } + if(strncmp(st1, search, 7) == 0) { + found = 1; + break; + } } while(fgets(line1, ST_SIZE-1, fp) != NULL); + sprintf(search, "2 %05ld", search_satno); - sprintf(search, "2 %05ld", search_satno); - - if(found) - { - fgets(line2, ST_SIZE-1, fp); - st2 = st_start(line2); - } - - if(!found || strncmp(st2, search, 7) != 0) - { - return -1; - } + if(found) { + fgets(line2, ST_SIZE-1, fp); + st2 = st_start(line2); + } + if(!found || strncmp(st2, search, 7) != 0) { + return -1; + } orb->ep_year = (int)i_read(st1, 19, 20); - + if(orb->ep_year < 57) orb->ep_year += 2000; else orb->ep_year += 1900; diff --git a/sgdp4h.h b/sgdp4h.h index d12b7ee..d2f2ddb 100644 --- a/sgdp4h.h +++ b/sgdp4h.h @@ -170,20 +170,20 @@ typedef struct orbit_s { /* Add the epoch time if required. */ - int ep_year;/* Year of epoch, e.g. 94 for 1994, 100 for 2000AD */ - double ep_day; /* Day of epoch from 00:00 Jan 1st ( = 1.0 ) */ - double rev; /* Mean motion, revolutions per day */ - double bstar; /* Drag term .*/ - double eqinc; /* Equatorial inclination, radians */ - double ecc; /* Eccentricity */ - double mnan; /* Mean anomaly at epoch from elements, radians */ - double argp; /* Argument of perigee, radians */ - double ascn; /* Right ascension (ascending node), radians */ - double smjaxs; /* Semi-major axis, km */ + int ep_year;/* Year of epoch, e.g. 94 for 1994, 100 for 2000AD */ + double ep_day; /* Day of epoch from 00:00 Jan 1st ( = 1.0 ) */ + double rev; /* Mean motion, revolutions per day */ + double bstar; /* Drag term .*/ + double eqinc; /* Equatorial inclination, radians */ + double ecc; /* Eccentricity */ + double mnan; /* Mean anomaly at epoch from elements, radians */ + double argp; /* Argument of perigee, radians */ + double ascn; /* Right ascension (ascending node), radians */ + double smjaxs; /* Semi-major axis, km */ double ndot2,nddot6; /* Mean motion derivatives */ - char desig[10]; /* International designation */ - long norb; /* Orbit number, for elements */ - int satno; /* Satellite number. */ + char desig[10]; /* International designation */ + long norb; /* Orbit number, for elements */ + int satno; /* Satellite number. */ } orbit_t;