See update notes

This commit is contained in:
KenanZhu111 committed 2024-10-31 14:20:09 +08:00
1 parent 8d22576a73
commit b28dd3e28d
9 files changed
+773 -779

No files matched your search

+6
View File
@@ -36,6 +36,12 @@ Features :
## Project Update ## Project Update
Update: 2024/10/31:
1. KNZ_GeoTrackLab: Fix some bug, Modify some UI logic.
2. KNZ_GeoTrackLab: Optimize code structure.
3. KNZ_GeoTrackLab: New added:
Elevation angle option.
Update: 2024/10/28 Update: 2024/10/28
1. KNZ_GeoTrackLab: Fix some bug. 1. KNZ_GeoTrackLab: Fix some bug.
2. KNZ_GeoTrackLab: Optimize code structure. 2. KNZ_GeoTrackLab: Optimize code structure.
+6
View File
@@ -36,6 +36,12 @@
## 项目更新 ## 项目更新
更新: 2024/10/31:
1. KNZ_GeoTrackLab: 修复一些bug, 优化UI逻辑.
2. KNZ_GeoTrackLab: 优化代码结构.
3. KNZ_GeoTrackLab: 新增:
截止高度角选项。
更新:2024/10/28 更新:2024/10/28
1. KNZ_GeoTrackLab:修复一些bug。 1. KNZ_GeoTrackLab:修复一些bug。
2. KNZ_GeoTrackLab:优化代码结构。 2. KNZ_GeoTrackLab:优化代码结构。
+119 -117
View File
@@ -39,8 +39,10 @@ ioncormode = ['OFF', 'Ion-Free LC', 'Broadcast']
ioncorstate = 0 ioncorstate = 0
trocormode = ['OFF', 'Hopfield', 'Saastamoinen'] trocormode = ['OFF', 'Hopfield', 'Saastamoinen']
trocorstate = 0 trocorstate = 0
h_anglemode = ['0','5','10','15','20','25','30','35','40','45','50']
h_anglestate = 0
#Sat system register part #Sat system register part
satsysdict = {1: "G", 4:"R", 2:"C", 3:"E", 5:"S"} satsysdict = {1: "G", 2:"C", 3:"E", 4:"R", 5:"S"}
satellite_system = 1 satellite_system = 1
##Combox Count-er ##Combox Count-er
ComboxObsCount = 0 ComboxObsCount = 0
@@ -50,7 +52,7 @@ Navvalue = ('',)
ComboxOutCount = 0 ComboxOutCount = 0
Outvalue = ('',) Outvalue = ('',)
# #
version = 'ver 1.5.3.1' version = 'ver 1.5.4.1'
# #
# #
# #
@@ -67,45 +69,60 @@ def Abo_windows():
abo = tk.Toplevel(root) abo = tk.Toplevel(root)
abo.title("About") abo.title("About")
abo.attributes('-toolwindow', 2) abo.attributes('-toolwindow', 2)
abo.geometry('200x100') Move_center(abo,200,100)
abo.minsize(200,100) abo.minsize(200,100)
abo.maxsize(200,100) abo.maxsize(200,100)
About = tk.Label(abo, text="\nKNZ_GeoTrackLab %s\n\nCopyright (c) 2024 by KenanZhu\nAll Right Reserved."%version) About = tk.Label(abo, text="\nKNZ_GeoTrackLab %s\n\nCopyright (c) 2024 by KenanZhu\nAll Right Reserved."%version)
About.pack(side=tk.TOP, expand=tk.YES) About.pack(side=tk.TOP, expand=tk.YES)
def Move_center(hwnd, win_x, win_y):
position_x = int((hwnd.winfo_screenwidth() - win_x) / 2)
position_y = int((hwnd.winfo_screenheight() - win_y) / 2)
hwnd.geometry(f'{win_x}x{win_y}+{position_x}+{position_y}')
class FUNCTION: class FUNCTION:
@staticmethod @staticmethod
def Colorchoose(i, label, mode): def Colorchoose(hwnd,i, label, mode):
# Brief # choice to change the color of draw # Brief # choice to change the color of draw
# Param # i : only for mode 1 # Param # i : for mode 0 & 1
# Param # label : match the label with the button # Param # label : match the label with the button
# Param # mode : color register type # Param # mode : color register type
# undo choice == 0 & # undo choice == 0 &
# middle choice store == 1 & # middle choice store == 1 &
# final confirm == 3 & # final confirm == 3 &
# satn color == 4 # satn color == 4 &
# satn undo == 5
# Return# none # Return# none
global enucolor global enucolor
if mode == 0: if mode == 0:
enucolor = ["#0080FF", "#0080FF", "#0080FF"] #enucolor = ["#0080FF", "#0080FF", "#0080FF"]
satncolor[0] = "#0080FF" #satncolor[0] = "#0080FF"
label.config(bg=enucolor[0]) label.config(bg=enucolor[i])
elif mode == 1: elif mode == 1:
colorvalue = tk.colorchooser.askcolor() colorvalue = tk.colorchooser.askcolor(parent=hwnd)
if colorvalue[1] is not None:
enucolormid[i] = str(colorvalue[1]) enucolormid[i] = str(colorvalue[1])
label.config(bg=str(colorvalue[1])) label.config(bg=str(colorvalue[1]))
else:
return
elif mode == 3: elif mode == 3:
enucolor[0] = enucolormid[0] enucolor[0] = enucolormid[0]
enucolor[1] = enucolormid[1] enucolor[1] = enucolormid[1]
enucolor[2] = enucolormid[2] enucolor[2] = enucolormid[2]
satncolor[0] = satncolormid[0] satncolor[0] = satncolormid[0]
elif mode == 4: elif mode == 4:
colorvalue = tk.colorchooser.askcolor() colorvalue = tk.colorchooser.askcolor(parent=hwnd)
if colorvalue[1] is not None:
satncolormid[0] = str(colorvalue[1]) satncolormid[0] = str(colorvalue[1])
label.config(bg=str(colorvalue[1])) label.config(bg=str(colorvalue[1]))
else:
return
elif mode==5:
label.config(bg=satncolor[0])
@staticmethod @staticmethod
def Linewchoose(entry0, entry1, entry2, mode): def Linewchoose(entry0, entry1, entry2, mode):
# Brief # input to change the width of line # Brief # input to change the width of line
@@ -159,7 +176,7 @@ class FUNCTION:
enulinew[1] = entry1.get() enulinew[1] = entry1.get()
enulinew[2] = entry2.get() enulinew[2] = entry2.get()
def Calcu_confirm(self, v, cboxi, cboxt): def Calcu_confirm(self, v, cboxi, cboxt, cboxangle):
# Brief # choice to change the ion & tro correction && confirm the sat system # Brief # choice to change the ion & tro correction && confirm the sat system
# Param # v sat system radio button value # Param # v sat system radio button value
# Param # cboxi the combo box of ion correction # Param # cboxi the combo box of ion correction
@@ -167,10 +184,12 @@ class FUNCTION:
# Return# none # Return# none
global ioncorstate global ioncorstate
global trocorstate global trocorstate
global h_anglestate
global satellite_system global satellite_system
ioncorstate = self.Ion_and_Trocbox(cboxi, 0) ioncorstate = self.ITA_cbox(cboxi, 0)
trocorstate = self.Ion_and_Trocbox(cboxt, 1) trocorstate = self.ITA_cbox(cboxt, 1)
h_anglestate = self.ITA_cbox(cboxangle, 2)
satellite_system = self.Satsys_button(v) satellite_system = self.Satsys_button(v)
print(ioncorstate, trocorstate, satellite_system) print(ioncorstate, trocorstate, satellite_system)
@@ -184,11 +203,12 @@ class FUNCTION:
return int(Systemdict.get(v.get())) return int(Systemdict.get(v.get()))
@staticmethod @staticmethod
def Ion_and_Trocbox(cbox, cortype): def ITA_cbox(cbox, cortype):
# Brief # get the value of combo box # Brief # get the value of combo box
# Param # cortype: correction type of # Param # cortype: correction type of
# ion == 0 & # ion == 0 &
# tro == 1 # tro == 1 &
# angle == 2
# Param # cbox: # Param # cbox:
# Return# ion | tro state code # Return# ion | tro state code
count = -1 count = -1
@@ -204,11 +224,18 @@ class FUNCTION:
if cbox.get() == tromode: if cbox.get() == tromode:
return count return count
elif cortype == 2:
for h_angle in h_anglemode:
count += 1
if cbox.get() == h_angle:
return count
@staticmethod @staticmethod
def GetObsFilePath(ObsFileSelectBox): def GetObsFilePath(hwnd, ObsFileSelectBox):
global ComboxObsCount global ComboxObsCount
global Obsvalue global Obsvalue
path = filedialog.askopenfilename(title='RINEX OBS File', path = filedialog.askopenfilename(parent=hwnd,
title='RINEX OBS File',
filetypes=[('RINEX OBS File(*.o*.*.*obs.*.*d)', '*.*o;*.*obs;*.*d'), filetypes=[('RINEX OBS File(*.o*.*.*obs.*.*d)', '*.*o;*.*obs;*.*d'),
('All Files', '*.*')]) ('All Files', '*.*')])
if path and path not in ObsFileSelectBox['value']: if path and path not in ObsFileSelectBox['value']:
@@ -218,10 +245,11 @@ class FUNCTION:
ObsFileSelectBox.current(ComboxObsCount) ObsFileSelectBox.current(ComboxObsCount)
@staticmethod @staticmethod
def GetNavFilePath(NavFileSelectBox): def GetNavFilePath(hwnd, NavFileSelectBox):
global ComboxNavCount global ComboxNavCount
global Navvalue global Navvalue
path = filedialog.askopenfilename(title='RINEX NAV File', path = filedialog.askopenfilename(parent=hwnd,
title='RINEX NAV File',
filetypes=[('RINEX NAV File(*.*nav.*.hnav.*.gnav.*.qnav.*.*n.*.*g.*.*h.*.*q.*.*p)', filetypes=[('RINEX NAV File(*.*nav.*.hnav.*.gnav.*.qnav.*.*n.*.*g.*.*h.*.*q.*.*p)',
'*.*nav;*.hnav;*.gnav;*.qnav;*.*n;*.*g;*.*h;*.*q;*.*p'), '*.*nav;*.hnav;*.gnav;*.qnav;*.*n;*.*g;*.*h;*.*q;*.*p'),
('All Files', '*.*')]) ('All Files', '*.*')])
@@ -232,10 +260,10 @@ class FUNCTION:
NavFileSelectBox.current(ComboxNavCount) NavFileSelectBox.current(ComboxNavCount)
@staticmethod @staticmethod
def AskDirectory(AskDirectorySelectBox): def AskDirectory(hwnd, AskDirectorySelectBox):
global ComboxOutCount global ComboxOutCount
global Outvalue global Outvalue
path = filedialog.askdirectory() path = filedialog.askdirectory(parent=hwnd)
if path and path not in AskDirectorySelectBox['value']: if path and path not in AskDirectorySelectBox['value']:
Outvalue += (path,) Outvalue += (path,)
AskDirectorySelectBox['value'] += (path + "/*.sp",) AskDirectorySelectBox['value'] += (path + "/*.sp",)
@@ -305,7 +333,8 @@ class FUNCTION:
dll = cdll.LoadLibrary('./brdm2pos.dll') dll = cdll.LoadLibrary('./brdm2pos.dll')
dll.brdm2pos.restype = c_double dll.brdm2pos.restype = c_double
match dll.brdm2pos(nav_path.encode(), obs_path.encode(), res_path.encode(), satellite_system): match dll.brdm2pos(nav_path.encode(), obs_path.encode(), res_path.encode(),
satellite_system, int(h_anglemode[h_anglestate])):
case 0.0: case 0.0:
ExecuteState.config(text='Generated successfully ! file : %s' % obsfile + ".sp") ExecuteState.config(text='Generated successfully ! file : %s' % obsfile + ".sp")
case -1.0: case -1.0:
@@ -322,9 +351,6 @@ class FUNCTION:
ExecuteState.config(text='Error ! no obs data') ExecuteState.config(text='Error ! no obs data')
windll.kernel32.FreeLibrary('./brdm2pos.dll') windll.kernel32.FreeLibrary('./brdm2pos.dll')
def _ExecuteFile(self,ExecuteState, def _ExecuteFile(self,ExecuteState,
ObsSelectBoxVar, ObsSelectBoxVar,
NavSelectBoxVar, NavSelectBoxVar,
@@ -377,7 +403,7 @@ class MAINGUI:
def initGUI(self, hwnd): def initGUI(self, hwnd):
hwnd.title("KNZ_GeoTrackLab %s"%version) hwnd.title("KNZ_GeoTrackLab %s"%version)
hwnd.geometry('1200x700') Move_center(hwnd,1200,700)
hwnd.minsize(1200, 700) hwnd.minsize(1200, 700)
icon_img = (b'AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAgBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' icon_img = (b'AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAgBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
@@ -614,7 +640,7 @@ class MAINGUI:
self.canvas0.draw() self.canvas0.draw()
self.satn.clear() self.satn.clear()
self.satn.plot(satnumnarry[0, :], marker='_', linestyle=None, color=satncolor[0], linewidth=0) self.satn.plot(satnumnarry[0, :], marker='|', ms=5, linestyle=None, color=satncolor[0], linewidth=0)
self.satn.set_title('Valid Sat Numbers', loc='left', fontsize=8) self.satn.set_title('Valid Sat Numbers', loc='left', fontsize=8)
self.satn.set_xlabel('Epochs') self.satn.set_xlabel('Epochs')
self.satn.grid(True, linestyle='--', alpha=0.7) self.satn.grid(True, linestyle='--', alpha=0.7)
@@ -630,19 +656,6 @@ class MAINGUI:
# Const define # Const define
self.sattrack.clear() self.sattrack.clear()
C_V = 299792458 C_V = 299792458
f1 = 1575.42
f2 = 1227.60
match satsysdict.get(satellite_system):
case 'G':
f1 = 1575.42
f2 = 1227.60
case 'E':
f1 = 1575.42
f2 = 1278.75
case 'C':
f1 = 1561.098
f2 = 1207.140
ENU_O = np.empty((3, 0)) ENU_O = np.empty((3, 0))
GDOP = np.empty((1, 0)) GDOP = np.empty((1, 0))
@@ -676,7 +689,7 @@ class MAINGUI:
obspath = len(Obs) obspath = len(Obs)
while obspath > 0: while obspath > 0:
flag = Obs[obspath - 1:obspath] flag = Obs[obspath - 1:obspath]
if flag == "/": if flag == "/" or flag == "\\":
obsfile = satsysdict.get(satellite_system) + "-" + Obs[obspath:-4] obsfile = satsysdict.get(satellite_system) + "-" + Obs[obspath:-4]
break break
obspath -= 1 obspath -= 1
@@ -733,9 +746,9 @@ class MAINGUI:
satY = np.empty((1, 0)) satY = np.empty((1, 0))
satZ = np.empty((1, 0)) satZ = np.empty((1, 0))
C1 = np.empty((1, 0)) C1 = np.empty((1, 0))
C2 = np.empty((1, 0))
ma = np.empty((1, 0)) ma = np.empty((1, 0))
np.empty((1, 0))
Dt = np.empty((1, 0)) Dt = np.empty((1, 0))
year = int(line[6:10]) year = int(line[6:10])
@@ -798,39 +811,14 @@ class MAINGUI:
n = -((satZ[0, count] - ap_Z) / R) n = -((satZ[0, count] - ap_Z) / R)
B = np.vstack((B, [l, m, n, 1])) B = np.vstack((B, [l, m, n, 1]))
Ptem.append(pow(math.sin(math.radians(ma[0, count])), 2)) Ptem.append(pow(math.sin(math.radians(ma[0, count])), 2))
Pl = 0
# Get the tropsphere correction # Get the tropsphere correction
match trocorstate: match trocorstate:
case 0: case 0:Tro = 0
Tro = 0 case 1:Tro = Trocor.Hop_tro_cor(apH, ma[0, count])
case 1: case 2:Tro = Trocor.Sas_tro_cor(apB, apH, ma[0, count])
Tro = Trocor.Hop_tro_cor(apH, ma[0, count])
case 2:
Tro = Trocor.Sas_tro_cor(apB, apH, ma[0, count])
pass
# Get the ionsphere correction
match ioncorstate:
case 0:
if C1[0, count] == 0 and C2[0, count] != 0:
Pl = C2[0, count]
elif C1[0, count] != 0 and C2[0, count] == 0:
Pl = C1[0, count]
case 1:
if C2[0, count] != 0 and C1[0, count] != 0:
Pl = (f1 * f1 * C1[0, count]) / (f1 * f1 - f2 * f2) - (
f2 * f2 * C2[0, count]) / (f1 * f1 - f2 * f2)
elif C1[0, count] == 0 and C2[0, count] != 0:
Pl = C2[0, count]
elif C1[0, count] != 0 and C2[0, count] == 0:
Pl = C1[0, count]
case 2:
pass
L = np.vstack( L = np.vstack(
( L, [Pl - R + C_V * Dt[0, count] - Tro] ) ( L, [C1[0, count] - R + C_V * Dt[0, count] - Tro] )
) )
count += 1 count += 1
@@ -853,7 +841,6 @@ class MAINGUI:
# ENU_O = np.hstack((ENU_O, [[0], [0], [0]])) # ENU_O = np.hstack((ENU_O, [[0], [0], [0]]))
# print("------------ ANOMALY RESOLUTION", file=of) # print("------------ ANOMALY RESOLUTION", file=of)
#else: #else:
ENU_O = np.hstack((ENU_O, [[ENU[0, 0]], [ENU[1, 0]], [ENU[2, 0]]])) ENU_O = np.hstack((ENU_O, [[ENU[0, 0]], [ENU[1, 0]], [ENU[2, 0]]]))
GDOP = np.hstack((GDOP, [ [math.sqrt(Qtrace)] ])) GDOP = np.hstack((GDOP, [ [math.sqrt(Qtrace)] ]))
@@ -875,9 +862,8 @@ class MAINGUI:
satY = np.hstack((satY, [[float(line[22:37])]])) satY = np.hstack((satY, [[float(line[22:37])]]))
satZ = np.hstack((satZ, [[float(line[38:53])]])) satZ = np.hstack((satZ, [[float(line[38:53])]]))
C1 = np.hstack((C1, [[float(line[55:69])]])) C1 = np.hstack((C1, [[float(line[55:69])]]))
C2 = np.hstack((C2, [[float(line[71:85])]])) ma = np.hstack((ma, [[float(line[71:85])]]))
ma = np.hstack((ma, [[float(line[86:101])]])) Dt = np.hstack((Dt, [[float(line[86:102])]]))
Dt = np.hstack((Dt, [[float(line[102:118])]]))
elif line.find("END") >= 0: elif line.find("END") >= 0:
self.ex.clear() self.ex.clear()
@@ -904,7 +890,7 @@ class MAINGUI:
self.canvas0.draw() self.canvas0.draw()
self.satn.clear() self.satn.clear()
self.satn.plot(satnumnarry[0, :], marker='_', ms=10, linestyle=None, color=satncolor[0], linewidth=0) self.satn.plot(satnumnarry[0, :], marker='|', ms=5, linestyle=None, color=satncolor[0], linewidth=0)
self.satn.set_title('Valid Satellite Numbers',loc='left', fontsize=8) self.satn.set_title('Valid Satellite Numbers',loc='left', fontsize=8)
self.satn.set_xlabel('Epochs') self.satn.set_xlabel('Epochs')
self.satn.grid(True, linestyle='--', alpha=0.7) self.satn.grid(True, linestyle='--', alpha=0.7)
@@ -940,7 +926,7 @@ class OPTGUI:
self.opthwnd = tk.Toplevel(hwnd) self.opthwnd = tk.Toplevel(hwnd)
self.opthwnd.title("Options") self.opthwnd.title("Options")
self.opthwnd.resizable(0,0) self.opthwnd.resizable(0,0)
self.opthwnd.geometry('320x250') Move_center(self.opthwnd,320,250)
self.opthwnd.minsize(320,250) self.opthwnd.minsize(320,250)
self.opthwnd.maxsize(320,250) self.opthwnd.maxsize(320,250)
@@ -1066,6 +1052,22 @@ class OPTGUI:
self.ctrobox.current(trocorstate) self.ctrobox.current(trocorstate)
self.ctrobox.pack(side=tk.RIGHT, anchor='e') self.ctrobox.pack(side=tk.RIGHT, anchor='e')
TOP3Frame0 = ttk.Frame(self.Main1Frame0)
TOP3Frame0.pack(side=tk.TOP, expand=tk.YES, padx='1px', pady='2px', fill=tk.X)
h_angle = ttk.Label(TOP3Frame0, text='Satellite Elevation(°) / #')
h_angle.pack(side=tk.LEFT, anchor='w', padx='1px')
self.angleentry = ttk.Entry(TOP3Frame0, width=8)
self.angleentry.pack(side=tk.RIGHT, anchor='w')
self.canglebox = ttk.Combobox(TOP3Frame0, width=6, height=10)
self.canglebox['state'] = 'readonly'
self.canglebox['value'] = ('0','5','10','15','20','25','30','35','40','45','50')
self.canglebox.current(h_anglestate)
self.canglebox.pack(side=tk.RIGHT, anchor='e')
# GNSS Options# # GNSS Options#
TOP5Frame0 = ttk.LabelFrame(self.Main1Frame0, text='Satellite system', labelanchor='nw') TOP5Frame0 = ttk.LabelFrame(self.Main1Frame0, text='Satellite system', labelanchor='nw')
TOP5Frame0.pack(side=tk.TOP, expand=tk.YES, padx='1px', pady='2px', fill=tk.X) TOP5Frame0.pack(side=tk.TOP, expand=tk.YES, padx='1px', pady='2px', fill=tk.X)
@@ -1132,15 +1134,15 @@ class OPTGUI:
SatnFrameB1 = tk.Frame(Buttom1Frame1) SatnFrameB1 = tk.Frame(Buttom1Frame1)
SatnFrameB1.pack(side=tk.LEFT, expand=tk.YES, padx='5px', pady='0px') SatnFrameB1.pack(side=tk.LEFT, expand=tk.YES, padx='5px', pady='0px')
satncolopt = ttk.Button(SatnFrameB1, text='Satn Color', width=10, satncolopt = ttk.Button(SatnFrameB1, text='Satn Color', width=10,
command=lambda: self.Cmd.Colorchoose(0, satncollab, 4)) command=lambda: self.Cmd.Colorchoose(self.opthwnd,0, satncollab, 4))
satncolopt.pack(side=tk.LEFT, expand=tk.YES, padx='5px', pady='0px') satncolopt.pack(side=tk.LEFT, expand=tk.YES, padx='5px', pady='0px')
satncollab = tk.Label(SatnFrameB1, width=5, height=1, bg=satncolormid[0]) satncollab = tk.Label(SatnFrameB1, width=5, height=1, bg=satncolor[0])
satncollab.pack(side=tk.LEFT, expand=tk.YES, padx='5px', pady='0px') satncollab.pack(side=tk.LEFT, expand=tk.YES, padx='5px', pady='0px')
LineConB1 = tk.Frame(Buttom1Frame1) LineConB1 = tk.Frame(Buttom1Frame1)
LineConB1.pack(side=tk.RIGHT, expand=tk.YES, padx='5px', pady='0px') LineConB1.pack(side=tk.RIGHT, expand=tk.YES, padx='5px', pady='0px')
linewre = ttk.Button(LineConB1, text='Undo', width=10, linewre = ttk.Button(LineConB1, text='Undo', width=10,
command=lambda: self.Cmd.Colorchoose(0, satncollab, 0)) command=lambda: self.Cmd.Colorchoose(self.opthwnd,0, satncollab, 5))
linewre.pack(side=tk.LEFT, expand=tk.YES, padx='1px') linewre.pack(side=tk.LEFT, expand=tk.YES, padx='1px')
# Line's colors options# # Line's colors options#
@@ -1150,7 +1152,7 @@ class OPTGUI:
EFrameL2 = tk.Frame(Left2Frame1) EFrameL2 = tk.Frame(Left2Frame1)
EFrameL2.pack(side=tk.TOP, expand=tk.YES, padx='5px', pady='0px') EFrameL2.pack(side=tk.TOP, expand=tk.YES, padx='5px', pady='0px')
ecolopt = ttk.Button(EFrameL2, text='E Color', width=10, ecolopt = ttk.Button(EFrameL2, text='E Color', width=10,
command=lambda: self.Cmd.Colorchoose(0, ecollab, 1)) command=lambda: self.Cmd.Colorchoose(self.opthwnd,0, ecollab, 1))
ecolopt.pack(side=tk.LEFT, expand=tk.YES, padx='5px', pady='0px') ecolopt.pack(side=tk.LEFT, expand=tk.YES, padx='5px', pady='0px')
ecollab = tk.Label(EFrameL2, width=5, height=1, bg=enucolor[0]) ecollab = tk.Label(EFrameL2, width=5, height=1, bg=enucolor[0])
ecollab.pack(side=tk.LEFT, expand=tk.YES, padx='5px', pady='0px') ecollab.pack(side=tk.LEFT, expand=tk.YES, padx='5px', pady='0px')
@@ -1158,7 +1160,7 @@ class OPTGUI:
NFrameL2 = tk.Frame(Left2Frame1) NFrameL2 = tk.Frame(Left2Frame1)
NFrameL2.pack(side=tk.TOP, expand=tk.YES, padx='5px', pady='0px') NFrameL2.pack(side=tk.TOP, expand=tk.YES, padx='5px', pady='0px')
ncolopt = ttk.Button(NFrameL2, text='N Color', width=10, ncolopt = ttk.Button(NFrameL2, text='N Color', width=10,
command=lambda: self.Cmd.Colorchoose(1, ncollab, 1)) command=lambda: self.Cmd.Colorchoose(self.opthwnd,1, ncollab, 1))
ncolopt.pack(side=tk.LEFT, expand=tk.YES, padx='5px', pady='0px') ncolopt.pack(side=tk.LEFT, expand=tk.YES, padx='5px', pady='0px')
ncollab = tk.Label(NFrameL2, width=5, height=1, bg=enucolor[1]) ncollab = tk.Label(NFrameL2, width=5, height=1, bg=enucolor[1])
ncollab.pack(side=tk.LEFT, expand=tk.YES, padx='5px', pady='0px') ncollab.pack(side=tk.LEFT, expand=tk.YES, padx='5px', pady='0px')
@@ -1166,7 +1168,7 @@ class OPTGUI:
UFrameL2 = tk.Frame(Left2Frame1) UFrameL2 = tk.Frame(Left2Frame1)
UFrameL2.pack(side=tk.TOP, expand=tk.YES, padx='5px', pady='0px') UFrameL2.pack(side=tk.TOP, expand=tk.YES, padx='5px', pady='0px')
ucolopt = ttk.Button(UFrameL2, text='U Color', width=10, ucolopt = ttk.Button(UFrameL2, text='U Color', width=10,
command=lambda: self.Cmd.Colorchoose(2, ucollab, 1)) command=lambda: self.Cmd.Colorchoose(self.opthwnd,2, ucollab, 1))
ucolopt.pack(side=tk.LEFT, expand=tk.YES, padx='5px', pady='0px') ucolopt.pack(side=tk.LEFT, expand=tk.YES, padx='5px', pady='0px')
ucollab = tk.Label(UFrameL2, width=5, height=1, bg=enucolor[2]) ucollab = tk.Label(UFrameL2, width=5, height=1, bg=enucolor[2])
ucollab.pack(side=tk.LEFT, expand=tk.YES, padx='5px', pady='0px') ucollab.pack(side=tk.LEFT, expand=tk.YES, padx='5px', pady='0px')
@@ -1174,9 +1176,9 @@ class OPTGUI:
ColorConL2 = tk.Frame(Left2Frame1) ColorConL2 = tk.Frame(Left2Frame1)
ColorConL2.pack(side=tk.TOP, expand=tk.YES, padx='5px', pady='0px') ColorConL2.pack(side=tk.TOP, expand=tk.YES, padx='5px', pady='0px')
colorcon = ttk.Button(ColorConL2, text='Undo', width=10, colorcon = ttk.Button(ColorConL2, text='Undo', width=10,
command=lambda: [self.Cmd.Colorchoose(0, ecollab, 0) command=lambda: [self.Cmd.Colorchoose(self.opthwnd,0, ecollab, 0)
, self.Cmd.Colorchoose(0, ncollab, 0) , self.Cmd.Colorchoose(self.opthwnd,1, ncollab, 0)
, self.Cmd.Colorchoose(0, ucollab, 0)]) , self.Cmd.Colorchoose(self.opthwnd,2, ucollab, 0)])
colorcon.pack(side=tk.LEFT, expand=tk.YES, padx='5px', pady='0px') colorcon.pack(side=tk.LEFT, expand=tk.YES, padx='5px', pady='0px')
def initCONFIRM(self): def initCONFIRM(self):
@@ -1187,12 +1189,11 @@ class OPTGUI:
command=lambda: [self.opthwnd.destroy()]) command=lambda: [self.opthwnd.destroy()])
TotalCancel.pack(side=tk.RIGHT, padx='1px', anchor='e') TotalCancel.pack(side=tk.RIGHT, padx='1px', anchor='e')
TotalCon = ttk.Button(Bottom0Frame0, text='Confirm', width=10, TotalCon = ttk.Button(Bottom0Frame0, text='Confirm', width=10,
command=lambda: [self.Cmd.Colorchoose(0, None, 3), command=lambda: [self.Cmd.Colorchoose(self.opthwnd,0, None, 3),
self.Cmd.Linewchoose(self.elinewidth, self.Cmd.Linewchoose(self.elinewidth,
self.nlinewidth, self.nlinewidth,
self.ulinewidth, 1), self.ulinewidth, 1),
self.Cmd.Calcu_confirm(self.v, self.cionbox, self.ctrobox), self.Cmd.Calcu_confirm(self.v, self.cionbox, self.ctrobox, self.canglebox)])
self.opthwnd.destroy()])
TotalCon.pack(side=tk.RIGHT, padx='1px', anchor='e') TotalCon.pack(side=tk.RIGHT, padx='1px', anchor='e')
class EXECUDUI: class EXECUDUI:
@@ -1214,9 +1215,9 @@ class EXECUDUI:
self.exehwnd = tk.Toplevel(hwnd) self.exehwnd = tk.Toplevel(hwnd)
self.exehwnd.title("RINEX Processor") self.exehwnd.title("RINEX Processor")
self.exehwnd.resizable(0,0) self.exehwnd.resizable(0,0)
self.exehwnd.geometry('400x215') Move_center(self.exehwnd,550,180)
self.exehwnd.minsize(400, 215) self.exehwnd.minsize(550,180)
self.exehwnd.maxsize(400, 215) self.exehwnd.maxsize(550,180)
global icon_img3 global icon_img3
icon_img3 = (b'AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAABAAADjsAAA47AAAAAAAAAAAAAAAAAAAAAAAAAA' icon_img3 = (b'AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAABAAADjsAAA47AAAAAAAAAAAAAAAAAAAAAAAAAA'
@@ -1289,41 +1290,41 @@ class EXECUDUI:
MainFrame0 = tk.Frame(self.exehwnd) MainFrame0 = tk.Frame(self.exehwnd)
MainFrame0.pack() MainFrame0.pack()
TopFrame1 = ttk.Frame(MainFrame0) TopFrame1 = ttk.Frame(MainFrame0)
TopFrame1.pack(side=tk.TOP, expand=tk.YES, padx='1px', pady='2px', fill=tk.X) TopFrame1.pack(side=tk.TOP, expand=tk.YES, padx='1px', pady='1px', fill=tk.X)
# ----------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------
ObsInFrame3 = ttk.LabelFrame(TopFrame1, text='RINEX Obs File') ObsInFrame3 = ttk.LabelFrame(TopFrame1, text='RINEX Obs File')
ObsInFrame3.pack(side=tk.TOP, expand=tk.YES, padx='1px', pady='2px', fill=tk.X) ObsInFrame3.pack(side=tk.TOP, expand=tk.YES, padx='1px', pady='0px', fill=tk.X)
ObsFileSelectBox = ttk.Combobox(ObsInFrame3, width=46, height=4, values=Obsvalue, ObsFileSelectBox = ttk.Combobox(ObsInFrame3, width=70, height=4, values=Obsvalue,
textvariable=self.ObsSelectBoxVar) textvariable=self.ObsSelectBoxVar)
ObsFileSelectBox.current(ComboxObsCount) ObsFileSelectBox.current(ComboxObsCount)
ObsFileSelectBox.pack(side=tk.LEFT, anchor='w', padx='1px', pady='1px') ObsFileSelectBox.pack(side=tk.LEFT, anchor='w', padx='0px', pady='0px')
ObsFileSelectButton = ttk.Button(ObsInFrame3, text='...', width=3, ObsFileSelectButton = ttk.Button(ObsInFrame3, text='...', width=3,
command=lambda: self.Cmd.GetObsFilePath(ObsFileSelectBox)) command=lambda: self.Cmd.GetObsFilePath(self.exehwnd,ObsFileSelectBox))
ObsFileSelectButton.pack(side=tk.RIGHT, anchor='e', padx='1px', pady='1px') ObsFileSelectButton.pack(side=tk.RIGHT, anchor='e', padx='1px', pady='0px')
# ----------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------
#----------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------
NavInFrame3 = ttk.LabelFrame(TopFrame1, text='RINEX Nav File') NavInFrame3 = ttk.LabelFrame(TopFrame1, text='RINEX Nav File')
NavInFrame3.pack(side=tk.TOP, expand=tk.YES, padx='1px', pady='2px', fill=tk.X) NavInFrame3.pack(side=tk.TOP, expand=tk.YES, padx='1px', pady='0px', fill=tk.X)
NavFileSelectBox = ttk.Combobox(NavInFrame3, width=46, height=4, values=Navvalue, NavFileSelectBox = ttk.Combobox(NavInFrame3, width=70, height=4, values=Navvalue,
textvariable=self.NavSelectBoxVar) textvariable=self.NavSelectBoxVar)
NavFileSelectBox.current(ComboxNavCount) NavFileSelectBox.current(ComboxNavCount)
NavFileSelectBox.pack(side=tk.LEFT, anchor='w', padx='1px', pady='1px') NavFileSelectBox.pack(side=tk.LEFT, anchor='w', padx='0px', pady='0px')
NavFileSelectButton = ttk.Button(NavInFrame3, text='...', width=3, NavFileSelectButton = ttk.Button(NavInFrame3, text='...', width=3,
command=lambda: self.Cmd.GetNavFilePath(NavFileSelectBox)) command=lambda: self.Cmd.GetNavFilePath(self.exehwnd,NavFileSelectBox))
NavFileSelectButton.pack(side=tk.RIGHT, anchor='e', padx='1px', pady='1px') NavFileSelectButton.pack(side=tk.RIGHT, anchor='e', padx='1px', pady='0px')
# ----------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------
BottomFrame1 = ttk.Frame(MainFrame0) BottomFrame1 = ttk.Frame(MainFrame0)
BottomFrame1.pack(side=tk.BOTTOM, expand=tk.YES, padx='1px', pady='2px', fill=tk.X) BottomFrame1.pack(side=tk.BOTTOM, expand=tk.YES, padx='1px', pady='0px', fill=tk.X)
FileOutFrame3 = ttk.LabelFrame(BottomFrame1, text='Output Directory') FileOutFrame3 = ttk.LabelFrame(BottomFrame1, text='Output Directory')
FileOutFrame3.pack(side=tk.TOP, expand=tk.YES, padx='1px', pady='2px', fill=tk.X) FileOutFrame3.pack(side=tk.TOP, expand=tk.YES, padx='1px', pady='0px', fill=tk.X)
## CheckButton Initialize ## CheckButton Initialize
AskOrNotCheckButton = ttk.Checkbutton(FileOutFrame3, text='Directory', AskOrNotCheckButton = ttk.Checkbutton(FileOutFrame3, text='Directory',
@@ -1332,21 +1333,21 @@ class EXECUDUI:
self.AskOrNotCheckButtonVar, self.AskOrNotCheckButtonVar,
AskDirectorySelectBox, AskDirectorySelectBox,
AskDirectorySelectButton)) AskDirectorySelectButton))
AskOrNotCheckButton.pack(side=tk.LEFT, anchor='w', padx='1px', pady='0px') AskOrNotCheckButton.pack(side=tk.LEFT, anchor='w', padx='0px', pady='0px')
## SelectBox Initialize ## SelectBox Initialize
AskDirectorySelectBox = ttk.Combobox(FileOutFrame3, width=36, height=4, values=Outvalue, AskDirectorySelectBox = ttk.Combobox(FileOutFrame3, width=60, height=4, values=Outvalue,
state=tk.DISABLED, textvariable=self.DirectorySelectBoxVar) state=tk.DISABLED, textvariable=self.DirectorySelectBoxVar)
AskDirectorySelectBox.current(ComboxOutCount) AskDirectorySelectBox.current(ComboxOutCount)
AskDirectorySelectBox.pack(side=tk.LEFT, anchor='w', padx='1px', pady='0px') AskDirectorySelectBox.pack(side=tk.LEFT, anchor='w', padx='0px', pady='0px')
## SelectButton Initialize ## SelectButton Initialize
AskDirectorySelectButton = ttk.Button(FileOutFrame3, text='...', width=3, AskDirectorySelectButton = ttk.Button(FileOutFrame3, text='...', width=3, state=tk.DISABLED,
state=tk.DISABLED, command=lambda: self.Cmd.AskDirectory(AskDirectorySelectBox)) command=lambda: self.Cmd.AskDirectory(self.exehwnd, AskDirectorySelectBox))
AskDirectorySelectButton.pack(side=tk.RIGHT, anchor='e', padx='2px', pady='0px') AskDirectorySelectButton.pack(side=tk.RIGHT, anchor='e', padx='1px', pady='0px')
ExeFrame3 = ttk.Frame(BottomFrame1) ExeFrame3 = ttk.Frame(BottomFrame1)
ExeFrame3.pack(side=tk.TOP, expand=tk.YES, padx='1px', pady='2px', fill=tk.X) ExeFrame3.pack(side=tk.TOP, expand=tk.YES, padx='1px', pady='0px', fill=tk.X)
ExitButton = ttk.Button(ExeFrame3, text='Exit', width=10, ExitButton = ttk.Button(ExeFrame3, text='Exit', width=10,
command=self.exehwnd.destroy) command=self.exehwnd.destroy)
@@ -1372,7 +1373,8 @@ def View_windowshow(text, view):
# Param # text : the show box of file of choice # Param # text : the show box of file of choice
# Param # view : the father window of text ctr box # Param # view : the father window of text ctr box
# Return# none # Return# none
f_path = filedialog.askopenfilename() f_path = filedialog.askopenfilename(parent=view)
if not f_path: return 0
view.title('Viewing: %s' % f_path) view.title('Viewing: %s' % f_path)
text.delete('1.0', 'end') text.delete('1.0', 'end')
with open(f_path, 'r') as f: with open(f_path, 'r') as f:
@@ -1388,7 +1390,7 @@ class VIEWGUI:
def initGUI(hwnd): def initGUI(hwnd):
view = tk.Toplevel(hwnd) view = tk.Toplevel(hwnd)
view.title("View") view.title("View")
view.geometry('900x600') Move_center(view,1000,600)
view.minsize(1000, 600) view.minsize(1000, 600)
global icon_img1 global icon_img1
+158 -226
View File
@@ -8,73 +8,61 @@
#include <time.h> #include <time.h>
#endif // _BRDM2POS_H_ #endif // _BRDM2POS_H_
/* CALCU CONST*/ /* CALCU CONST*/
#define C_V 299792458 #define C_V 299792458 /* Speed of light (m/s) */
#define GM 398600500000000 #define GM 398600500000000 /* */
#define math_e 2.718281828459 #define math_e 2.718281828459 /* Natural constant e */
#define PI 3.141592653589793 #define PI 3.141592653589793 /* Ratio of circumference to diameter */
#define Earth_e 7.2921151467e-5 #define Earth_e 7.2921151467e-5 /* Rotational angular velocity of the earths (omega/s) */
#define C20 1.0826257e-3 #define C20 1.0826257e-3 /* */
#define DAYSEC 86400 /* The total second of a day */
/*WGS-84 CONST*/ /*WGS-84 CONST*/
#define a 6378137.0 #define a 6378137.0
#define e2 (0.0033528106647475*(2 - 0.0033528106647475)) #define e2 (0.0033528106647475*(2 - 0.0033528106647475))
/*PZ-90 CONST*/ /*PZ-90 CONST*/
#define TSTEP 30.0 #define TSTEP 30.0 /* RK-4 step */
/*GNSS OBSERV TYPE*/ /*GNSS OBSERV TYPE*/
#define FREQ1 1.57542E9 /* L1/E1/B1C frequency (Hz) */
#define FREQ2 1.22760E9 /* L2 frequency (Hz) */
#define FREQ5 1.17645E9 /* L5/E5a/B2a frequency (Hz) */
#define FREQ6 1.27875E9 /* E6/L6 frequency (Hz) */
#define FREQ7 1.20714E9 /* E5b frequency (Hz) */
#define FREQ8 1.191795E9 /* E5a+b frequency (Hz) */
#define FREQ9 2.492028E9 /* S frequency (Hz) */
#define FREQ1_GLO 1.60200E9 /* GLONASS G1 base frequency (Hz) */
#define DFRQ1_GLO 0.56250E6 /* GLONASS G1 bias frequency (Hz/n) */
#define FREQ2_GLO 1.24600E9 /* GLONASS G2 base frequency (Hz) */
#define DFRQ2_GLO 0.43750E6 /* GLONASS G2 bias frequency (Hz/n) */
#define FREQ3_GLO 1.202025E9 /* GLONASS G3 frequency (Hz) */
#define FREQ1a_GLO 1.600995E9 /* GLONASS G1a frequency (Hz) */
#define FREQ2a_GLO 1.248060E9 /* GLONASS G2a frequency (Hz) */
#define FREQ1_BDS 1.561098E9 /* BDS B1I frequency (Hz) */
#define FREQ2_BDS 1.20714E9 /* BDS B2I/B2b frequency (Hz) */
#define FREQ3_BDS 1.26852E9 /* BDS B3 frequency (Hz) */
//frequency 1 //frequency 1
#define C1 100 #define C1 100
#define C1A 100 #define C1A 100
#define C1B 101 #define C1B 101
#define C1C 102 #define C1C 102
#define C1D 103 #define C1D 103
#define C1E
#define C1F
#define C1G
#define C1H
#define C1I
#define C1J
#define C1K
#define C1L 104 #define C1L 104
#define C1M 105 #define C1M 105
#define C1N
#define C1O
#define C1P 106 #define C1P 106
#define C1Q
#define C1R
#define C1S 107 #define C1S 107
#define C1T
#define C1U
#define C1V
#define C1W
#define C1X 108 #define C1X 108
#define C1Y 109 #define C1Y 109
#define C1Z 110 #define C1Z 110
//frequency 2 //frequency 2
#define C2 200 #define C2 200
#define C2A
#define C2B
#define C2C 200 #define C2C 200
#define C2D 201 #define C2D 201
#define C2E
#define C2F
#define C2G
#define C2H
#define C2I 202 #define C2I 202
#define C2J
#define C2K
#define C2L 203 #define C2L 203
#define C2M 204 #define C2M 204
#define C2N
#define C2O
#define C2P 205 #define C2P 205
#define C2Q 206 #define C2Q 206
#define C2R #define C2R
#define C2S 207 #define C2S 207
#define C2T
#define C2U
#define C2V
#define C2W
#define C2X 208 #define C2X 208
#define C2Y 209 #define C2Y 209
#define C2Z 210 #define C2Z 210
@@ -90,88 +78,21 @@
#define C4X 402 #define C4X 402
//frequency 5 //frequency 5
#define C5 500 #define C5 500
#define C5A
#define C5B
#define C5C
#define C5D
#define C5E
#define C5F
#define C5G
#define C5H
#define C5I 500 #define C5I 500
#define C5J
#define C5K
#define C5L
#define C5M
#define C5N
#define C5O
#define C5P
#define C5Q 501 #define C5Q 501
#define C5R
#define C5S
#define C5T
#define C5U
#define C5V
#define C5W
#define C5X 502 #define C5X 502
#define C5Y
#define C5Z
//frequency 6 //frequency 6
#define C6 600 #define C6 600
#define C6A 600 #define C6A 600
#define C6B 601 #define C6B 601
#define C6C 602 #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 C6X 603
#define C6Y
#define C6Z 604 #define C6Z 604
//frequency 7 //frequency 7
#define C7 700 #define C7 700
#define C7A
#define C7B
#define C7C
#define C7D
#define C7E
#define C7F
#define C7G
#define C7H
#define C7I 700 #define C7I 700
#define C7J
#define C7K
#define C7L
#define C7M
#define C7N
#define C7O
#define C7P
#define C7Q 701 #define C7Q 701
#define C7R
#define C7S
#define C7T
#define C7U
#define C7V
#define C7W
#define C7X 702 #define C7X 702
#define C7Y
#define C7Z
//frequency 8 //frequency 8
#define C8 800 #define C8 800
#define C8I 800 #define C8I 800
@@ -184,11 +105,10 @@
#define GLO 04 #define GLO 04
#define SBAS 05 #define SBAS 05
#define MAXRINEX 1000 #define MAXRINEX 4096 /* Max length of line of rinex file */
#define DAYSEC 86400 #define MAXPATH 260 /* Max length of file path */
//satellite position & clock bias structure
typedef struct typedef struct pos_ts{//Satellite position
{
double X; double X;
double Y; double Y;
double Z; double Z;
@@ -196,9 +116,8 @@ typedef struct
double delta_t; double delta_t;
double delta_clk; double delta_clk;
}pos_ts; }pos_ts;
//receiver station position & clock bias structure
typedef struct typedef struct stations{//
{
double X; double X;
double Y; double Y;
double Z; double Z;
@@ -207,9 +126,27 @@ typedef struct
double H; double H;
double delta_TR; double delta_TR;
}stations; }stations;
//longitude & latitude structure
typedef struct typedef struct rah{//
{ double R;
double A;
double H;
}rah;
typedef struct enu{//East/North/Up coordinate system
double E;
double N;
double U;
}enu;
typedef struct blh{//Longitude/Latitude/Altitude coordinate system
double B;
double L;
double H;
}blh;
typedef struct blhdms{//Longitude/Latitude/Altitude coordinate system
//With Degree/Minute/Second
double B; double B;
int B_d; int B_d;
int B_m; int B_m;
@@ -219,54 +156,37 @@ typedef struct
int L_m; int L_m;
int L_s; int L_s;
double H; double H;
}blhs; }blhdms;
//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
{ typedef struct nav_head{//Header data of file of nav
double B; double ver; /* RINEX version */
double L; char type[20]; /* RINEX file format */
double H;
}xyz2blh; double ION_GPSA[4]; /* Ionosphere correction parameters alpha GPS */
//header data of file of nav double ION_GPSB[4]; /* Ionosphere correction parameters belta GPS */
typedef struct nav_head double ION_BDSA[4]; /* Ionosphere correction parameters alpha BeiDou */
{ double ION_BDSB[4]; /* Ionosphere correction parameters belta BeiDou */
double ver;//rinex double ION_QZSA[4]; /* Ionosphere correction parameters alpha QZSS */
char type[20]; double ION_QZSB[4]; /* Ionosphere correction parameters belta QZSS */
double ION_GPSA[4]; double ION_IRNA[4]; /* Ionosphere correction parameters alpha */
double ION_GPSB[4]; double ION_IRNB[4]; /* Ionosphere correction parameters belta */
double ION_BDSA[4];
double ION_BDSB[4]; double GPUT[4]; /* Time system correction of GPST */
double ION_QZSA[4]; double GLUT[4]; /* Time system correction of GLONASST */
double ION_QZSB[4]; double GAUT[4]; /* Time system correction of GALT */
double ION_IRNA[4]; double BDUT[4]; /* Time system correction of BDT */
double ION_IRNB[4]; double QZUT[4]; /* Time system correction of QZST */
double GPUT[4]; double IRUT[4]; /* Time system correction of */
double GLUT[4]; double SBUT[4]; /* Time system correction of SBAST */
double GAUT[4];
double BDUT[4]; int leap; /* Leap second */
double QZUT[4];
double IRUT[4];
double SBUT[4];
int leap;
}nav_head, * pnav_head; }nav_head, * pnav_head;
//body data of file of nav: GPS BeiDou Galileo
typedef struct nav_body typedef struct nav_body{//Body data of file of nav: GPS BeiDou Galileo GLONASS
{
int sPRN_GPS; int sPRN_BDS; int sPRN_GAL; int sPRN_GLO; /* GPS BeiDou Galileo GLONASS*/
int sPRN_GPS; int sPRN_BDS; int sPRN_GAL; int sPRN_GLO;/* System */
int TOC_Y; int TOC_Y;
int TOC_M; int TOC_M;
int TOC_D; int TOC_D;
@@ -313,93 +233,105 @@ typedef struct nav_body
double spare2; double spare2;
}nav_body, * pnav_body; }nav_body, * pnav_body;
//header data of file of obs
typedef struct obs_head typedef struct obs_head{//Header data of file of obs
{
double ver; double ver;
char type[30]; char type[30];
double apX; double apX;
double apY; double apY;
double apZ; double apZ;
double apB;
double apL;
double apH;
double ANTH; double ANTH;
double ANTdeltaE; double ANTdeltaE;
double ANTdeltaN; double ANTdeltaN;
int obstypenum_gps;
int obstypenum_bds; int obstypenum_gps; /* Observation amount of GPS */
int obstypenum_gal; int obstypenum_bds; /* Observation amount of BeiDou */
int obstypenum_glo; int obstypenum_gal; /* Observation amount of Galilro */
int obscode_gps[40]; int obstypenum_glo; /* Observation amount of GLONASS */
int obscode_bds[40];
int obscode_gal[40]; int obscode_gps[40];/* Observation code of GPS */
int obscode_glo[40]; int obscode_bds[40];/* Observation code of BeiDou */
double interval; int obscode_gal[40];/* Observation code of Galileo */
int f_y; int obscode_glo[40];/* Observation code of GLONASS */
int f_m;
int f_d; double interval; /* */
int f_h;
int f_min; int f_y; /* Year of first observe */
double f_sec; int f_m; /* Month of first observe */
int l_y; int f_d; /* Day of first observe */
int l_m; int f_h; /* Hour of first observe */
int l_d; int f_min; /* Minute of first observe */
int l_h; double f_sec; /* Second of first observe */
int l_min;
double l_sec; int l_y; /* Year of last observe */
char tsys[5];//time system int l_m; /* Month of last observe */
int l_d; /* Day of last observe */
int l_h; /* Hour of last observe */
int l_min; /* Minute of last observe */
double l_sec; /* Second of last observe */
char tsys[5]; /* Time system of obs */
}obs_head, * pobs_head; }obs_head, * pobs_head;
//epoch data of file of obs
typedef struct obs_epoch typedef struct obs_epoch{//Epoch data of file of obs
{ int y; /* Epoch year */
int y; int m; /* Epoch month */
int m; int d; /* Epoch day */
int d; int h; /* Epoch hour */
int h; int min; /* Epoch minute */
int min; double sec; /* Epoch second */
double sec;//epoch time int p_flag; /* Epoch flag */
int p_flag;//epoch flag int sat_num; /* The total number of obsable sat */
int sat_num;//the total number of obsable sat int gps_num; /* The total GPS satellite */
int gps_num;//the total gps sat int bds_num; /* The total BeiDou satellite */
int bds_num;//the total bds sat int gal_num; /* The total Galileo satellite */
int gal_num;//the total galileo sat int glo_num; /* The total GLONASS satellite */
int glo_num;//the total glonass sat int sPRN[84]; /* Total sprn of obs satellite */
int sPRN[84];//total sprn of obs sat int sPRN_GPS[32];/* Total sprn of GPS satellite in this epoch */
int sPRN_GPS[32]; int sPRN_BDS[60];/* Total sprn of BeiDou satellite in this epoch */
int sPRN_BDS[60]; int sPRN_GAL[30];/* Total sprn of Galileo satellite in this epoch */
int sPRN_GAL[30]; int sPRN_GLO[24];/* Total sprn of GLONASS satellite in this epoch */
int sPRN_GLO[24];
}obs_epoch, * pobs_epoch; }obs_epoch, * pobs_epoch;
//body data of file of obs
typedef struct obs_body typedef struct obs_body{//Body data of file of obs
{ double obs_gps[30][26];/* GPS obs data */
double obs_gps[20][26];//GPS obs data double obs_bds[40][26];/* BeiDou obs data */
double obs_bds[30][26];//BDS obs data double obs_gal[30][26];/* Galileo obs data */
double obs_gal[20][26];//GALILEO obs data double obs_glo[30][26];/* GLONASS obs data */
double obs_glo[20][26];//GLONASS obs data
}obs_body, * pobs_body; }obs_body, * pobs_body;
//
//Contain in timesys.cpp
extern double JDUTC2GPST(double); extern double JDUTC2GPST(double);
extern double Time2GPST(int, int, int, double, int, double); extern double Time2GPST(int, int, int, double, int, double);
extern double UTCTime2JD(int, int, int, double, int, double); extern double UTCTime2JD(int, int, int, double, int, double);
// //Contain in coordtrans.cpp
extern double deg2rad(double); extern double deg2rad(double);
extern double rad2deg(double); extern double rad2deg(double);
// extern rah rahcal(rah, double, double, double);
extern rahcal RAHCAL(rahcal, double, double, double); extern enu blh2enu(enu, double, double, double, double, double);
extern blh2enu BLH2ENU(blh2enu, double, double, double, double, double); extern blh xyz2blh(blh, double, double, double);
extern xyz2blh XYZ2BLH(xyz2blh, double, double, double); //Contain in readrnx.cpp
//
extern int getsatnum(FILE*); extern int getsatnum(FILE*);
extern int get_epochnum(FILE*); extern int get_epochnum(FILE*);
extern void initobs_e(pobs_epoch, pobs_body);
extern void freeobs_e(pobs_epoch, pobs_body); extern void freeobs_e(pobs_epoch, pobs_body);
extern int Type2Code(int, char buff[MAXRINEX]); extern int type2code(int, char buff[MAXRINEX]);
extern int Code2Type(int, int, int typearr[36]); extern int code2type(int, int, int typearr[36]);
extern int select_epoch(double, int, pnav_body, int, int); extern int select_epoch(double, int, pnav_body, int, int);
// //Contain in readrnx.cpp/read
extern void read_n_h(FILE*, pnav_head); extern void read_n_h(FILE*, pnav_head);
extern void read_n_b(FILE*, pnav_body); extern void read_n_b(FILE*, pnav_body);
extern void read_o_h(FILE*, pobs_head); extern void read_o_h(FILE*, pobs_head);
extern void read_o_eb(FILE*, pobs_head, pobs_epoch, pobs_body); extern void read_o_eb(FILE*, pobs_head, pobs_epoch, pobs_body);
// //Contain in solutionout.cpp
extern "C" _declspec(dllexport) double brdm2pos(char nav_path[260], char obs_path[260], char res_path[260], int gnsscode); extern FILE* outputheader(pobs_head, char obs_path[MAXPATH], char nav_path[MAXPATH], char res_path[MAXPATH]);
extern void outputbodydata(pobs_head, pobs_body, pos_ts, rah, FILE*, int, int, int);
//Entry function
extern "C" _declspec(dllexport) double brdm2pos(char nav_path[MAXPATH], char obs_path[MAXPATH], char res_path[MAXPATH],
int GNSS, int Hangle);
+60 -57
View File
@@ -1,57 +1,61 @@
#include "brdm2pos.h" #include "brdm2pos.h"
using namespace std; using namespace std;
/* -------------------------------------------------------------------------- */ /**
/// @brief degree to radian * Degree to radian.
/// @param deg *
/// @return return radian * \param deg: Degree
/* -------------------------------------------------------------------------- */ * \return Radian
*/
double deg2rad(double deg) double deg2rad(double deg)
{ {
double rad = (PI / 180) * deg; double rad = (PI / 180) * deg;
return rad; return rad;
} }
/* -------------------------------------------------------------------------- */ /**
/// @brief radian to degree * Radian to degree .
/// @param rad *
/// @return return degree * \param rad: Radian
/* -------------------------------------------------------------------------- */ * \return Degree
*/
double rad2deg(double rad) double rad2deg(double rad)
{ {
double deg = (180 / PI) * rad; double deg = (180 / PI) * rad;
return deg; return deg;
} }
/* -------------------------------------------------------------------------- */ /**
/// @brief satellite azimuth angle calculation * Azimuth/Calculate.
/// @param rahcal parameter transfer structure *
/// @param E east * \param rah: Parameter transfer structure
/// @param N north * \param E: East
/// @param U up * \param N: North
/// @return return structure contain R, A, H members * \param U: Up
/* -------------------------------------------------------------------------- */ * \return structure contain R, A, H members
rahcal RAHCAL(rahcal rahcal, */
rah rahcal(rah rah,
double E, double N, double U) double E, double N, double U)
{ {
rahcal.H = atan2(U, sqrt(E * E + N * N)); rah.H = atan2(U, sqrt(E * E + N * N));
rahcal.A = atan2(E, U); rah.A = atan2(E, U);
if (rahcal.A < 0) if (rah.A < 0)
rahcal.A += 2 * PI; rah.A += 2 * PI;
if (rahcal.A > 2 * PI) if (rah.A > 2 * PI)
rahcal.A -= 2 * PI; rah.A -= 2 * PI;
rahcal.R = sqrt(E * E + N * N + U * U); rah.R = sqrt(E * E + N * N + U * U);
return rahcal; return rah;
} }
/* -------------------------------------------------------------------------- */ /**
/// @brief convert BLH coordinates to ENU coordinates * Convert BLH coordinates to ENU coordinates.
/// @param blh2enu parameter transfer structure *
/// @param stationB latitude of receiver station * \param enu: Parameter transfer structure
/// @param stationL longitude of receiver station * \param stationB: Latitude of receiver station
/// @param deltax X-coordinate difference of satellite arrival center * \param stationL: Longitude of receiver station
/// @param deltay Y-coordinate difference of satellite arrival center * \param deltax: Deltax X-coordinate difference of satellite arrival center
/// @param deltaz Z-coordinate difference of satellite arrival center * \param deltay: Deltax Y-coordinate difference of satellite arrival center
/// @return return type of structure contain E, N, U members * \param deltaz: Deltax Z-coordinate difference of satellite arrival center
/* -------------------------------------------------------------------------- */ * \return
blh2enu BLH2ENU(blh2enu blh2enu, */
enu blh2enu(enu enu,
double stationB, double stationL, double stationB, double stationL,
double deltax, double deltay, double deltaz) double deltax, double deltay, double deltaz)
{ {
@@ -59,29 +63,28 @@ blh2enu BLH2ENU(blh2enu blh2enu,
double cosB = cos(stationB); double cosB = cos(stationB);
double sinL = sin(stationL); double sinL = sin(stationL);
double cosL = cos(stationL); double cosL = cos(stationL);
blh2enu.E = -sinL * (deltax)+cosL * (deltay); enu.E = -sinL * (deltax) +cosL * (deltay);
blh2enu.N = -sinB * cosL * (deltax)-sinB * sinL * (deltay)+cosB * (deltaz); enu.N = -sinB * cosL * (deltax)-sinB * sinL * (deltay)+cosB * (deltaz);
blh2enu.U = cosB * cosL * (deltax)+cosB * sinL * (deltay)+sinB * (deltaz); enu.U = cosB * cosL * (deltax)+cosB * sinL * (deltay)+sinB * (deltaz);
return blh2enu; return enu;
} }
/* -------------------------------------------------------------------------- */ /**
/// @brief Convert ECEF geostationary coordinates to BLH coordinates * Convert ECEF geostationary coordinates to BLH coordinates.
/// @param xyz2blh parameter transfer structure *
/// @param X X coordinates of ECEF * \param blh: Parameter transfer structure
/// @param Y Y coordinates of ECEF * \param X: X coordinates of ECEF
/// @param Z Z coordinates of ECEF * \param Y; Y coordinates of ECEF
/// @param a major semiaxis of WGS-84 ellipsoid * \param Z: Z coordinates of ECEF
/// @param e2 the square of the first eccentricity of WGS-84 ellipsoid * \return type of structure contain B, L, H members
/// @return return type of structure contain B, L, H members */
/* -------------------------------------------------------------------------- */ blh xyz2blh(blh blh,
xyz2blh XYZ2BLH(xyz2blh xyz2blh,
double X, double Y, double Z) double X, double Y, double Z)
{ {
double B = 0.0, N = 0.0, H = 0.0, R0, R1, deltaH, deltaB; double B = 0.0, N = 0.0, H = 0.0, R0, R1, deltaH, deltaB;
R0 = sqrt(pow(X, 2) + pow(Y, 2)); R0 = sqrt(pow(X, 2) + pow(Y, 2));
R1 = sqrt(pow(X, 2) + pow(Y, 2) + pow(Z, 2)); R1 = sqrt(pow(X, 2) + pow(Y, 2) + pow(Z, 2));
xyz2blh.L = atan2(Y, X); blh.L = atan2(Y, X);
N = a; N = a;
H = R1 - a; H = R1 - a;
B = atan2(Z * (N + H), R0 * (N * (1 - e2) + H)); B = atan2(Z * (N + H), R0 * (N * (1 - e2) + H));
@@ -92,8 +95,8 @@ xyz2blh XYZ2BLH(xyz2blh xyz2blh,
H = R0 / cos(B) - N; H = R0 / cos(B) - N;
B = atan2(Z * (N + H), R0 * (N * (1 - e2) + H)); B = atan2(Z * (N + H), R0 * (N * (1 - e2) + H));
} while (fabs(deltaH - H) > 1.0e-3 && fabs(deltaB - B) > 1.0e-9); } while (fabs(deltaH - H) > 1.0e-3 && fabs(deltaB - B) > 1.0e-9);
xyz2blh.B = B; blh.B = B;
xyz2blh.H = H; blh.H = H;
return xyz2blh; return blh;
} }
+143 -202
View File
@@ -1,23 +1,32 @@
#include "brdm2pos.h" #include "brdm2pos.h"
#define MAXTOE_GPS 7200.0
#define MAXTOE_BDS 21600.0
#define MAXTOE_GAL 14400.0
#define MAXTOE_GLO 1800.0
#define MAXTOE_SBS 360.0
using namespace std; using namespace std;
/* -------------------------------------------------------------------------- */ /**
/// @brief find the nearest obs epoch with boardcast * 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 SecofWeek: SecofWeek second of week of obs epoch time
/// @param nav_b nav data file structure * \param sPRN: sPRN the satellite PRN which need to match
/// @param satnum total number of boardcast satellite * \param nav_b: Nav data file structure
/// @param syscode GNSS code, more on PPUBLIC.H * \param satnum: Total number of boardcast satellite
/// @return Return the absolute epoch number of the best epoch * \param syscode: GNSS code
/// When there is no matching satellite number, the function returns -1 * \return the absolute epoch number of the best epoch
/* -------------------------------------------------------------------------- */ * -1 ,no match satellite
*/
int select_epoch(double SecofWeek, int sPRN, pnav_body nav_b, int satnum, int syscode) int select_epoch(double SecofWeek, int sPRN, pnav_body nav_b, int satnum, int syscode)
{ {
int best_epoch = -1; int best_epoch = -1;
double min = 10000;//Initialize the minimum value double min;//Initialize the minimum value
double Min; double Min;
if (syscode == GPS){//Be judged as GPS
if (syscode == GPS){//GPS
min = MAXTOE_GPS;
for (int i = 0; i < satnum; i++){ for (int i = 0; i < satnum; i++){
if (sPRN == nav_b[i].sPRN_GPS){ if (sPRN == nav_b[i].sPRN_GPS && nav_b[i].sHEA == 0) {
Min = fabs(SecofWeek - nav_b[i].TOE); Min = fabs(SecofWeek - nav_b[i].TOE);
if (Min <= min){ if (Min <= min){
best_epoch = i; best_epoch = i;
@@ -26,7 +35,8 @@ int select_epoch(double SecofWeek, int sPRN, pnav_body nav_b, int satnum, int sy
} }
}return best_epoch; }return best_epoch;
} }
if (syscode == BDS){//Be judged as BeiDou else if (syscode == BDS){//BeiDou
min = MAXTOE_BDS;
for (int i = 0; i < satnum; i++){ for (int i = 0; i < satnum; i++){
if (sPRN == nav_b[i].sPRN_BDS){ if (sPRN == nav_b[i].sPRN_BDS){
Min = fabs(SecofWeek - nav_b[i].TOE); Min = fabs(SecofWeek - nav_b[i].TOE);
@@ -37,7 +47,8 @@ int select_epoch(double SecofWeek, int sPRN, pnav_body nav_b, int satnum, int sy
} }
}return best_epoch; }return best_epoch;
} }
if (syscode == GAL){//Be judged as Galileo else if (syscode == GAL){//Galileo
min = MAXTOE_GAL;
for (int i = 0; i < satnum; i++){ for (int i = 0; i < satnum; i++){
if (sPRN == nav_b[i].sPRN_GAL){ if (sPRN == nav_b[i].sPRN_GAL){
Min = fabs(SecofWeek - nav_b[i].TOE); Min = fabs(SecofWeek - nav_b[i].TOE);
@@ -48,7 +59,8 @@ int select_epoch(double SecofWeek, int sPRN, pnav_body nav_b, int satnum, int sy
} }
}return best_epoch; }return best_epoch;
} }
if (syscode == GLO){ else if (syscode == GLO){//GLONASS
min = MAXTOE_GLO;
for (int i = 0; i < satnum; i++){ for (int i = 0; i < satnum; i++){
if (sPRN == nav_b[i].sPRN_GLO){ if (sPRN == nav_b[i].sPRN_GLO){
Min = fabs(SecofWeek - nav_b[i].TOE); Min = fabs(SecofWeek - nav_b[i].TOE);
@@ -61,17 +73,37 @@ int select_epoch(double SecofWeek, int sPRN, pnav_body nav_b, int satnum, int sy
}return best_epoch; }return best_epoch;
}return best_epoch; }return best_epoch;
} }
/* -------------------------------------------------------------------------- */ /**
/// @brief converts the observation type to the numeric code defined in PUBLIC.H * Match the observation type(char*) with the code type(int).
/// @param i reads the number of incoming loops in the loop *
/// @param buff type of incoming observation * \param Lxcodeindex: Frequency X observation type(char*)
/// @return Returns the obs code * \param code_original: The observation will matched
/* -------------------------------------------------------------------------- */ * \param freq: Observation frequency
int Type2Code(int i, char buff[MAXRINEX]) * \return code type
*/
static int findtype(const char Lxcodeindex[60], char code_original[4], int freq)
{ {
int code_return = 0; int code_return = 0;
char code_contrast[4]; char code_contrast[4] = "/0";
char code_original[4];
for (int j = 0; j < (strlen(Lxcodeindex) / 3); j++) {
strncpy(code_contrast, Lxcodeindex + 0 + j * 3, 3);
if (strcmp(code_contrast, code_original) == 0) {
code_return = j + freq;
}
}return code_return;
}
/**
* Converts the observation type to the numeric code defined.
*
* \param i: Reads the number of incoming loops in the loop
* \param buff: Type of incoming observation
* \return
*/
int type2code(int i, char buff[MAXRINEX])
{
int code_return = 0;
char code_original[4] = "/0";
const char L1codeindex[] = "C1AC1BC1CC1DC1LC1MC1PC1SC1XC1YC1Z";//obs type of different frequency const char L1codeindex[] = "C1AC1BC1CC1DC1LC1MC1PC1SC1XC1YC1Z";//obs type of different frequency
const char L2codeindex[] = "C2CC2DC2IC2LC2MC2PC2QC2SC2XC2YC2Z"; const char L2codeindex[] = "C2CC2DC2IC2LC2MC2PC2QC2SC2XC2YC2Z";
@@ -82,133 +114,72 @@ int Type2Code(int i, char buff[MAXRINEX])
const char L7codeindex[] = "C7IC7QC7XC7DC7PC7Z"; const char L7codeindex[] = "C7IC7QC7XC7DC7PC7Z";
const char L8codeindex[] = "C8IC8QC8X"; const char L8codeindex[] = "C8IC8QC8X";
memset(code_contrast, 0, sizeof(code_contrast));
memset(code_original, 0, sizeof(code_original));
strncpy(code_original, buff + 7 + 4 * i, 3); strncpy(code_original, buff + 7 + 4 * i, 3);
if (strstr(code_original, "1")) { if (strstr(code_original, "1")) return findtype(L1codeindex, code_original, C1);
for (int j = 0; j < (strlen(L1codeindex) / 3); j++) { else if (strstr(code_original, "2")) return findtype(L2codeindex, code_original, C2);
strncpy(code_contrast, L1codeindex + 0 + j * 3, 3); else if (strstr(code_original, "3")) return findtype(L3codeindex, code_original, C3);
if (strcmp(code_contrast, code_original) == 0) { else if (strstr(code_original, "4")) return findtype(L4codeindex, code_original, C4);
code_return = j + 100; else if (strstr(code_original, "5")) return findtype(L5codeindex, code_original, C5);
return code_return; else if (strstr(code_original, "6")) return findtype(L6codeindex, code_original, C6);
break; else if (strstr(code_original, "7")) return findtype(L7codeindex, code_original, C7);
else if (strstr(code_original, "8")) return findtype(L8codeindex, code_original, C8);
else return 0;
} }
} /**
} * Match the obs code and convert into type.
if (strstr(code_original, "2")) { *
for (int j = 0; j < (strlen(L2codeindex) / 3); j++) { * \param type: Obs type that you want to match
strncpy(code_contrast, L2codeindex + 0 + j * 3, 3); * \param typenum: The total number of obs types
strncpy(code_original, buff + 7 + 4 * i, 3); * \param typearr: Type codes store arrays
if (strcmp(code_contrast, code_original) == 0) { * \return the array position of the corresponding obs type code
code_return = j + 200; */
return code_return; int code2type(int type, int typenum, int typearr[36])
break;
}
}
}
if (strstr(code_original, "3")) {
for (int j = 0; j < (strlen(L3codeindex) / 3); j++) {
strncpy(code_contrast, L3codeindex + 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;
}
}
}
if (strstr(code_original, "4")) {
for (int j = 0; j < (strlen(L3codeindex) / 3); j++) {
strncpy(code_contrast, L3codeindex + 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;
}
}
}
if (strstr(code_original, "5")) {
for (int j = 0; j < (strlen(L5codeindex) / 3); j++) {
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;
}
}
}
if (strstr(code_original, "6")) {
for (int j = 0; j < (strlen(L6codeindex) / 3); j++) {
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;
}
}
}
if (strstr(code_original, "7")) {
for (int j = 0; j < (strlen(L7codeindex) / 3); j++) {
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;
}
}
}
if (strstr(code_original, "8")) {
for (int j = 0; j < (strlen(L8codeindex) / 3); j++) {
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; int pos;
for (pos = 0; pos < typenum; pos++) { for (pos = 0; pos < typenum; pos++) {
if ((typearr[pos] - typearr[pos] % 100) == typecode) { if ((typearr[pos] - typearr[pos] % 100) == type) {
return pos; return pos;
} }
}return pos; }return pos;
} }
/* -------------------------- Read the file of rnx -------------------------- */ /**
/* -------------------------------------------------------------------------- */ * Broad form of function code2type.
/// @brief Convert the string to number *
/// @param buff * \param exclude: The excluded type
/// @param i Position of begin to read * \param typenum: The total number of obs types
/// @param n The number of character will to capture * \param typearr: Type codes store arrays
/// @return Number of string you captured * \return the array position of the corresponding obs type code
/* -------------------------------------------------------------------------- */ */
int code2type_broad(int exclude, int freq, int typenum, int typearr[36])
{
int pos;
for (pos = 0; pos < typenum; pos++) {
if (typearr[pos] == 0 ? (0) : ((typearr[pos] - typearr[pos] % 100) == exclude ? 0 : 1)) {
return pos;
}
}return pos;
}
/*Read the file of rnx*/
/**
* Convert the string to number.
*
* \param buff
* \param i: Position of begin to read
* \param n: The number of character will to capture
* \return number of string you captured
*
* @Author: T. TAKASU
*
* 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
*/
static double strtonum(const char* buff, int i, int n) static double strtonum(const char* buff, int i, int n)
{ {
double value = 0.0; double value = 0.0;char str[256] = { 0 };char* p = str;
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) { if (i < 0 || (int)strlen(buff) < i || (int)sizeof(str) - 1 < n) {
return 0.0; return 0.0;
} }
@@ -224,11 +195,12 @@ void freeobs_e(pobs_epoch obs_e, pobs_body obs_b)
free(obs_e); free(obs_b); free(obs_e); free(obs_b);
} }
/*Read the file of nav*/ /*Read the file of nav*/
/* -------------------------------------------------------------------------- */ /**
/// @brief get the total number of satellite boardcast data of nav file * Get the total amount of satellite boardcast data of nav file .
/// @param fp_nav the file pointer of nav file *
/// @return total number of satellite boardcast data * \param fp_nav: The file pointer of nav file
/* -------------------------------------------------------------------------- */ * \return amount of satellite
*/
int getsatnum(FILE* fp_nav) int getsatnum(FILE* fp_nav)
{ {
int satnum = 0; int satnum = 0;
@@ -595,11 +567,12 @@ void read_n_b(FILE* fp_nav, pnav_body nav_b)
} }
} }
/*Read the file of obs*/ /*Read the file of obs*/
/* -------------------------------------------------------------------------- */ /**
/// @brief get the total number of epoch of obs * Get the total amount of epoch of obs.
/// @param fp_obs the file pointer of obs *
/// @return epoch number * \param fp_obs: The file pointer of obs
/* -------------------------------------------------------------------------- */ * \return amount of epoch
*/
int get_epochnum(FILE* fp_obs) int get_epochnum(FILE* fp_obs)
{ {
int n = 0; int n = 0;
@@ -656,70 +629,38 @@ void read_o_h(FILE* fp_obs, pobs_head obs_h)
strncpy(&flag, buff + 0, 1); strncpy(&flag, buff + 0, 1);
if (flag == 'G') { if (flag == 'G') {
obs_h->obstypenum_gps = (int)strtonum(buff, 4, 2); obs_h->obstypenum_gps = (int)strtonum(buff, 4, 2);
if (obs_h->obstypenum_gps <= 13) { for (i = 0; i < obs_h->obstypenum_gps;) {
for (i = 0; i < obs_h->obstypenum_gps; i++) { for (int j = 0; j < 13; i++, j++) {
obs_h->obscode_gps[i] = Type2Code(i, buff); if (i == obs_h->obstypenum_gps) break;
} else obs_h->obscode_gps[i] = type2code(i, buff);
} }i == obs_h->obstypenum_gps? 0 : fgets(buff, MAXRINEX, fp_obs);
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; }continue;
} }
else if (flag == 'C') { else if (flag == 'C') {
obs_h->obstypenum_bds = (int)strtonum(buff, 4, 2); obs_h->obstypenum_bds = (int)strtonum(buff, 4, 2);
if (obs_h->obstypenum_bds <= 13) { for (i = 0; i < obs_h->obstypenum_bds;) {
for (i = 0; i < obs_h->obstypenum_bds; i++) { for (int j = 0; j < 13; i++, j++) {
obs_h->obscode_bds[i] = Type2Code(i, buff); if (i == obs_h->obstypenum_bds) break;
} else obs_h->obscode_bds[i] = type2code(i, buff);
} }i == obs_h->obstypenum_bds ? 0 : fgets(buff, MAXRINEX, fp_obs);
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; }continue;
} }
else if (flag == 'E') { else if (flag == 'E') {
obs_h->obstypenum_gal = (int)strtonum(buff, 4, 2); obs_h->obstypenum_gal = (int)strtonum(buff, 4, 2);
if (obs_h->obstypenum_gal <= 13) { for (i = 0; i < obs_h->obstypenum_gal;) {
for (i = 0; i < obs_h->obstypenum_gal; i++) { for (int j = 0; j < 13; i++, j++) {
obs_h->obscode_gal[i] = Type2Code(i, buff); if (i == obs_h->obstypenum_gal) break;
} else obs_h->obscode_gal[i] = type2code(i, buff);
} }i == obs_h->obstypenum_gal ? 0 : fgets(buff, MAXRINEX, fp_obs);
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 (flag == 'R') { else if (flag == 'R') {
obs_h->obstypenum_glo = (int)strtonum(buff, 4, 2); obs_h->obstypenum_glo = (int)strtonum(buff, 4, 2);
if (obs_h->obstypenum_glo <= 13) { for (i = 0; i < obs_h->obstypenum_glo;) {
for (i = 0; i < obs_h->obstypenum_glo; i++) { for (int j = 0; j < 13; i++, j++) {
obs_h->obscode_glo[i] = Type2Code(i, buff); if (i == obs_h->obstypenum_glo) break;
} else obs_h->obscode_glo[i] = type2code(i, buff);
} }i == obs_h->obstypenum_glo ? 0 : fgets(buff, MAXRINEX, fp_obs);
else if (obs_h->obstypenum_glo > 13) {
for (i = 0; i < 13; i++) {
obs_h->obscode_glo[i] = Type2Code(i, buff);
}
fgets(buff, MAXRINEX, fp_obs);
for (i = 0; i < obs_h->obstypenum_glo - 13; i++) {
obs_h->obscode_glo[i + 13] = Type2Code(i, buff);
}
}continue; }continue;
}continue; }continue;
} }
+150 -167
View File
@@ -76,14 +76,15 @@ pos_ts glo_pos(int best_epoch, double Weeksec,
return pos_t; return pos_t;
} }
/*Calculate the satellite position of other systems on this epoch*/ /*Calculate the satellite position of other systems on this epoch*/
pos_ts sat_pos(int sPRN, int best_epoch, double Weeksec, int gnsscode, pos_ts sat_pos(int sPRN, int best_epoch, double Weeksec, int GNSS,
pnav_body nav_b, pobs_head obs_h, pos_ts pos_t) pnav_body nav_b, pobs_head obs_h, pos_ts pos_t)
{ {
double T_S = Weeksec - pos_t.delta_t; double T_S = Weeksec - pos_t.delta_t;
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; double tk;
if (gnsscode == BDS) tk = T_S - nav_b[best_epoch].TOE - 14;
if (GNSS == BDS) tk = T_S - nav_b[best_epoch].TOE - 14;//BDST = GPST + 14
else tk = T_S - nav_b[best_epoch].TOE; else tk = T_S - nav_b[best_epoch].TOE;
if (tk > 32400)tk -= 604800; if (tk > 32400)tk -= 604800;
@@ -115,16 +116,8 @@ pos_ts sat_pos(int sPRN, int best_epoch, double Weeksec, int gnsscode,
double y = r * sin(u); double y = r * sin(u);
double l, X, Y, Z; double l, X, Y, Z;
if (gnsscode == BDS) { if (GNSS == BDS && (sPRN <= 5 || sPRN >= 59)) {//BDS GEO Satellites
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; 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); X = x * cos(l) - y * cos(i) * sin(l);
Y = x * sin(l) + y * cos(i) * cos(l); Y = x * sin(l) + y * cos(i) * cos(l);
@@ -136,7 +129,7 @@ pos_ts sat_pos(int sPRN, int best_epoch, double Weeksec, int gnsscode,
X = X * cos(p) + Y * sin(p) * cos(f) + Z * sin(p) * sin(f); 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); Y = X * -sin(p) + Y * cos(p) * cos(f) + Z * cos(p) * sin(f);
Z = Y * -sin(f) + Z * cos(f); Z = Y * -sin(f) + Z * cos(f);
}
} }
else { else {
l = nav_b[best_epoch].OMEGA + (nav_b[best_epoch].deltaomega - Earth_e) * tk - Earth_e * nav_b[best_epoch].TOE; l = nav_b[best_epoch].OMEGA + (nav_b[best_epoch].deltaomega - Earth_e) * tk - Earth_e * nav_b[best_epoch].TOE;
@@ -148,44 +141,49 @@ pos_ts sat_pos(int sPRN, int best_epoch, double Weeksec, int gnsscode,
pos_t.Y = -sin(Earth_e * pos_t.delta_t) * X + cos(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 pos_t.Z = Z;//Correction of earth rotation
double TGD; double TGD=0.0;
if (gnsscode == GPS) TGD = nav_b[best_epoch].TGD; if (GNSS == GPS) TGD = nav_b[best_epoch].TGD;
else if (gnsscode == GAL) TGD = nav_b[best_epoch].BGDa; else if (GNSS == GAL) TGD = nav_b[best_epoch].BGDa;
else if (gnsscode == BDS) TGD = 0; else if (GNSS == BDS) TGD = nav_b[best_epoch].TGD1;
//Recalculate the diatance of satellite-receiver
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)); 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));
double rela = 2 * sqrt(GM) * nav_b[best_epoch].e * nav_b[best_epoch].sqrtA * sin(Es) / pow(C_V, 2);//Relativistic effect //Get relativistic effect correction
pos_t.delta_clk = nav_b[best_epoch].sa0 + nav_b[best_epoch].sa1 * tk + nav_b[best_epoch].sa2 * pow(tk, 2) - rela - TGD; double rela = 2 * sqrt(GM) * nav_b[best_epoch].e * nav_b[best_epoch].sqrtA * sin(Es) / pow(C_V, 2);
pos_t.delta_clk = nav_b[best_epoch].sa0 + nav_b[best_epoch].sa1 * tk + nav_b[best_epoch].sa2 * pow(tk, 2) - rela + TGD;
pos_t.deltat = pos_t.delta_t; pos_t.deltat = pos_t.delta_t;
pos_t.delta_t = R / C_V + pos_t.delta_clk; pos_t.delta_t = R / C_V + pos_t.delta_clk;
return pos_t; return pos_t;
} }
/* -------------------------------------------------------------------------- */ /**
/// @brief Calculate the position of satellite in the ECEF coordinate system by the broadcast ephemeris and epoch information * .
/// @param obs_h Observation header data *
/// @param obs_e Observation epoch data * \param obs_h: Observation header data
/// @param obs_b Observation data * \param obs_e: Observation epoch data
/// @param nav_b Navigation data * \param obs_b: Observation data
/// @param res_file The file path of result file of satellite position * \param nav_b: Navigation data
/// @param station Prior information about station location * \param res_file: The file path of result file of satellite position
/// @param gnsscode GNSS system code * \param GNSS: GNSS system code
/// @param satnum The total number of satellite of designated satellite system * \param satnum: The total number of satellite of designated satellite system
/// @return 1 refer OK * \return
/* -------------------------------------------------------------------------- */ */
int sat_pos_cal(pobs_head obs_h, pobs_epoch obs_e, pobs_body obs_b, int sat_pos_cal(pobs_head obs_h, pobs_epoch obs_e, pobs_body obs_b,
pnav_body nav_b, pnav_body nav_b,
FILE* res_file, stations station, FILE* res_file,
int gnsscode, int satnum) int GNSS, int satnum, int Hangle)
{ {
//the beginning second of observation //the beginning second of observation
double beginsec = Time2GPST(obs_h->f_y, obs_h->f_m, obs_h->f_d, obs_h->f_h, obs_h->f_min, obs_h->f_sec); double beginsec = Time2GPST(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 //the ending second of observation
double endinsec = Time2GPST(obs_h->l_y, obs_h->l_m, obs_h->l_d, obs_h->l_h, obs_h->l_min, obs_h->l_sec); double endinsec = Time2GPST(obs_h->l_y, obs_h->l_m, obs_h->l_d, obs_h->l_h, obs_h->l_min, obs_h->l_sec);
blhs blh = { 0 }; blh2enu enu = { 0 }; rah in_rah = { 0 }; rah tem_rah = { 0 };
rahcal rah = { 0 }; pos_ts pos_t = { 0 }; enu in_enu = { 0 }; enu tem_enu = { 0 };
xyz2blh tem1 = { 0 }; blh2enu tem2 = { 0 }; rahcal tem3 = { 0 }; blh in_blh = { 0 }; blh tem_blh = { 0 };
pos_ts pos_t = { 0 };
int y = obs_e->y; int m = obs_e->m; int d = obs_e->d; int y = obs_e->y; int m = obs_e->m; int d = obs_e->d;
double h = obs_e->h; int min = obs_e->min; double sec = obs_e->sec; double h = obs_e->h; int min = obs_e->min; double sec = obs_e->sec;
@@ -194,141 +192,123 @@ int sat_pos_cal(pobs_head obs_h, pobs_epoch obs_e, pobs_body obs_b,
int epochcount = round((Weeksec - beginsec) / obs_h->interval) + 1; int epochcount = round((Weeksec - beginsec) / obs_h->interval) + 1;
fprintf(res_file, "\n>%04d %04d %02d %02d %02d %02d %07.04f" fprintf(res_file, "\n>%04d %04d %02d %02d %02d %02d %07.04f"
, epochcount, obs_e->y, obs_e->m, obs_e->d, obs_e->h, obs_e->min, obs_e->sec); , epochcount, obs_e->y, obs_e->m, obs_e->d, obs_e->h, obs_e->min, obs_e->sec);
int sat_num = 0, sPRN = 0, SIGN = 0, PERS = 0; int sat_num = 0, sPRN = 0, PERS = 0;
double detat_toc; double detat_toc;
//Check the GNSS and assign the satellite number
if (gnsscode == GPS)sat_num = obs_e->gps_num; //Match the system and assign the satellite number
else if (gnsscode == GAL)sat_num = obs_e->gal_num; if (GNSS == GPS)sat_num = obs_e->gps_num;
else if (gnsscode == BDS)sat_num = obs_e->bds_num; else if (GNSS == GAL)sat_num = obs_e->gal_num;
else if (gnsscode == GLO)sat_num = obs_e->glo_num; else if (GNSS == BDS)sat_num = obs_e->bds_num;
else if (GNSS == GLO)sat_num = obs_e->glo_num;
for (int j = 0; j < sat_num; j++) { for (int j = 0; j < sat_num; j++) {
if (gnsscode == GPS) {
sPRN = obs_e->sPRN_GPS[j]; SIGN = GPS; //Match system and assign the sPRN
PERS = obs_b->obs_gps[j][Code2Type(C1, obs_h->obstypenum_gps, obs_h->obscode_gps)] / C_V; if (GNSS == GPS) {
sPRN = obs_e->sPRN_GPS[j];
PERS = obs_b->obs_gps[j][code2type(C1, obs_h->obstypenum_gps, obs_h->obscode_gps)] / C_V;
} }
else if (gnsscode == GAL) { else if (GNSS == GAL) {
sPRN = obs_e->sPRN_GAL[j]; SIGN = GAL; sPRN = obs_e->sPRN_GAL[j];
PERS = obs_b->obs_gal[j][Code2Type(C1, obs_h->obstypenum_gal, obs_h->obscode_gal)] / C_V; PERS = obs_b->obs_gal[j][code2type(C1, obs_h->obstypenum_gal, obs_h->obscode_gal)] / C_V;
} }
else if (gnsscode == BDS) { else if (GNSS == BDS) {
sPRN = obs_e->sPRN_BDS[j]; SIGN = BDS; sPRN = obs_e->sPRN_BDS[j];
PERS = obs_b->obs_bds[j][Code2Type(C2, obs_h->obstypenum_bds, obs_h->obscode_bds)] / C_V; PERS = obs_b->obs_bds[j][code2type(C2, obs_h->obstypenum_bds, obs_h->obscode_bds)] / C_V;
} }
else if (gnsscode == GLO) { else if (GNSS == GLO) {
sPRN = obs_e->sPRN_GLO[j]; SIGN = GLO; sPRN = obs_e->sPRN_GLO[j];
PERS = obs_b->obs_glo[j][Code2Type(C1, obs_h->obstypenum_glo, obs_h->obscode_glo)] / C_V; PERS = obs_b->obs_glo[j][code2type(C1, obs_h->obstypenum_glo, obs_h->obscode_glo)] / C_V;
} }
int best_epoch = select_epoch(Weeksec, sPRN, nav_b, satnum, SIGN); //Match the nearest satellite of nav with this epoch
int best_epoch = select_epoch(Weeksec, sPRN, nav_b, satnum, GNSS);
if (best_epoch == -1)//when the sPRN is not exist function will return -1 if (best_epoch == -1)//when the sPRN is not exist function will return -1
break; break;
if (SIGN == BDS) detat_toc = Weeksec - nav_b[best_epoch].TOE - 14;
if (GNSS == BDS) detat_toc = Weeksec - nav_b[best_epoch].TOE - 14;//BDST = GPST + 14s
else detat_toc = Weeksec - nav_b[best_epoch].TOE; else detat_toc = Weeksec - nav_b[best_epoch].TOE;
//Iterative approximate propagation time //Iterative approximate propagation time
//Exclude GLONASS if (GNSS == GLO) {
if (SIGN == GLO) {
pos_t.delta_t = PERS - //Get the approximately transit of signal
station.delta_TR + pos_t.delta_t = PERS - 0 +
nav_b[best_epoch].sa0 + nav_b[best_epoch].sa0 +
nav_b[best_epoch].sa1 * detat_toc; nav_b[best_epoch].sa1 * detat_toc;
pos_t.deltat = 0.0;
pos_t.deltat = 0.0;
//Satellite position calculation
while (fabs(pos_t.delta_t - pos_t.deltat) > 1.0e-9) { while (fabs(pos_t.delta_t - pos_t.deltat) > 1.0e-9) {
pos_t = glo_pos(best_epoch, Weeksec, nav_b, obs_h, pos_t); pos_t = glo_pos(best_epoch, Weeksec, nav_b, obs_h, pos_t);
} }
} }
//Exclude GLONASS
else { else {
pos_t.delta_t = PERS -
station.delta_TR + //Get the approximately transit of signal
pos_t.delta_t = PERS - 0 +
nav_b[best_epoch].sa0 + nav_b[best_epoch].sa0 +
nav_b[best_epoch].sa1 * detat_toc + nav_b[best_epoch].sa1 * detat_toc +
nav_b[best_epoch].sa2 * pow(detat_toc, 2); nav_b[best_epoch].sa2 * pow(detat_toc, 2);
pos_t.deltat = 0.0; pos_t.deltat = 0.0;
//Satellite position calculation
while (fabs(pos_t.delta_t - pos_t.deltat) > 1.0e-9) { while (fabs(pos_t.delta_t - pos_t.deltat) > 1.0e-9) {
pos_t = sat_pos(sPRN, best_epoch, Weeksec, gnsscode, nav_b, obs_h, pos_t); pos_t = sat_pos(sPRN, best_epoch, Weeksec, GNSS, nav_b, obs_h, pos_t);
} }
} }
//Satellite blh position calculation //Satellite blh position calculation
tem1 = XYZ2BLH(tem1, pos_t.X, pos_t.Y, pos_t.Z); tem_blh = xyz2blh(tem_blh, pos_t.X, pos_t.Y, pos_t.Z);
blh.B = rad2deg(tem1.B); in_blh.B = rad2deg(tem_blh.B);
blh.L = rad2deg(tem1.L); in_blh.L = rad2deg(tem_blh.L);
blh.H = tem1.H; in_blh.H = tem_blh.H;
double deltax = pos_t.X - obs_h->apX; double deltax = pos_t.X - obs_h->apX;
double deltay = pos_t.Y - obs_h->apY; double deltay = pos_t.Y - obs_h->apY;
double deltaz = pos_t.Z - obs_h->apZ; double deltaz = pos_t.Z - obs_h->apZ;
tem2 = BLH2ENU(tem2, station.B, station.L, deltax, deltay, deltaz); tem_enu = blh2enu(tem_enu, obs_h->apB, obs_h->apL, deltax, deltay, deltaz);
enu.E = tem2.E; in_enu.E = tem_enu.E;
enu.N = tem2.N; in_enu.N = tem_enu.N;
enu.U = tem2.U; in_enu.U = tem_enu.U;
//Satellite elevation Angle calculation //Satellite elevation Angle calculation
tem3 = RAHCAL(tem3, enu.E, enu.N, enu.U); tem_rah = rahcal(tem_rah, in_enu.E, in_enu.N, in_enu.U);
rah.R = tem3.R; in_rah.R = tem_rah.R;
rah.A = rad2deg(tem3.A); in_rah.A = rad2deg(tem_rah.A);
rah.H = rad2deg(tem3.H); in_rah.H = rad2deg(tem_rah.H);
if (blh.H < 0 || rah.H < 10 || nav_b[best_epoch].sHEA != 0) { if (in_blh.H < 0 || in_rah.H < Hangle || nav_b[best_epoch].sHEA != 0) {
continue; continue;
} }
else { else outputbodydata(obs_h, obs_b, pos_t, in_rah, res_file, sPRN, j, GNSS);
if (SIGN == GPS) {
fprintf(res_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->obs_gps[j][Code2Type(C1, obs_h->obstypenum_gps, obs_h->obscode_gps)]
, obs_b->obs_gps[j][Code2Type(C2, obs_h->obstypenum_gps, obs_h->obscode_gps)]
, rah.H, pos_t.delta_clk);//GPS satellite pos output
}
else if (SIGN == GAL) {
fprintf(res_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->obs_gal[j][Code2Type(C1, obs_h->obstypenum_gal, obs_h->obscode_gal)]
, obs_b->obs_gal[j][Code2Type(C6, obs_h->obstypenum_gal, obs_h->obscode_gal)]
, rah.H, pos_t.delta_clk);//Galileo satellite pos output
}
else if (SIGN == BDS) {
if (sPRN >= 19) {
fprintf(res_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->obs_bds[j][Code2Type(C2, obs_h->obstypenum_bds, obs_h->obscode_bds)]
, obs_b->obs_bds[j][Code2Type(C7, obs_h->obstypenum_bds, obs_h->obscode_bds)]
, rah.H, pos_t.delta_clk);//BDS-3 satellite pos output
}
else {
fprintf(res_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->obs_bds[j][Code2Type(C2, obs_h->obstypenum_bds, obs_h->obscode_bds)]
, obs_b->obs_bds[j][Code2Type(C7, obs_h->obstypenum_bds, obs_h->obscode_bds)]
, rah.H, pos_t.delta_clk);//BDS-2 satellite pos output
}
}
else if (SIGN == GLO) {
fprintf(res_file, "\nR %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->obs_glo[j][Code2Type(C1, obs_h->obstypenum_glo, obs_h->obscode_glo)]
, obs_b->obs_glo[j][Code2Type(C2, obs_h->obstypenum_glo, obs_h->obscode_glo)]
, rah.H, pos_t.delta_clk);//Galileo satellite pos output
}
}
}return 1; }return 1;
} }
/* -------------------------------------------------------------------------- */ /**
/// @brief The entry function of full .dll package, * The entrance of function.
/// @param nav_path The RINEX navigation file's path *
/// @param obs_path The RINEX observation file's path * \param nav_path: The RINEX navigation file's path
/// @param res_path The Satellite output file's path * \param obs_path: The RINEX observation file's path
/// @param gnsscode The GNSS position you want to calculate * \param res_path: The satellite position solution output path
/// @return 0 refer complete solution; -1 refer fail to complete solution * \param GNSS: GNSS code
/// @return > 0 refer partlt complete solution * \return
/* -------------------------------------------------------------------------- */ * -1 ,Can not open the nav file
double brdm2pos(char nav_path[260], char obs_path[260], char res_path[260], int gnsscode) * -2 ,Can not open the obs file
* -3 ,Mismatch version or format of nav
* -4 ,No data of nav
* -5 ,Mismatch version or format of obs
* -6 ,No data of obs
* 0 ,Soulution generated completely
* >0 ,Some epoch cant be calculate
*/
double brdm2pos(char nav_path[MAXPATH], char obs_path[MAXPATH], char res_path[MAXPATH],
int GNSS, int Hangle)
{ {
int satnum, epochunum, result = 0; int satnum, epochnum, result = 0;
pos_ts pos_t = { 0 }; pos_ts pos_t = { 0 };
xyz2blh tem2 = { 0 }; blh apblh = { 0 };
stations station = { 0 };
time_t gen_time; time(&gen_time);
pnav_head nav_h = NULL; pnav_head nav_h = NULL;
pnav_body nav_b = NULL; pnav_body nav_b = NULL;
@@ -337,77 +317,80 @@ double brdm2pos(char nav_path[260], char obs_path[260], char res_path[260], int
pobs_epoch obs_e = NULL; pobs_epoch obs_e = NULL;
FILE* fp_nav = fopen(nav_path, "r"); FILE* fp_nav = fopen(nav_path, "r");
if (fp_nav == NULL) return -1; if (fp_nav == NULL) return -1;//cant read nav file
//Get the amount of satellite
satnum = getsatnum(fp_nav); satnum = getsatnum(fp_nav);
switch (satnum) { switch (satnum) {
case -1: return -3;//mismatch version or format case -1: return -3;//mismatch version or format
case 0: return -4;//no data case 0: return -4;//no data
default: default: break;
break;
} }
rewind(fp_nav); rewind(fp_nav);
nav_h = (pnav_head)malloc(sizeof(nav_head)); nav_h = (pnav_head)malloc(sizeof(nav_head));
nav_b = (pnav_body)malloc(sizeof(nav_body) * (satnum)); nav_b = (pnav_body)malloc(sizeof(nav_body) * (satnum));
if (nav_h && nav_b) {
read_n_h(fp_nav, nav_h); read_n_b(fp_nav, nav_b); if (nav_h && nav_b) { read_n_h(fp_nav, nav_h); read_n_b(fp_nav, nav_b); }
}
fclose(fp_nav); fclose(fp_nav);
FILE* fp_obs = fopen(obs_path, "r"); FILE* fp_obs = fopen(obs_path, "r");
if (fp_obs == NULL) return -2; if (fp_obs == NULL) return -2;//cant read obs file
epochunum = get_epochnum(fp_obs);
switch (epochunum) { //Get the amonut of obs epoch
epochnum = get_epochnum(fp_obs);
switch (epochnum) {
case -1: return -5;//mismatch version or format case -1: return -5;//mismatch version or format
case 0: return -6;//no data case 0: return -6;//no data
default: default: break;
break;
} }
rewind(fp_obs); obs_h = (pobs_head)malloc(sizeof(obs_head));
rewind(fp_obs);
obs_h = (pobs_head)malloc(sizeof(obs_head));
if (obs_h) { if (obs_h) {
//Read the header of obs
read_o_h(fp_obs, obs_h); read_o_h(fp_obs, obs_h);
tem2 = XYZ2BLH(tem2, obs_h->apX, obs_h->apY, obs_h->apZ); //Convert the approximately position (ECEF > LLA)
station.B = tem2.B; station.L = tem2.L; station.H = tem2.H; apblh = xyz2blh(apblh, obs_h->apX, obs_h->apY, obs_h->apZ);
obs_h->apB = apblh.B;
obs_h->apL = apblh.L;
obs_h->apH = apblh.H;
//Out put the header of solution file //Output header of solution
FILE* result_file_clear = fopen(res_path, "w"); FILE* result_file = outputheader(obs_h, obs_path, nav_path, res_path);
fclose(result_file_clear);
FILE* result_file = fopen(res_path, "a+");
fprintf(result_file, "@ GENERATE PROGRAM : KNZ_GeoTrackLab ver1.5.3.1\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_path);
fprintf(result_file, "@ NAV FILE PATH : %s\n", nav_path);
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);
fprintf(result_file, "END OF HEADER\n");
//Begin to calculate //Begin to calculate
for (int i = 0; i < epochunum; i++) { for (int i = 0; i < epochnum; i++) {
//Allocate memory for obs epoch and body data //Allocate memory for obs epoch and body data
obs_e = (pobs_epoch)malloc(sizeof(obs_epoch)); obs_e = (pobs_epoch)malloc(sizeof(obs_epoch));
obs_b = (pobs_body)malloc(sizeof(obs_body)); obs_b = (pobs_body)malloc(sizeof(obs_body));
//Read epoch data
read_o_eb(fp_obs, obs_h, obs_e, obs_b); read_o_eb(fp_obs, obs_h, obs_e, obs_b);
//Calculate the position of satellite
result += sat_pos_cal(obs_h, obs_e, obs_b, nav_b, result += sat_pos_cal(obs_h, obs_e, obs_b, nav_b,
result_file, station, result_file,
gnsscode, satnum); GNSS, satnum, Hangle);
fprintf(result_file, "\n"); fprintf(result_file, "\n");
//Free epoch data
freeobs_e(obs_e, obs_b); freeobs_e(obs_e, obs_b);
} }
free(obs_h); free(nav_h); free(nav_b); //Output the signal of ending
fprintf(result_file, "\nEND"); fclose(result_file); fprintf(result_file, "\nEND"); fclose(result_file);
if (epochunum == result) return 0;
//free nav & obs memory of data
free(obs_h); free(nav_h); free(nav_b);
if (epochnum == result) return 0;
else return epochnum - result;
} }
} }
+103
View File
@@ -0,0 +1,103 @@
#include "brdm2pos.h"
using namespace std;
/*Output the header data of satllite position solution*/
FILE* outputheader(pobs_head obs_h,
char obs_path[MAXPATH], char nav_path[MAXPATH], char res_path[MAXPATH])
{
time_t gen_time;
time(&gen_time);
FILE* result_file_clear = fopen(res_path, "w");
fclose(result_file_clear);
FILE* result_file = fopen(res_path, "a+");
fprintf(result_file, "@ GENERATE PROGRAM : KNZ_GeoTrackLab ver1.5.4.1\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_path);
fprintf(result_file, "@ NAV FILE PATH : %s\n", nav_path);
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
, obs_h->apB, obs_h->apL, obs_h->apH);
fprintf(result_file, "END OF HEADER\n");
return result_file;
}
/*Ion correction by IF-IC*/
static double ionofree(pobs_body obs_b, pobs_head obs_h, int j, int GNSS)
{
double P1=0.0, P2=0.0, freq1=0.0, freq2=0.0;
//Match the code with system
switch (GNSS) {
case GPS:
P1 = obs_b->obs_gps[j][code2type(C1, obs_h->obstypenum_gps, obs_h->obscode_gps)];
P2 = obs_b->obs_gps[j][code2type(C2, obs_h->obstypenum_gps, obs_h->obscode_gps)];
freq1 = FREQ1; freq2 = FREQ2;
break;
case BDS:
P1 = obs_b->obs_bds[j][code2type(C2, obs_h->obstypenum_bds, obs_h->obscode_bds)];
P2 = obs_b->obs_bds[j][code2type(C7, obs_h->obstypenum_bds, obs_h->obscode_bds)];
freq1 = FREQ1_BDS; freq2 = FREQ2_BDS;
break;
case GAL:
P1 = obs_b->obs_gal[j][code2type(C1, obs_h->obstypenum_gal, obs_h->obscode_gal)];
P2 = obs_b->obs_gal[j][code2type(C5, obs_h->obstypenum_gal, obs_h->obscode_gal)];
freq1 = FREQ1; freq2 = FREQ6;
break;
case GLO:
P1 = obs_b->obs_glo[j][code2type(C1, obs_h->obstypenum_glo, obs_h->obscode_glo)];
P2 = obs_b->obs_glo[j][code2type(C2, obs_h->obstypenum_glo, obs_h->obscode_glo)];
freq1 = FREQ1_GLO; freq2 = FREQ2_GLO;
break;
}
//IF-IC
if (P1 != 0.0 && P2 != 0.0) {
P1 = (pow(freq1, 2) * P1) / (pow(freq1, 2) - pow(freq2, 2))
- (pow(freq2, 2) * P2) / (pow(freq1, 2) - pow(freq2, 2));
return P1;
}
if (P1 == 0.0 || P2 == 0.0) {
if (P1 == 0.0 && P2 != 0.0) return P2;
if (P1 != 0.0 && P2 == 0.0) return P1;
return 0.0;
}
}
/*Output the satellite solution data*/
void outputbodydata(pobs_head obs_h, pobs_body obs_b,
pos_ts pos_t, rah in_rah, FILE* res_file,
int sPRN, int j, int GNSS)
{
double P = ionofree(obs_b, obs_h, j, GNSS);
if (P == 0) return;
switch (GNSS) {
case GPS:
fprintf(res_file, "\nG %02d| %15.05f %15.05f %15.05f %15.05f %15.05f %16.13f"
, sPRN, pos_t.X, pos_t.Y, pos_t.Z
, P, in_rah.H, pos_t.delta_clk);
break;
case BDS:
if (sPRN <= 5 || sPRN >= 59) break;
else;
fprintf(res_file, "\nC %02d| %15.05f %15.05f %15.05f %15.05f %15.05f %16.13f"
, sPRN, pos_t.X, pos_t.Y, pos_t.Z
, P, in_rah.H, pos_t.delta_clk);
break;
case GAL:
fprintf(res_file, "\nE %02d| %15.05f %15.05f %15.05f %15.05f %15.05f %16.13f"
, sPRN, pos_t.X, pos_t.Y, pos_t.Z
, P, in_rah.H, pos_t.delta_clk);
break;
case GLO:
fprintf(res_file, "\nR %02d| %15.05f %15.05f %15.05f %15.05f %15.05f %16.13f"
, sPRN, pos_t.X, pos_t.Y, pos_t.Z
, P, in_rah.H, pos_t.delta_clk);
break;
}
}
+28 -10
View File
@@ -1,15 +1,16 @@
#include "brdm2pos.h" #include "brdm2pos.h"
using namespace std; using namespace std;
/* -------------------------------------------------------------------------- */ /**
/// @brief convert UTC to GPS Second of week * Convert Time format to GPS second of week.
/// @param y year *
/// @param m month * \param y: Year of
/// @param d day * \param m: Month of
/// @param h hour * \param d: Day of
/// @param min minute * \param h: Hour of
/// @param sec second * \param min: Minute of
/// @return return GPS Second of week * \param sec: Second of
/* -------------------------------------------------------------------------- */ * \return GPS: Second of week
*/
double Time2GPST(int y, int m, int d, double h, int min, double sec) double Time2GPST(int y, int m, int d, double h, int min, double sec)
{ {
if (m > 2) if (m > 2)
@@ -31,6 +32,12 @@ double Time2GPST(int y, int m, int d, double h, int min, double sec)
double secofweek = (MJD - 44244.0 - gpsweek * 7.0) * 86400.0; double secofweek = (MJD - 44244.0 - gpsweek * 7.0) * 86400.0;
return secofweek; return secofweek;
} }
/**
* Convert UTC(SU) time to GPS second of week.
*
* \param JD_UTCSU: JD of UTC(SU) time
* \return GPS: Second of week
*/
double JDUTC2GPST(double JD_UTCSU) double JDUTC2GPST(double JD_UTCSU)
{ {
double n;//Leap second double n;//Leap second
@@ -48,6 +55,17 @@ double JDUTC2GPST(double JD_UTCSU)
double secofweek = (MJD - 44244.0 - gpsweek * 7.0) * 86400.0; double secofweek = (MJD - 44244.0 - gpsweek * 7.0) * 86400.0;
return secofweek; return secofweek;
} }
/**
* Convert UTC time to JD format.
*
* \param y: Year of UTC time
* \param m: Month of UTC time
* \param d: Day of UTC time
* \param h: Hour of UTC time
* \param min: Minute of UTC time
* \param sec: Second of UTC time
* \return JD:
*/
double UTCTime2JD(int y, int m, int d, double h, int min, double sec) double UTCTime2JD(int y, int m, int d, double h, int min, double sec)
{ {
if (m > 2) if (m > 2)