From c52a3dd4b51d88528cff2eec7c7ec8434a0cb622 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 14 Aug 2019 12:48:09 +0200 Subject: [PATCH 1/2] Remove unused variables --- src/algorithms/libs/rtklib/rtklib_rtksvr.cc | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/algorithms/libs/rtklib/rtklib_rtksvr.cc b/src/algorithms/libs/rtklib/rtklib_rtksvr.cc index 9c31c05de..5524742f2 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtksvr.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtksvr.cc @@ -471,15 +471,6 @@ int decoderaw(rtksvr_t *svr, int index) /* decode download file ------------------------------------------------------*/ void decodefile(rtksvr_t *svr, int index) { - int i = 0; - char glo_fcn[MAXPRNGLO + 1]; - - // Allocate space for GLONASS frequency channels depending on availability - for (i = 0; i < MAXPRNGLO + 1; i++) - { - glo_fcn[i] = '0'; - } - nav_t nav{}; char file[1024]; int nb; From d298bdf0a90d76d9c72293797f6efb446e58a222 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 14 Aug 2019 20:06:48 +0200 Subject: [PATCH 2/2] Remove unused functions with defects in memory management --- src/algorithms/libs/rtklib/rtklib_preceph.cc | 155 ------------------- src/algorithms/libs/rtklib/rtklib_preceph.h | 21 +-- 2 files changed, 12 insertions(+), 164 deletions(-) diff --git a/src/algorithms/libs/rtklib/rtklib_preceph.cc b/src/algorithms/libs/rtklib/rtklib_preceph.cc index 38dbab200..ceb6db3b5 100644 --- a/src/algorithms/libs/rtklib/rtklib_preceph.cc +++ b/src/algorithms/libs/rtklib/rtklib_preceph.cc @@ -625,161 +625,6 @@ int readdcb(const char *file, nav_t *nav, const sta_t *sta) } -/* add satellite fcb ---------------------------------------------------------*/ -int addfcb(nav_t *nav, gtime_t ts, gtime_t te, int sat, - const double *bias, const double *std) -{ - fcbd_t *nav_fcb; - int i; - int j; - - if (nav->nf > 0 && fabs(timediff(ts, nav->fcb[nav->nf - 1].ts)) <= 1e-3) - { - for (i = 0; i < 3; i++) - { - nav->fcb[nav->nf - 1].bias[sat - 1][i] = bias[i]; - nav->fcb[nav->nf - 1].std[sat - 1][i] = std[i]; - } - return 1; - } - if (nav->nf >= nav->nfmax) - { - nav->nfmax = nav->nfmax <= 0 ? 2048 : nav->nfmax * 2; - if (!(nav_fcb = static_cast(realloc(nav->fcb, sizeof(fcbd_t) * nav->nfmax)))) - { - free(nav->fcb); - nav->nf = nav->nfmax = 0; - return 0; - } - nav->fcb = nav_fcb; - } - for (i = 0; i < MAXSAT; i++) - { - for (j = 0; j < 3; j++) - { - nav->fcb[nav->nf].bias[i][j] = nav->fcb[nav->nf].std[i][j] = 0.0; - } - } - for (i = 0; i < 3; i++) - { - nav->fcb[nav->nf].bias[sat - 1][i] = bias[i]; - nav->fcb[nav->nf].std[sat - 1][i] = std[i]; - } - nav->fcb[nav->nf].ts = ts; - nav->fcb[nav->nf++].te = te; - return 1; -} - - -/* read satellite fcb file ---------------------------------------------------*/ -int readfcbf(const char *file, nav_t *nav) -{ - FILE *fp; - gtime_t ts; - gtime_t te; - double ep1[6]; - double ep2[6]; - double bias[3] = {}; - double std[3] = {}; - char buff[1024]; - char str[32]; - char *p; - int sat; - - trace(3, "readfcbf: file=%s\n", file); - - if (!(fp = fopen(file, "re"))) - { - trace(2, "fcb parameters file open error: %s\n", file); - return 0; - } - while (fgets(buff, sizeof(buff), fp)) - { - if ((p = strchr(buff, '#'))) - { - *p = '\0'; - } - if (sscanf(buff, - "%lf/%lf/%lf %lf:%lf:%lf %lf/%lf/%lf %lf:%lf:%lf %s" - "%lf %lf %lf %lf %lf %lf", - ep1, ep1 + 1, ep1 + 2, ep1 + 3, ep1 + 4, ep1 + 5, - ep2, ep2 + 1, ep2 + 2, ep2 + 3, ep2 + 4, ep2 + 5, str, bias, std, bias + 1, std + 1, - bias + 2, std + 2) < 17) - { - continue; - } - if (!(sat = satid2no(str))) - { - continue; - } - ts = epoch2time(ep1); - te = epoch2time(ep2); - if (!addfcb(nav, ts, te, sat, bias, std)) - { - fclose(fp); - return 0; - } - } - fclose(fp); - return 1; -} - - -/* compare satellite fcb -----------------------------------------------------*/ -int cmpfcb(const void *p1, const void *p2) -{ - auto *q1 = (fcbd_t *)p1; - auto *q2 = (fcbd_t *)p2; - double tt = timediff(q1->ts, q2->ts); - return tt < -1e-3 ? -1 : (tt > 1e-3 ? 1 : 0); -} - - -/* read satellite fcb data ----------------------------------------------------- - * read satellite fractional cycle bias (dcb) parameters - * args : char *file I fcb parameters file (wild-card * expanded) - * nav_t *nav IO navigation data - * return : status (1:ok,0:error) - * notes : fcb data appended to navigation data - *-----------------------------------------------------------------------------*/ -int readfcb(const char *file, nav_t *nav) -{ - char *efiles[MAXEXFILE] = {}; - int i; - int n; - - trace(3, "readfcb : file=%s\n", file); - - for (i = 0; i < MAXEXFILE; i++) - { - if (!(efiles[i] = static_cast(malloc(1024)))) - { - for (i--; i >= 0; i--) - { - free(efiles[i]); - } - return 0; - } - } - n = expath(file, efiles, MAXEXFILE); - - for (i = 0; i < n; i++) - { - readfcbf(efiles[i], nav); - } - for (i = 0; i < MAXEXFILE; i++) - { - free(efiles[i]); - } - - if (nav->nf > 1) - { - qsort(nav->fcb, nav->nf, sizeof(fcbd_t), cmpfcb); - } - return 1; -} - - /* polynomial interpolation by Neville's algorithm ---------------------------*/ double interppol(const double *x, double *y, int n) { diff --git a/src/algorithms/libs/rtklib/rtklib_preceph.h b/src/algorithms/libs/rtklib/rtklib_preceph.h index 1186b6a88..cd682e22c 100644 --- a/src/algorithms/libs/rtklib/rtklib_preceph.h +++ b/src/algorithms/libs/rtklib/rtklib_preceph.h @@ -72,27 +72,29 @@ const double EXTERR_CLK = 1e-3; /* extrapolation error for clock (m/s) */ const double EXTERR_EPH = 5e-7; /* extrapolation error for ephem (m/s^2) */ int code2sys(char code); + int readsp3h(FILE *fp, gtime_t *time, char *type, int *sats, double *bfact, char *tsys); + int addpeph(nav_t *nav, peph_t *peph); + void readsp3b(FILE *fp, char type, int *sats, int ns, const double *bfact, char *tsys, int index, int opt, nav_t *nav); + int cmppeph(const void *p1, const void *p2); + void combpeph(nav_t *nav, int opt); + void readsp3(const char *file, nav_t *nav, int opt); + int readsap(const char *file, gtime_t time, nav_t *nav); + int readdcbf(const char *file, nav_t *nav, const sta_t *sta); + int readdcb(const char *file, nav_t *nav, const sta_t *sta); -int addfcb(nav_t *nav, gtime_t ts, gtime_t te, int sat, - const double *bias, const double *std); -int readfcbf(const char *file, nav_t *nav); -int readdcb(const char *file, nav_t *nav, const sta_t *sta); -int addfcb(nav_t *nav, gtime_t ts, gtime_t te, int sat, - const double *bias, const double *std); -int readfcbf(const char *file, nav_t *nav); -int cmpfcb(const void *p1, const void *p2); -int readfcb(const char *file, nav_t *nav); + double interppol(const double *x, double *y, int n); + int pephpos(gtime_t time, int sat, const nav_t *nav, double *rs, double *dts, double *vare, double *varc); @@ -101,6 +103,7 @@ int pephclk(gtime_t time, int sat, const nav_t *nav, double *dts, void satantoff(gtime_t time, const double *rs, int sat, const nav_t *nav, double *dant); + int peph2pos(gtime_t time, int sat, const nav_t *nav, int opt, double *rs, double *dts, double *var);