From 8d22576a73c6defd8408f9a55923081e3db60470 Mon Sep 17 00:00:00 2001 From: KenanZhu111 <3471685733@qq.com> Date: Mon, 28 Oct 2024 19:27:59 +0800 Subject: [PATCH] Update: 2024/10/28 1. KNZ_GeoTrackLab: Fix some bug. 2. KNZ_GeoTrackLab: Optimize code structure. --- src/brdm2pos.h | 46 +++++++++++++++++++++++----------------------- src/readrnx.cpp | 9 +-------- src/rnx2pos.cpp | 14 ++++++++------ 3 files changed, 32 insertions(+), 37 deletions(-) diff --git a/src/brdm2pos.h b/src/brdm2pos.h index 1e45d4b..33a7d88 100644 --- a/src/brdm2pos.h +++ b/src/brdm2pos.h @@ -24,9 +24,9 @@ /*GNSS OBSERV TYPE*/ //frequency 1 #define C1 100 -#define C1A 100 -#define C1B 101 -#define C1C 102 +#define C1A 100 +#define C1B 101 +#define C1C 102 #define C1D 103 #define C1E #define C1F @@ -54,8 +54,8 @@ #define C2 200 #define C2A #define C2B -#define C2C 200 -#define C2D 201 +#define C2C 200 +#define C2D 201 #define C2E #define C2F #define C2G @@ -63,23 +63,23 @@ #define C2I 202 #define C2J #define C2K -#define C2L 203 -#define C2M 204 +#define C2L 203 +#define C2M 204 #define C2N #define C2O -#define C2P 205 -#define C2Q 206 +#define C2P 205 +#define C2Q 206 #define C2R -#define C2S 207 +#define C2S 207 #define C2T #define C2U #define C2V #define C2W #define C2X 208 -#define C2Y 209 -#define C2Z 210 +#define C2Y 209 +#define C2Z 210 //frequency 3 -#define C3 300 +#define C3 300 #define C3I 300 #define C3Q 301 #define C3X 302 @@ -98,7 +98,7 @@ #define C5F #define C5G #define C5H -#define C5I 500 +#define C5I 500 #define C5J #define C5K #define C5L @@ -106,14 +106,14 @@ #define C5N #define C5O #define C5P -#define C5Q 501 +#define C5Q 501 #define C5R #define C5S #define C5T #define C5U #define C5V #define C5W -#define C5X 502 +#define C5X 502 #define C5Y #define C5Z //frequency 6 @@ -178,11 +178,11 @@ #define C8Q 801 #define C8X 802 /*GNSS CODE*/ -#define GPS 01 -#define BDS 02 -#define GAL 03 -#define GLO 04 -#define SBAS 05 +#define GPS 01 +#define BDS 02 +#define GAL 03 +#define GLO 04 +#define SBAS 05 #define MAXRINEX 1000 #define DAYSEC 86400 @@ -298,8 +298,8 @@ typedef struct nav_body double deltaomega; double IDOT; - double L2code; int Datasource; - double GPSweek; double BDTweek; double GALweek; + double L2code; int Datasource; + double GPSweek; double BDTweek; double GALweek; double L2Pflag; double sACC; diff --git a/src/readrnx.cpp b/src/readrnx.cpp index 8bff24a..a3373fd 100644 --- a/src/readrnx.cpp +++ b/src/readrnx.cpp @@ -218,12 +218,6 @@ static double strtonum(const char* buff, int i, int n) *p = '\0'; return sscanf(str, "%lf", &value) == 1 ? value : 0.0; } -/*Allocate the memory of observation structure*/ -void initobs_e(pobs_epoch obs_e, pobs_body obs_b) -{ - obs_e = (pobs_epoch)malloc(sizeof(obs_epoch)); - obs_b = (pobs_body)malloc(sizeof(obs_body)); -} /*Free the memory of observation structure*/ void freeobs_e(pobs_epoch obs_e, pobs_body obs_b) { @@ -664,7 +658,7 @@ void read_o_h(FILE* fp_obs, pobs_head obs_h) obs_h->obstypenum_gps = (int)strtonum(buff, 4, 2); if (obs_h->obstypenum_gps <= 13) { for (i = 0; i < obs_h->obstypenum_gps; i++) { - obs_h->obscode_gps[i + 1] = Type2Code(i, buff); + obs_h->obscode_gps[i] = Type2Code(i, buff); } } else if (obs_h->obstypenum_gps > 13) { @@ -760,7 +754,6 @@ void read_o_h(FILE* fp_obs, pobs_head obs_h) /*Read the body data of file of obs*/ void read_o_eb(FILE* fp_obs, pobs_head obs_h, pobs_epoch obs_e, pobs_body obs_b) { - initobs_e(obs_e, obs_b); char buff[MAXRINEX] = { 0 }; char flag = { 0 }; while (fgets(buff, MAXRINEX, fp_obs)) { diff --git a/src/rnx2pos.cpp b/src/rnx2pos.cpp index 7e03517..517eb91 100644 --- a/src/rnx2pos.cpp +++ b/src/rnx2pos.cpp @@ -368,9 +368,7 @@ double brdm2pos(char nav_path[260], char obs_path[260], char res_path[260], int rewind(fp_obs); obs_h = (pobs_head)malloc(sizeof(obs_head)); - obs_e = (pobs_epoch)malloc(sizeof(obs_epoch)); - obs_b = (pobs_body)malloc(sizeof(obs_body)); - if (obs_h && obs_e && obs_b) { + if (obs_h) { read_o_h(fp_obs, obs_h); tem2 = XYZ2BLH(tem2, obs_h->apX, obs_h->apY, obs_h->apZ); @@ -396,14 +394,18 @@ double brdm2pos(char nav_path[260], char obs_path[260], char res_path[260], int //Begin to calculate for (int i = 0; i < epochunum; i++) { + //Allocate memory for obs epoch and body data + obs_e = (pobs_epoch)malloc(sizeof(obs_epoch)); + obs_b = (pobs_body)malloc(sizeof(obs_body)); + read_o_eb(fp_obs, obs_h, obs_e, obs_b); result += sat_pos_cal(obs_h, obs_e, obs_b, nav_b, result_file, station, gnsscode, satnum); - fprintf(result_file, "\n"); - } - freeobs_e(obs_e, obs_b); + fprintf(result_file, "\n"); + freeobs_e(obs_e, obs_b); + } free(obs_h); free(nav_h); free(nav_b); fprintf(result_file, "\nEND"); fclose(result_file); if (epochunum == result) return 0;