Archived
Implement GUI by WIN32 API
This commit is contained in:
1 parent
6dbb8aa67d
commit
3ffe92bb31
10 files changed
+361
-98072
No files matched your search
-31613
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
+282
@@ -0,0 +1,282 @@
|
|||||||
|
/*
|
||||||
|
* @Author: KenanZhu111 3471685733@qq.com
|
||||||
|
* @Date: 2024-09-27 19:05:41
|
||||||
|
* @LastEditors: KenanZhu111 3471685733@qq.com
|
||||||
|
* @LastEditTime: 2024-09-27 19:55:46
|
||||||
|
* @FilePath: \Sat_Position_Solving_ver1.4.7\maingui.c
|
||||||
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
||||||
|
*/
|
||||||
|
#include<stdio.h>
|
||||||
|
#include<wchar.h>
|
||||||
|
#include<stdlib.h>
|
||||||
|
#include<string.h>
|
||||||
|
#include<windows.h>
|
||||||
|
#include<Commdlg.h>
|
||||||
|
|
||||||
|
#include"headers/public.h"
|
||||||
|
#include"headers/read.h"
|
||||||
|
#include"headers/cal_mod.h"
|
||||||
|
|
||||||
|
#pragma comment(linker,"\"/manifestdependency:type='win32' \
|
||||||
|
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
|
||||||
|
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||||
|
|
||||||
|
#define FILEEXOP TEXT("All Files(*.*)\0*.*\0"\
|
||||||
|
"Obs Files(*.o*)\0*.20o;*.21o;*.22o;*.23o;*.24o\0"\
|
||||||
|
"Nav Files(*.p*)\0*.20p;*.21p;*.22p;*.23p;*.24p\0\0");
|
||||||
|
#define FILEEXSV TEXT("All Files(*.*)\0*.*\0"\
|
||||||
|
"Spos Files(*.sp*)\0*.sp\0\0");
|
||||||
|
|
||||||
|
|
||||||
|
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
||||||
|
|
||||||
|
FILE * fp_nav = NULL;
|
||||||
|
FILE * fp_obs = NULL;
|
||||||
|
FILE * result_file = NULL;
|
||||||
|
|
||||||
|
pnav_head nav_h = NULL;
|
||||||
|
pnav_body nav_b = NULL;
|
||||||
|
pobs_head obs_h = NULL;
|
||||||
|
pobs_epoch obs_e = NULL;
|
||||||
|
pobs_body obs_b = NULL;
|
||||||
|
int o_epochnum = 0;
|
||||||
|
int gps_satnum = 0;
|
||||||
|
|
||||||
|
int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int iCmdShow) {
|
||||||
|
|
||||||
|
|
||||||
|
WNDCLASS wndclass;
|
||||||
|
wndclass.style = CS_HREDRAW | CS_VREDRAW;
|
||||||
|
wndclass.lpfnWndProc = WndProc;
|
||||||
|
wndclass.cbClsExtra = 0;
|
||||||
|
wndclass.cbWndExtra = 0;
|
||||||
|
wndclass.hInstance = hInstance;
|
||||||
|
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||||
|
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
|
wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
|
||||||
|
wndclass.lpszMenuName = NULL;
|
||||||
|
wndclass.lpszClassName = TEXT("SPP");
|
||||||
|
|
||||||
|
RegisterClass(&wndclass);
|
||||||
|
|
||||||
|
HWND hwnd;
|
||||||
|
hwnd = CreateWindow(
|
||||||
|
TEXT("SPP"),
|
||||||
|
TEXT("SPP Calculate"),
|
||||||
|
WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
|
||||||
|
650,
|
||||||
|
300,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
hInstance,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
HFONT hFont = (HFONT)GetStockObject(SYSTEM_FIXED_FONT);
|
||||||
|
SendMessage(hwnd, WM_SETFONT, (WPARAM)hFont, 1);
|
||||||
|
|
||||||
|
ShowWindow(hwnd, iCmdShow);
|
||||||
|
UpdateWindow(hwnd);
|
||||||
|
|
||||||
|
MSG msg;
|
||||||
|
while (GetMessage(&msg, NULL, 0, 0)) {
|
||||||
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessage(&msg);
|
||||||
|
}
|
||||||
|
return msg.wParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
int FileSelectDialog(const wchar_t *path)
|
||||||
|
{
|
||||||
|
OPENFILENAME ofn;
|
||||||
|
ZeroMemory(&ofn, sizeof(ofn));
|
||||||
|
ofn.lStructSize = sizeof(ofn);
|
||||||
|
ofn.lpstrFile = path;
|
||||||
|
ofn.nMaxFile = MAX_PATH;
|
||||||
|
ofn.lpstrFilter = FILEEXOP;
|
||||||
|
ofn.lpstrTitle = TEXT("Open From");
|
||||||
|
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_SHOWHELP;
|
||||||
|
return GetOpenFileName(&ofn);
|
||||||
|
}
|
||||||
|
|
||||||
|
int FileSaveDialog(const wchar_t* path)
|
||||||
|
{
|
||||||
|
OPENFILENAME ofn;
|
||||||
|
ZeroMemory(&ofn, sizeof(ofn));
|
||||||
|
ofn.lStructSize = sizeof(ofn);
|
||||||
|
ofn.lpstrDefExt = TEXT(".sp");
|
||||||
|
ofn.lpstrFile = path;
|
||||||
|
ofn.nMaxFile = MAX_PATH;
|
||||||
|
ofn.lpstrFilter = FILEEXSV;
|
||||||
|
ofn.lpstrTitle = TEXT("Save To");
|
||||||
|
ofn.Flags = OFN_OVERWRITEPROMPT | OFN_SHOWHELP;
|
||||||
|
return GetSaveFileName(&ofn);
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){
|
||||||
|
|
||||||
|
const wchar_t wobs_file[MAX_PATH] = { 0 };
|
||||||
|
const wchar_t wnav_file[MAX_PATH] = { 0 };
|
||||||
|
const wchar_t wres_file[MAX_PATH] = { 0 };
|
||||||
|
char obs_file[MAX_PATH] = { 0 };
|
||||||
|
char nav_file[MAX_PATH] = { 0 };
|
||||||
|
char res_file[MAX_PATH] = { 0 };
|
||||||
|
|
||||||
|
HWND hwndopt;
|
||||||
|
|
||||||
|
RECT rect;
|
||||||
|
TCHAR* SATSYS[5] = { TEXT("GPS"), TEXT("GLO"),TEXT("SBAS"), TEXT("BeiDou"), TEXT("Galileo") };
|
||||||
|
static int cxchar, cychar;
|
||||||
|
switch (msg) {
|
||||||
|
|
||||||
|
case WM_CREATE:
|
||||||
|
cxchar = LOWORD(GetDialogBaseUnits());
|
||||||
|
cychar = HIWORD(GetDialogBaseUnits());
|
||||||
|
|
||||||
|
GetWindowRect(hwnd, &rect);
|
||||||
|
MoveWindow(hwnd, rect.left, rect.bottom, 50 * cxchar, 15 * cychar, TRUE);
|
||||||
|
|
||||||
|
CreateWindow(TEXT("Button"), TEXT("Load Obs file"), WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON,
|
||||||
|
cxchar, 5 * cychar,
|
||||||
|
16 * cxchar, 2 * cychar,
|
||||||
|
hwnd, (HMENU)3301, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
|
||||||
|
CreateWindow(TEXT("Button"), TEXT("Load Nav file"), WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON,
|
||||||
|
17 * cxchar, 5 * cychar,
|
||||||
|
16 * cxchar, 2 * cychar,
|
||||||
|
hwnd, (HMENU)3302, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
|
||||||
|
CreateWindow(TEXT("Button"), TEXT("Sat-Position Calculate"), WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON,
|
||||||
|
cxchar, 7 * cychar,
|
||||||
|
32 * cxchar, 2 * cychar,
|
||||||
|
hwnd, (HMENU)3303, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
|
||||||
|
CreateWindow(TEXT("Button"), TEXT("Options..."), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
|
||||||
|
36 * cxchar, 7 * cychar,
|
||||||
|
10 * cxchar, 2 * cychar,
|
||||||
|
hwnd, (HMENU)3304, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
|
||||||
|
CreateWindow(TEXT("Button"), TEXT("Plot"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
|
||||||
|
36 * cxchar, 5 * cychar,
|
||||||
|
10 * cxchar, 2 * cychar,
|
||||||
|
hwnd, (HMENU)3304, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
|
||||||
|
|
||||||
|
|
||||||
|
for (int i = 0; i < 5; i++)
|
||||||
|
{
|
||||||
|
CreateWindow(TEXT("Button"), SATSYS[i], WS_VISIBLE|WS_CHILD|BS_AUTOCHECKBOX,
|
||||||
|
(2 + 9 * i) * cxchar, 21 * cychar/2,
|
||||||
|
8 * cxchar, 5 * cychar/3,
|
||||||
|
hwnd, (HMENU)(5500 + i), ((LPCREATESTRUCT)lParam)->hInstance, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateWindow(TEXT("Button"), TEXT("GNSS"), WS_VISIBLE | WS_CHILD | BS_GROUPBOX,
|
||||||
|
cxchar, 19 * cychar/2,
|
||||||
|
47 * cxchar, 6 * cychar/2,
|
||||||
|
hwnd, (HMENU)(1001), ((LPCREATESTRUCT)lParam)->hInstance, NULL);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
case WM_COMMAND:
|
||||||
|
switch(LOWORD(wParam))
|
||||||
|
{
|
||||||
|
case 3301:
|
||||||
|
while(MessageBox(hwnd,TEXT("Please choose Obs file"),TEXT("NOTICE"),MB_ICONASTERISK|MB_YESNO) == IDYES)
|
||||||
|
{
|
||||||
|
FileSelectDialog(wobs_file);
|
||||||
|
wcstombs(obs_file, wobs_file, MAX_PATH);
|
||||||
|
fp_obs = fopen(obs_file, TEXT("r"));
|
||||||
|
if (fp_obs != NULL)
|
||||||
|
{
|
||||||
|
o_epochnum = get_epochnum(fp_obs);
|
||||||
|
rewind(fp_obs);
|
||||||
|
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);
|
||||||
|
read_o_b(fp_obs, obs_e, obs_b, obs_h->obstypenum_gps, obs_h->obstypenum_bds);
|
||||||
|
}
|
||||||
|
fclose(fp_obs);
|
||||||
|
if (o_epochnum > 0)
|
||||||
|
{
|
||||||
|
MessageBox(hwnd, TEXT("File of Obs load complete!"), TEXT("NOTICE"), MB_ICONASTERISK);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
return 0;
|
||||||
|
case 3302:
|
||||||
|
while(MessageBox(hwnd,TEXT("Please choose Nav file"),TEXT("NOTICE"),MB_ICONASTERISK|MB_YESNO) == IDYES)
|
||||||
|
{
|
||||||
|
FileSelectDialog(wnav_file);
|
||||||
|
wcstombs(nav_file, wnav_file, MAX_PATH);
|
||||||
|
fp_nav = fopen(nav_file, TEXT("r"));
|
||||||
|
if (fp_nav != NULL)
|
||||||
|
{
|
||||||
|
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 * 2);
|
||||||
|
if (nav_h && nav_b)
|
||||||
|
{
|
||||||
|
read_n_h(fp_nav, nav_h);
|
||||||
|
read_n_b(fp_nav, nav_b);
|
||||||
|
}
|
||||||
|
fclose(fp_nav);
|
||||||
|
if (gps_satnum > 0)
|
||||||
|
{
|
||||||
|
MessageBox(hwnd, TEXT("File of Nav load complete!"), TEXT("NOTICE"), MB_ICONASTERISK);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
return 0;
|
||||||
|
case 3303:
|
||||||
|
if (fp_obs == NULL || fp_nav == NULL)
|
||||||
|
{
|
||||||
|
MessageBox(hwnd, TEXT("No Data File!"), TEXT("WARNING"), MB_ICONERROR | MB_OK);
|
||||||
|
}
|
||||||
|
else if (fp_obs != NULL && fp_nav != NULL)
|
||||||
|
{
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
FileSaveDialog(wres_file);
|
||||||
|
if (wres_file == TEXT(""))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wcstombs(res_file, wres_file, MAX_PATH);
|
||||||
|
sat_gps_pos_clac(result_file, nav_b, obs_e, obs_b, obs_h, o_epochnum, gps_satnum, res_file);
|
||||||
|
free(obs_h); free(obs_e); free(obs_b); free(nav_h); free(nav_b);
|
||||||
|
fp_nav = NULL; fp_obs = NULL; result_file = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
return 0;
|
||||||
|
case 3304:
|
||||||
|
|
||||||
|
break;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
case WM_CLOSE:
|
||||||
|
if(MessageBox(hwnd, TEXT("You're shutting the program"), TEXT("Confirm"), MB_YESNO | MB_ICONASTERISK) == IDYES )
|
||||||
|
DestroyWindow(hwnd);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
case WM_DESTROY:
|
||||||
|
PostQuitMessage(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||||
|
}
|
||||||
+72
-110
@@ -16,10 +16,10 @@
|
|||||||
#include"select_epo.h"
|
#include"select_epo.h"
|
||||||
|
|
||||||
/* ------------------------------- GPS卫星位置计算函数 ------------------------------ */
|
/* ------------------------------- GPS卫星位置计算函数 ------------------------------ */
|
||||||
void gps_pos(int eponum, int sPRN, int best_epoch, double GPSsec,
|
pos_ts gps_pos(int sPRN, int best_epoch, double GPSsec,
|
||||||
pnav_body nav_b, pobs_head obs_h, ppos_t pos_t)
|
pnav_body nav_b, pobs_head obs_h, pos_ts pos_t)
|
||||||
{
|
{
|
||||||
double T_S = GPSsec - pos_t[eponum].deltat[sPRN];//计算信号发射时刻
|
double T_S = GPSsec - pos_t.deltat[sPRN];//计算信号发射时刻
|
||||||
double n_0 = sqrt(GM) / pow(nav_b[best_epoch].sqrtA,3);
|
double n_0 = sqrt(GM) / pow(nav_b[best_epoch].sqrtA,3);
|
||||||
double n = n_0 + nav_b[best_epoch].deltan; //计算卫星运行平均角速度
|
double n = n_0 + nav_b[best_epoch].deltan; //计算卫星运行平均角速度
|
||||||
double tk = T_S - nav_b[best_epoch].TOE;//计算归化时间
|
double tk = T_S - nav_b[best_epoch].TOE;//计算归化时间
|
||||||
@@ -51,14 +51,15 @@ void gps_pos(int eponum, int sPRN, int best_epoch, double GPSsec,
|
|||||||
double X = x * cos(l) - y * cos(i) * sin(l);
|
double X = x * cos(l) - y * cos(i) * sin(l);
|
||||||
double Y = x * sin(l) + y * cos(i) * cos(l);
|
double Y = x * sin(l) + y * cos(i) * cos(l);
|
||||||
double Z = y * sin(i);//卫星在地固系下的直角坐标
|
double Z = y * sin(i);//卫星在地固系下的直角坐标
|
||||||
pos_t[eponum].X[sPRN] = cos(Earth_e * pos_t[eponum].delta_t[sPRN]) * X + sin(Earth_e * pos_t[eponum].delta_t[sPRN]) * Y;
|
pos_t.X[sPRN] = cos(Earth_e * pos_t.delta_t[sPRN]) * X + sin(Earth_e * pos_t.delta_t[sPRN]) * Y;
|
||||||
pos_t[eponum].Y[sPRN] = -sin(Earth_e * pos_t[eponum].delta_t[sPRN]) * X + cos(Earth_e * pos_t[eponum].delta_t[sPRN]) * Y;
|
pos_t.Y[sPRN] = -sin(Earth_e * pos_t.delta_t[sPRN]) * X + cos(Earth_e * pos_t.delta_t[sPRN]) * Y;
|
||||||
pos_t[eponum].Z[sPRN] = Z;
|
pos_t.Z[sPRN] = Z;
|
||||||
double R = sqrt(pow(pos_t[eponum].X[sPRN] - obs_h->apX, 2) + pow(pos_t[eponum].Y[sPRN] - obs_h->apY, 2) + pow(pos_t[eponum].Z[sPRN] - obs_h->apY, 2));
|
double R = sqrt(pow(pos_t.X[sPRN] - obs_h->apX, 2) + pow(pos_t.Y[sPRN] - obs_h->apY, 2) + pow(pos_t.Z[sPRN] - obs_h->apY, 2));
|
||||||
pos_t[eponum].deltat[sPRN] = pos_t[eponum].delta_t[sPRN];
|
pos_t.deltat[sPRN] = pos_t.delta_t[sPRN];
|
||||||
pos_t[eponum].delta_t[sPRN] = R / C_V;
|
pos_t.delta_t[sPRN] = R / C_V;
|
||||||
double rela = 2*sqrt(GM) * nav_b[best_epoch].e * nav_b[best_epoch].sqrtA * sin(Es)/pow(C_V,2);
|
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;
|
pos_t.delta_clk[sPRN] = nav_b[best_epoch].sa0 + nav_b[best_epoch].sa1 * tk + nav_b[best_epoch].sa2 * pow(tk,2) - rela;
|
||||||
|
return pos_t;
|
||||||
}
|
}
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
@@ -66,150 +67,111 @@ void gps_pos(int eponum, int sPRN, int best_epoch, double GPSsec,
|
|||||||
/* ------------------------------- GPS卫星位置计算&输出 ------------------------------ */
|
/* ------------------------------- GPS卫星位置计算&输出 ------------------------------ */
|
||||||
void sat_gps_pos_clac(FILE * result_file,
|
void sat_gps_pos_clac(FILE * result_file,
|
||||||
pnav_body nav_b, pobs_epoch obs_e, pobs_body obs_b,
|
pnav_body nav_b, pobs_epoch obs_e, pobs_body obs_b,
|
||||||
pobs_head obs_h, pstation station, ppos_t pos_t,
|
pobs_head obs_h,
|
||||||
pblh blh, penu enu, prah rah,
|
int o_epochnum, int gps_satnum, char res_file[MAX_PATH])
|
||||||
int o_epochnum, int gps_satnum)
|
{
|
||||||
{ int progress = 0;
|
for (int i = 0; i < o_epochnum; i++)//第i个历元
|
||||||
int count = 0;
|
{
|
||||||
|
result_file = fopen(res_file, "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);
|
||||||
|
|
||||||
|
int y = obs_e[i].y;
|
||||||
|
int m = obs_e[i].m;
|
||||||
|
int d = obs_e[i].d;
|
||||||
|
double h = obs_e[i].h;
|
||||||
|
int min = obs_e[i].min;
|
||||||
|
double sec = obs_e[i].sec;
|
||||||
|
|
||||||
xyz2blh tem1 = { 0 };
|
xyz2blh tem1 = { 0 };
|
||||||
xyz2blh tem2 = { 0 };
|
xyz2blh tem2 = { 0 };
|
||||||
blh2enu tem3 = { 0 };
|
blh2enu tem3 = { 0 };
|
||||||
rahcal tem4 = { 0 };
|
rahcal tem4 = { 0 };
|
||||||
deg2dms temb = { 0 };
|
deg2dms temb = { 0 };
|
||||||
deg2dms teml = { 0 };
|
deg2dms teml = { 0 };
|
||||||
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 i = 0; i < o_epochnum; i++)//第i个历元
|
|
||||||
{
|
|
||||||
result_file = fopen(".\\Pos_out\\LLA_result.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);
|
|
||||||
result_file = fopen(".\\PyGMT_out\\LLA_result.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);
|
|
||||||
result_file = fopen(".\\Result_out\\LLA_result.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);
|
|
||||||
|
|
||||||
|
|
||||||
|
blhs blh = { 0 };
|
||||||
|
enus enu = { 0 };
|
||||||
|
rahs rah = { 0 };
|
||||||
|
pos_ts pos_t = { 0 };
|
||||||
|
stations station = { 0 };
|
||||||
for (int j = 0; j < obs_e[i].gps_num; j++)//第j颗GPS卫星
|
for (int j = 0; j < obs_e[i].gps_num; j++)//第j颗GPS卫星
|
||||||
{
|
{
|
||||||
int y = obs_e[i].y; int m = obs_e[i].m; int d = obs_e[i].d;
|
double GPSsec = Time2GPSsec(y, m, d, h, min, sec);//转换为GPS周内秒
|
||||||
double h = obs_e[i].h; int min = obs_e[i].min; double sec = obs_e[i].sec;
|
|
||||||
//转换为GPS周内秒
|
|
||||||
double GPSsec = Time2GPSsec(y, m, d, h, min, sec);
|
|
||||||
int sPRN = obs_e[i].sPRN_GPS[j];
|
int sPRN = obs_e[i].sPRN_GPS[j];
|
||||||
//遍历N文件GPS卫星数据块,寻找最佳历元
|
int best_epoch = select_epoch(GPSsec, sPRN, nav_b, gps_satnum); //遍历N文件GPS卫星数据块,寻找最佳历元
|
||||||
int best_epoch = select_epoch(GPSsec, sPRN, nav_b, gps_satnum);
|
double detat_toc = GPSsec - nav_b[best_epoch].TOE;//观测时刻 - 参考时刻
|
||||||
//观测时刻 - 参考时刻
|
station.delta_TR == 0.0;
|
||||||
double detat_toc = GPSsec - nav_b[best_epoch].TOE;
|
|
||||||
station[i].delta_TR == 0.0;
|
|
||||||
|
|
||||||
//计算近似的信号传播时间,接收机钟差已初始化为0(伪距/光速-接收机钟差+卫星钟差)
|
//计算近似的信号传播时间,接收机钟差已初始化为0(伪距/光速-接收机钟差+卫星钟差)
|
||||||
pos_t[i].delta_t[sPRN] = (obs_b[i].obs_gps[j][Code2Type(C1C, obs_h->obstypenum_gps, obs_h->obscode_gps)] / C_V) - station[i].delta_TR + nav_b[best_epoch].sa0 + nav_b[best_epoch].sa1 * detat_toc + nav_b[best_epoch].sa2 * pow(detat_toc, 2);
|
pos_t.delta_t[sPRN] = (obs_b[i].obs_gps[j][Code2Type(C1C, obs_h->obstypenum_gps, obs_h->obscode_gps)] / C_V) - station.delta_TR + nav_b[best_epoch].sa0 + nav_b[best_epoch].sa1 * detat_toc + nav_b[best_epoch].sa2 * pow(detat_toc, 2);
|
||||||
|
pos_t.deltat[sPRN] = 0.0;//判断收敛
|
||||||
|
while (fabs(pos_t.delta_t[sPRN] - pos_t.deltat[sPRN]) > 0.00001){
|
||||||
|
|
||||||
//判断收敛
|
pos_t = gps_pos(sPRN, best_epoch, GPSsec, nav_b, obs_h, pos_t);
|
||||||
pos_t[i].deltat[sPRN] = 0.0;
|
|
||||||
while (fabs(pos_t[i].delta_t[sPRN] - pos_t[i].deltat[sPRN]) > 0.00001){
|
|
||||||
|
|
||||||
gps_pos( i, sPRN, best_epoch, GPSsec, nav_b, obs_h, pos_t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------- 地固坐标系转经纬大地高坐标系 ----------------------------- */
|
/* ----------------------------- 地固坐标系转经纬大地高坐标系 ----------------------------- */
|
||||||
tem1 = XYZ2BLH( tem1, pos_t[i].X[sPRN], pos_t[i].Y[sPRN], pos_t[i].Z[sPRN]);
|
tem1 = XYZ2BLH( tem1, pos_t.X[sPRN], pos_t.Y[sPRN], pos_t.Z[sPRN]);
|
||||||
blh->B = rad2deg(tem1.B);
|
blh.B = rad2deg(tem1.B);
|
||||||
blh->L = rad2deg(tem1.L);
|
blh.L = rad2deg(tem1.L);
|
||||||
blh->H = tem1.H;
|
blh.H = tem1.H;
|
||||||
|
|
||||||
tem2 = XYZ2BLH( tem2, obs_h->apX, obs_h->apY, obs_h->apZ);
|
tem2 = XYZ2BLH( tem2, obs_h->apX, obs_h->apY, obs_h->apZ);
|
||||||
station->B = tem2.B;
|
station.B = tem2.B;
|
||||||
station->L = tem2.L;
|
station.L = tem2.L;
|
||||||
station->H = tem2.H;
|
station.H = tem2.H;
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* ----------------------------- 经纬大地高坐标系转站心坐标系 ----------------------------- */
|
/* ----------------------------- 经纬大地高坐标系转站心坐标系 ----------------------------- */
|
||||||
double deltax = pos_t[i].X[sPRN] - obs_h->apX;
|
double deltax = pos_t.X[sPRN] - obs_h->apX;
|
||||||
double deltay = pos_t[i].Y[sPRN] - obs_h->apY;
|
double deltay = pos_t.Y[sPRN] - obs_h->apY;
|
||||||
double deltaz = pos_t[i].Z[sPRN] - obs_h->apZ;
|
double deltaz = pos_t.Z[sPRN] - obs_h->apZ;
|
||||||
|
|
||||||
tem3 = BLH2ENU(tem3, station->B, station->L, deltax, deltay, deltaz);
|
tem3 = BLH2ENU(tem3, station.B, station.L, deltax, deltay, deltaz);
|
||||||
enu->E = tem3.E;
|
enu.E = tem3.E;
|
||||||
enu->N = tem3.N;
|
enu.N = tem3.N;
|
||||||
enu->U = tem3.U;
|
enu.U = tem3.U;
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* ---------------------------- 卫星方位角a,高度角h,向径r计算 --------------------------- */
|
/* ---------------------------- 卫星方位角a,高度角h,向径r计算 --------------------------- */
|
||||||
tem4 = RAHCAL(tem4, enu->E, enu->N, enu->U);
|
tem4 = RAHCAL(tem4, enu.E, enu.N, enu.U);
|
||||||
rah->R = tem4.R;
|
rah.R = tem4.R;
|
||||||
rah->A = rad2deg(tem4.A);
|
rah.A = rad2deg(tem4.A);
|
||||||
rah->H = rad2deg(tem4.H);
|
rah.H = rad2deg(tem4.H);
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
if (blh->H < 0 || nav_b[best_epoch].sHEA != 0)
|
if (blh.H < 0 ||nav_b[best_epoch].sHEA != 0)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
temb = DEG2DMS(temb, blh->B);
|
temb = DEG2DMS(temb, blh.B);
|
||||||
blh->B_d = temb.D;
|
blh.B_d = temb.D;
|
||||||
blh->B_m = temb.M;
|
blh.B_m = temb.M;
|
||||||
blh->B_s = temb.S;
|
blh.B_s = temb.S;
|
||||||
|
|
||||||
teml = DEG2DMS(teml, blh->L);
|
teml = DEG2DMS(teml, blh.L);
|
||||||
blh->L_d = teml.D;
|
blh.L_d = teml.D;
|
||||||
blh->L_m = teml.M;
|
blh.L_m = teml.M;
|
||||||
blh->L_s = teml.S;
|
blh.L_s = teml.S;
|
||||||
|
|
||||||
result_file = fopen(".\\Pos_out\\LLA_result.txt", "a+");
|
result_file = fopen(res_file, "a+");
|
||||||
fprintf(result_file, "\nG%02d[sPRN] %4d° %02d′ %02d″ %4d° %02d′ %02d″ %15.05f",sPRN, blh->B_d, blh->B_m, blh->B_s, blh->L_d, blh->L_m, blh->L_s, blh->H);
|
|
||||||
fclose(result_file);
|
|
||||||
result_file = fopen(".\\PyGMT_out\\LLA_result.txt", "a+");
|
|
||||||
fprintf(result_file, "\nG%02d[sPRN] %10.05f %10.05f %15.05f",sPRN, blh->B, blh->L, blh->H);
|
|
||||||
fclose(result_file);
|
|
||||||
result_file = fopen(".\\Result_out\\LLA_result.txt", "a+");
|
|
||||||
fprintf(result_file, "\nG%02d[sPRN] %15.05f %15.05f %15.05f %15.05f %15.05f %15.05f %15.12f %16.13f"
|
fprintf(result_file, "\nG%02d[sPRN] %15.05f %15.05f %15.05f %15.05f %15.05f %15.05f %15.12f %16.13f"
|
||||||
,sPRN, pos_t[i].X[sPRN], pos_t[i].Y[sPRN], pos_t[i].Z[sPRN]
|
,sPRN, pos_t.X[sPRN], pos_t.Y[sPRN], pos_t.Z[sPRN]
|
||||||
,obs_b[i].obs_gps[j][Code2Type(C1C, obs_h->obstypenum_gps, obs_h->obscode_gps)]
|
,obs_b[i].obs_gps[j][Code2Type(C1C, obs_h->obstypenum_gps, obs_h->obscode_gps)]
|
||||||
,obs_b[i].obs_gps[j][Code2Type(C2L, obs_h->obstypenum_gps, obs_h->obscode_gps)]
|
,obs_b[i].obs_gps[j][Code2Type(C2L, obs_h->obstypenum_gps, obs_h->obscode_gps)]
|
||||||
,rah->H, nav_b[best_epoch].TGD, pos_t[i].delta_clk[sPRN]);
|
,rah.H, nav_b[best_epoch].TGD, pos_t.delta_clk[sPRN]);
|
||||||
fclose(result_file);
|
fclose(result_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
result_file = fopen(".\\Result_out\\LLA_result.txt", "a+");
|
result_file = fopen(res_file, "a+");
|
||||||
fprintf(result_file, "\n");
|
fprintf(result_file, "\n");
|
||||||
fclose(result_file);
|
fclose(result_file);
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
//const char * progressstr = "[----------------------------------------------------]100%%";
|
|
||||||
|
|
||||||
int progress_now = (int)(((i+1)*100/2880));
|
|
||||||
if ((progress_now - progress)>=2)
|
|
||||||
{
|
|
||||||
printf("=");
|
|
||||||
count++;
|
|
||||||
progress = progress_now;
|
|
||||||
printf("=]%3d%%", progress);
|
|
||||||
for(int countb = 0; countb < (5); countb++)
|
|
||||||
{
|
|
||||||
printf("\b");
|
|
||||||
}
|
}
|
||||||
}
|
result_file = fopen(res_file, "a+");
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
}
|
|
||||||
|
|
||||||
result_file = fopen(".\\Result_out\\LLA_result.txt", "a+");
|
|
||||||
fprintf(result_file, "\nEND");
|
fprintf(result_file, "\nEND");
|
||||||
fclose(result_file);
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+5
-5
@@ -42,7 +42,7 @@
|
|||||||
double deltat[36];//改正前的信号传播时间
|
double deltat[36];//改正前的信号传播时间
|
||||||
double delta_t[36];//改正后的信号传播时间
|
double delta_t[36];//改正后的信号传播时间
|
||||||
double delta_clk[36];
|
double delta_clk[36];
|
||||||
}pos_t, *ppos_t;
|
}pos_ts;
|
||||||
|
|
||||||
//测站位置结构体
|
//测站位置结构体
|
||||||
typedef struct
|
typedef struct
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
double L;
|
double L;
|
||||||
double H;
|
double H;
|
||||||
double delta_TR;
|
double delta_TR;
|
||||||
}station, *pstation;
|
}stations;
|
||||||
//经纬高结构体
|
//经纬高结构体
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -67,21 +67,21 @@
|
|||||||
int L_m;
|
int L_m;
|
||||||
int L_s;
|
int L_s;
|
||||||
double H;
|
double H;
|
||||||
}blh, *pblh;
|
}blhs;
|
||||||
//东北天结构体
|
//东北天结构体
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
double E;
|
double E;
|
||||||
double N;
|
double N;
|
||||||
double U;
|
double U;
|
||||||
}enu, *penu;
|
}enus;
|
||||||
//高度方位角结构体
|
//高度方位角结构体
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
double R;
|
double R;
|
||||||
double A;
|
double A;
|
||||||
double H;
|
double H;
|
||||||
}rah, *prah;
|
}rahs;
|
||||||
/* ------------------------------- FOR READ.H ------------------------------- */
|
/* ------------------------------- FOR READ.H ------------------------------- */
|
||||||
//导航头文件结构体
|
//导航头文件结构体
|
||||||
typedef struct nav_head
|
typedef struct nav_head
|
||||||
|
|||||||
+2
-2
@@ -139,7 +139,7 @@ extern void read_o_h(FILE* fp_obs, pobs_head obs_h)
|
|||||||
}
|
}
|
||||||
else if (strstr(lable, "INTERVAL"))
|
else if (strstr(lable, "INTERVAL"))
|
||||||
{
|
{
|
||||||
obs_h->interval = strtonum(buff, 0, 11);
|
obs_h->interval = strtonum(buff, 0, 10);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (strstr(lable, "TIME OF FIRST OBS"))
|
else if (strstr(lable, "TIME OF FIRST OBS"))
|
||||||
@@ -243,7 +243,7 @@ int getgpssatnum(FILE* fp_nav)
|
|||||||
char satvar;
|
char satvar;
|
||||||
char* lable = buff + 60;
|
char* lable = buff + 60;
|
||||||
//fgets函数,读取一行,当读取结束后返回NULL指针,格式如下:
|
//fgets函数,读取一行,当读取结束后返回NULL指针,格式如下:
|
||||||
//char * fgets ( char * str, int num, FILE * stream );
|
//wchar_t * fgets ( wchar_t * str, int num, FILE * stream );
|
||||||
while (fgets(buff, MAXRINEX, fp_nav))
|
while (fgets(buff, MAXRINEX, fp_nav))
|
||||||
{
|
{
|
||||||
if (flag == 1)
|
if (flag == 1)
|
||||||
|
|||||||
@@ -1,137 +0,0 @@
|
|||||||
#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\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\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\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\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\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\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
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
/*
|
|
||||||
* @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 }版本RINEX观测值文件与广播星历文件读取
|
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
#include<stdio.h>
|
|
||||||
#include<stdlib.h>
|
|
||||||
#include<string.h>
|
|
||||||
#include<unistd.h>
|
|
||||||
|
|
||||||
#include"headers/read.h"
|
|
||||||
#include"headers/cal_mod.h"
|
|
||||||
#include"headers/terminal.h"
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
//数据读取
|
|
||||||
FILE * fp_nav = NULL; //导航星历文件指针
|
|
||||||
FILE * fp_obs = NULL; //观测值文件指针
|
|
||||||
FILE * result_file = NULL;//结果输出文件指针
|
|
||||||
|
|
||||||
pstation station = NULL;
|
|
||||||
ppos_t pos_t = NULL;
|
|
||||||
pblh blh = NULL;
|
|
||||||
penu enu = NULL;
|
|
||||||
prah rah = NULL;
|
|
||||||
|
|
||||||
pnav_head nav_h = NULL;
|
|
||||||
pnav_body nav_b = NULL;
|
|
||||||
pobs_head obs_h = NULL;
|
|
||||||
pobs_epoch obs_e = NULL;
|
|
||||||
pobs_body obs_b = NULL;//创建结构体指针,并将其初始化为空
|
|
||||||
|
|
||||||
int over = 0;
|
|
||||||
|
|
||||||
while(over == 0)
|
|
||||||
{
|
|
||||||
int langop;
|
|
||||||
pfilename filetype = NULL;
|
|
||||||
|
|
||||||
/* ---------------------------------- 终端显示 ---------------------------------- */
|
|
||||||
langop = Begin_inTermianl();
|
|
||||||
filetype = (pfilename)malloc(sizeof(pfilename) * 512);
|
|
||||||
filetype = InO_inTermianl(langop, filetype);
|
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
//O文件读取
|
|
||||||
fp_obs = fopen(filetype->obs_file, "r");
|
|
||||||
|
|
||||||
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));
|
|
||||||
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);
|
|
||||||
read_o_b(fp_obs, obs_e, obs_b, obs_h->obstypenum_gps, obs_h->obstypenum_bds);
|
|
||||||
}
|
|
||||||
fclose(fp_obs);
|
|
||||||
|
|
||||||
filetype = OutO_InN_inTermianl(fp_obs, langop, filetype);//显示函数
|
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
//N文件读取
|
|
||||||
fp_nav = fopen(filetype->nav_file, "r");
|
|
||||||
|
|
||||||
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);
|
|
||||||
read_n_b(fp_nav, nav_b);
|
|
||||||
}
|
|
||||||
fclose(fp_nav);
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
End_inTerminal(fp_nav, fp_obs, langop, over);//显示函数
|
|
||||||
}
|
|
||||||
system("pause");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user