fix some bugs

This commit is contained in:
KenanZhu111 committed 2024-11-08 16:39:42 +08:00
1 parent 80e29d68c7
commit fc181301c7
10 files changed
+109 -88

No files matched your search

+4 -1
View File
@@ -32,7 +32,10 @@ Support method of orientation
* As of October 5, 2024, Matlab project will no longer be considered.[ADIN 2024/10/5] * As of October 5, 2024, Matlab project will no longer be considered.[ADIN 2024/10/5]
## Project Update ## Project Update
Update: 2024/11/03: Update: 2024/11/08:
1. KNZ_GeoTrackLab: Fix some bug。
Update: 2024/11/05:
1. KNZ_GeoTrackLab: Fix some bug, Optimize UI logic。 1. KNZ_GeoTrackLab: Fix some bug, Optimize UI logic。
2. KNZ_GeoTrackLab: New added function of save and change 2. KNZ_GeoTrackLab: New added function of save and change
file for View. file for View.
+3
View File
@@ -32,6 +32,9 @@
* 自 2024 年 10 月 5 日起,Matlab 项目将不再考虑。[ADIN 2024/10/5] * 自 2024 年 10 月 5 日起,Matlab 项目将不再考虑。[ADIN 2024/10/5]
## 项目更新 ## 项目更新
更新:2024/11/08:
1. KNZ_GeoTrackLab: 修复一些bug。
更新:2024/11/05: 更新:2024/11/05:
1. KNZ_GeoTrackLab: 修复一些bug, 优化UI逻辑。 1. KNZ_GeoTrackLab: 修复一些bug, 优化UI逻辑。
2. KNZ_GeoTrackLab: 为View文本编辑器增添保存修改功能。 2. KNZ_GeoTrackLab: 为View文本编辑器增添保存修改功能。
+72 -63
View File
@@ -391,13 +391,19 @@ class CALLBACK:
# Brief : Plot by open ksln as pos solution. # Brief : Plot by open ksln as pos solution.
# Author: @KenanZhu All Right Reserved. # Author: @KenanZhu All Right Reserved.
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
system = self.system.get(int(self.cfg_get['Options_Calc']['sat_system']))
path = filedialog.askopenfilename(title='Open as Pos Solution', path = filedialog.askopenfilename(title='Open as Pos Solution',
filetypes=[('Solution File(*.ksln)', '*.ksln'), filetypes=[('Solution File(*.ksln)', '*.ksln'),
('All Files', '*.*')]) ('All Files', '*.*')])
if not path: return if not path: return
if not path.find('.ksln'):
plotstate.config(text='Error : Unsupported format !')
return
with open(path,'r')as f: with open(path,'r')as f:
while 1: while 1:
line = f.readline() line = f.readline()
if not line: return
if line.find('APPROX POSITION XYZ')>=0: if line.find('APPROX POSITION XYZ')>=0:
apx = float(line[22:35]) apx = float(line[22:35])
apy = float(line[35:48]) apy = float(line[35:48])
@@ -416,23 +422,24 @@ class CALLBACK:
elif line.find('<END OF HEADER')>=0: elif line.find('<END OF HEADER')>=0:
plotstate.config(text="Reading...") plotstate.config(text="Reading...")
break break
satnum = 0 satnum = 0
ENU = np.empty((3,0)) ENU = np.empty((3,0))
EPO = np.empty((1,0)) EPO = np.empty((1,0))
NUM = np.empty((1,0)) NUM = np.empty((1,0))
while 1: while 1:
line = f.readline() line = f.readline()
if not line: return
if line[0:1]=='>': if line[0:1]=='>':
satnum = 0 satnum = 0
EPO = np.hstack((EPO,[[float(line[1:6])]])) EPO = np.hstack((EPO,[[float(line[1:6])]]))
plotstate.config(text='Reading...%5d/%5d Mode: Single solving' plotstate.config(text='Reading...%5d/%5d Mode: Single solving'
%(int(line[1:6]), int(86400/ive))) %(int(line[1:6]), int(86400/ive)))
elif line[0:1]==self.system.get(int( elif line[0:1]==system:
self.cfg_get['Options_Calc']['sat_system'] if not line.find('END')==-1: pass
)) and line.find('END')==-1 and line.find('Rec')==-1: elif not line.find('Rec')==-1: pass
satnum += 1 else:
satnum += 1
elif line.find('Rec:')>=0: elif line.find('Rec:')>=0:
if line.find('insufficient')>=0: if line.find('insufficient')>=0:
@@ -449,7 +456,7 @@ class CALLBACK:
]) ])
ENU = np.hstack((ENU,S@ds)) ENU = np.hstack((ENU,S@ds))
NUM = np.hstack((NUM,[[satnum]])) NUM = np.hstack((NUM,[[satnum]]))
elif line.find('END')>=0: if line.find('END')>=0:
# plot on the e # plot on the e
# ------------------------------------------------------------------- # -------------------------------------------------------------------
explot.clear() explot.clear()
@@ -509,7 +516,6 @@ class CALLBACK:
satnplot.set_title('Valid Satellite Numbers', loc='left', fontsize=8) satnplot.set_title('Valid Satellite Numbers', loc='left', fontsize=8)
satnplot.set_xlabel('Epochs') satnplot.set_xlabel('Epochs')
satnplot.grid(True, linestyle='--', alpha=0.7) satnplot.grid(True, linestyle='--', alpha=0.7)
canvas1.draw() canvas1.draw()
f.close() f.close()
@@ -545,20 +551,18 @@ class CALLBACK:
filetypes=[('Solution File(*.ssln)', '*.ssln'), filetypes=[('Solution File(*.ssln)', '*.ssln'),
('All Files', '*.*')]) ('All Files', '*.*')])
if not path: return if not path: return
sattrack.clear() if not path.find('.ssln')>=0:
plotstate.config(text="Error : Unsupported format !")
sattrack.coastlines(resolution='110m') return
sattrack.gridlines()
with open(path,'r') as f: with open(path,'r') as f:
while 1: while 1:
line = f.readline() line = f.readline()
if not line: return
if line.find('APPROX POSITION BLH')>=0: if line.find('APPROX POSITION BLH')>=0:
sattrack.clear()
apb = math.degrees( float(line[22:35]) ) apb = math.degrees( float(line[22:35]) )
apl = math.degrees( float(line[35:48]) ) apl = math.degrees( float(line[35:48]) )
plotstate.config(text="Plotting...") plotstate.config(text="Plotting...")
sattrack.scatter( sattrack.scatter(
apl, apl,
apb, apb,
@@ -576,63 +580,68 @@ class CALLBACK:
transform=ccrs.PlateCarree() transform=ccrs.PlateCarree()
) )
canvas2.draw() canvas2.draw()
elif line.find('GENERATE SOURCE')>=0: elif line.find('GENERATE SOURCE')>=0:
marker = line[22:26] marker = line[22:26]
elif line.find('TIME OF FIRST OBS')>=0:
yea = int(line[22:26])
mon = int(line[27:29])
day = int(line[30:32])
hou = int(line[33:35])
min = int(line[36:38])
sec = float(line[39:46])
elif line.find('INTERVAL')>=0: elif line.find('INTERVAL')>=0:
ive = float(line[22:27]) ive = float(line[22:27])
elif line.find('<END OF HEADER')>=0: elif line.find('<END OF HEADER')>=0:
sattrack.coastlines(resolution='110m')
sattrack.gridlines(draw_labels=True, dms=True, x_inline=False, y_inline=False)
sattrack.set_title('Ground Track of %s%02d (GPST: %04d/%02d/%02d/%02d/%02d/%7.04f)'
%(system,satprn,yea,mon,day,hou,min,sec),
loc='left',fontsize=14,weight='bold')
break break
epoch = 0
while 1: while 1:
line =f.readline() line = f.readline()
if line[0:1]==blank: if not line: break
pass if line.find('END')>=0: break
if not str(line[ 0: 1])==system: continue
if not int(line[ 1: 3])==satprn: continue
if not int(line[41:46])%anirat==0: continue
plotstate.config(text="Reading...%5d/%5d Mode: Sat track plot"
% (int(line[41:46]), int(86400 / ive)))
# Judge twice
if not int(line[ 1: 3])==satprn:break
b = math.degrees( float(line[ 4:13]) )
l = math.degrees( float(line[14:23]) )
sattrack.scatter(
l,
b,
color='b',
s=2,
transform=ccrs.PlateCarree()
)
canvas2.draw()
elif line[0:1]==system and line.find('END')==-1 and line.find('Rec')==-1: text = sattrack.text(
epoch = int(line[41:46]) l,
plotstate.config(text="Reading...%5d/%5d Mode: Sat track plot" b,
% (int(line[41:46]), int(86400 / ive))) 4*blank+system+'%02d'%satprn,
color='k',
if int(line[1:3])==satprn and epoch%anirat==0: fontsize=10,
b = math.degrees( float(line[ 4:13]) ) fontweight='bold',
l = math.degrees( float(line[14:23]) ) transform=ccrs.PlateCarree()
sattrack.scatter( )
l, point = sattrack.scatter(
b, l,
color='b', b,
s=2, color='b',
transform=ccrs.PlateCarree() s=10,
) transform=ccrs.PlateCarree()
canvas2.draw() )
text = sattrack.text( canvas2.draw()
l, text.remove()
b, point.remove()
4*blank+system+'%02d'%satprn, plotstate.config(text="Done ! Track plot form: sys=%s sat=%2d interval=%2d"
color='k', % (system, satprn, anirat))
fontsize=10, return
fontweight='bold',
transform=ccrs.PlateCarree()
)
point = sattrack.scatter(
l,
b,
color='b',
s=10,
transform=ccrs.PlateCarree()
)
canvas2.draw()
text.remove()
point.remove()
else:
pass
elif line.find('END')>=0:
plotstate.config(text="Done ! Track plot form: sys=%s sat=%2d interval=%2d"
%(system, satprn, anirat))
def _Plot2polar(self, sattrack, plotstate, canvas2): def _Plot2polar(self, sattrack, plotstate, canvas2):
T = threading.Thread( T = threading.Thread(
+3 -4
View File
@@ -30,7 +30,7 @@ from matplotlib.backends.backend_tkagg import (
import tkinter as tk import tkinter as tk
import tkinter.font as tkfont import tkinter.font as tkfont
import cartopy.crs as ccrs import cartopy.crs as ccrs
#import cartopy.feature as cfeature import cartopy.io.shapereader as shp
import matplotlib as mpl import matplotlib as mpl
mpl.use('TkAgg') mpl.use('TkAgg')
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
@@ -63,7 +63,6 @@ def _instanceABO(hwndparemt, cfg_get_, func_):
T = threading.Thread(target=lambda :instanceABO(hwndparemt, cfg_get_, func_)) T = threading.Thread(target=lambda :instanceABO(hwndparemt, cfg_get_, func_))
T.start() T.start()
# noinspection PyUnusedLocal,PyProtectedMember # noinspection PyUnusedLocal,PyProtectedMember
class MAINGUI: class MAINGUI:
def __init__(self, hwnd_, func_): def __init__(self, hwnd_, func_):
@@ -395,9 +394,9 @@ class MAINGUI:
self.sattrack.gridlines() self.sattrack.gridlines()
fig.subplots_adjust( fig.subplots_adjust(
left=0, left=0,
bottom=0.03, bottom=0.045,
right=1, right=1,
top=0.95 top=0.90
) )
for spine in ['right', 'left']: for spine in ['right', 'left']:
self.sattrack.spines[spine].set_visible(False) self.sattrack.spines[spine].set_visible(False)
Binary file not shown.
Binary file not shown.
+11
View File
@@ -108,6 +108,17 @@
#define GLO 04 #define GLO 04
#define SBAS 05 #define SBAS 05
#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
#define TIMEGAP_GPS 7200.0
#define TIMEGAP_BDS 3600.0
#define TIMEGAP_GAL 600.0
#define TIMEGAP_GLO 1800.0
#define MAXRINEX 4096 /* Max length of line of rinex file */ #define MAXRINEX 4096 /* Max length of line of rinex file */
#define MAXPATH 260 /* Max length of file path */ #define MAXPATH 260 /* Max length of file path */
+3 -6
View File
@@ -1,10 +1,4 @@
#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;
/** /**
* Find the nearest obs epoch with boardcast. * Find the nearest obs epoch with boardcast.
@@ -296,6 +290,7 @@ void read_n_b(FILE* fp_nav, pnav_body nav_b)
case 0: case 0:
nav_b[i_g].sPRN_BDS = -1; nav_b[i_g].sPRN_BDS = -1;
nav_b[i_g].sPRN_GAL = -1; nav_b[i_g].sPRN_GAL = -1;
nav_b[i_g].sPRN_GLO = -1;
nav_b[i_g].sPRN_GPS = (int)strtonum(buff, 1, 2); 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_Y = (int)strtonum(buff, 4, 4);
nav_b[i_g].TOC_M = (int)strtonum(buff, 9, 2); nav_b[i_g].TOC_M = (int)strtonum(buff, 9, 2);
@@ -368,6 +363,7 @@ void read_n_b(FILE* fp_nav, pnav_body nav_b)
case 0: case 0:
nav_b[i_g].sPRN_GPS = -1; nav_b[i_g].sPRN_GPS = -1;
nav_b[i_g].sPRN_GAL = -1; nav_b[i_g].sPRN_GAL = -1;
nav_b[i_g].sPRN_GLO = -1;
nav_b[i_g].sPRN_BDS = (int)strtonum(buff, 1, 2); 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_Y = (int)strtonum(buff, 4, 4);
nav_b[i_g].TOC_M = (int)strtonum(buff, 9, 2); nav_b[i_g].TOC_M = (int)strtonum(buff, 9, 2);
@@ -440,6 +436,7 @@ void read_n_b(FILE* fp_nav, pnav_body nav_b)
case 0: case 0:
nav_b[i_g].sPRN_BDS = -1; nav_b[i_g].sPRN_BDS = -1;
nav_b[i_g].sPRN_GPS = -1; nav_b[i_g].sPRN_GPS = -1;
nav_b[i_g].sPRN_GLO = -1;
nav_b[i_g].sPRN_GAL = (int)strtonum(buff, 1, 2); 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_Y = (int)strtonum(buff, 4, 4);
nav_b[i_g].TOC_M = (int)strtonum(buff, 9, 2); nav_b[i_g].TOC_M = (int)strtonum(buff, 9, 2);
+11 -11
View File
@@ -336,7 +336,7 @@ int sat_pos_cal(pobs_head obs_h, pobs_epoch obs_e, pobs_body obs_b,
int sat_cal(pnav_body nav_b, pobs_head obs_h, FILE* solu,int satnum, int GNSS) { int sat_cal(pnav_body nav_b, pobs_head obs_h, FILE* solu,int satnum, int GNSS) {
int ii, i, sPRN=0; int ii, i, sPRN=0;
double Min, min, Weeksec=0, Beginsec, STOP; double Min, min, Weeksec=0, Beginsec, STOP=0;
pos_ts pos = { 0 }; pos_ts pos = { 0 };
blh in_blh = { 0 }; blh in_blh = { 0 };
@@ -357,36 +357,36 @@ int sat_cal(pnav_body nav_b, pobs_head obs_h, FILE* solu,int satnum, int GNSS) {
Weeksec = Weeksec =
fabs(sPRN - nav_b[i].sPRN_GPS) > 0 ? Beginsec : Weeksec; fabs(sPRN - nav_b[i].sPRN_GPS) > 0 ? Beginsec : Weeksec;
sPRN = nav_b[i].sPRN_GPS; sPRN = nav_b[i].sPRN_GPS;
STOP = 3600.0; STOP = TIMEGAP_GPS/2;
break; break;
case BDS:if (nav_b[i].sPRN_BDS == -1) { continue; } case BDS:if (nav_b[i].sPRN_BDS == -1) { continue; }
Weeksec = Weeksec =
fabs(sPRN - nav_b[i].sPRN_BDS) > 0 ? Beginsec : Weeksec; fabs(sPRN - nav_b[i].sPRN_BDS) > 0 ? Beginsec : Weeksec;
sPRN = nav_b[i].sPRN_BDS; sPRN = nav_b[i].sPRN_BDS;
STOP = 1800.0; STOP = TIMEGAP_BDS/2;
break; break;
case GAL:if (nav_b[i].sPRN_GAL == -1) { continue; } case GAL:if (nav_b[i].sPRN_GAL == -1) { continue; }
Weeksec = Weeksec =
fabs(sPRN - nav_b[i].sPRN_GAL) > 0 ? Beginsec : Weeksec; fabs(sPRN - nav_b[i].sPRN_GAL) > 0 ? Beginsec : Weeksec;
sPRN = nav_b[i].sPRN_GAL; sPRN = nav_b[i].sPRN_GAL;
STOP = 300.0; STOP = TIMEGAP_GAL/2;
break; break;
case GLO:if (nav_b[i].sPRN_GLO == -1) { continue; } case GLO:if (nav_b[i].sPRN_GLO == -1) { continue; }
Weeksec = Weeksec =
fabs(sPRN - nav_b[i].sPRN_GLO) > 0 ? Beginsec : Weeksec; fabs(sPRN - nav_b[i].sPRN_GLO) > 0 ? Beginsec : Weeksec;
sPRN = nav_b[i].sPRN_GLO; sPRN = nav_b[i].sPRN_GLO;
STOP = 900.0; STOP = TIMEGAP_GLO/2+18;
break; break;
} }
for (Weeksec; fabs(Weeksec - nav_b[i].TOE) <= STOP; Weeksec += 30.0) {
if (Weeksec - Beginsec >= DAYSEC) break;
else if (Weeksec - Beginsec >= DAYSEC - STOP) STOP += STOP;
if (GNSS != GLO) pos = sat_pos(sPRN, i, Weeksec, GNSS, nav_b, obs_h, pos);
else if (GNSS == GLO) pos = glo_pos(i, Weeksec, nav_b, obs_h, pos);
for (Weeksec; fabs(Weeksec-nav_b[i].TOE)<=3600.0; Weeksec += 30.0) {
if (Weeksec - Beginsec == 86400.0) {
break;
}
pos = sat_pos(sPRN, i, Weeksec, GNSS, nav_b, obs_h, pos);
in_blh = xyz2blh(in_blh, pos.X, pos.Y, pos.Z); in_blh = xyz2blh(in_blh, pos.X, pos.Y, pos.Z);
outdata(in_blh, solu, sPRN, GNSS); outdata(in_blh, solu, sPRN, GNSS);
fprintf(solu, ">>%05d", (int)(Weeksec-Beginsec)/30+1); fprintf(solu, ">>%05d", (int)(Weeksec - Beginsec) / 30 + 1);
} }
}return 0; }return 0;
} }
+2 -3
View File
@@ -169,9 +169,8 @@ FILE* headerout(pobs_head obs_h, int mode,
FILE* result_file = fopen(res_path, "a+"); FILE* result_file = fopen(res_path, "a+");
fprintf(result_file, ">GENERATE PROGRAM : KNZ_GeoTrackLab ver%s\n", KNZ_GTL_VER); fprintf(result_file, ">GENERATE PROGRAM : KNZ_GeoTrackLab ver%s\n", KNZ_GTL_VER);
fprintf(result_file, " GENERATE SOURCE : %.10s\n", obs_h->marker); fprintf(result_file, " GENERATE SOURCE : %.10s\n", obs_h->marker);
if (mode == 0); fprintf(result_file, " GENERATE TYPE : Position Resolve\n");
if (mode != 1); fprintf(result_file, " GENERATE TYPE : Position Resolve\n"); if (mode == 1); fprintf(result_file, " GENERATE TYPE : Satellite Position\n");
if (mode == 0); fprintf(result_file, " GENERATE TYPE : Satellite Position\n");
fprintf(result_file, " GENERATE TIME : %s", ctime(&gen_time)); fprintf(result_file, " GENERATE TIME : %s", ctime(&gen_time));
fprintf(result_file, " OBS FILE PATH : %s\n", obs_path); fprintf(result_file, " OBS FILE PATH : %s\n", obs_path);
fprintf(result_file, " NAV FILE PATH : %s\n", nav_path); fprintf(result_file, " NAV FILE PATH : %s\n", nav_path);