Archived
WORING IN RESULT THE PROBLEM OF POINTER
This commit is contained in:
1 parent
1784076340
commit
54547f9d3e
7 files changed
+147
-134
No files matched your search
@@ -13,70 +13,8 @@
|
||||
#include"blh2enu.h"
|
||||
#include"rahcal.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
#define a 6378137.0//长半轴
|
||||
#define f (1 / 298.257223563)//扁率
|
||||
#define e2 (f*(2-f))//第一偏心率平方
|
||||
#define C_V 299792458//光速(m)
|
||||
#define GM 398600500000000//地心引力常数
|
||||
#define math_e 2.718281828459 //e值
|
||||
#define PI 3.141592653589793
|
||||
#define Earth_e 7.2921151467e-5 //地球自转角速度
|
||||
#define C1 0
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
//卫星位置结构体
|
||||
typedef struct
|
||||
{
|
||||
double X[36];
|
||||
double Y[36];
|
||||
double Z[36];
|
||||
double deltat[36];//改正前的信号传播时间
|
||||
double delta_t[36];//改正后的信号传播时间
|
||||
double delta_clk[36];
|
||||
}pos_t, *ppos_t;
|
||||
|
||||
//测站位置结构体
|
||||
typedef struct
|
||||
{
|
||||
double X;
|
||||
double Y;
|
||||
double Z;
|
||||
double B;
|
||||
double L;
|
||||
double H;
|
||||
double delta_TR;
|
||||
}station, *pstation;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double B;
|
||||
int B_d;
|
||||
int B_m;
|
||||
int B_s;
|
||||
double L;
|
||||
int L_d;
|
||||
int L_m;
|
||||
int L_s;
|
||||
double H;
|
||||
}blh, *pblh;
|
||||
|
||||
typedef struct enu
|
||||
{
|
||||
double E;
|
||||
double N;
|
||||
double U;
|
||||
}enu, *penu;
|
||||
|
||||
typedef struct rah
|
||||
{
|
||||
double R;
|
||||
double A;
|
||||
double H;
|
||||
}rah, *prah;
|
||||
|
||||
/* ------------------------------- GPS卫星位置计算函数 ------------------------------ */
|
||||
int gps_pos(int eponum, int sPRN, int best_epoch, double GPSsec,
|
||||
/* ------------------------------- GPS卫星位置计算函数 ------------------------------ */
|
||||
int gps_pos(int eponum, int sPRN, int best_epoch, double GPSsec,
|
||||
pnav_body nav_b, pobs_head obs_h, ppos_t pos_t)
|
||||
{
|
||||
double T_S = GPSsec - pos_t[eponum].deltat[sPRN];//计算信号发射时刻
|
||||
@@ -120,11 +58,11 @@
|
||||
double rela = 2*sqrt(GM) * nav_b[best_epoch].e * nav_b[best_epoch].sqrtA * sin(Es)/pow(C_V,2);
|
||||
pos_t[eponum].delta_clk[sPRN] = nav_b[best_epoch].sa0 + nav_b[best_epoch].sa1 * tk + nav_b[best_epoch].sa2 * pow(tk,2) - rela;
|
||||
}
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
/* ------------------------------- GPS卫星位置计算 ------------------------------ */
|
||||
int sat_gps_pos_clac(FILE * result_file,
|
||||
/* ------------------------------- GPS卫星位置计算&输出 ------------------------------ */
|
||||
int sat_gps_pos_clac(FILE * result_file,
|
||||
pnav_body nav_b, pobs_epoch obs_e, pobs_body obs_b,
|
||||
pobs_head obs_h, pstation station, ppos_t pos_t,
|
||||
pblh blh, penu enu, prah rah,
|
||||
@@ -149,9 +87,6 @@
|
||||
teml = (pdeg2dms)malloc(sizeof(pdeg2dms)* 512);
|
||||
for (int i = 0; i < o_epochnum; i++)//第i个历元
|
||||
{
|
||||
|
||||
|
||||
|
||||
result_file = fopen(".\\Pos_out\\LLA_result_for_read.txt", "a+");
|
||||
fprintf(result_file, "\n>%04d %04d %02d %02d %02d %02d %07.04f",i + 1 ,obs_e[i].y ,obs_e[i].m ,obs_e[i].d ,obs_e[i].h ,obs_e[i].min ,obs_e[i].sec);
|
||||
fclose(result_file);
|
||||
@@ -187,12 +122,12 @@
|
||||
}
|
||||
|
||||
/* ----------------------------- 地固坐标系转经纬大地高坐标系 ----------------------------- */
|
||||
tem1 = XYZ2BLH( tem1, pos_t[i].X[sPRN], pos_t[i].Y[sPRN], pos_t[i].Z[sPRN], a, e2);
|
||||
tem1 = XYZ2BLH( tem1, pos_t[i].X[sPRN], pos_t[i].Y[sPRN], pos_t[i].Z[sPRN]);
|
||||
blh->B = rad2deg(tem1->B);
|
||||
blh->L = rad2deg(tem1->L);
|
||||
blh->H = tem1->H;
|
||||
|
||||
tem2 = XYZ2BLH( tem2, obs_h->apX, obs_h->apY, obs_h->apZ, a, e2);
|
||||
tem2 = XYZ2BLH( tem2, obs_h->apX, obs_h->apY, obs_h->apZ);
|
||||
station->B = tem2->B;
|
||||
station->L = tem2->L;
|
||||
station->H = tem2->H;
|
||||
@@ -254,10 +189,10 @@
|
||||
int progress_now = (int)(((i+1)*100/2880));
|
||||
if ((progress_now - progress)>=2)
|
||||
{
|
||||
printf("-");
|
||||
printf("=");
|
||||
count++;
|
||||
progress = progress_now;
|
||||
printf("-]%3d%%", progress);
|
||||
printf("=]%3d%%", progress);
|
||||
for(int countb = 0; countb < (5); countb++)
|
||||
{
|
||||
printf("\b");
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef _DEGRRAD_H_
|
||||
#define _DEGRRAD_H_
|
||||
#define PI 3.141592653589793
|
||||
|
||||
#include"read.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/// @brief 角度转弧度
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* @Author: KenanZhu111 3471685733@qq.com
|
||||
* @Date: 2024-09-03 16:26:35
|
||||
* @LastEditors: KenanZhu111 3471685733@qq.com
|
||||
* @LastEditTime: 2024-09-22 17:33:35
|
||||
* @FilePath: \Sat_Position_Solving_ver1.4\main.c
|
||||
*/
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* 仅支持{ Ver 3.04 }版本RENIX观测值文件与广播星历文件读取
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@@ -85,5 +93,6 @@ while(over == 0)
|
||||
|
||||
End_inTerminal(fp_nav, fp_obs, langop, over);//显示函数
|
||||
}
|
||||
system("pause");
|
||||
return 0;
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
#ifndef _RAHCAL_H_
|
||||
#define _RAHCAL_H_
|
||||
#define PI 3.141592653589793
|
||||
|
||||
#include<stdlib.h>
|
||||
#include<math.h>
|
||||
|
||||
#include"read.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double R;
|
||||
|
||||
@@ -5,60 +5,87 @@
|
||||
#include<string.h>
|
||||
|
||||
#define MAXRINEX 1000//一行最大字符数
|
||||
/* ------------------------------ WGS-84 CONST ------------------------------ */
|
||||
#define a 6378137.0
|
||||
#define e2 (0.0033528106647475*(2 - 0.0033528106647475))
|
||||
#define C_V 299792458
|
||||
#define GM 398600500000000
|
||||
#define math_e 2.718281828459
|
||||
#define PI 3.141592653589793
|
||||
#define Earth_e 7.2921151467e-5
|
||||
#define C1 0
|
||||
/* ----------------------------- GPS OBSERV TYPE ---------------------------- */
|
||||
#define C1C 101
|
||||
#define C1S 102
|
||||
#define C1L 103
|
||||
#define C1X 104
|
||||
#define C1P 105
|
||||
#define C1W 106
|
||||
#define C1Y 107
|
||||
#define C1M 108
|
||||
|
||||
void setstr(char* des, const char* src, int n)
|
||||
{
|
||||
char* p = des;
|
||||
const char* q = src;
|
||||
while (*q && q < src+n)
|
||||
{
|
||||
*p++ = *q++;
|
||||
}
|
||||
*p-- = '\0';
|
||||
//去掉尾部空格
|
||||
while (p >= des && *p == ' ')
|
||||
{
|
||||
*p-- = '\0';
|
||||
}
|
||||
}
|
||||
#define C2C 201
|
||||
#define C2S 202
|
||||
#define C2L 203
|
||||
#define C2X 204
|
||||
#define C2P 205
|
||||
#define C2W 206
|
||||
#define C2Y 207
|
||||
#define C2M 208
|
||||
|
||||
/* ---------------------- 获取文件数据块行数,从END OF HEADER后开始起算 --------------------- */
|
||||
extern int getgpssatnum(FILE* fp_nav)
|
||||
{
|
||||
int gps_satnum = 0;
|
||||
int flag = 0;
|
||||
char buff[MAXRINEX];//用来存放读取到的字符串
|
||||
char satvar;
|
||||
char* lable = buff + 60;
|
||||
//fgets函数,读取一行,当读取结束后返回NULL指针,格式如下:
|
||||
//char * fgets ( char * str, int num, FILE * stream );
|
||||
while (fgets(buff, MAXRINEX, fp_nav))
|
||||
#define C5I 501
|
||||
#define C5Q 502
|
||||
#define C5X 503
|
||||
/* ------------------------------ FOR CALMOD.H ------------------------------ */
|
||||
//卫星位置结构体
|
||||
typedef struct
|
||||
{
|
||||
if (flag == 1)
|
||||
{
|
||||
while (fgets(buff, MAXRINEX, fp_nav))
|
||||
{
|
||||
strncpy(&satvar, buff + 0, 1);
|
||||
if (satvar != 'G')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (satvar == 'G')
|
||||
{
|
||||
gps_satnum++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
double X[36];
|
||||
double Y[36];
|
||||
double Z[36];
|
||||
double deltat[36];//改正前的信号传播时间
|
||||
double delta_t[36];//改正后的信号传播时间
|
||||
double delta_clk[36];
|
||||
}pos_t, *ppos_t;
|
||||
|
||||
}
|
||||
|
||||
if (strstr(lable, "END OF HEADER"))
|
||||
//测站位置结构体
|
||||
typedef struct
|
||||
{
|
||||
flag = 1;
|
||||
}
|
||||
}
|
||||
return gps_satnum;
|
||||
}
|
||||
double X;
|
||||
double Y;
|
||||
double Z;
|
||||
double B;
|
||||
double L;
|
||||
double H;
|
||||
double delta_TR;
|
||||
}station, *pstation;
|
||||
//经纬高结构体
|
||||
typedef struct
|
||||
{
|
||||
double B;
|
||||
int B_d;
|
||||
int B_m;
|
||||
int B_s;
|
||||
double L;
|
||||
int L_d;
|
||||
int L_m;
|
||||
int L_s;
|
||||
double H;
|
||||
}blh, *pblh;
|
||||
//东北天结构体
|
||||
typedef struct enu
|
||||
{
|
||||
double E;
|
||||
double N;
|
||||
double U;
|
||||
}enu, *penu;
|
||||
//高度方位角结构体
|
||||
typedef struct rah
|
||||
{
|
||||
double R;
|
||||
double A;
|
||||
double H;
|
||||
}rah, *prah;
|
||||
|
||||
/* ------------------------ 将字符串转换为浮点数,i起始位置,n输入多少个字符 ----------------------- */
|
||||
static double strtonum(const char* buff, int i, int n)
|
||||
@@ -230,6 +257,7 @@ typedef struct obs_body
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* 读取O文件
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/* -------------------------------- 获取O文件历元数 -------------------------------- */
|
||||
extern int get_epochnum(FILE* fp_obs)
|
||||
{
|
||||
@@ -437,6 +465,45 @@ extern void read_o_b(FILE* fp_obs, pobs_epoch obs_e, pobs_body obs_b, int type_g
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* 读取N文件
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/* ---------------------- 获取文件数据块行数,从END OF HEADER后开始起算 --------------------- */
|
||||
extern int getgpssatnum(FILE* fp_nav)
|
||||
{
|
||||
int gps_satnum = 0;
|
||||
int flag = 0;
|
||||
char buff[MAXRINEX];//用来存放读取到的字符串
|
||||
char satvar;
|
||||
char* lable = buff + 60;
|
||||
//fgets函数,读取一行,当读取结束后返回NULL指针,格式如下:
|
||||
//char * fgets ( char * str, int num, FILE * stream );
|
||||
while (fgets(buff, MAXRINEX, fp_nav))
|
||||
{
|
||||
if (flag == 1)
|
||||
{
|
||||
while (fgets(buff, MAXRINEX, fp_nav))
|
||||
{
|
||||
strncpy(&satvar, buff + 0, 1);
|
||||
if (satvar != 'G')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (satvar == 'G')
|
||||
{
|
||||
gps_satnum++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (strstr(lable, "END OF HEADER"))
|
||||
{
|
||||
flag = 1;
|
||||
}
|
||||
}
|
||||
return gps_satnum;
|
||||
}
|
||||
|
||||
/* -------------------------------- 读取N文件数据头 -------------------------------- */
|
||||
void read_n_h(FILE* fp_nav, pnav_head nav_h)
|
||||
{
|
||||
|
||||
+8
-8
@@ -50,7 +50,7 @@ void ReadO_inTerminal(FILE *fp_obs, int langop, char obs_file[20])
|
||||
{
|
||||
if (langop == 0 && fp_obs == NULL)
|
||||
{
|
||||
printf("|>> 观测文件%s读取失败,请检查文件名或者确认文件是否被移动\n", obs_file);
|
||||
printf("|>> 观测文件%s读取失败,请检查文件名或者确认文件是否被移动\n\n", obs_file);
|
||||
}
|
||||
else if (langop == 0 && fp_obs != NULL)
|
||||
{
|
||||
@@ -63,7 +63,7 @@ void ReadO_inTerminal(FILE *fp_obs, int langop, char obs_file[20])
|
||||
}
|
||||
else if (langop == 1 && fp_obs != NULL)
|
||||
{
|
||||
printf("|>> The observation file %s has been read successfully and data is being processed...\n", obs_file);
|
||||
printf("|>> The observation file %s has been read successfully and data is being processed...\n\n", obs_file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,13 +72,13 @@ pfilename OutO_InN_inTermianl(FILE *fp_obs, int langop, pfilename filename)
|
||||
if (langop == 0 && fp_obs != NULL)
|
||||
{
|
||||
printf("|>>> 观测文件读取完成! <<<|\n\n\n");
|
||||
printf("|>> 请输入导航文件的文件名(包含拓展名):\n");
|
||||
printf("|>> 请输入导航文件的文件名(包含拓展名):\n\n");
|
||||
scanf("%s", &filename->nav_file);
|
||||
}
|
||||
if (langop == 1 && fp_obs != NULL)
|
||||
{
|
||||
printf("|>>> Observation file read complete! <<<|\n\n\n");
|
||||
printf("|>> Please enter the file name (including the extension) of the Navigation data file.:\n");
|
||||
printf("|>> Please enter the file name (including the extension) of the Navigation data file.:\n\n");
|
||||
scanf("%s", &filename->nav_file);
|
||||
}
|
||||
return filename;
|
||||
@@ -88,7 +88,7 @@ void ReadN_inTerminal(FILE *fp_nav, FILE *fp_obs, int langop, char nav_file[20])
|
||||
{
|
||||
if (langop == 0 && fp_obs != NULL && fp_nav == NULL)
|
||||
{
|
||||
printf("|>> 导航文件%s读取失败,请检查文件名或者确认文件是否被移动\n", nav_file);
|
||||
printf("|>> 导航文件%s读取失败,请检查文件名或者确认文件是否被移动\n\n", nav_file);
|
||||
}
|
||||
else if (langop == 0 && fp_obs != NULL && fp_nav != NULL)
|
||||
{
|
||||
@@ -97,7 +97,7 @@ void ReadN_inTerminal(FILE *fp_nav, FILE *fp_obs, int langop, char nav_file[20])
|
||||
|
||||
if (langop == 1 && fp_obs != NULL && fp_nav == NULL)
|
||||
{
|
||||
printf("|>> Navigation file %s failed to be read. Please check the file name or confirm whether the file has been moved\n", nav_file);
|
||||
printf("|>> Navigation file %s failed to be read. Please check the file name or confirm whether the file has been moved\n\n", nav_file);
|
||||
}
|
||||
else if (langop == 1 && fp_obs != NULL && fp_nav != NULL)
|
||||
{
|
||||
@@ -109,11 +109,11 @@ void OutN_inTerminal(FILE *fp_nav, FILE *fp_obs, int langop)
|
||||
{
|
||||
if (langop == 0 && fp_obs != NULL && fp_nav != NULL)
|
||||
{
|
||||
printf("|>>> 导航文件读取完成! <<<|\n\n");printf("|>> 正在计算数据:[-");
|
||||
printf("|>>> 导航文件读取完成! <<<|\n\n");printf("|>> 正在计算数据:[=");
|
||||
}
|
||||
if (langop == 1 && fp_obs != NULL && fp_nav != NULL)
|
||||
{
|
||||
printf("|>>> Navigation file read complete! <<<|\n\n");printf("|>> Calculating data:[-");
|
||||
printf("|>>> Navigation file read complete! <<<|\n\n");printf("|>> Calculating data:[=");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ typedef struct
|
||||
/// @return 返回自定义结构体类型包含B,L,H成员
|
||||
/* -------------------------------------------------------------------------- */
|
||||
pxyz2blh XYZ2BLH(pxyz2blh xyz2blh,
|
||||
double X, double Y, double Z, double a, double e2)
|
||||
double X, double Y, double Z)
|
||||
|
||||
{
|
||||
xyz2blh = (pxyz2blh)malloc(sizeof(pxyz2blh));
|
||||
|
||||
Reference in new issue
Block a user