Archived
None
This commit is contained in:
1 parent
5ccca138b6
commit
3852cdbc1b
3 files changed
+192
-106
No files matched your search
@@ -131,8 +131,27 @@
|
||||
int o_epochnum, int gps_satnum)
|
||||
{ int progress = 0;
|
||||
int count = 0;
|
||||
pxyz2blh tem1 = NULL;
|
||||
pxyz2blh tem2 = NULL;
|
||||
pblh2enu tem3 = NULL;
|
||||
prahcal tem4 = NULL;
|
||||
pdeg2dms temb = NULL;
|
||||
pdeg2dms teml = NULL;
|
||||
blh = (pblh)malloc(sizeof(pblh) * o_epochnum* 256);
|
||||
enu = (penu)malloc(sizeof(penu) * o_epochnum* 256);
|
||||
rah = (prah)malloc(sizeof(prah) * o_epochnum* 256);
|
||||
pos_t = (ppos_t)malloc(sizeof(ppos_t) * o_epochnum* 256);
|
||||
station = (pstation)malloc(sizeof(pstation) * o_epochnum* 256);
|
||||
tem1 = (pxyz2blh)malloc(sizeof(pxyz2blh)* 512);
|
||||
tem2 = (pxyz2blh)malloc(sizeof(pxyz2blh)* 512);
|
||||
tem3 = (pblh2enu)malloc(sizeof(pblh2enu)* 512);
|
||||
temb = (pdeg2dms)malloc(sizeof(pdeg2dms)* 512);
|
||||
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);
|
||||
@@ -142,12 +161,7 @@
|
||||
result_file = fopen(".\\Observation_Station_Site-Solving_by_Matlab\\LLA_result_for_Matlab.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);
|
||||
|
||||
blh = (pblh)malloc(sizeof(pblh) * o_epochnum * 256);
|
||||
enu = (penu)malloc(sizeof(penu) * o_epochnum * 256);
|
||||
rah = (prah)malloc(sizeof(prah) * o_epochnum * 256);
|
||||
pos_t = (ppos_t)malloc(sizeof(ppos_t) * o_epochnum * 256);
|
||||
station = (pstation)malloc(sizeof(pstation) * o_epochnum *256);
|
||||
|
||||
|
||||
for (int j = 0; j < obs_e[i].gps_num; j++)//第j颗GPS卫星
|
||||
{
|
||||
@@ -172,16 +186,12 @@
|
||||
gps_pos( i, sPRN, best_epoch, GPSsec, nav_b, obs_h, pos_t);
|
||||
}
|
||||
|
||||
/* ----------------------------- 地固坐标系转经纬大地高坐标系 ----------------------------- */
|
||||
pxyz2blh tem1 = NULL;
|
||||
tem1 = (pxyz2blh)malloc(sizeof(pxyz2blh));
|
||||
/* ----------------------------- 地固坐标系转经纬大地高坐标系 ----------------------------- */
|
||||
tem1 = XYZ2BLH( tem1, pos_t[i].X[sPRN], pos_t[i].Y[sPRN], pos_t[i].Z[sPRN], a, e2);
|
||||
blh->B = rad2deg(tem1->B);
|
||||
blh->L = rad2deg(tem1->L);
|
||||
blh->H = rad2deg(tem1->H);
|
||||
|
||||
pxyz2blh tem2 = NULL;
|
||||
tem2 = (pxyz2blh)malloc(sizeof(pxyz2blh));
|
||||
tem2 = XYZ2BLH( tem2, obs_h->apX, obs_h->apY, obs_h->apZ, a, e2);
|
||||
station->B = tem2->B;
|
||||
station->L = tem2->L;
|
||||
@@ -192,8 +202,7 @@
|
||||
double deltax = pos_t[i].X[sPRN] - obs_h->apX;
|
||||
double deltay = pos_t[i].Y[sPRN] - obs_h->apY;
|
||||
double deltaz = pos_t[i].Z[sPRN] - obs_h->apZ;
|
||||
pblh2enu tem3 = NULL;
|
||||
tem3 = (pblh2enu)malloc(sizeof(pblh2enu));
|
||||
|
||||
tem3 = BLH2ENU(tem3, station->B, station->L, deltax, deltay, deltaz);
|
||||
enu->E = tem3->E;
|
||||
enu->N = tem3->N;
|
||||
@@ -201,29 +210,22 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/* ---------------------------- 卫星方位角a,高度角h,向径r计算 --------------------------- */
|
||||
prahcal tem4 = NULL;
|
||||
tem4 = (prahcal)malloc(sizeof(prahcal));
|
||||
tem4 = RAHCAL(tem4, enu->E, enu->N, enu->U);
|
||||
rah->R = tem4->R;
|
||||
rah->A = rad2deg(tem4->A);
|
||||
rah->H = rad2deg(tem4->H);
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
if (blh->H < 0 || nav_b[best_epoch].sHEA != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
pdeg2dms temb = NULL;
|
||||
temb = (pdeg2dms)malloc(sizeof(pdeg2dms));
|
||||
temb = DEG2DMS(temb, blh->B);
|
||||
blh->B_d = temb->D;
|
||||
blh->B_m = temb->M;
|
||||
blh->B_s = temb->S;
|
||||
|
||||
pdeg2dms teml = NULL;
|
||||
teml = (pdeg2dms)malloc(sizeof(pdeg2dms));
|
||||
teml = DEG2DMS(teml, blh->L);
|
||||
blh->L_d = teml->D;
|
||||
blh->L_m = teml->M;
|
||||
@@ -240,14 +242,8 @@
|
||||
,sPRN, pos_t[i].X[sPRN], pos_t[i].Y[sPRN], pos_t[i].Z[sPRN], obs_b[i].obs_gps[j][C1], obs_b[i].obs_gps[j][10], rah->H, nav_b[best_epoch].TGD, pos_t[i].delta_clk[sPRN]);
|
||||
fclose(result_file);
|
||||
}
|
||||
}
|
||||
//释放指针内存
|
||||
free(blh);pblh blh = NULL;
|
||||
free(enu);penu enu = NULL;
|
||||
free(rah);prah rah = NULL;
|
||||
free(pos_t);ppos_t pos_t = NULL;
|
||||
free(station);pstation station = NULL;
|
||||
|
||||
}
|
||||
result_file = fopen(".\\Observation_Station_Site-Solving_by_Matlab\\LLA_result_for_Matlab.txt", "a+");
|
||||
fprintf(result_file, "\n");
|
||||
fclose(result_file);
|
||||
@@ -274,7 +270,11 @@
|
||||
result_file = fopen(".\\Observation_Station_Site-Solving_by_Matlab\\LLA_result_for_Matlab.txt", "a+");
|
||||
fprintf(result_file, "\nEND");
|
||||
fclose(result_file);
|
||||
|
||||
free(blh);blh = NULL;
|
||||
free(enu);enu = NULL;
|
||||
free(rah);rah = NULL;
|
||||
free(pos_t);pos_t = NULL;
|
||||
free(station);station = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include"read.h"
|
||||
#include"cal_mod.h"
|
||||
#include"terminal.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
@@ -30,111 +31,59 @@ int main(void)
|
||||
|
||||
int over = 0;
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
while(over == 0)
|
||||
{
|
||||
int langop;
|
||||
char obs_flie[20];
|
||||
char nav_file[20];
|
||||
pfilename filetype = NULL;
|
||||
|
||||
printf("|**************SPP-pseudorange-positioning*****************************************|\n");
|
||||
printf("**@Author: KenanZhu\n**@Date: 2024/09/21\n**@Make by: C & Python & Matlab\n");
|
||||
printf("**@INTRO: \n**The main functions of the software include:\n");
|
||||
printf("**read RINEX3.04 files, and output three formats of document files,\n");
|
||||
printf("**please cooperate with the corresponding tools for processing.\n");
|
||||
printf("**Specific please see:\n https://github.com/KenanZhu111/SPP_-pseudorange-positioning\n");
|
||||
printf("|**********************************************************************************|\n\n");
|
||||
|
||||
printf("|>>> 请选择您的语言:/Please choose your language <<<|\n--------------------\n[1 | ENG][0 | 中文]\n--------------------\n");
|
||||
scanf("%d",&langop);
|
||||
|
||||
if (langop == 0)
|
||||
{ printf("|>>> 本程序只支持 ver3.04 RINEX文件的读取 <<<|\n\n");
|
||||
printf("|>> 请输入观测数据文件的文件名(包含拓展名):\n");
|
||||
scanf("%s", &obs_flie);}
|
||||
if (langop == 1)
|
||||
{ printf("|>>> This program only supports reading ver3.04 RINEX files <<<|\n\n");
|
||||
printf("|>> Please enter the file name (including the extension) of the observation data file.:\n");
|
||||
scanf("%s", &obs_flie);}
|
||||
/* ---------------------------------- 终端显示 ---------------------------------- */
|
||||
langop = Begin_inTermianl();
|
||||
filetype = (pfilename)malloc(sizeof(pfilename) * 512);
|
||||
filetype = InO_inTermianl(langop, filetype);
|
||||
/* -------------------------------------------------------------------------- */
|
||||
//O文件读取
|
||||
fp_obs = fopen(obs_flie, "r");
|
||||
if (langop == 0 && fp_obs == NULL)
|
||||
{printf("|>> 观测文件%s读取失败,请检查文件名或者确认文件是否被移动\n", obs_flie);}
|
||||
else if (langop == 0 && fp_obs != NULL)
|
||||
{printf("|>> 观测文件%s读取成功,正在处理数据...\n\n", obs_flie);}
|
||||
|
||||
if (langop == 1 && fp_obs == NULL)
|
||||
{printf("|>> Observation file %s failed to be read. Please check the file name or confirm whether the file has been moved\n\n", obs_flie);}
|
||||
else if (langop == 1 && fp_obs != NULL)
|
||||
{printf("|>> The observation file %s has been read successfully and data is being processed...\n", obs_flie);}
|
||||
fp_obs = fopen(filetype->obs_file, "r");
|
||||
|
||||
int o_epochnum = get_epochnum(fp_obs);//O文件历元数
|
||||
ReadO_inTerminal(fp_obs, langop, filetype->obs_file);//显示函数
|
||||
|
||||
int o_epochnum = get_epochnum(fp_obs);
|
||||
rewind(fp_obs);
|
||||
obs_h = (pobs_head)malloc(sizeof(obs_head));//给O文件头开辟空间
|
||||
obs_h = (pobs_head)malloc(sizeof(obs_head));
|
||||
obs_e = (pobs_epoch)malloc(sizeof(obs_epoch) * o_epochnum);
|
||||
obs_b = (pobs_body)malloc(sizeof(obs_body) * o_epochnum);
|
||||
if (obs_h && obs_e && obs_b)
|
||||
{
|
||||
read_o_h(fp_obs, obs_h);//读取O文件头
|
||||
read_o_b(fp_obs, obs_e, obs_b, obs_h->obstypenum_gps, obs_h->obstypenum_bds);//读取O数据块
|
||||
read_o_h(fp_obs, obs_h);
|
||||
read_o_b(fp_obs, obs_e, obs_b, obs_h->obstypenum_gps, obs_h->obstypenum_bds);
|
||||
}
|
||||
fclose(fp_obs);//关闭O文件
|
||||
fclose(fp_obs);
|
||||
|
||||
if (langop == 0 && fp_obs != NULL)
|
||||
{ printf("|>>> 观测文件读取完成! <<<|\n\n\n");
|
||||
printf("|>> 请输入导航文件的文件名(包含拓展名):\n");
|
||||
scanf("%s", &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");
|
||||
scanf("%s", &nav_file);}
|
||||
filetype = OutO_InN_inTermianl(fp_obs, langop, filetype);//显示函数
|
||||
/* -------------------------------------------------------------------------- */
|
||||
//N文件读取
|
||||
fp_nav = fopen(nav_file, "r");
|
||||
fp_obs = fopen(obs_flie, "r");
|
||||
if (langop == 0 && fp_obs != NULL && fp_nav == NULL)
|
||||
{printf("|>> 导航文件%s读取失败,请检查文件名或者确认文件是否被移动\n", nav_file);}
|
||||
else if (langop == 0 && fp_obs != NULL && fp_nav != NULL)
|
||||
{printf("|>> 观测文件%s读取成功,正在处理数据...\n\n", nav_file);}
|
||||
|
||||
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);}
|
||||
else if (langop == 1 && fp_obs != NULL && fp_nav != NULL)
|
||||
{printf("|>> The Navigation file %s has been read successfully and data is being processed...\n\n", nav_file);}
|
||||
fp_nav = fopen(filetype->nav_file, "r");
|
||||
|
||||
int gps_satnum = getgpssatnum(fp_nav);//获取导航文件GPS卫星数据块数
|
||||
rewind(fp_nav);//将文件指针返回值起始位置
|
||||
nav_h = (pnav_head)malloc(sizeof(nav_head));//给N文件头开辟空间
|
||||
ReadN_inTerminal(fp_nav, fp_obs, langop, filetype->nav_file);
|
||||
|
||||
int gps_satnum = getgpssatnum(fp_nav);
|
||||
rewind(fp_nav);
|
||||
nav_h = (pnav_head)malloc(sizeof(nav_head));
|
||||
nav_b = (pnav_body)malloc(sizeof(nav_body) * gps_satnum * 20);
|
||||
if (nav_h && nav_b)
|
||||
{
|
||||
read_n_h(fp_nav, nav_h);//读取N头文件
|
||||
read_n_b(fp_nav, nav_b);//读取N数据块
|
||||
read_n_h(fp_nav, nav_h);
|
||||
read_n_b(fp_nav, nav_b);
|
||||
}
|
||||
fclose(fp_nav);//关闭N文件
|
||||
fclose(fp_nav);
|
||||
|
||||
if (langop == 0 && fp_obs != NULL && fp_nav != NULL)
|
||||
{printf("|>>> 导航文件读取完成! <<<|\n\n");printf("|>> 正在计算数据:[-");}
|
||||
if (langop == 1 && fp_obs != NULL && fp_nav != NULL)
|
||||
{printf("|>>> Navigation file read complete! <<<|\n\n");printf("|>> Calculating data:[-");}
|
||||
OutN_inTerminal(fp_nav, fp_obs, langop);//显示函数
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
if (fp_obs != NULL && fp_nav != NULL)
|
||||
{
|
||||
over = sat_gps_pos_clac(result_file, nav_b, obs_e, obs_b, obs_h, station, pos_t, blh, enu, rah, o_epochnum, gps_satnum);
|
||||
}
|
||||
/* -------------------------------------------------------------------------- */
|
||||
if (langop == 0 && fp_nav != NULL && fp_obs != NULL)
|
||||
{ if (over == 1)
|
||||
{printf("\n数据生成完毕!");}
|
||||
if (over != 1)
|
||||
{printf("\n数据处理发生错误!");}}
|
||||
if (langop == 1 && fp_nav != NULL && fp_obs != NULL)
|
||||
{ if (over == 1)
|
||||
{printf("\nData generation completed!");}
|
||||
if (over != 1)
|
||||
{printf("\nData processing error!");}}
|
||||
|
||||
End_inTerminal(fp_nav, fp_obs, langop, over);//显示函数
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
#ifndef _TERMINAL_H_
|
||||
#define _TREMINAL_H_
|
||||
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char obs_file[20];
|
||||
char nav_file[20];
|
||||
}filename, *pfilename;
|
||||
|
||||
|
||||
int Begin_inTermianl()
|
||||
{
|
||||
int langop;
|
||||
printf("|**************SPP-pseudorange-positioning*****************************************|\n");
|
||||
printf("**@Author: KenanZhu\n**@Date: 2024/09/21\n**@Make by: C & Python & Matlab\n");
|
||||
printf("**@INTRO: \n**The main functions of the software include:\n");
|
||||
printf("**read RINEX3.04 files, and output three formats of document files,\n");
|
||||
printf("**please cooperate with the corresponding tools for processing.\n");
|
||||
printf("**Specific please see:\n https://github.com/KenanZhu111/SPP_-pseudorange-positioning\n");
|
||||
printf("|**********************************************************************************|\n\n");
|
||||
|
||||
printf("|>>> 请选择您的语言:/Please choose your language <<<|\n--------------------\n[1 | ENG][0 | 中文]\n--------------------\n");
|
||||
scanf("%d",&langop);
|
||||
|
||||
return langop;
|
||||
}
|
||||
|
||||
pfilename InO_inTermianl(int langop, pfilename filename)
|
||||
{
|
||||
filename = (pfilename)malloc(sizeof(pfilename));
|
||||
if (langop == 0)
|
||||
{
|
||||
printf("|>>> 本程序只支持 ver3.04 RINEX文件的读取 <<<|\n\n");
|
||||
printf("|>> 请输入观测数据文件的文件名(包含拓展名):\n");
|
||||
scanf("%s", &filename->obs_file);
|
||||
}
|
||||
if (langop == 1)
|
||||
{
|
||||
printf("|>>> This program only supports reading ver3.04 RINEX files <<<|\n\n");
|
||||
printf("|>> Please enter the file name (including the extension) of the observation data file.:\n");
|
||||
scanf("%s", &filename->obs_file);
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
void ReadO_inTerminal(FILE *fp_obs, int langop, char obs_file[20])
|
||||
{
|
||||
if (langop == 0 && fp_obs == NULL)
|
||||
{
|
||||
printf("|>> 观测文件%s读取失败,请检查文件名或者确认文件是否被移动\n", obs_file);
|
||||
}
|
||||
else if (langop == 0 && fp_obs != NULL)
|
||||
{
|
||||
printf("|>> 观测文件%s读取成功,正在处理数据...\n\n", obs_file);
|
||||
}
|
||||
|
||||
if (langop == 1 && fp_obs == NULL)
|
||||
{
|
||||
printf("|>> Observation file %s failed to be read. Please check the file name or confirm whether the file has been moved\n\n", obs_file);
|
||||
}
|
||||
else if (langop == 1 && fp_obs != NULL)
|
||||
{
|
||||
printf("|>> The observation file %s has been read successfully and data is being processed...\n", obs_file);
|
||||
}
|
||||
}
|
||||
|
||||
pfilename OutO_InN_inTermianl(FILE *fp_obs, int langop, pfilename filename)
|
||||
{
|
||||
if (langop == 0 && fp_obs != NULL)
|
||||
{
|
||||
printf("|>>> 观测文件读取完成! <<<|\n\n\n");
|
||||
printf("|>> 请输入导航文件的文件名(包含拓展名):\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");
|
||||
scanf("%s", &filename->nav_file);
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
else if (langop == 0 && fp_obs != NULL && fp_nav != NULL)
|
||||
{
|
||||
printf("|>> 观测文件%s读取成功,正在处理数据...\n\n", nav_file);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
else if (langop == 1 && fp_obs != NULL && fp_nav != NULL)
|
||||
{
|
||||
printf("|>> The Navigation file %s has been read successfully and data is being processed...\n\n", nav_file);
|
||||
}
|
||||
}
|
||||
|
||||
void OutN_inTerminal(FILE *fp_nav, FILE *fp_obs, int langop)
|
||||
{
|
||||
if (langop == 0 && fp_obs != NULL && fp_nav != NULL)
|
||||
{
|
||||
printf("|>>> 导航文件读取完成! <<<|\n\n");printf("|>> 正在计算数据:[-");
|
||||
}
|
||||
if (langop == 1 && fp_obs != NULL && fp_nav != NULL)
|
||||
{
|
||||
printf("|>>> Navigation file read complete! <<<|\n\n");printf("|>> Calculating data:[-");
|
||||
}
|
||||
}
|
||||
|
||||
void End_inTerminal(FILE *fp_nav, FILE *fp_obs, int langop, int over)
|
||||
{
|
||||
if (langop == 0 && fp_nav != NULL && fp_obs != NULL)
|
||||
{ if (over == 1)
|
||||
{printf("\n数据生成完毕!");}
|
||||
if (over != 1)
|
||||
{printf("\n数据处理发生错误!");}
|
||||
}
|
||||
if (langop == 1 && fp_nav != NULL && fp_obs != NULL)
|
||||
{
|
||||
if (over == 1)
|
||||
{printf("\nData generation completed!");}
|
||||
if (over != 1)
|
||||
{printf("\nData processing error!");}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user