diff --git a/README.md b/README.md index 40669aa..dceec75 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,10 @@ Support method of orientation * As of October 5, 2024, Matlab project will no longer be considered.[ADIN 2024/10/5] ## 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。 2. KNZ_GeoTrackLab: New added function of save and change file for View. diff --git a/READMECN.md b/READMECN.md index 7c9f33a..ae2421a 100644 --- a/READMECN.md +++ b/READMECN.md @@ -32,6 +32,9 @@ * 自 2024 年 10 月 5 日起,Matlab 项目将不再考虑。[ADIN 2024/10/5] ## 项目更新 +更新:2024/11/08: +1. KNZ_GeoTrackLab: 修复一些bug。 + 更新:2024/11/05: 1. KNZ_GeoTrackLab: 修复一些bug, 优化UI逻辑。 2. KNZ_GeoTrackLab: 为View文本编辑器增添保存修改功能。 diff --git a/app/Func_callback.py b/app/Func_callback.py index cef5f4a..27a3cc9 100644 --- a/app/Func_callback.py +++ b/app/Func_callback.py @@ -391,13 +391,19 @@ class CALLBACK: # Brief : Plot by open ksln as pos solution. # 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', filetypes=[('Solution File(*.ksln)', '*.ksln'), ('All Files', '*.*')]) if not path: return + if not path.find('.ksln'): + plotstate.config(text='Error : Unsupported format !') + return with open(path,'r')as f: while 1: line = f.readline() + if not line: return if line.find('APPROX POSITION XYZ')>=0: apx = float(line[22:35]) apy = float(line[35:48]) @@ -416,23 +422,24 @@ class CALLBACK: elif line.find('=0: plotstate.config(text="Reading...") break - satnum = 0 ENU = np.empty((3,0)) EPO = np.empty((1,0)) NUM = np.empty((1,0)) while 1: line = f.readline() + if not line: return if line[0:1]=='>': satnum = 0 EPO = np.hstack((EPO,[[float(line[1:6])]])) plotstate.config(text='Reading...%5d/%5d Mode: Single solving' %(int(line[1:6]), int(86400/ive))) - elif line[0:1]==self.system.get(int( - self.cfg_get['Options_Calc']['sat_system'] - )) and line.find('END')==-1 and line.find('Rec')==-1: - satnum += 1 + elif line[0:1]==system: + if not line.find('END')==-1: pass + elif not line.find('Rec')==-1: pass + else: + satnum += 1 elif line.find('Rec:')>=0: if line.find('insufficient')>=0: @@ -449,7 +456,7 @@ class CALLBACK: ]) ENU = np.hstack((ENU,S@ds)) NUM = np.hstack((NUM,[[satnum]])) - elif line.find('END')>=0: + if line.find('END')>=0: # plot on the e # ------------------------------------------------------------------- explot.clear() @@ -509,7 +516,6 @@ class CALLBACK: satnplot.set_title('Valid Satellite Numbers', loc='left', fontsize=8) satnplot.set_xlabel('Epochs') satnplot.grid(True, linestyle='--', alpha=0.7) - canvas1.draw() f.close() @@ -545,20 +551,18 @@ class CALLBACK: filetypes=[('Solution File(*.ssln)', '*.ssln'), ('All Files', '*.*')]) if not path: return - sattrack.clear() - - sattrack.coastlines(resolution='110m') - sattrack.gridlines() - + if not path.find('.ssln')>=0: + plotstate.config(text="Error : Unsupported format !") + return with open(path,'r') as f: while 1: line = f.readline() - + if not line: return if line.find('APPROX POSITION BLH')>=0: + sattrack.clear() apb = math.degrees( float(line[22:35]) ) apl = math.degrees( float(line[35:48]) ) plotstate.config(text="Plotting...") - sattrack.scatter( apl, apb, @@ -576,63 +580,68 @@ class CALLBACK: transform=ccrs.PlateCarree() ) canvas2.draw() - elif line.find('GENERATE SOURCE')>=0: 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: ive = float(line[22:27]) - elif line.find('=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 - - epoch = 0 while 1: - line =f.readline() - if line[0:1]==blank: - pass - - elif line[0:1]==system and line.find('END')==-1 and line.find('Rec')==-1: - epoch = int(line[41:46]) - plotstate.config(text="Reading...%5d/%5d Mode: Sat track plot" - % (int(line[41:46]), int(86400 / ive))) - - if int(line[1:3])==satprn and epoch%anirat==0: - 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() - text = sattrack.text( - l, - b, - 4*blank+system+'%02d'%satprn, - color='k', - fontsize=10, - 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)) + line = f.readline() + if not line: break + 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() + + text = sattrack.text( + l, + b, + 4*blank+system+'%02d'%satprn, + color='k', + fontsize=10, + fontweight='bold', + transform=ccrs.PlateCarree() + ) + point = sattrack.scatter( + l, + b, + color='b', + s=10, + transform=ccrs.PlateCarree() + ) + canvas2.draw() + text.remove() + point.remove() + plotstate.config(text="Done ! Track plot form: sys=%s sat=%2d interval=%2d" + % (system, satprn, anirat)) + return def _Plot2polar(self, sattrack, plotstate, canvas2): T = threading.Thread( diff --git a/app/Ui_main.py b/app/Ui_main.py index fc9561a..dbf8c2f 100644 --- a/app/Ui_main.py +++ b/app/Ui_main.py @@ -30,7 +30,7 @@ from matplotlib.backends.backend_tkagg import ( import tkinter as tk import tkinter.font as tkfont import cartopy.crs as ccrs -#import cartopy.feature as cfeature +import cartopy.io.shapereader as shp import matplotlib as mpl mpl.use('TkAgg') 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.start() - # noinspection PyUnusedLocal,PyProtectedMember class MAINGUI: def __init__(self, hwnd_, func_): @@ -395,9 +394,9 @@ class MAINGUI: self.sattrack.gridlines() fig.subplots_adjust( left=0, - bottom=0.03, + bottom=0.045, right=1, - top=0.95 + top=0.90 ) for spine in ['right', 'left']: self.sattrack.spines[spine].set_visible(False) diff --git a/doc/KNZ_GeoTrackLab ver 1.5.1.docx b/doc/KNZ_GeoTrackLab ver 1.5.1.docx index 5f4d172..0631a9a 100644 Binary files a/doc/KNZ_GeoTrackLab ver 1.5.1.docx and b/doc/KNZ_GeoTrackLab ver 1.5.1.docx differ diff --git a/doc/KNZ_GeoTrackLab ver 1.5.5.0.docx b/doc/KNZ_GeoTrackLab ver 1.5.5.0.docx new file mode 100644 index 0000000..47ce4d3 Binary files /dev/null and b/doc/KNZ_GeoTrackLab ver 1.5.5.0.docx differ diff --git a/src/brdm2pos.h b/src/brdm2pos.h index 550a8db..1bd75ed 100644 --- a/src/brdm2pos.h +++ b/src/brdm2pos.h @@ -108,6 +108,17 @@ #define GLO 04 #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 MAXPATH 260 /* Max length of file path */ diff --git a/src/readrnx.cpp b/src/readrnx.cpp index e04dc02..2c53c75 100644 --- a/src/readrnx.cpp +++ b/src/readrnx.cpp @@ -1,10 +1,4 @@ #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; /** * Find the nearest obs epoch with boardcast. @@ -296,6 +290,7 @@ void read_n_b(FILE* fp_nav, pnav_body nav_b) case 0: nav_b[i_g].sPRN_BDS = -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].TOC_Y = (int)strtonum(buff, 4, 4); 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: nav_b[i_g].sPRN_GPS = -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].TOC_Y = (int)strtonum(buff, 4, 4); 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: nav_b[i_g].sPRN_BDS = -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].TOC_Y = (int)strtonum(buff, 4, 4); nav_b[i_g].TOC_M = (int)strtonum(buff, 9, 2); diff --git a/src/rnx2pos.cpp b/src/rnx2pos.cpp index 86cdafe..c765224 100644 --- a/src/rnx2pos.cpp +++ b/src/rnx2pos.cpp @@ -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 ii, i, sPRN=0; - double Min, min, Weeksec=0, Beginsec, STOP; + double Min, min, Weeksec=0, Beginsec, STOP=0; pos_ts pos = { 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 = fabs(sPRN - nav_b[i].sPRN_GPS) > 0 ? Beginsec : Weeksec; sPRN = nav_b[i].sPRN_GPS; - STOP = 3600.0; + STOP = TIMEGAP_GPS/2; break; case BDS:if (nav_b[i].sPRN_BDS == -1) { continue; } Weeksec = fabs(sPRN - nav_b[i].sPRN_BDS) > 0 ? Beginsec : Weeksec; sPRN = nav_b[i].sPRN_BDS; - STOP = 1800.0; + STOP = TIMEGAP_BDS/2; break; case GAL:if (nav_b[i].sPRN_GAL == -1) { continue; } Weeksec = fabs(sPRN - nav_b[i].sPRN_GAL) > 0 ? Beginsec : Weeksec; sPRN = nav_b[i].sPRN_GAL; - STOP = 300.0; + STOP = TIMEGAP_GAL/2; break; case GLO:if (nav_b[i].sPRN_GLO == -1) { continue; } Weeksec = fabs(sPRN - nav_b[i].sPRN_GLO) > 0 ? Beginsec : Weeksec; sPRN = nav_b[i].sPRN_GLO; - STOP = 900.0; + STOP = TIMEGAP_GLO/2+18; 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); outdata(in_blh, solu, sPRN, GNSS); - fprintf(solu, ">>%05d", (int)(Weeksec-Beginsec)/30+1); + fprintf(solu, ">>%05d", (int)(Weeksec - Beginsec) / 30 + 1); } }return 0; } diff --git a/src/solutions.cpp b/src/solutions.cpp index 544759e..efe97f1 100644 --- a/src/solutions.cpp +++ b/src/solutions.cpp @@ -169,9 +169,8 @@ FILE* headerout(pobs_head obs_h, int mode, FILE* result_file = fopen(res_path, "a+"); fprintf(result_file, ">GENERATE PROGRAM : KNZ_GeoTrackLab ver%s\n", KNZ_GTL_VER); fprintf(result_file, " GENERATE SOURCE : %.10s\n", obs_h->marker); - - if (mode != 1); fprintf(result_file, " GENERATE TYPE : Position Resolve\n"); - if (mode == 0); fprintf(result_file, " GENERATE TYPE : Satellite Position\n"); + if (mode == 0); fprintf(result_file, " GENERATE TYPE : Position Resolve\n"); + if (mode == 1); 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);