BIG UPDATE:

1. Full gui
2. Integrated KNZ_Calculate and KNZ_Plot
3. Realized GPS, BeiDou, Galileo, GLONASS satellite position calculation,
4. New module added: 3D satellite orbit display
This commit is contained in:
KenanZhu111 committed 2024-10-26 10:14:53 +08:00
1 parent aba6c009ab
commit 68f31ded24
28 files changed
+3431 -3465

No files matched your search

-39
View File
@@ -1,41 +1,2 @@
# **MAIN FUNCTION INTRODUCTION**
* Reads the specified observation data and navigation data.
* Calculate the coordinates of each epoch of the satellite in the ECEF coordinate system (.sp file).[ADIN 2024/10/5]
* ~~With the help of PyGMT, the output document information is processed and the satellite ground track map is drawn.~~
* ~~With the help of MatLab tool, the satellite position is calculated and the station position is obtained by simultaneous solution, and the precision is evaluated by comparing with the coordinates of the precise station.~~
* With the help of SPP_plot, the coordinates of the station can be calculated. And draw the image.[ADIN 2024/10/5]
# MAIN NOTICE
## Program notice
### About main calculate
* ~~Due to the lack of program writing experience, the ease of file reading is not perfect, if you need to read other observation files and navigation files, you can make changes in the ***main.c*** file.~~
* ~~It is constantly modified and updated, and the reading of the file is controlled through the form of the terminal, and is optimized visually.[ADIN 2024/9/22]~~
* After a few updates, the observation file and navigation ephemeris file can be selected through the file dialog, and the SPP_calculate program can generate satellite position information (.sp file) in a folder specified by the user.[ADIN 2024/10/5]
* The format of the (.sp file) is described in detail in the help documentation.
### About PyGMT(STOP)
* ~~I have improved the drawing part of PyGMT to ensure that the output data can be used independently.~~
* As of October 5, 2024, projects for PyGMT drawing will no longer be considered.[ADIN 2024/10/5]
### About Matlab(STOP)(REPLACEED BY SPP_plot)
* ~~When the new station data is needed for calculation, two parts of parameters in the Matlab source file need to be corrected, the first is the exact coordinates of the station in the file header, and the second is the longitude, latitude and elevation information of the station in the file header.(OINP)~~
### About PyPlot
* With the help of python's tkinter and matplotlib libraries, it is realized to read and process the.sp file generated by SPP_calculate and generate the (.po file) in the (.sp file) sibling directory. The generated.po file can be processed by SPP_plot to obtain line plots of ENU components.
* At present, the algorithm of station position calculation is integrated in the plot, and only two default tropospheric and ionospheric correction algorithms are supported at present, and the accuracy is still being optimized.
* The format of the (.po file) is described in detail in the help documentation.
## Project notice
* Due to my limited programming level, ~~PyGMT drawing used too miscellaneous judgment statements, resulting in slow drawing or debugging errors,~~ please forgive.
* When writing the code, with the help of the existing open source code results, and different degrees of reference, here one by one mark and express thanks:
| *https://blog.csdn.net/why1472587?type=blog*
| *https://zhuanlan.zhihu.com/p/416072448*
| *https://www.pygmt.org/latest/index.html*
| *https://blog.csdn.net/FrankXCR/article/details/135438701*
### Document label specification
* [ADIN TIME]: new added in "TIME"(e.g. [ADIN 2024/9/22]: new added in 2024/9/22).
* (OINP): Operation in progress, or in urgent need of improvement.
* (STOP): No longer update maintenance or consider implementing features.
#### *This program code is solely for study and communication purposes* ####
-564
View File
@@ -1,564 +0,0 @@
#include<stdio.h>
#include<wchar.h>
#include<stdlib.h>
#include<string.h>
#include<windows.h>
#include<Commdlg.h>
#include<commctrl.h>
#pragma comment(lib, "comctl32")
#include"resource.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='*'\"")
HWND hwndb[15];//BUTTON HANDLE
HWND hwndopt;//OPTIONS HANDLE
HWND hwndopt_def_ion;//DEFAULT ION COR
HWND hwndopt_def_tro;//DEFAULT TRO COR
HWND hwndopt_confirm;//OPTION CONFIRM
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;
/*INITIAL CONST*/
int o_epochnum = 0;
int satnum = 0;
/*INITIAL SETTINGS*/
static int ionoption = 0;
static int trooption = 0;
/* ------------- */
char obs_f[MAX_PATH] = { 0 };
char nav_f[MAX_PATH] = { 0 };
char path[MAX_PATH];
const wchar_t wpath[MAX_PATH];//PROGRAM'S FOLDER
static void ProgressBar(HWND hwnd, int BEG, int DES)//PROGRESS BAR FUNCTION
{
PBRANGE range;
SendMessage(hwnd, PBM_SETRANGE, (WPARAM)FALSE, (LPARAM)(MAKELPARAM(0, 100)));
SendMessage(hwnd, PBM_GETRANGE, (WPARAM)TRUE, (LPARAM)&range);
SendMessage(hwnd, PBM_SETPOS, (WPARAM)BEG, (LPARAM)0);
for (int i = 0; i < DES - BEG; i += fabs(DES - BEG)/(DES - BEG))
{
SendMessage(hwnd, PBM_SETPOS, (WPARAM)(int)( i + BEG / 10), (LPARAM)0);
if (SendMessage(hwnd, PBM_GETPOS, (WPARAM)0, (LPARAM)0) == range.iHigh * DES/PBSTATEFULL)
{
break;
}
}
SendMessage(hwnd, PBM_SETPOS, (WPARAM)DES, (LPARAM)0);
}
static int FileSelobsDialog(const wchar_t* path)//FILEDIALOG FOR OBS
{
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;
return GetOpenFileName(&ofn);
}
static int FileSelnavDialog(const wchar_t* path)//FILEDIALOG FOR NAV
{
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = path;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFilter = FILEEXNP;
ofn.lpstrTitle = TEXT("Open From");
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
return GetOpenFileName(&ofn);
}
static int FileSaveDialog(const wchar_t* path)//FILEDIALOG FOR SAVE
{
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;
return GetSaveFileName(&ofn);
}
//DWORD WINAPI PBThreadProc(LPVOID lpParameter);//PROGRESS BAR WINDOW
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);//MAIN WINDOW
LRESULT CALLBACK OptWndProc(HWND, UINT, WPARAM, LPARAM);//OPTION WINDOW
int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int iCmdShow) {
WNDCLASS wndclass;
wndclass.style = CS_PARENTDC;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = TEXT("CAL");
RegisterClass(&wndclass);
wndclass.lpfnWndProc = OptWndProc;
wndclass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON2));
wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = TEXT("OPT");
RegisterClass(&wndclass);
HWND hwnd;
hwnd = CreateWindow(
TEXT("CAL"),
TEXT("KNZ_Calculate"),
WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
0,
0,
0,
0,
NULL,
NULL,
hInstance,
NULL);
HICON Delico,Relico;
HFONT hbFont;
hbFont = CreateFont(
15,
0,
0,
0,
FW_LIGHT,
FALSE,
FALSE,
FALSE,
DEFAULT_CHARSET,
OUT_OUTLINE_PRECIS,
CLIP_DEFAULT_PRECIS,
CLEARTYPE_QUALITY,
VARIABLE_PITCH,
TEXT("Segoe UI"));
SendMessage(hwnd, WM_SETFONT, (WPARAM)hbFont, 1);
for (int i = 0; i < 12; i++)
{
SendMessage(hwndb[i], WM_SETFONT, (WPARAM)hbFont, 1);
}
Delico = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON3));
Relico = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON4));
SendMessage(hwndb[11], BM_SETIMAGE, IMAGE_ICON, (LPARAM)Delico);
SendMessage(hwndb[12], BM_SETIMAGE, IMAGE_ICON, (LPARAM)Relico);
SendMessage(hwndb[13], BM_SETIMAGE, IMAGE_ICON, (LPARAM)Delico);
SendMessage(hwndb[14], BM_SETIMAGE, IMAGE_ICON, (LPARAM)Relico);
ShowWindow(hwnd, iCmdShow);
UpdateWindow(hwnd);
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
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 };//BE COMPATIBLE WITH MSVC
RECT rect;
TCHAR* SATSYS[5] = { TEXT("GPS"),TEXT("GLO"),TEXT("BeiDou"),TEXT("Galileo"),TEXT("SBAS") };
static HWND hwndPB;
static int cxchar, cychar;
static int gnssencode;//GNSS SET STATE CODE
switch (msg) {
case WM_CREATE:
{
getcwd(path, sizeof(path));//GET THE PROGRAM'S FOLDER
const char plot[] = "KNZ_Plot.exe";
sprintf(path, "%s\\%s", path, plot);
cxchar = LOWORD(GetDialogBaseUnits());
cychar = HIWORD(GetDialogBaseUnits());//GET THE SYS FONT SIZE
MoveWindow(hwnd, (GetSystemMetrics(SM_CXSCREEN) - 50 * cxchar) / 2, (GetSystemMetrics(SM_CYSCREEN) - 16 * cychar) / 2, 50 * cxchar, 16 * cychar, TRUE);//REPAINT THE MAIN WINDOW
InitCommonControls();
hwndPB = CreateWindowEx(0, PROGRESS_CLASS, NULL, WS_CHILD | WS_VISIBLE,
0.5 * cxchar, 12.5 * cychar,
47 * cxchar, 3 * cychar/4,
hwnd, (HMENU)PROGRESS, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
//CREATE THE BUTTONS
hwndb[0] = CreateWindow(TEXT("Button"), TEXT("Open Obs Data"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
cxchar, 5 * cychar,
14 * cxchar, 2 * cychar,
hwnd, (HMENU)OBSBUTTON, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
hwndb[1] = CreateWindow(TEXT("Button"), TEXT("Open Nav Data"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
17 * cxchar, 5 * cychar,
14 * cxchar, 2 * cychar,
hwnd, (HMENU)NAVBUTTON, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
hwndb[2] = CreateWindow(TEXT("Button"), TEXT("Sat-Position Calculate"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
cxchar, 7 * cychar,
32 * cxchar, 2 * cychar,
hwnd, (HMENU)CALBUTTON, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
hwndb[3] = CreateWindow(TEXT("Button"), TEXT("Options..."), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
36 * cxchar, 7 * cychar,
10 * cxchar, 2 * cychar,
hwnd, (HMENU)OPTBUTTON, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
hwndb[4] = CreateWindow(TEXT("Button"), TEXT("Plot"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
36 * cxchar, 5 * cychar,
10 * cxchar, 2 * cychar,
hwnd, (HMENU)PLOBUTTON, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
for (int i = 0; i < 5; i++)
{
hwndb[i + 5] = CreateWindow(TEXT("Button"), SATSYS[i], WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX,
(2 + 7 * i) * cxchar, 21 * cychar / 2,
7 * cxchar, 5 * cychar / 3,
hwnd, (HMENU)(5500 + i), ((LPCREATESTRUCT)lParam)->hInstance, NULL);
}
hwndb[10] = CreateWindow(TEXT("Button"), TEXT("Satellite System"), WS_VISIBLE | WS_CHILD | BS_GROUPBOX,
1 * cxchar / 2, 19 * cychar / 2,
47 * cxchar, 6 * cychar / 2,
hwnd, (HMENU)SYSGROUP, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
hwndb[11] = CreateWindow(TEXT("Button"), NULL, WS_VISIBLE | WS_CHILD | BS_ICON | BS_PUSHBUTTON,
15 * cxchar, 5 * cychar,
2 * cxchar, 1 * cychar,
hwnd, (HMENU)OBSCLEAR, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
hwndb[12] = CreateWindow(TEXT("Button"), NULL, WS_VISIBLE | WS_CHILD | BS_ICON | BS_PUSHBUTTON,
15 * cxchar, 6 * cychar,
2 * cxchar, 1 * cychar,
hwnd, (HMENU)OBSRELOD, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
hwndb[13] = CreateWindow(TEXT("Button"), NULL, WS_VISIBLE | WS_CHILD | BS_ICON | BS_PUSHBUTTON,
31 * cxchar, 5 * cychar,
2 * cxchar, 1 * cychar,
hwnd, (HMENU)NAVCLEAR, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
hwndb[14] = CreateWindow(TEXT("Button"), NULL, WS_VISIBLE | WS_CHILD | BS_ICON | BS_PUSHBUTTON,
31 * cxchar, 6 * cychar,
2 * cxchar, 1 * cychar,
hwnd, (HMENU)NAVRELOD, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
return 0;
}
case WM_COMMAND:
switch(LOWORD(wParam))
{
/* -------------------------- LOAD OBS DATA BUTTON -------------------------- */
case OBSBUTTON:
if (fp_obs == NULL)
{
FileSelobsDialog(wobs_file);
wcstombs(obs_file, wobs_file, MAX_PATH);
fp_obs = fopen(obs_file, TEXT("r"));
if (fp_obs != NULL)
{
strcpy(obs_f, obs_file);
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);
ProgressBar(hwndPB, PBSTATENONE, PBSTATEHALF);
read_o_b(fp_obs, obs_e, obs_b, obs_h);
}
fclose(fp_obs);
ProgressBar(hwndPB, PBSTATEHALF, PBSTATEFULL);
}
}
else
{
MessageBox(hwnd, TEXT("File of Obs has already been loaded ! \nTo load new data file of Obs, \nPlease clear the existing data first"), TEXT("NOTICE"), MB_ICONASTERISK | MB_OK);
}
break;
return 0;
/* -------------------------- LOAD NAV DATA BUTTON -------------------------- */
case NAVBUTTON:
if (fp_nav == NULL)
{
FileSelnavDialog(wnav_file);
wcstombs(nav_file, wnav_file, MAX_PATH);
fp_nav = fopen(nav_file, TEXT("r"));
if (fp_nav != NULL)
{
strcpy(nav_f, nav_file);
satnum = getsatnum(fp_nav);
rewind(fp_nav);
nav_h = (pnav_head)malloc(sizeof(nav_head));
nav_b = (pnav_body)malloc(sizeof(nav_body) * (satnum));
if (nav_h && nav_b)
{
read_n_h(fp_nav, nav_h);
ProgressBar(hwndPB, PBSTATENONE, PBSTATEHALF);
read_n_b(fp_nav, nav_b);
}
fclose(fp_nav);
ProgressBar(hwndPB, PBSTATEHALF, PBSTATEFULL);
}
}
else
{
MessageBox(hwnd, TEXT("File of Nav has already been loaded ! \nTo load new data file of Nav, \nPlease clear the existing data first"), TEXT("NOTICE"), MB_ICONASTERISK | MB_OK);
}
break;
return 0;
/* -------------------------- CLEAR OBS DATA BUTTON ------------------------- */
case OBSCLEAR:
while (fp_obs != NULL)
{
free(obs_h); free(obs_e); free(obs_b);
fp_obs = NULL; obs_e = NULL; obs_b = NULL;
ProgressBar(hwndPB, PBSTATEFULL, PBSTATENONE);
while (MessageBox(hwnd, TEXT("File of Obs has been cleared."), TEXT("NOTICE"), MB_ICONASTERISK | MB_OK) == IDOK)
{
break;
}
}
break;
return 0;
case OBSRELOD:
if (fp_obs != NULL)
{
if (o_epochnum > 100)
{
ProgressBar(hwndPB, PBSTATENONE, PBSTATEFULL);
MessageBox(hwnd, TEXT("File of Obs Reload complete !"), TEXT("NOTICE"), MB_ICONASTERISK | MB_OK);
break;
}
}
break;
return 0;
/* -------------------------- CLEAR NAV DATA BUTTON ------------------------- */
case NAVCLEAR:
while(fp_nav != NULL)
{
free(nav_h); free(nav_b);
fp_nav = NULL;nav_h = NULL; nav_b = NULL;
ProgressBar(hwndPB, PBSTATEFULL, PBSTATENONE);
while (MessageBox(hwnd, TEXT("File of Nav has been cleared."), TEXT("NOTICE"), MB_ICONASTERISK | MB_OK) == IDOK)
{
break;
}
}
break;
return 0;
case NAVRELOD:
if (fp_nav != NULL)
{
if (satnum > 100)
{
ProgressBar(hwndPB, PBSTATENONE, PBSTATEFULL);
MessageBox(hwnd, TEXT("File of Nav Reload complete !"), TEXT("NOTICE"), MB_ICONASTERISK | MB_OK);
break;
}
}
break;
return 0;
/* ---------------------------- CALCAULATE BUTTON --------------------------- */
case CALBUTTON:
if (fp_obs == NULL && fp_nav == NULL)
{
MessageBox(hwnd, TEXT("No Data File !"), TEXT("STOP"), MB_ICONERROR | MB_OKCANCEL | MB_DEFBUTTON1);
}
else if (fp_obs == NULL && fp_nav != NULL)
{
MessageBox(hwnd, TEXT("No Obs Data File !"), TEXT("STOP"), MB_ICONERROR | MB_OKCANCEL | MB_DEFBUTTON1);
}
else if (fp_obs != NULL && fp_nav == NULL)
{
MessageBox(hwnd, TEXT("No Nav Data File !"), TEXT("STOP"), MB_ICONERROR | MB_OKCANCEL | MB_DEFBUTTON1);
}
else if (fp_obs != NULL && fp_nav != NULL)
{
int ALLSTATE = 0x0000;
for (int i = 0; i < 5; i++){ALLSTATE += SendMessage(hwndb[i + 5], BM_GETCHECK, wParam, lParam);}
if (ALLSTATE == 0x0000)
{ while (MessageBox(hwnd, TEXT("No GNSS is choosen\nPlease Retry"), TEXT("STOP"), MB_ICONERROR | MB_RETRYCANCEL) == IDRETRY)
{
break;}}
else
{ FileSaveDialog(wres_file);
wcstombs(res_file, wres_file, MAX_PATH);
if (res_file[0] == '\0')
{ while (MessageBox(hwnd, TEXT("Failed to select a save path.\nThe data has been cleared !"), TEXT("WARNING"), MB_ICONWARNING | MB_OK) == IDOK)
{ break;}}
else
{ gnssencode = pow(GPS, SendMessage(hwndb[5], BM_GETCHECK, wParam, lParam))
* pow(GLO, SendMessage(hwndb[6], BM_GETCHECK, wParam, lParam))
* pow(BDS, SendMessage(hwndb[7], BM_GETCHECK, wParam, lParam))
* pow(GAL, SendMessage(hwndb[8], BM_GETCHECK, wParam, lParam))
* pow(SBAS, SendMessage(hwndb[9], BM_GETCHECK, wParam, lParam));
sat_pos_clac(result_file, hwndPB,
nav_b, obs_e, obs_b, obs_h,
o_epochnum, satnum, gnssencode,
res_file, obs_f, nav_f,
ionoption, trooption);
}
free(obs_h); free(obs_e); free(obs_b); free(nav_h); free(nav_b);
fp_nav = NULL; fp_obs = NULL; result_file = NULL;
nav_h = NULL; nav_b = NULL; obs_h = NULL; obs_e = NULL; obs_b = NULL;
}
}
break;
return 0;
/* ----------------------------- OPTIONS BUTTON ----------------------------- */
case OPTBUTTON:
DestroyWindow(hwndopt);
hwndopt = CreateWindow(TEXT("OPT"), TEXT("Options"), WS_CAPTION | WS_SYSMENU,
0, 0,
0, 0,
NULL, NULL, GetWindowLongPtr(hwndopt, GWLP_HINSTANCE), NULL);
HFONT hbFont;
hbFont = CreateFont(
15,0,0,0,
FW_LIGHT,FALSE,FALSE,FALSE,
DEFAULT_CHARSET,OUT_OUTLINE_PRECIS,
CLIP_DEFAULT_PRECIS,CLEARTYPE_QUALITY,
VARIABLE_PITCH,TEXT("Segoe UI"));
SendMessage(hwndopt_def_ion, WM_SETFONT, (WPARAM)hbFont, 1);
SendMessage(hwndopt_def_tro, WM_SETFONT, (WPARAM)hbFont, 1);
SendMessage(hwndopt_confirm, WM_SETFONT, (WPARAM)hbFont, 1);//SEND FONT SETTING MESSAGE
while (ionoption == 1) { SendMessage(hwndopt_def_ion, BM_SETCHECK, wParam, lParam); break; };
while (trooption == 1) { SendMessage(hwndopt_def_tro, BM_SETCHECK, wParam, lParam); break; };//SEND SETTING STATE MESSAGE
break;
return 0;
/* ------------------------------- PLOT BUTTON ------------------------------ */
case PLOBUTTON: {
mbstowcs(wpath, path, MAX_PATH);
if (ShellExecute(NULL, TEXT("open"), wpath, NULL, NULL, SW_SHOW) <= 32)
{
MessageBox(hwnd, TEXT("Failed to open Plot module !\nThe file may be removed or be damaged.\n "), TEXT("ERROR"), MB_ICONERROR | MB_OK);
}
break;
return 0;
}
/* ------------------------------- DEFAULT MSG ------------------------------ */
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
case WM_CLOSE:
DestroyWindow(hwnd);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
LRESULT CALLBACK OptWndProc(HWND hwndopt, UINT msg, WPARAM wParam, LPARAM lParam)
{
static int cxchar, cychar;
RECT rect;
switch (msg)
{
case WM_CREATE:
cxchar = LOWORD(GetDialogBaseUnits());
cychar = HIWORD(GetDialogBaseUnits());
MoveWindow(hwndopt, (GetSystemMetrics(SM_CXSCREEN) - 30 * cxchar) / 2, (GetSystemMetrics(SM_CYSCREEN) - 7 * cychar) / 2, 30 * cxchar, 7 * cychar, TRUE);
ShowWindow(hwndopt, SW_SHOWDEFAULT);
UpdateWindow(hwndopt);
hwndopt_def_ion = CreateWindow(TEXT("BUTTON"), TEXT("Use Default ION_COR"), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
2 * cxchar, 0, 18 * cxchar, 2 * cychar, hwndopt, (HMENU)OPTDFION, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
hwndopt_def_tro = CreateWindow(TEXT("BUTTON"), TEXT("Use Default TRO_COR"), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
2 * cxchar, 2 * cychar, 18 * cxchar, 2 * cychar, hwndopt, (HMENU)OPTDFTRO, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
hwndopt_confirm = CreateWindow(TEXT("BUTTON"), TEXT("Confirm"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
20 * cxchar, 5 * cychar/2, 7 * cxchar, 3 * cychar/2, hwndopt, (HMENU)OPTCONFI, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
break;
return 0;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case OPTDFION:
break;
return 0;
case OPTDFTRO:
break;
return 0;
case OPTCONFI:
if (SendMessage(hwndopt_def_ion, BM_GETCHECK, wParam, lParam) == BST_CHECKED){ionoption = 1;}
else{ionoption = 0;}
if (SendMessage(hwndopt_def_tro, BM_GETCHECK, wParam, lParam) == BST_CHECKED){trooption = 1;}
else{trooption = 0;}//GET CHECKBOX'S SETTINGS
DestroyWindow(hwndopt);
break;
return 0;
}
break;
return 0;
case WM_CLOSE:
DestroyWindow(hwndopt);
break;
return 0;
case WM_DESTROY:
break;
return 0;
default:
return DefWindowProc(hwndopt, msg, wParam, lParam);
}
return 0;
}
+1571
View File
File diff suppressed because it is too large. Load diff
+36
View File
@@ -0,0 +1,36 @@
##Tro correct-Hopfield
import math
def Hop_tro_cor(H, ma):
global e
P0 = 1013.25
e0 = 11.69
T0 = 288.15
p = P0 * pow((1.0 - 0.0068 / T0 / H) , 5)
T = 288.15 - 0.0068 * H
if H > 11000:
e = 0
if H <= 11000:
e = e0 * pow( (1.0 - 0.0068 * H / T0) , 4)
deltaSd = 1.552e-5 * p * (40136 + 148.72 * (T - 273.16) - H) / T
deltaSw = 1.552e-5 * 4810 * e * (11000 - H) / pow(T , 2)
#Dry
dtropd = deltaSd / math.sqrt( math.sin( math.radians( math.degrees( pow(math.radians(ma) , 2) ) + 6.25) ) )
#Wet
dtropw = deltaSw / math.sqrt( math.sin( math.radians( math.degrees( pow(math.radians(ma) , 2) ) + 6.25) ) )
dtrop = dtropw + dtropd
return dtrop
#Tro corrct-Saastamoinen
def Sas_tro_cor(B, H, ma):
global e
P0 = 1013.25 * pow( (1 - 2.2557 * 10e-5 * H), 5.2568)
e0 = 11.69
T0 = 15 - 6.5 * 10e-3 * H + 273.15
deltaSd = 2.2768e-3 * P0 / (1 - 2.66e-3 * math.cos(2 * B) - 2.8e-4 * H * 1e3)
deltaSw = 2.2768e-3 * (1255 / T0 + 0.05) * e0
# Dry
dtropd = deltaSd / math.sqrt( math.sin( math.radians( math.degrees( pow(math.radians(ma), 2) ) + 6.25) ) )
# Wet
dtropw = deltaSw / math.sqrt( math.sin( math.radians( math.degrees( pow(math.radians(ma), 2) ) + 6.25) ) )
dtrop = dtropw + dtropd
return dtrop
-34
View File
@@ -1,34 +0,0 @@
#ifndef _2GPST_H_
#define _2GPST_H_
/* -------------------------------------------------------------------------- */
/// @brief convert UTC to GPS Second of week
/// @param y year
/// @param m month
/// @param d day
/// @param h hour
/// @param min minute
/// @param sec second
/// @return return GPS Second of week
/* -------------------------------------------------------------------------- */
double Time2Weeksec(int y, int m, int d, double h, int min, double sec)
{
if (m > 2)
{
y = y;
m = m;
}
if (m <= 2)
{
y = y - 1;
m = m + 12;
}
h = h + min/60.0 + sec/3600.0;
double JD = (int)(365.25 * y) + (int)(30.6001 * (m + 1)) + d + h/24.0 + 1720981.5;
double MJD = JD - 2400000.5;
int gpsweek = (int)((MJD - 44244) / 7);
double secofweek = (MJD - 44244.0 - gpsweek * 7.0) * 86400.0;
return secofweek;
}
#endif
-38
View File
@@ -1,38 +0,0 @@
#ifndef _BLH2ENU_H_
#define _BLH2ENU_H_
#include<stdlib.h>
#include<math.h>
typedef struct
{
double E;
double N;
double U;
}blh2enu;
/* -------------------------------------------------------------------------- */
/// @brief convert BLH coordinates to ENU coordinates
/// @param blh2enu parameter transfer structure
/// @param stationB latitude of receiver station
/// @param stationL longitude of receiver station
/// @param deltax X-coordinate difference of satellite arrival center
/// @param deltay Y-coordinate difference of satellite arrival center
/// @param deltaz Z-coordinate difference of satellite arrival center
/// @return return type of structure contain E, N, U members
/* -------------------------------------------------------------------------- */
blh2enu BLH2ENU(blh2enu blh2enu,
double stationB, double stationL,
double deltax, double deltay, double deltaz)
{
double sinB = sin(stationB);
double cosB = cos(stationB);
double sinL = sin(stationL);
double cosL = cos(stationL);
blh2enu.E = - sinL*(deltax) + cosL*(deltay);
blh2enu.N = -sinB*cosL*(deltax) - sinB*sinL*(deltay) + cosB*(deltaz);
blh2enu.U = cosB*cosL*(deltax) + cosB*sinL*(deltay) + sinB*(deltaz);
return blh2enu;
}
#endif
-491
View File
@@ -1,491 +0,0 @@
#ifndef _CAL_MOD_H_
#define _CAL_MOD_H_
#include<stdio.h>
#include<stdlib.h>
#include<Windows.h>
#include<math.h>
#include<time.h>
#include"public.h"
#include"2gpst.h"
#include"rahcal.h"
#include"xyz2blh.h"
#include"degRrad.h"
#include"deg2dms.h"
#include"blh2enu.h"
#include"type2code.h"
#include"select_epo.h"
/* -------------------- GPS Satellite position calculate -------------------- */
pos_ts gps_pos(int sPRN, int best_epoch, double GPSsec,
pnav_body nav_b, pobs_head obs_h, pos_ts pos_t)
{ double T_S = GPSsec - pos_t.delta_t;
double n_0 = sqrt(GM) / pow(nav_b[best_epoch].sqrtA,3);
double n = n_0 + nav_b[best_epoch].deltan;
double tk = T_S - nav_b[best_epoch].TOE;
if (tk > 32400)tk -= 604800;
else if (tk < -32400)tk += 604800;
double Ms = nav_b[best_epoch].M0 + n * tk;
double Es = Ms, E0;
do
{
E0 = Es;
Es = Ms + nav_b[best_epoch].e * sin(Es);
} while (fabs(Es - E0) > 1.0e-10);
double cosfs = (cos(Es) - nav_b[best_epoch].e) / (1 - nav_b[best_epoch].e * cos(Es));
double sinfs = (sqrt(1 - pow(nav_b[best_epoch].e, 2)) * sin(Es)) / (1 - nav_b[best_epoch].e * cos(Es));
double fs = atan2(sinfs, cosfs);
double u0 = fs + nav_b[best_epoch].omega;
double epsilon_u = nav_b[best_epoch].Cus * sin(2 * u0) + nav_b[best_epoch].Cuc * cos(2 * u0);
double epsilon_r = nav_b[best_epoch].Crs * sin(2 * u0) + nav_b[best_epoch].Crc * cos(2 * u0);
double epsilon_i = nav_b[best_epoch].Cis * sin(2 * u0) + nav_b[best_epoch].Cic * cos(2 * u0);
double u = u0 + epsilon_u;
double r = pow(nav_b[best_epoch].sqrtA, 2) * (1 - nav_b[best_epoch].e * cos(Es)) + epsilon_r;
double i = nav_b[best_epoch].i0 + epsilon_i + nav_b[best_epoch].IDOT * tk;
double x = r * cos(u);
double y = r * sin(u);
double l = nav_b[best_epoch].OMEGA + (nav_b[best_epoch].deltaomega - Earth_e) * tk - Earth_e * nav_b[best_epoch].TOE;
double X = x * cos(l) - y * cos(i) * sin(l);
double Y = x * sin(l) + y * cos(i) * cos(l);
double Z = y * sin(i);
pos_t.X = cos(Earth_e * pos_t.delta_t) * X + sin(Earth_e * pos_t.delta_t) * Y;
pos_t.Y = -sin(Earth_e * pos_t.delta_t) * X + cos(Earth_e * pos_t.delta_t) * Y;
pos_t.Z = Z;//Correction of earth rotation
double R = sqrt(pow(pos_t.X - obs_h->apX, 2) + pow(pos_t.Y - obs_h->apY, 2) + pow(pos_t.Z - obs_h->apZ, 2));
pos_t.deltat = pos_t.delta_t;
double rela = 2*sqrt(GM) * nav_b[best_epoch].e * nav_b[best_epoch].sqrtA * sin(Es)/pow(C_V,2);//Relativistic effect
pos_t.delta_clk = nav_b[best_epoch].sa0 + nav_b[best_epoch].sa1 * tk + nav_b[best_epoch].sa2 * pow(tk,2) - rela - nav_b[best_epoch].TGD;
pos_t.delta_t = R / C_V + pos_t.delta_clk;
return pos_t;}
/* -------------------- GAL Satellite position calculate -------------------- */
pos_ts gal_pos(int sPRN, int best_epoch, double GALsec,
pnav_body nav_b, pobs_head obs_h, pos_ts pos_t)
{ double T_S = GALsec - pos_t.delta_t;
double n_0 = sqrt(GM) / pow(nav_b[best_epoch].sqrtA, 3);
double n = n_0 + nav_b[best_epoch].deltan;
double tk = T_S - nav_b[best_epoch].TOE;
if (tk > 32400)tk -= 604800;
else if (tk < -32400)tk += 604800;
double Ms = nav_b[best_epoch].M0 + n * tk;
double Es = Ms, E0;
do
{
E0 = Es;
Es = Ms + nav_b[best_epoch].e * sin(Es);
} while (fabs(Es - E0) > 1.0e-10);
double cosfs = (cos(Es) - nav_b[best_epoch].e) / (1 - nav_b[best_epoch].e * cos(Es));
double sinfs = (sqrt(1 - pow(nav_b[best_epoch].e, 2)) * sin(Es)) / (1 - nav_b[best_epoch].e * cos(Es));
double fs = atan2(sinfs, cosfs);
double u0 = fs + nav_b[best_epoch].omega;
double epsilon_u = nav_b[best_epoch].Cus * sin(2 * u0) + nav_b[best_epoch].Cuc * cos(2 * u0);
double epsilon_r = nav_b[best_epoch].Crs * sin(2 * u0) + nav_b[best_epoch].Crc * cos(2 * u0);
double epsilon_i = nav_b[best_epoch].Cis * sin(2 * u0) + nav_b[best_epoch].Cic * cos(2 * u0);
double u = u0 + epsilon_u;
double r = pow(nav_b[best_epoch].sqrtA, 2) * (1 - nav_b[best_epoch].e * cos(Es)) + epsilon_r;
double i = nav_b[best_epoch].i0 + epsilon_i + nav_b[best_epoch].IDOT * tk;
double x = r * cos(u);
double y = r * sin(u);
double l = nav_b[best_epoch].OMEGA + (nav_b[best_epoch].deltaomega - Earth_e) * tk - Earth_e * nav_b[best_epoch].TOE;
double X = x * cos(l) - y * cos(i) * sin(l);
double Y = x * sin(l) + y * cos(i) * cos(l);
double Z = y * sin(i);
pos_t.X = cos(Earth_e * pos_t.delta_t) * X + sin(Earth_e * pos_t.delta_t) * Y;
pos_t.Y = -sin(Earth_e * pos_t.delta_t) * X + cos(Earth_e * pos_t.delta_t) * Y;
pos_t.Z = Z;//Correction of earth rotation
double R = sqrt(pow(pos_t.X - obs_h->apX, 2) + pow(pos_t.Y - obs_h->apY, 2) + pow(pos_t.Z - obs_h->apZ, 2));
pos_t.deltat = pos_t.delta_t;
double rela = 2 * sqrt(GM) * nav_b[best_epoch].e * nav_b[best_epoch].sqrtA * sin(Es) / pow(C_V, 2);//Relativistic effect
pos_t.delta_clk = nav_b[best_epoch].sa0 + nav_b[best_epoch].sa1 * tk + nav_b[best_epoch].sa2 * pow(tk, 2) - rela - nav_b[best_epoch].BGDa;
pos_t.delta_t = R / C_V + pos_t.delta_clk;
return pos_t;}
/* -------------------- BDS Satellite position calculate -------------------- */
pos_ts bds_pos(int sPRN, int best_epoch, double BDSsec,
pnav_body nav_b, pobs_head obs_h, pos_ts pos_t)
{ double T_S = BDSsec - pos_t.delta_t;
double n_0 = sqrt(GM) / pow(nav_b[best_epoch].sqrtA, 3);
double n = n_0 + nav_b[best_epoch].deltan;
double tk = T_S - nav_b[best_epoch].TOE - 14;
if (tk > 32400)tk -= 604800;
else if (tk < -32400)tk += 604800;
double Ms = nav_b[best_epoch].M0 + n * tk;
double Es = Ms, E0;
do
{
E0 = Es;
Es = Ms + nav_b[best_epoch].e * sin(Es);
} while (fabs(Es - E0) > 1.0e-10);
double cosfs = (cos(Es) - nav_b[best_epoch].e) / (1 - nav_b[best_epoch].e * cos(Es));
double sinfs = (sqrt(1 - pow(nav_b[best_epoch].e, 2)) * sin(Es)) / (1 - nav_b[best_epoch].e * cos(Es));
double fs = atan2(sinfs, cosfs);
double u0 = fs + nav_b[best_epoch].omega;
double epsilon_u = nav_b[best_epoch].Cus * sin(2 * u0) + nav_b[best_epoch].Cuc * cos(2 * u0);
double epsilon_r = nav_b[best_epoch].Crs * sin(2 * u0) + nav_b[best_epoch].Crc * cos(2 * u0);
double epsilon_i = nav_b[best_epoch].Cis * sin(2 * u0) + nav_b[best_epoch].Cic * cos(2 * u0);
double u = u0 + epsilon_u;
double r = pow(nav_b[best_epoch].sqrtA, 2) * (1 - nav_b[best_epoch].e * cos(Es)) + epsilon_r;
double i = nav_b[best_epoch].i0 + epsilon_i + nav_b[best_epoch].IDOT * tk;
double x = r * cos(u);
double y = r * sin(u);
double l, X, Y, Z;
if (sPRN > 5 && sPRN < 59) //BDS IGSO & MEO Satellites
{
l = nav_b[best_epoch].OMEGA + (nav_b[best_epoch].deltaomega - Earth_e) * tk - Earth_e * nav_b[best_epoch].TOE;
X = x * cos(l) - y * cos(i) * sin(l);
Y = x * sin(l) + y * cos(i) * cos(l);
Z = y * sin(i);}
else // BDS GEO Satellites
{
l = nav_b[best_epoch].OMEGA + nav_b[best_epoch].deltaomega * tk - Earth_e * nav_b[best_epoch].TOE;
X = x * cos(l) - y * cos(i) * sin(l);
Y = x * sin(l) + y * cos(i) * cos(l);
Z = y * sin(i);
double f = deg2rad(-5);
double p = Earth_e * tk;
X = X * cos(p) + Y * sin(p) * cos(f) + Z * sin(p) * sin(f);
Y = X * -sin(p) + Y * cos(p) * cos(f) + Z * cos(p) * sin(f);
Z = Y * -sin(f) + Z * cos(f);}
pos_t.X = cos(Earth_e * pos_t.delta_t) * X + sin(Earth_e * pos_t.delta_t) * Y;
pos_t.Y = -sin(Earth_e * pos_t.delta_t) * X + cos(Earth_e * pos_t.delta_t) * Y;
pos_t.Z = Z;//Correction of earth rotation
double rela = 2 * sqrt(GM) * nav_b[best_epoch].e * nav_b[best_epoch].sqrtA * sin(Es) / pow(C_V, 2);//Relativistic effect
pos_t.delta_clk = nav_b[best_epoch].sa0 + nav_b[best_epoch].sa1 * tk + nav_b[best_epoch].sa2 * pow(tk, 2) - rela;
double R = sqrt(pow(pos_t.X - obs_h->apX, 2) + pow(pos_t.Y - obs_h->apY, 2) + pow(pos_t.Z - obs_h->apZ, 2));
pos_t.deltat = pos_t.delta_t;
pos_t.delta_t = R / C_V + pos_t.delta_clk;
return pos_t;}
/* -------------------------------- Satellite position calculate & Output -------------------------------- */
void sat_pos_clac(FILE* result_file,HWND hwndPB,
pnav_body nav_b, pobs_epoch obs_e, pobs_body obs_b,pobs_head obs_h,
int o_epochnum, int satnum, int gnssdecode,
char res_file[MAX_PATH], char obs_file[MAX_PATH], char nav_file[MAX_PATH],
int ionoption, int trooption)
{
PBRANGE range;
SendMessage(hwndPB, PBM_SETRANGE, (WPARAM)FALSE, (LPARAM)(MAKELPARAM(0, 100)));
SendMessage(hwndPB, PBM_GETRANGE, (WPARAM)TRUE, (LPARAM)&range);
time_t gen_time;time(&gen_time);stations station = { 0 };xyz2blh tem2 = { 0 };
tem2 = XYZ2BLH(tem2, obs_h->apX, obs_h->apY, obs_h->apZ);
station.B = tem2.B;
station.L = tem2.L;
station.H = tem2.H;
result_file = fopen(res_file, "w");
fclose(result_file);
result_file = fopen(res_file, "a+");
fprintf(result_file, "@ GENERATE PROGRAM : KNZ_Calculate v1.2.2\n");
fprintf(result_file, "@ GENERATE TYPE : Satellite Position\n");
fprintf(result_file, "@ GENERATE TIME : %s", ctime(&gen_time));
fprintf(result_file, "@ OBS FILE PATH : %s\n", obs_file);
fprintf(result_file, "@ NAV FILE PATH : %s\n", nav_file);
fprintf(result_file, "@ TIME OF FIRST OBS : %4d %02d %02d %02d %02d %07.4f\n"
, obs_h->f_y, obs_h->f_m, obs_h->f_d, obs_h->f_h, obs_h->f_min, obs_h->f_sec);
fprintf(result_file, "@ TIME OF LAST OBS : %4d %02d %02d %02d %02d %07.4f\n"
, obs_h->l_y, obs_h->l_m, obs_h->l_d, obs_h->l_h, obs_h->l_min, obs_h->l_sec);
fprintf(result_file, "@ APPROX POSITION XYZ: %13.04f%13.04f%13.04f\n@ APPROX POSITION BLH: %12.07f %12.07f %12.07f\n"
, obs_h->apX, obs_h->apY, obs_h->apZ
, station.B, station.L, station.H);
if (ionoption == 0) { fprintf(result_file, "@ IONOS OPT : NULL\n"); }
if (ionoption == 1) { fprintf(result_file, "@ IONOS OPT : DEFAULT\n"); }
if (trooption == 0) { fprintf(result_file, "@ TROPO OPT : NULL\n@\n\n"); }
if (trooption == 1) { fprintf(result_file, "@ TROPO OPT : DEFAULT\n@\n\n"); }
fclose(result_file);
//the beginning second of observation
double beginsec = Time2Weeksec(obs_h->f_y, obs_h->f_m, obs_h->f_d, obs_h->f_h, obs_h->f_min, obs_h->f_sec);
//the ending second of observation
double endinsec = Time2Weeksec(obs_h->l_y, obs_h->l_m, obs_h->l_d, obs_h->l_h, obs_h->l_min, obs_h->l_sec);
for (int i = 0; i < o_epochnum; i++)
{ 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 };
blh2enu tem3 = { 0 };
rahcal tem4 = { 0 };
deg2dms temb = { 0 };
deg2dms teml = { 0 };
blhs blh = { 0 };
enus enu = { 0 };
rahs rah = { 0 };
pos_ts pos_t = { 0 };
double Weeksec = Time2Weeksec(y, m, d, h, min, sec);
int epochcount = round((Weeksec - beginsec) / obs_h->interval) + 1;
result_file = fopen(res_file, "a+");
fprintf(result_file, "\n>%04d %04d %02d %02d %02d %02d %07.04f"
, epochcount, 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);
if (gnssdecode % GPS == 0)//Be judged as GPS
{
for (int j = 0; j < obs_e[i].gps_num; j++)
{
int sPRN = obs_e[i].sPRN_GPS[j];
int best_epoch = select_epoch(Weeksec, sPRN, nav_b, satnum, GPS);
if (best_epoch == -1)//when the sPRN is not exist func will return -1
break;
double detat_toc = Weeksec - nav_b[best_epoch].TOE;
//Iterative approximate propagation time
pos_t.delta_t = (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 = 0.0;
while (fabs(pos_t.delta_t - pos_t.deltat) > 1.0e-9)
{
pos_t = gps_pos(sPRN, best_epoch, Weeksec, nav_b, obs_h, pos_t);
}
tem1 = XYZ2BLH(tem1, pos_t.X, pos_t.Y, pos_t.Z);
blh.B = rad2deg(tem1.B);
blh.L = rad2deg(tem1.L);
blh.H = tem1.H;
double deltax = pos_t.X - obs_h->apX;
double deltay = pos_t.Y - obs_h->apY;
double deltaz = pos_t.Z - obs_h->apZ;
tem3 = BLH2ENU(tem3, station.B, station.L, deltax, deltay, deltaz);
enu.E = tem3.E;
enu.N = tem3.N;
enu.U = tem3.U;
//Satellite altitude Angle calculation
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 || rah.H < 10 || nav_b[best_epoch].sHEA != 0)
{
continue;
}
else
{
temb = DEG2DMS(temb, blh.B);
blh.B_d = temb.D;
blh.B_m = temb.M;
blh.B_s = temb.S;
teml = DEG2DMS(teml, blh.L);
blh.L_d = teml.D;
blh.L_m = teml.M;
blh.L_s = teml.S;
result_file = fopen(res_file, "a+");
fprintf(result_file, "\nG %02d| %15.05f %15.05f %15.05f %15.05f %15.05f %15.05f %16.13f"
, sPRN, pos_t.X, pos_t.Y, pos_t.Z
, 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)]
, rah.H, pos_t.delta_clk);//GPS satellite
fclose(result_file);
}
}
}
if (gnssdecode % BDS == 0)//Be judged as BeiDou
{
for (int j = 0; j < obs_e[i].bds_num; j++)
{
int sPRN = obs_e[i].sPRN_BDS[j];
int best_epoch = select_epoch(Weeksec, sPRN, nav_b, satnum, BDS);
if (best_epoch == -1)//when the sPRN is not exist func will return -1
break;
double detat_toc = Weeksec - nav_b[best_epoch].TOE - 14;//BDST - GPST = 14s
//Iterative approximate propagation time
pos_t.delta_t = (obs_b[i].obs_bds[j][Code2Type(C2I, obs_h->obstypenum_bds, obs_h->obscode_bds)] / 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 = 0.0;
while (fabs(pos_t.delta_t - pos_t.deltat) > 1.0e-9)
{
pos_t = bds_pos(sPRN, best_epoch, Weeksec, nav_b, obs_h, pos_t);
}
tem1 = XYZ2BLH(tem1, pos_t.X, pos_t.Y, pos_t.Z);
blh.B = rad2deg(tem1.B);
blh.L = rad2deg(tem1.L);
blh.H = tem1.H;
double deltax = pos_t.X - obs_h->apX;
double deltay = pos_t.Y - obs_h->apY;
double deltaz = pos_t.Z - obs_h->apZ;
tem3 = BLH2ENU(tem3, station.B, station.L, deltax, deltay, deltaz);
enu.E = tem3.E;
enu.N = tem3.N;
enu.U = tem3.U;
//Satellite altitude Angle calculation
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 || rah.H < 10 || nav_b[best_epoch].sHEA != 0){
continue;
}
else{
temb = DEG2DMS(temb, blh.B);
blh.B_d = temb.D;
blh.B_m = temb.M;
blh.B_s = temb.S;
teml = DEG2DMS(teml, blh.L);
blh.L_d = teml.D;
blh.L_m = teml.M;
blh.L_s = teml.S;
result_file = fopen(res_file, "a+");
if (sPRN >= 19) {
fprintf(result_file, "\nCC%02d| %15.05f %15.05f %15.05f %15.05f %15.05f %15.05f %16.13f"
, sPRN, pos_t.X, pos_t.Y, pos_t.Z
, obs_b[i].obs_bds[j][Code2Type(C2I, obs_h->obstypenum_bds, obs_h->obscode_bds)]
, obs_b[i].obs_bds[j][Code2Type(C7I, obs_h->obstypenum_bds, obs_h->obscode_bds)]
, rah.H, pos_t.delta_clk);//BDS-3 satellite
}
else {
fprintf(result_file, "\nCB%02d| %15.05f %15.05f %15.05f %15.05f %15.05f %15.05f %16.13f"
, sPRN, pos_t.X, pos_t.Y, pos_t.Z
, obs_b[i].obs_bds[j][Code2Type(C2I, obs_h->obstypenum_bds, obs_h->obscode_bds)]
, obs_b[i].obs_bds[j][Code2Type(C7I, obs_h->obstypenum_bds, obs_h->obscode_bds)]
, rah.H, pos_t.delta_clk);//BDS-2 satellite
}
fclose(result_file);
}
}
}
if (gnssdecode % GAL == 0)//Be judged as Galileo
{
for (int j = 0; j < obs_e[i].gal_num; j++)
{
int sPRN = obs_e[i].sPRN_GAL[j];
int best_epoch = select_epoch(Weeksec, sPRN, nav_b, satnum, GAL);
if (best_epoch == -1)//when the sPRN is not exist func will return -1
break;
double detat_toc = Weeksec - nav_b[best_epoch].TOE;
//Iterative approximate propagation time
pos_t.delta_t = (obs_b[i].obs_gal[j][Code2Type(C1C, obs_h->obstypenum_gal, obs_h->obscode_gal)] / 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 = 0.0;
while (fabs(pos_t.delta_t - pos_t.deltat) > 1.0e-9)
{
pos_t = gal_pos(sPRN, best_epoch, Weeksec, nav_b, obs_h, pos_t);
}
tem1 = XYZ2BLH(tem1, pos_t.X, pos_t.Y, pos_t.Z);
blh.B = rad2deg(tem1.B);
blh.L = rad2deg(tem1.L);
blh.H = tem1.H;
double deltax = pos_t.X - obs_h->apX;
double deltay = pos_t.Y - obs_h->apY;
double deltaz = pos_t.Z - obs_h->apZ;
tem3 = BLH2ENU(tem3, station.B, station.L, deltax, deltay, deltaz);
enu.E = tem3.E;
enu.N = tem3.N;
enu.U = tem3.U;
//Satellite altitude Angle calculation
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 || rah.H < 10 || nav_b[best_epoch].sHEA != 0)
{ continue;}
else
{
temb = DEG2DMS(temb, blh.B);
blh.B_d = temb.D;
blh.B_m = temb.M;
blh.B_s = temb.S;
teml = DEG2DMS(teml, blh.L);
blh.L_d = teml.D;
blh.L_m = teml.M;
blh.L_s = teml.S;
result_file = fopen(res_file, "a+");
fprintf(result_file, "\nE %02d| %15.05f %15.05f %15.05f %15.05f %15.05f %15.05f %16.13f"
, sPRN, pos_t.X, pos_t.Y, pos_t.Z
, obs_b[i].obs_gal[j][Code2Type(C1C, obs_h->obstypenum_gps, obs_h->obscode_gps)]
, obs_b[i].obs_gal[j][Code2Type(C6C, obs_h->obstypenum_gps, obs_h->obscode_gps)]
, rah.H, pos_t.delta_clk);//Galileo satellite
fclose(result_file);
}
}
}
result_file = fopen(res_file, "a+");
fprintf(result_file, "\n");
fclose(result_file);
SendMessage(hwndPB, PBM_SETPOS, (WPARAM)((int)(i * 100 / o_epochnum)), (LPARAM)0);
}
result_file = fopen(res_file, "a+");
fprintf(result_file, "\nEND");
fclose(result_file);
SendMessage(hwndPB, PBM_SETPOS, (WPARAM)range.iHigh, (LPARAM)0);
}
#endif
-32
View File
@@ -1,32 +0,0 @@
#ifndef _DEG2DMS_H_
#define _DEG2DMS_H_
#include<stdlib.h>
#include<math.h>
typedef struct
{
double D;
double M;
double S;
}deg2dms;
/* -------------------------------------------------------------------------- */
/// @brief Converts decimal degrees to degree minutes and seconds
/// @param deg2dms Parameter transfer structure
/// @param D The number of degrees to convert
/// @return return structure contain degree minute second
/* -------------------------------------------------------------------------- */
deg2dms DEG2DMS(deg2dms deg2dms,
double D)
{
int sig = D / fabs(D);//sign judgment
deg2dms.D = (int)(D);//to degree
deg2dms.M = (int)((D - deg2dms.D) * 60);//to minute
deg2dms.S = (int)(((D - deg2dms.D) * 60 - deg2dms.M) * 60);//to second
deg2dms.M = deg2dms.M * sig;
deg2dms.S = deg2dms.S * sig;
return deg2dms;
}
#endif
-27
View File
@@ -1,27 +0,0 @@
#ifndef _DEGRRAD_H_
#define _DEGRRAD_H_
#include"public.h"
/* -------------------------------------------------------------------------- */
/// @brief degree to radian
/// @param deg
/// @return return radian
/* -------------------------------------------------------------------------- */
double deg2rad(double deg)
{
double rad = (PI / 180) * deg;
return rad;
}
/* -------------------------------------------------------------------------- */
/// @brief radian to degree
/// @param rad
/// @return return degree
/* -------------------------------------------------------------------------- */
double rad2deg(double rad)
{
double deg = (180 / PI) * rad;
return deg;
}
#endif
-302
View File
@@ -1,302 +0,0 @@
#ifndef _PUBLIC_H_
#define _PUBLIC_H_
/* --------------------------------- FOR UI --------------------------------- */
//FILE SELECT DIALOGS
#define FILEEXOP TEXT("RINEX OBS(*.o*.*.*obs.*.*d)\0*.*o;*.*obs;*.*d\0"\
"All Files(*.*)\0*.*\0\0");
#define FILEEXNP TEXT("RINEX NAV(*.*nav.*.hnav.*.gnav.*.qnav.*.*n.*.*g.*.*h.*.*q.*.*p)\0*.*nav;*.hnav;*.gnav;*.qnav;*.*n;*.*g;*.*h;*.*q;*.*p\0"\
"All Files(*.*)\0*.*\0\0")
#define FILEEXSV TEXT("Spos Files(*.sp*)\0*.sp\0"\
"All Files(*.*)\0*.*\0\0");
//DEF MAIN WINDOW BUTTONS
#define OBSBUTTON 3301
#define NAVBUTTON 3302
#define CALBUTTON 3303
#define OPTBUTTON 3304
#define PLOBUTTON 3305
#define OBSCLEAR 3306
#define OBSRELOD 3307
#define NAVCLEAR 3308
#define NAVRELOD 3309
#define PROGRESS 3310
//DEF MAIN WINDOW GNSS NUTTONS
#define GPSCHECK 5500
#define GLOCHECK 5501
#define BEICHECK 5502
#define GALCHECK 5503
#define SBACHECK 5504
#define SYSGROUP 1001
//DEF OPTIONS WINDOW CHECK+BOXS
#define OPTDFION 7001
#define OPTDFTRO 7002
#define OPTCONFI 7003
//DEFINE PROGRESSBAR STATE
#define PBSTATENONE 0
#define PBSTATEHALF 500
#define PBSTATEFULL 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
/* ----------------------------- GNSS OBSERV TYPE --------------------------- */
#define C1C 100
#define C1S 101
#define C1L 102
#define C1X 103
#define C1P 104
#define C1W 105
#define C1Y 106
#define C1M 107
#define C1A 108
#define C1B 109
#define C1Z 110
#define C2C 200
#define C2S 201
#define C2L 202
#define C2X 203
#define C2P 204
#define C2W 205
#define C2Y 206
#define C2M 207
#define C2I 208
#define C2Q 209
#define C2X 210
#define C5I 500
#define C5Q 501
#define C5X 502
#define C6A 600
#define C6B 601
#define C6C 602
#define C6X 603
#define C6Z 604
#define C7I 700
#define C7Q 701
#define C7X 702
#define C7D 703
#define C7P 704
#define C7Z 705
#define C8I 800
#define C8Q 801
#define C8X 802
/* ------------------------------- GNSS CODE -------------------------------- */
#define GPS 03
#define BDS 07
#define GAL 11
#define GLO 13
#define SBAS 17
/* ------------------------------ FOR CALMOD.H ------------------------------ */
#define MAXRINEX 1000
#define DAYSEC 86400
//satellite position & clock bias structure
typedef struct
{
double X;
double Y;
double Z;
double deltat;
double delta_t;
double delta_clk;
}pos_ts;
//receiver station position & clock bias structure
typedef struct
{
double X;
double Y;
double Z;
double B;
double L;
double H;
double delta_TR;
}stations;
//longitude & latitude structure
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;
}blhs;
//local Cartesian coordinates coordinate system structure
typedef struct
{
double E;
double N;
double U;
}enus;
//satellite azimuth angle structure
typedef struct
{
double R;
double A;
double H;
}rahs;
/* ------------------------------- FOR READ.H ------------------------------- */
//header data of file of nav
typedef struct nav_head
{
double ver;//rinex
char type[20];
double ION_GPSA[4];
double ION_GPSB[4];
double ION_BDSA[4];
double ION_BDSB[4];
double ION_QZSA[4];
double ION_QZSB[4];
double ION_IRNA[4];
double ION_IRNB[4];
double GPUT[4];
double GLUT[4];
double GAUT[4];
double BDUT[4];
double QZUT[4];
double IRUT[4];
double SBUT[4];
int leap;
}nav_head, *pnav_head;
//body data of file of nav: GPS BeiDou Galileo
typedef struct nav_body
{
int sPRN_GPS; int sPRN_BDS; int sPRN_GAL;
int TOC_Y;
int TOC_M;
int TOC_D;
int TOC_H;
int TOC_Min;
int TOC_Sec;
double sa0;
double sa1;
double sa2;
double IODE; double AODE;
double Crs;
double deltan;
double M0;
double Cuc;
double e;
double Cus;
double sqrtA;
double TOE;
double Cic;
double OMEGA;
double Cis;
double i0;
double Crc;
double omega;
double deltaomega;
double IDOT;
double L2code; int Datasource;
double GPSweek; double BDTweek; double GALweek;
double L2Pflag;
double sACC;
double sHEA;
double TGD; double TGD1; double BGDa;
double IODC; double TGD2; double BGDb;
double TTN;
double fit; double AODC;
double spare1;
double spare2;
}nav_body, *pnav_body;
//header data of file of obs
typedef struct obs_head
{
double ver;
char type[30];
double apX;
double apY;
double apZ;
double ANTH;
double ANTdeltaE;
double ANTdeltaN;
int obstypenum_gps;
int obstypenum_bds;
int obstypenum_gal;
int obscode_gps[26];
int obscode_bds[26];
int obscode_gal[26];
double interval;
int f_y;
int f_m;
int f_d;
int f_h;
int f_min;
double f_sec;
int l_y;
int l_m;
int l_d;
int l_h;
int l_min;
double l_sec;
char tsys[5];//time system
}obs_head,*pobs_head;
//epoch data of file of obs
typedef struct obs_epoch
{
int y;
int m;
int d;
int h;
int min;
double sec;//epoch time
int p_flag;//epoch flag
int sat_num;//the total number of obsable sat
int gps_num;//the total gps sat
int bds_num;//the total bds sat
int gal_num;//the total galileo sat
int sPRN[84];//total sprn of obs sat
int sPRN_GPS[30];
int sPRN_BDS[60];
int sPRN_GAL[30];
}obs_epoch,*pobs_epoch;
//body data of file of obs
typedef struct obs_body
{
double obs_gps[30][26];//GPS obs data
double obs_bds[60][26];//BDS obs data
double obs_gal[30][26];//GALILEO obs data
}obs_body,*pobs_body;
/* -------------------------------------------------------------------------- */
#endif
-37
View File
@@ -1,37 +0,0 @@
#ifndef _RAHCAL_H_
#define _RAHCAL_H_
#include<stdlib.h>
#include<math.h>
#include"public.h"
typedef struct
{
double R;
double A;
double H;
}rahcal;
/* -------------------------------------------------------------------------- */
/// @brief satellite azimuth angle calculation
/// @param rahcal parameter transfer structure
/// @param E east
/// @param N north
/// @param U up
/// @return return structure contain R, A, H members
/* -------------------------------------------------------------------------- */
rahcal RAHCAL(rahcal rahcal,
double E, double N, double U)
{
rahcal.H = atan2(U, sqrt(E * E + N * N));
rahcal.A = atan2(E, U);
if (rahcal.A < 0)
rahcal.A += 2 * PI;
if (rahcal.A > 2 * PI)
rahcal.A -= 2 * PI;
rahcal.R = sqrt(E * E + N * N + U * U);
return rahcal;
}
#endif
-577
View File
@@ -1,577 +0,0 @@
#ifndef _READ_H_
#define _READ_H_
#include<stdio.h>
#include<string.h>
#include"public.h"
#include"type2code.h"
static double strtonum(const char* buff, int i, int n)
{
double value = 0.0;
char str[256] = { 0 };
char* p = str;
/* ---------------------------------- */
/// Function will return 0.0 as error code when three occasion are below:
/// 1.Begining position < 0
/// 2.The number of Byte of read < i
/// 3.The Byte size of string < n
/* ---------------------------------- */
if (i < 0 || (int)strlen(buff) < i || (int)sizeof(str) - 1 < n)
{
return 0.0;
}
for (buff += i; *buff && --n >= 0; buff++)
{
*p++ = ((*buff == 'D' || *buff == 'd') ? 'e' : *buff);
}
*p = '\0';
return sscanf(str, "%lf", &value) == 1 ? value : 0.0;
}
/* -------------------------- Read the file of obs -------------------------- */
/* -------------------------------------------------------------------------- */
/// @brief get the total number of epoch of obs
/// @param fp_obs the file pointer of obs
/// @return epoch number
/* -------------------------------------------------------------------------- */
extern int get_epochnum(FILE* fp_obs)
{
int n = 0;
int satnum = 0;
char flag;
char buff[MAXRINEX];
while (fgets(buff, MAXRINEX, fp_obs))
{ satnum = (int)strtonum(buff, 33, 2);
strncpy(&flag, buff + 0, 1);
if (flag == '>')
{ n++;}
}
return n;
}
/* ------------------- Read the header data of file of obs ------------------ */
extern void read_o_h(FILE* fp_obs, pobs_head obs_h)
{
char buff[MAXRINEX] = { 0 };
char flag = { 0 };
char* lable = buff + 60;
int i = 0;
int j = 0;
obs_h->interval = 30;
obs_h->f_y = obs_h->f_m = obs_h->f_d = obs_h->f_h = obs_h->f_min = obs_h->f_sec = 0;
obs_h->l_y = obs_h->l_m = obs_h->l_d = obs_h->l_h = obs_h->l_min = obs_h->l_sec = 0;
memset(obs_h->obscode_gps, 0, sizeof(obs_h->obscode_gps));
memset(obs_h->obscode_bds, 0, sizeof(obs_h->obscode_bds));
memset(obs_h->obscode_gal, 0, sizeof(obs_h->obscode_gal));
while (fgets(buff, MAXRINEX, fp_obs))
{ if (strstr(lable, "RINEX VERSION / TYPE"))
{ obs_h->ver = strtonum(buff, 0, 9);
strncpy(obs_h->type, buff + 20, 30);
continue;}
else if (strstr(lable, "APPROX POSITION XYZ"))
{ obs_h->apX = strtonum(buff, 0, 14);
obs_h->apY = strtonum(buff, 0 + 14, 14);
obs_h->apZ = strtonum(buff, 0 + 14 + 14, 14);
continue;}
else if (strstr(lable, "ANTENNA: DELTA H/E/N"))
{ obs_h->ANTH = strtonum(buff, 0, 14);
obs_h->ANTdeltaE = strtonum(buff, 14, 14);
obs_h->ANTdeltaN = strtonum(buff, 14 + 14, 14);
continue;}
else if (strstr(lable, "SYS / # / OBS TYPES"))
{ char flag = {0};
strncpy(&flag, buff + 0, 1);
if (flag == 'G')
{ 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);}}
else if (obs_h->obstypenum_gps > 13)
{ for (i = 0; i < 13; i++)
{ obs_h->obscode_gps[i] = Type2Code(i, buff);}
fgets(buff, MAXRINEX, fp_obs);
for (i = 0; i < obs_h->obstypenum_gps - 13; i++)
{ obs_h->obscode_gps[i + 13] = Type2Code(i, buff);}}
continue;}
else if (flag == 'C')
{ obs_h->obstypenum_bds = (int)strtonum(buff, 4, 2);
if (obs_h->obstypenum_bds <= 13)
{ for (i = 0; i < obs_h->obstypenum_bds; i++)
{ obs_h->obscode_bds[i] = Type2Code(i, buff);}}
else if (obs_h->obstypenum_bds > 13)
{ for (i = 0; i < 13; i++)
{ obs_h->obscode_bds[i] = Type2Code(i, buff);}
fgets(buff, MAXRINEX, fp_obs);
for (i = 0; i < obs_h->obstypenum_bds - 13; i++)
{ obs_h->obscode_bds[i + 13] = Type2Code(i, buff);}}
continue;}
else if (flag == 'E')
{ obs_h->obstypenum_gal = (int)strtonum(buff, 4, 2);
if (obs_h->obstypenum_gal <= 13)
{ for (i = 0; i < obs_h->obstypenum_gal; i++)
{obs_h->obscode_gal[i] = Type2Code(i, buff);}}
else if (obs_h->obstypenum_gal > 13)
{ for (i = 0; i < 13; i++)
{obs_h->obscode_gal[i] = Type2Code(i, buff);}
fgets(buff, MAXRINEX, fp_obs);
for (i = 0; i < obs_h->obstypenum_gal - 13; i++)
{obs_h->obscode_gal[i + 13] = Type2Code(i, buff);}}
continue;}
continue;}
else if (strstr(lable, "INTERVAL"))
{ obs_h->interval = strtonum(buff, 0, 10);
continue;}
else if (strstr(lable, "TIME OF FIRST OBS"))
{ obs_h->f_y = (int)strtonum(buff, 2, 4);
obs_h->f_m = (int)strtonum(buff, 2 + 6, 4);
obs_h->f_d = (int)strtonum(buff, 2 + 6 + 6, 4);
obs_h->f_h = (int)strtonum(buff, 2 + 6 + 6 + 6, 4);
obs_h->f_min = (int)strtonum(buff, 2 + 6 + 6 + 6 + 6, 4);
obs_h->f_sec = strtonum(buff, 2 + 6 + 6 + 6 + 6 + 6, 9);
strncpy(obs_h->tsys, buff + 6 + 6 + 6 + 6 + 6 + 18, 3);
continue;}
else if (strstr(lable, "TIME OF LAST OBS"))
{ obs_h->l_y = (int)strtonum(buff, 2, 4);
obs_h->l_m = (int)strtonum(buff, 2 + 6, 4);
obs_h->l_d = (int)strtonum(buff, 2 + 6 + 6, 4);
obs_h->l_h = (int)strtonum(buff, 2 + 6 + 6 + 6, 4);
obs_h->l_min = (int)strtonum(buff, 2 + 6 + 6 + 6 + 6, 4);
obs_h->l_sec = strtonum(buff, 2 + 6 + 6 + 6 + 6 + 6, 9);
continue;}
else if (strstr(lable, "END OF HEADER"))
{ break;}
}
}
/* -------------------- Read the body data of file of obs ------------------- */
extern void read_o_b(FILE* fp_obs, pobs_epoch obs_e, pobs_body obs_b, pobs_head obs_h)
{
int n = 0;
char buff[MAXRINEX] = { 0 };
char flag = { 0 };
while (fgets(buff, MAXRINEX, fp_obs))
{
int i = 0;
int j_g = 0;
int k_g = 0;
int j_c = 0;
int k_c = 0;
int j_ga = 0;
int k_ga = 0;
obs_e[n].gps_num = 0;
obs_e[n].bds_num = 0;
obs_e[n].gal_num = 0;
obs_e[n].y = (int)strtonum(buff, 2, 4);
obs_e[n].m = (int)strtonum(buff, 7, 2);
obs_e[n].d = (int)strtonum(buff, 10, 2);
obs_e[n].h = (int)strtonum(buff, 13, 2);
obs_e[n].min = (int)strtonum(buff, 16, 2);
obs_e[n].sec = strtonum(buff, 19, 10);
obs_e[n].p_flag = (int)strtonum(buff, 31, 1);
obs_e[n].sat_num = strtonum(buff, 33, 3);
strncpy(&flag, buff + 0, 1);
memset(obs_e[n].sPRN, 0, sizeof(obs_e[n].sPRN));
memset(obs_e[n].sPRN_GPS, 0, sizeof(obs_e[n].sPRN_GPS));
memset(obs_e[n].sPRN_BDS, 0, sizeof(obs_e[n].sPRN_BDS));
memset(obs_e[n].sPRN_GAL, 0, sizeof(obs_e[n].sPRN_GAL));
memset(obs_b[n].obs_gps, 0, sizeof(obs_b[n].obs_gps));
memset(obs_b[n].obs_bds, 0, sizeof(obs_b[n].obs_bds));
memset(obs_b[n].obs_gal, 0, sizeof(obs_b[n].obs_gal));
for (i = 0; i < obs_e[n].sat_num; i++)
{
if (flag == 'G')
{ obs_e[n].sPRN[i] = strtonum(buff, 1, 2);
obs_e[n].sPRN_GPS[j_g] = obs_e[n].sPRN[i];
for (k_g = 0; k_g < obs_h->obstypenum_gps; k_g++)
{ obs_b[n].obs_gps[j_g][k_g] = strtonum(buff, 3 + 16 * k_g, 14);}
obs_e[n].gps_num++; j_g++;
fgets(buff, MAXRINEX, fp_obs);
strncpy(&flag, buff + 0, 1);}
else if (flag == 'C')
{ obs_e[n].sPRN[i] = strtonum(buff, 1, 2);
obs_e[n].sPRN_BDS[j_c] = obs_e[n].sPRN[i];
for (k_c = 0; k_c < obs_h->obstypenum_bds; k_c++)
{ obs_b[n].obs_bds[j_c][k_c] = strtonum(buff, 3 + 16 * k_c, 14);}
obs_e[n].bds_num++; j_c++;
fgets(buff, MAXRINEX, fp_obs);
strncpy(&flag, buff + 0, 1);
}
else if (flag == 'E')
{ obs_e[n].sPRN[i] = strtonum(buff, 1, 2);
obs_e[n].sPRN_GAL[j_ga] = obs_e[n].sPRN[i];
for (k_ga = 0; k_ga < obs_h->obstypenum_gal; k_ga++)
{ obs_b[n].obs_gal[j_ga][k_ga] = strtonum(buff, 3 + 16 * k_ga, 14);}
obs_e[n].gal_num++; j_ga++;
fgets(buff, MAXRINEX, fp_obs);
strncpy(&flag, buff + 0, 1);
}
else if (flag != 'G'&& flag != 'C'&& flag != 'E')
{
fgets(buff, MAXRINEX, fp_obs);
strncpy(&flag, buff + 0, 1);
}
}
n++;
}
}
/* -------------------------- Read the file of nav -------------------------- */
/* -------------------------------------------------------------------------- */
/// @brief get the total number of satellite boardcast data of nav file
/// @param fp_nav the file pointer of nav file
/// @return total number of satellite boardcast data
/* -------------------------------------------------------------------------- */
static int getsatnum(FILE* fp_nav)
{
int satnum = 0;
int flag = 0;
char buff[MAXRINEX];
char satvar;
char* lable = buff + 60;
while (fgets(buff, MAXRINEX, fp_nav))
{ if (strstr(lable, "END OF HEADER"))
{ flag = 1;}
if (flag == 1)
{ while (fgets(buff, MAXRINEX, fp_nav))
{ strncpy(&satvar, buff + 0, 1);
if (satvar == 'G' || satvar == 'E' || satvar == 'R' || satvar == 'S' || satvar == 'C' || satvar == 'I' || satvar == 'J')
{ satnum++;}
else
{ continue;}}}}
return satnum;
}
/* ------------------- Read the header data of file of nav ------------------ */
void read_n_h(FILE* fp_nav, pnav_head nav_h)
{
char buff[MAXRINEX] = { 0 };
char* lable = buff;
int i = 0;
int j = 0;
while (fgets(buff, MAXRINEX, fp_nav))
{
if (strstr(lable, "RINEX VERSION / TYPE"))
{ nav_h->ver = strtonum(buff, 0, 9);
strncpy((nav_h->type), buff + 20, 15);
continue;}
else if (strstr(lable, "GPSA"))
{ nav_h->ION_GPSA[0] = strtonum(buff, 6, 12);
nav_h->ION_GPSA[1] = strtonum(buff, 6 + 12, 12);
nav_h->ION_GPSA[2] = strtonum(buff, 6 + 12 + 12, 12);
nav_h->ION_GPSA[3] = strtonum(buff, 6 + 12 + 12 + 12, 12);
continue;}
else if (strstr(lable, "GPSB"))
{ nav_h->ION_GPSB[0] = strtonum(buff, 6, 12);
nav_h->ION_GPSB[1] = strtonum(buff, 6 + 12, 12);
nav_h->ION_GPSB[2] = strtonum(buff, 6 + 12 + 12, 12);
nav_h->ION_GPSB[3] = strtonum(buff, 6 + 12 + 12 + 12, 12);
continue;}
else if (strstr(lable, "BDSA"))
{ nav_h->ION_BDSA[0] = strtonum(buff, 6, 12);
nav_h->ION_BDSA[1] = strtonum(buff, 6 + 12, 12);
nav_h->ION_BDSA[2] = strtonum(buff, 6 + 12 + 12, 12);
nav_h->ION_BDSA[3] = strtonum(buff, 6 + 12 + 12 + 12, 12);
continue;}
else if (strstr(lable, "BDSB"))
{ nav_h->ION_BDSB[0] = strtonum(buff, 6, 12);
nav_h->ION_BDSB[1] = strtonum(buff, 6 + 12, 12);
nav_h->ION_BDSB[2] = strtonum(buff, 6 + 12 + 12, 12);
nav_h->ION_BDSB[3] = strtonum(buff, 6 + 12 + 12 + 12, 12);
continue;}
else if (strstr(lable, "BDUT"))
{ nav_h->BDUT[0] = strtonum(buff, 5, 17);
nav_h->BDUT[1] = strtonum(buff, 5 + 17, 16);
nav_h->BDUT[2] = strtonum(buff, 5 + 17 + 16, 7);
nav_h->BDUT[3] = strtonum(buff, 5 + 17 + 16 + 7, 5);
continue;}
else if (strstr(lable, "GPUT"))
{ nav_h->GPUT[0] = strtonum(buff, 5, 17);
nav_h->GPUT[1] = strtonum(buff, 5 + 17, 16);
nav_h->GPUT[2] = strtonum(buff, 5 + 17 + 16, 7);
nav_h->GPUT[3] = strtonum(buff, 5 + 17 + 16 + 7, 5);
continue;}
else if (strstr(lable, "LEAP SECONDS"))
{ nav_h->leap = (int)strtonum(buff, 4, 2);}
else if (strstr(lable, "END OF HEADER"))
break;
}
}
/* -------------------- Read the body data of file of nav ------------------- */
void read_n_b(FILE* fp_nav, pnav_body nav_b)
{
int i_g = 0;
char buff[MAXRINEX] = { 0 };
char flag = { 0 };
while (fgets(buff, MAXRINEX, fp_nav))
{
int j_g = 0;
int j_c = 0;
int j_ga = 0;
int j_gl = 0;
strncpy(&flag, buff + 0, 1);
if(flag == 'G')
{ for (j_g = 0; j_g < 8; j_g++)
{ switch (j_g)
{
case 0:
nav_b[i_g].sPRN_BDS = -1;
nav_b[i_g].sPRN_GAL = -1;
nav_b[i_g].sPRN_GPS = (int)strtonum(buff, 1, 2);
nav_b[i_g].TOC_Y = (int)strtonum(buff, 4, 4);
nav_b[i_g].TOC_M = (int)strtonum(buff, 9, 2);
nav_b[i_g].TOC_D = (int)strtonum(buff, 12, 2);
nav_b[i_g].TOC_H = (int)strtonum(buff, 15, 2);
nav_b[i_g].TOC_Min = (int)strtonum(buff, 18, 2);
nav_b[i_g].TOC_Sec = strtonum(buff, 21, 2);
nav_b[i_g].sa0 = strtonum(buff, 23, 19);
nav_b[i_g].sa1 = strtonum(buff, 23 + 19, 19);
nav_b[i_g].sa2 = strtonum(buff, 23 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 1:
nav_b[i_g].IODE = strtonum(buff, 4, 19);
nav_b[i_g].Crs = strtonum(buff, 4 + 19, 19);
nav_b[i_g].deltan = strtonum(buff, 4 + 19 + 19, 19);
nav_b[i_g].M0 = strtonum(buff, 4 + 19 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 2:
nav_b[i_g].Cuc = strtonum(buff, 4, 19);
nav_b[i_g].e = strtonum(buff, 4 + 19, 19);
nav_b[i_g].Cus = strtonum(buff, 4 + 19 + 19, 19);
nav_b[i_g].sqrtA = strtonum(buff, 4 + 19 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 3:
nav_b[i_g].TOE = strtonum(buff, 4, 19);
nav_b[i_g].Cic = strtonum(buff, 4 + 19, 19);
nav_b[i_g].OMEGA = strtonum(buff, 4 + 19 + 19, 19);
nav_b[i_g].Cis = strtonum(buff, 4 + 19 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 4:
nav_b[i_g].i0 = strtonum(buff, 4, 19);
nav_b[i_g].Crc = strtonum(buff, 4 + 19, 19);
nav_b[i_g].omega = strtonum(buff, 4 + 19 + 19, 19);
nav_b[i_g].deltaomega = strtonum(buff, 4 + 19 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 5:
nav_b[i_g].IDOT = strtonum(buff, 4, 19);
nav_b[i_g].L2code = strtonum(buff, 4 + 19, 19);
nav_b[i_g].GPSweek= strtonum(buff, 4 + 19 + 19, 19);
nav_b[i_g].L2Pflag = strtonum(buff, 4 + 19 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 6:
nav_b[i_g].sACC = strtonum(buff, 4, 19);
nav_b[i_g].sHEA = strtonum(buff, 4 + 19, 19);
nav_b[i_g].TGD = strtonum(buff, 4 + 19 + 19, 19);
nav_b[i_g].IODC = strtonum(buff, 4 + 19 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 7:
nav_b[i_g].TTN = strtonum(buff, 4, 19);
nav_b[i_g].fit = strtonum(buff, 4 + 19, 19);
//nav_b[i_g].spare1 = strtonum(buff, 4 + 19 + 19, 19);
//nav_b[i_g].spare2 = strtonum(buff, 4 + 19 + 19 + 19, 19);
break;
}}
i_g++;
continue;}
if(flag == 'C')
{ for (j_c = 0; j_c < 8; j_c++)
{ switch (j_c)
{
case 0:
nav_b[i_g].sPRN_GPS = -1;
nav_b[i_g].sPRN_GAL = -1;
nav_b[i_g].sPRN_BDS = (int)strtonum(buff, 1, 2);
nav_b[i_g].TOC_Y = (int)strtonum(buff, 4, 4);
nav_b[i_g].TOC_M = (int)strtonum(buff, 9, 2);
nav_b[i_g].TOC_D = (int)strtonum(buff, 12, 2);
nav_b[i_g].TOC_H = (int)strtonum(buff, 15, 2);
nav_b[i_g].TOC_Min = (int)strtonum(buff, 18, 2);
nav_b[i_g].TOC_Sec = strtonum(buff, 21, 2);
nav_b[i_g].sa0 = strtonum(buff, 23, 19);
nav_b[i_g].sa1 = strtonum(buff, 23 + 19, 19);
nav_b[i_g].sa2 = strtonum(buff, 23 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 1:
nav_b[i_g].AODE = strtonum(buff, 4, 19);
nav_b[i_g].Crs = strtonum(buff, 4 + 19, 19);
nav_b[i_g].deltan = strtonum(buff, 4 + 19 + 19, 19);
nav_b[i_g].M0 = strtonum(buff, 4 + 19 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 2:
nav_b[i_g].Cuc = strtonum(buff, 4, 19);
nav_b[i_g].e = strtonum(buff, 4 + 19, 19);
nav_b[i_g].Cus = strtonum(buff, 4 + 19 + 19, 19);
nav_b[i_g].sqrtA = strtonum(buff, 4 + 19 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 3:
nav_b[i_g].TOE = strtonum(buff, 4, 19);
nav_b[i_g].Cic = strtonum(buff, 4 + 19, 19);
nav_b[i_g].OMEGA = strtonum(buff, 4 + 19 + 19, 19);
nav_b[i_g].Cis = strtonum(buff, 4 + 19 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 4:
nav_b[i_g].i0 = strtonum(buff, 4, 19);
nav_b[i_g].Crc = strtonum(buff, 4 + 19, 19);
nav_b[i_g].omega = strtonum(buff, 4 + 19 + 19, 19);
nav_b[i_g].deltaomega = strtonum(buff, 4 + 19 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 5:
nav_b[i_g].IDOT = strtonum(buff, 4, 19);
//nav_b[i_g].L2code = strtonum(buff, 4 + 19, 19);
nav_b[i_g].BDTweek = strtonum(buff, 4 + 19 + 19, 19);
//nav_b[i_g].L2Pflag = strtonum(buff, 4 + 19 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 6:
nav_b[i_g].sACC = strtonum(buff, 4, 19);
nav_b[i_g].sHEA = strtonum(buff, 4 + 19, 19);
nav_b[i_g].TGD1 = strtonum(buff, 4 + 19 + 19, 19);
nav_b[i_g].TGD2 = strtonum(buff, 4 + 19 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 7:
//nav_b[i_g].TTN = strtonum(buff, 4, 19);
nav_b[i_g].AODC = strtonum(buff, 4 + 19, 19);
//nav_b[i_g].spare1 = strtonum(buff, 4 + 19 + 19, 19);
//nav_b[i_g].spare2 = strtonum(buff, 4 + 19 + 19 + 19, 19);
break;
}}
i_g++;
continue;}
if (flag == 'E')
{ for (j_ga = 0; j_ga < 8; j_ga++)
{ switch (j_ga)
{
case 0:
nav_b[i_g].sPRN_BDS = -1;
nav_b[i_g].sPRN_GPS = -1;
nav_b[i_g].sPRN_GAL = (int)strtonum(buff, 1, 2);
nav_b[i_g].TOC_Y = (int)strtonum(buff, 4, 4);
nav_b[i_g].TOC_M = (int)strtonum(buff, 9, 2);
nav_b[i_g].TOC_D = (int)strtonum(buff, 12, 2);
nav_b[i_g].TOC_H = (int)strtonum(buff, 15, 2);
nav_b[i_g].TOC_Min = (int)strtonum(buff, 18, 2);
nav_b[i_g].TOC_Sec = strtonum(buff, 21, 2);
nav_b[i_g].sa0 = strtonum(buff, 23, 19);
nav_b[i_g].sa1 = strtonum(buff, 23 + 19, 19);
nav_b[i_g].sa2 = strtonum(buff, 23 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 1:
nav_b[i_g].IODE = strtonum(buff, 4, 19);
nav_b[i_g].Crs = strtonum(buff, 4 + 19, 19);
nav_b[i_g].deltan = strtonum(buff, 4 + 19 + 19, 19);
nav_b[i_g].M0 = strtonum(buff, 4 + 19 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 2:
nav_b[i_g].Cuc = strtonum(buff, 4, 19);
nav_b[i_g].e = strtonum(buff, 4 + 19, 19);
nav_b[i_g].Cus = strtonum(buff, 4 + 19 + 19, 19);
nav_b[i_g].sqrtA = strtonum(buff, 4 + 19 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 3:
nav_b[i_g].TOE = strtonum(buff, 4, 19);
nav_b[i_g].Cic = strtonum(buff, 4 + 19, 19);
nav_b[i_g].OMEGA = strtonum(buff, 4 + 19 + 19, 19);
nav_b[i_g].Cis = strtonum(buff, 4 + 19 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 4:
nav_b[i_g].i0 = strtonum(buff, 4, 19);
nav_b[i_g].Crc = strtonum(buff, 4 + 19, 19);
nav_b[i_g].omega = strtonum(buff, 4 + 19 + 19, 19);
nav_b[i_g].deltaomega = strtonum(buff, 4 + 19 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 5:
nav_b[i_g].IDOT = strtonum(buff, 4, 19);
//nav_b[i_g].L2code = strtonum(buff, 4 + 19, 19);
nav_b[i_g].GALweek = strtonum(buff, 4 + 19 + 19, 19);
//nav_b[i_g].L2Pflag = strtonum(buff, 4 + 19 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 6:
nav_b[i_g].sACC = strtonum(buff, 4, 19);
nav_b[i_g].sHEA = strtonum(buff, 4 + 19, 19);
nav_b[i_g].BGDa = strtonum(buff, 4 + 19 + 19, 19);
nav_b[i_g].BGDb = strtonum(buff, 4 + 19 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 7:
//nav_b[i_g].TTN = strtonum(buff, 4, 19);
//nav_b[i_g].fit = strtonum(buff, 4 + 19, 19);
//nav_b[i_g].spare1 = strtonum(buff, 4 + 19 + 19, 19);
//nav_b[i_g].spare2 = strtonum(buff, 4 + 19 + 19 + 19, 19);
break;
}}
i_g++;
continue;}
}
}
/* ------------------------------ END OF READ_H ----------------------------- */
#endif
-58
View File
@@ -1,58 +0,0 @@
#ifndef _SELECT_EPO_H_
#define _SELECT_EPO_H_
#include<math.h>
#include"public.h"
/* -------------------------------------------------------------------------- */
/// @brief find the nearest obs epoch with boardcast
/// @param SecofWeek second of week of obs epoch time
/// @param sPRN the satellite PRN which need to match
/// @param nav_b nav data file structure
/// @param satnum total number of boardcast satellite
/// @param syscode GNSS code, more on PPUBLIC.H
/// @return Return the absolute epoch number of the best epoch
/// When there is no matching satellite number, the function returns -1
/* -------------------------------------------------------------------------- */
extern int select_epoch(double SecofWeek, int sPRN, pnav_body nav_b, int satnum, int syscode)
{
int best_epoch = -1;
double min = 10000;//Initialize the minimum value
double Min;
if (syscode == GPS)//Be judged as GPS
{ for (int i = 0; i < satnum; i++)
{ if (sPRN == nav_b[i].sPRN_GPS)
{ Min = fabs(SecofWeek - nav_b[i].TOE);
if (Min <= min)
{
best_epoch = i;
min = Min;
}}}
return best_epoch;}
if (syscode == BDS)//Be judged as BeiDou
{ for (int i = 0; i < satnum; i++)
{ if (sPRN == nav_b[i].sPRN_BDS)
{ Min = fabs(SecofWeek - nav_b[i].TOE);
if (Min <= min)
{
best_epoch = i;
min = Min;
}}}
return best_epoch;}
if (syscode == GAL)//Be judged as Galileo
{for (int i = 0; i < satnum; i++)
{ if (sPRN == nav_b[i].sPRN_GAL)
{ Min = fabs(SecofWeek - nav_b[i].TOE);
if (Min <= min)
{
best_epoch = i;
min = Min;
}}}
return best_epoch;}
return best_epoch;
}
/* --------------------------- END OF SELECT_EPO_H -------------------------- */
#endif
-108
View File
@@ -1,108 +0,0 @@
#ifndef _TYPE2CODE_H_
#define _TYPE2CODE_H_
#include<string.h>
#include<stdio.h>
#include"public.h"
/* -------------------------------------------------------------------------- */
/// @brief converts the observation type to the numeric code defined in PUBLIC.H
/// @param i reads the number of incoming loops in the loop
/// @param buff type of incoming observation
/// @return Returns the obs code
/* -------------------------------------------------------------------------- */
int Type2Code(int i, char buff[1000])
{
int code_return = 0;
char code_contrast[4];
char code_original[4];
const char L1codeindex[] = "C1CC1SC1LC1XC1PC1WC1YC1MC1AC1BC1Z";//obs type of different frequency
const char L2codeindex[] = "C2CC2SC2LC2XC2PC2WC2YC2MC2IC2QC2X";
const char L5codeindex[] = "C5IC5QC5X";
const char L6codeindex[] = "C6AC6BC6CC6XC6Z";
const char L7codeindex[] = "C7IC7QC7XC7DC7PC7Z";
const char L8codeindex[] = "C8JC8QC8X";
for(int j = 0; j < (strlen(L1codeindex)/3); j++)
{ memset(code_contrast,0,sizeof(code_contrast));
memset(code_original,0,sizeof(code_original));
strncpy(code_contrast, L1codeindex + 0 + j * 3 , 3);
strncpy(code_original, buff + 7 + 4 * i , 3);
if(strcmp(code_contrast,code_original) == 0)
{ code_return = j + 100;
return code_return;
break;}}
for (int j = 0; j < (strlen(L2codeindex) / 3); j++)
{ memset(code_contrast, 0, sizeof(code_contrast));
memset(code_original, 0, sizeof(code_original));
strncpy(code_contrast, L2codeindex + 0 + j * 3, 3);
strncpy(code_original, buff + 7 + 4 * i, 3);
if (strcmp(code_contrast, code_original) == 0)
{ code_return = j + 200;
return code_return;
break;}}
for (int j = 0; j < (strlen(L5codeindex) / 3); j++)
{ memset(code_contrast, 0, sizeof(code_contrast));
memset(code_original, 0, sizeof(code_original));
strncpy(code_contrast, L5codeindex + 0 + j * 3, 3);
strncpy(code_original, buff + 7 + 4 * i, 3);
if (strcmp(code_contrast, code_original) == 0)
{ code_return = j + 500;
return code_return;
break;}}
for (int j = 0; j < (strlen(L6codeindex) / 3); j++)
{ memset(code_contrast, 0, sizeof(code_contrast));
memset(code_original, 0, sizeof(code_original));
strncpy(code_contrast, L6codeindex + 0 + j * 3, 3);
strncpy(code_original, buff + 7 + 4 * i, 3);
if (strcmp(code_contrast, code_original) == 0)
{ code_return = j + 600;
return code_return;
break;}}
for (int j = 0; j < (strlen(L7codeindex) / 3); j++)
{ memset(code_contrast, 0, sizeof(code_contrast));
memset(code_original, 0, sizeof(code_original));
strncpy(code_contrast, L7codeindex + 0 + j * 3, 3);
strncpy(code_original, buff + 7 + 4 * i, 3);
if (strcmp(code_contrast, code_original) == 0)
{ code_return = j + 700;
return code_return;
break;}}
for (int j = 0; j < (strlen(L8codeindex) / 3); j++)
{ memset(code_contrast, 0, sizeof(code_contrast));
memset(code_original, 0, sizeof(code_original));
strncpy(code_contrast, L8codeindex + 0 + j * 3, 3);
strncpy(code_original, buff + 7 + 4 * i, 3);
if (strcmp(code_contrast, code_original) == 0)
{ code_return = j + 800;
return code_return;
break;}}
return code_return;
}
/* -------------------------------------------------------------------------- */
/// @brief the type of the obs value read matches the type code stored in an array
/// @param typecode obs type that you want to match
/// @param typenum the total number of obs types
/// @param typearr type codes store arrays
/// @return returns the array position of the corresponding obs type code
/* -------------------------------------------------------------------------- */
int Code2Type(int typecode, int typenum, int typearr[36])
{
int pos;
for (pos = 0; pos < typenum; pos++)
{ if (typearr[pos] == typecode)
{ break;
return pos;}}
return pos;
}
#endif
-50
View File
@@ -1,50 +0,0 @@
#ifndef _XYZ2BLH_H_
#define _XYZ2BLH_H_
#include<stdlib.h>
#include<math.h>
#include"public.h"
typedef struct
{
double B;
double L;
double H;
}xyz2blh;
/* -------------------------------------------------------------------------- */
/// @brief Convert ECEF geostationary coordinates to BLH coordinates
/// @param xyz2blh parameter transfer structure
/// @param X X coordinates of ECEF
/// @param Y Y coordinates of ECEF
/// @param Z Z coordinates of ECEF
/// @param a major semiaxis of WGS-84 ellipsoid
/// @param e2 the square of the first eccentricity of WGS-84 ellipsoid
/// @return return type of structure contain B, L, H members
/* -------------------------------------------------------------------------- */
xyz2blh XYZ2BLH(xyz2blh xyz2blh,
double X, double Y, double Z)
{
double B = 0.0, N = 0.0, H = 0.0, R0, R1, deltaH, deltaB;
R0 = sqrt(pow(X, 2) + pow(Y, 2));
R1 = sqrt(pow(X, 2) + pow(Y, 2) + pow(Z, 2));
xyz2blh.L = atan2(Y, X);
N = a;
H = R1 - a;
B = atan2(Z * (N + H), R0 * (N * (1 - e2) + H));
do
{
deltaH = N;
deltaB = B;
N = a / sqrt(1 - e2 * pow(sin(B), 2));
H = R0 / cos(B) - N;
B = atan2(Z * (N + H), R0 * (N * (1 - e2) + H));
} while (fabs(deltaH - H) > 1.0e-3 && fabs(deltaB - B) > 1.0e-9);
xyz2blh.B = B;
xyz2blh.H = H;
return xyz2blh;
}
#endif
-1065
View File
File diff suppressed because it is too large. Load diff
-24
View File
@@ -1,24 +0,0 @@
##Tro correct-Hopfield
import math
def def_tro_cor(H, ma):
P0 = 1013.25
e0 = 11.69
T0 = 288.15
p = P0 * pow((1.0 - 0.0068 / T0 / H) , 5)
T = 288.15 - 0.0068 * H
if H > 11000:
e = 0
if H <= 11000:
e = e0 * pow( (1.0 - 0.0068 * H / T0) , 4)
deltaSd = 0.00001552 * p * (40136 + 148.72 * (T - 273.16) - H) / T
deltaSw = 0.0746512 * e * (11000 - H) / pow(T , 2)
#Dry
dtropd = deltaSd / math.sqrt( math.sin( math.radians( math.degrees( pow(math.radians(ma) , 2) ) + 6.25) ) )
#Wet
dtropw = deltaSw / math.sqrt( math.sin( math.radians( math.degrees( pow(math.radians(ma) , 2) ) + 6.25) ) )
dtrop = dtropw + dtropd
return dtrop
Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

-19
View File
@@ -1,19 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ 生成的包含文件。
// 供 SPP_calculate.rc 使用
//
#define IDI_ICON1 101
#define IDI_ICON2 102
#define IDI_ICON3 103
#define IDI_ICON4 105
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 106
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
+1416
View File
File diff suppressed because it is too large. Load diff
+5
View File
@@ -0,0 +1,5 @@
#pragma once
#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容
// Windows 头文件
#include <windows.h>
+5
View File
@@ -0,0 +1,5 @@
// pch.cpp: 与预编译标头对应的源文件
#include "pch.h"
// 当使用预编译的头时,需要使用此源文件,编译才能成功。
+398
View File
@@ -0,0 +1,398 @@
// pch.h: 这是预编译标头文件。
// 下方列出的文件仅编译一次,提高了将来生成的生成性能。
// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。
// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。
// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。
#ifndef PCH_H
#define PCH_H
// 添加要在此处预编译的标头
#include "framework.h"
#endif
/* ------------------------------ CALCU CONST ------------------------------- */
#define C_V 299792458
#define GM 398600500000000
#define math_e 2.718281828459
#define PI 3.141592653589793
#define Earth_e 7.2921151467e-5
#define C20 1.0826257e-3
/* ------------------------------ WGS-84 CONST ------------------------------ */
#define a 6378137.0
#define e2 (0.0033528106647475*(2 - 0.0033528106647475))
/* ------------------------------- PZ-90 CONST ------------------------------ */
//
#define TSTEP 30.0
/* ----------------------------- GNSS OBSERV TYPE --------------------------- */
//frequency 1
#define C1 100
#define C1A 100
#define C1B 101
#define C1C 102
#define C1D 103
#define C1E
#define C1F
#define C1G
#define C1H
#define C1I
#define C1J
#define C1K
#define C1L 104
#define C1M 105
#define C1N
#define C1O
#define C1P 106
#define C1Q
#define C1R
#define C1S 107
#define C1T
#define C1U
#define C1V
#define C1W
#define C1X 108
#define C1Y 109
#define C1Z 110
//frequency 2
#define C2 200
#define C2A
#define C2B
#define C2C 200
#define C2D 201
#define C2E
#define C2F
#define C2G
#define C2H
#define C2I 202
#define C2J
#define C2K
#define C2L 203
#define C2M 204
#define C2N
#define C2O
#define C2P 205
#define C2Q 206
#define C2R
#define C2S 207
#define C2T
#define C2U
#define C2V
#define C2W
#define C2X 208
#define C2Y 209
#define C2Z 210
//frequency 3
#define C3 300
#define C3I 300
#define C3Q 301
#define C3X 302
//frequency 4
#define C4 400
#define C4A 400
#define C4B 401
#define C4X 402
//frequency 5
#define C5 500
#define C5A
#define C5B
#define C5C
#define C5D
#define C5E
#define C5F
#define C5G
#define C5H
#define C5I 500
#define C5J
#define C5K
#define C5L
#define C5M
#define C5N
#define C5O
#define C5P
#define C5Q 501
#define C5R
#define C5S
#define C5T
#define C5U
#define C5V
#define C5W
#define C5X 502
#define C5Y
#define C5Z
//frequency 6
#define C6 600
#define C6A 600
#define C6B 601
#define C6C 602
#define C6D
#define C6E
#define C6F
#define C6G
#define C6H
#define C6I
#define C6J
#define C6K
#define C6L
#define C6M
#define C6N
#define C6O
#define C6P
#define C6Q
#define C6R
#define C6S
#define C6T
#define C6U
#define C6V
#define C6W
#define C6X 603
#define C6Y
#define C6Z 604
//frequency 7
#define C7 700
#define C7A
#define C7B
#define C7C
#define C7D
#define C7E
#define C7F
#define C7G
#define C7H
#define C7I 700
#define C7J
#define C7K
#define C7L
#define C7M
#define C7N
#define C7O
#define C7P
#define C7Q 701
#define C7R
#define C7S
#define C7T
#define C7U
#define C7V
#define C7W
#define C7X 702
#define C7Y
#define C7Z
//frequency 8
#define C8 800
#define C8I 800
#define C8Q 801
#define C8X 802
/* ------------------------------- GNSS CODE -------------------------------- */
#define GPS 01
#define BDS 02
#define GAL 03
#define GLO 04
#define SBAS 05
/* ------------------------------ FOR CALMOD.H ------------------------------ */
#define MAXRINEX 1000
#define DAYSEC 86400
//satellite position & clock bias structure
typedef struct
{
double X;
double Y;
double Z;
double deltat;
double delta_t;
double delta_clk;
}pos_ts;
//receiver station position & clock bias structure
typedef struct
{
double X;
double Y;
double Z;
double B;
double L;
double H;
double delta_TR;
}stations;
//longitude & latitude structure
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;
}blhs;
//satellite azimuth angle structure
typedef struct
{
double R;
double A;
double H;
}rahcal;
//local Cartesian coordinates coordinate system structure
typedef struct
{
double E;
double N;
double U;
}blh2enu;
typedef struct
{
double B;
double L;
double H;
}xyz2blh;
/* ------------------------------- FOR READ.H ------------------------------- */
//header data of file of nav
typedef struct nav_head
{
double ver;//rinex
char type[20];
double ION_GPSA[4];
double ION_GPSB[4];
double ION_BDSA[4];
double ION_BDSB[4];
double ION_QZSA[4];
double ION_QZSB[4];
double ION_IRNA[4];
double ION_IRNB[4];
double GPUT[4];
double GLUT[4];
double GAUT[4];
double BDUT[4];
double QZUT[4];
double IRUT[4];
double SBUT[4];
int leap;
}nav_head, * pnav_head;
//body data of file of nav: GPS BeiDou Galileo
typedef struct nav_body
{
int sPRN_GPS; int sPRN_BDS; int sPRN_GAL; int sPRN_GLO;
int TOC_Y;
int TOC_M;
int TOC_D;
int TOC_H;
int TOC_Min;
int TOC_Sec;
double sa0;
double sa1;
double sa2; double Dos;
double IODE; double AODE; double SatX;
double Crs; double SatXv;
double deltan; double SatXa;
double M0;
double Cuc; double SatY;
double e; double SatYv;
double Cus; double SatYa;
double sqrtA; int FreN;
double TOE; double SatZ;
double Cic; double SatZv;
double OMEGA; double SatZa;
double Cis; int AOO;
double i0;
double Crc;
double omega;
double deltaomega;
double IDOT;
double L2code; int Datasource;
double GPSweek; double BDTweek; double GALweek;
double L2Pflag;
double sACC;
double sHEA;
double TGD; double TGD1; double BGDa;
double IODC; double TGD2; double BGDb;
double TTN;
double fit; double AODC;
double spare1;
double spare2;
}nav_body, * pnav_body;
//header data of file of obs
typedef struct obs_head
{
double ver;
char type[30];
double apX;
double apY;
double apZ;
double ANTH;
double ANTdeltaE;
double ANTdeltaN;
int obstypenum_gps;
int obstypenum_bds;
int obstypenum_gal;
int obstypenum_glo;
int obscode_gps[40];
int obscode_bds[40];
int obscode_gal[40];
int obscode_glo[40];
double interval;
int f_y;
int f_m;
int f_d;
int f_h;
int f_min;
double f_sec;
int l_y;
int l_m;
int l_d;
int l_h;
int l_min;
double l_sec;
char tsys[5];//time system
}obs_head, * pobs_head;
//epoch data of file of obs
typedef struct obs_epoch
{
int y;
int m;
int d;
int h;
int min;
double sec;//epoch time
int p_flag;//epoch flag
int sat_num;//the total number of obsable sat
int gps_num;//the total gps sat
int bds_num;//the total bds sat
int gal_num;//the total galileo sat
int glo_num;//the total glonass sat
int sPRN[84];//total sprn of obs sat
int sPRN_GPS[32];
int sPRN_BDS[60];
int sPRN_GAL[30];
int sPRN_GLO[24];
}obs_epoch, * pobs_epoch;
//body data of file of obs
typedef struct obs_body
{
double obs_gps[20][26];//GPS obs data
double obs_bds[30][26];//BDS obs data
double obs_gal[20][26];//GALILEO obs data
double obs_glo[20][26];//GLONASS obs data
}obs_body, * pobs_body;
extern "C" _declspec(dllexport) double Start(char nav_path[260], char obs_path[260], char res_path[260], int gnsscode);