Browse Source

change tool_calcgps, not complete.

yuchuli 1 year ago
parent
commit
997e6b3d62

+ 74 - 0
src/tool/tool_calcgps/.gitignore

@@ -0,0 +1,74 @@
+# This file is used to ignore files which are generated
+# ----------------------------------------------------------------------------
+
+*~
+*.autosave
+*.a
+*.core
+*.moc
+*.o
+*.obj
+*.orig
+*.rej
+*.so
+*.so.*
+*_pch.h.cpp
+*_resource.rc
+*.qm
+.#*
+*.*#
+core
+!core/
+tags
+.DS_Store
+.directory
+*.debug
+Makefile*
+*.prl
+*.app
+moc_*.cpp
+ui_*.h
+qrc_*.cpp
+Thumbs.db
+*.res
+*.rc
+/.qmake.cache
+/.qmake.stash
+
+# qtcreator generated files
+*.pro.user*
+CMakeLists.txt.user*
+
+# xemacs temporary files
+*.flc
+
+# Vim temporary files
+.*.swp
+
+# Visual Studio generated files
+*.ib_pdb_index
+*.idb
+*.ilk
+*.pdb
+*.sln
+*.suo
+*.vcproj
+*vcproj.*.*.user
+*.ncb
+*.sdf
+*.opensdf
+*.vcxproj
+*vcxproj.*
+
+# MinGW generated files
+*.Debug
+*.Release
+
+# Python byte code
+*.pyc
+
+# Binaries
+# --------
+*.dll
+*.exe
+

+ 11 - 0
src/tool/tool_calcgps/main.cpp

@@ -0,0 +1,11 @@
+#include "mainwindow.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+    QApplication a(argc, argv);
+    MainWindow w;
+    w.show();
+    return a.exec();
+}

+ 85 - 0
src/tool/tool_calcgps/mainwindow.cpp

@@ -0,0 +1,85 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+#include "math/gnss_coordinate_convert.h"
+
+MainWindow::MainWindow(QWidget *parent)
+    : QMainWindow(parent)
+    , ui(new Ui::MainWindow)
+{
+    ui->setupUi(this);
+
+    setWindowTitle(tr("GPS Calculate Tool"));
+}
+
+MainWindow::~MainWindow()
+{
+    delete ui;
+}
+
+
+void MainWindow::on_pushButton_LonLatConvertXY_clicked()
+{
+    double x,y;
+    double lon = ui->lineEdit_1_Lon->text().toDouble();
+    double lat = ui->lineEdit_1_Lat->text().toDouble();
+
+    GaussProjCal(lon,lat,&x,&y);
+
+    ui->lineEdit_1_x->setText(QString::number(x,'f',3));
+    ui->lineEdit_1_y->setText(QString::number(y,'f',3));
+}
+
+
+void MainWindow::on_pushButton_LonLatConvertRel_clicked()
+{
+    double lon_base,lat_base,heading_base;
+    double lon_test,lat_test,heading_test;
+
+    double x_base,y_base,hdg_base;
+    double x_test,y_test,hdg_test;
+
+    double x_rel,y_rel,hdg_rel;
+    double x_rel_raw,y_rel_raw;
+
+    lon_base = ui->lineEdit_2_Lon->text().toDouble();
+    lat_base = ui->lineEdit_2_Lat->text().toDouble();
+    heading_base = ui->lineEdit_2_Heading->text().toDouble();
+
+
+    GaussProjCal(lon_base,lat_base,&x_base,&y_base);
+    GaussProjCal(lon_test,lat_test,&x_test,&y_test);
+
+    x_rel_raw = x_test - x_base;
+    y_rel_raw = y_test - y_base;
+
+    hdg_base = (90-heading_base)*M_PI/180.0;
+    normalhdg(hdg_base);
+
+    hdg_test = (90-heading_test)*M_PI/180.0;
+    normalhdg(hdg_test);
+
+    hdg_rel = hdg_test - hdg_base;
+    normalhdg(hdg_rel);
+
+
+}
+
+
+void MainWindow::on_pushButton_RelConvertLonLat_clicked()
+{
+
+}
+
+
+void MainWindow::normalheading(double & heading)
+{
+    while(heading>=360.0)heading = heading - 360.0;
+    while(heading<0)heading = heading + 360.0;
+}
+
+void MainWindow::normalhdg(double & hdg)
+{
+    while(hdg >= (2.0*M_PI))hdg = hdg - M_PI * 2.0;
+    while(hdg < 0)hdg  = hdg  + M_PI * 2.0;
+}

+ 32 - 0
src/tool/tool_calcgps/mainwindow.h

@@ -0,0 +1,32 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+QT_BEGIN_NAMESPACE
+namespace Ui { class MainWindow; }
+QT_END_NAMESPACE
+
+class MainWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    MainWindow(QWidget *parent = nullptr);
+    ~MainWindow();
+
+private slots:
+    void on_pushButton_LonLatConvertXY_clicked();
+
+    void on_pushButton_LonLatConvertRel_clicked();
+
+    void on_pushButton_RelConvertLonLat_clicked();
+
+private:
+    Ui::MainWindow *ui;
+
+private:
+    void normalheading(double & heading);
+    void normalhdg(double & hdg);
+};
+#endif // MAINWINDOW_H

+ 550 - 0
src/tool/tool_calcgps/mainwindow.ui

@@ -0,0 +1,550 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>838</width>
+    <height>655</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralwidget">
+   <widget class="QGroupBox" name="groupBox">
+    <property name="geometry">
+     <rect>
+      <x>50</x>
+      <y>30</y>
+      <width>601</width>
+      <height>131</height>
+     </rect>
+    </property>
+    <property name="title">
+     <string>经纬度转大地</string>
+    </property>
+    <widget class="QLabel" name="label">
+     <property name="geometry">
+      <rect>
+       <x>30</x>
+       <y>42</y>
+       <width>51</width>
+       <height>21</height>
+      </rect>
+     </property>
+     <property name="text">
+      <string>经度:</string>
+     </property>
+    </widget>
+    <widget class="QLabel" name="label_2">
+     <property name="geometry">
+      <rect>
+       <x>28</x>
+       <y>80</y>
+       <width>51</width>
+       <height>31</height>
+      </rect>
+     </property>
+     <property name="text">
+      <string>纬度:</string>
+     </property>
+    </widget>
+    <widget class="QLineEdit" name="lineEdit_1_Lon">
+     <property name="geometry">
+      <rect>
+       <x>90</x>
+       <y>37</y>
+       <width>141</width>
+       <height>31</height>
+      </rect>
+     </property>
+    </widget>
+    <widget class="QLineEdit" name="lineEdit_1_Lat">
+     <property name="geometry">
+      <rect>
+       <x>90</x>
+       <y>80</y>
+       <width>141</width>
+       <height>31</height>
+      </rect>
+     </property>
+    </widget>
+    <widget class="QPushButton" name="pushButton_LonLatConvertXY">
+     <property name="geometry">
+      <rect>
+       <x>280</x>
+       <y>50</y>
+       <width>71</width>
+       <height>51</height>
+      </rect>
+     </property>
+     <property name="text">
+      <string>转换</string>
+     </property>
+    </widget>
+    <widget class="QLabel" name="label_3">
+     <property name="geometry">
+      <rect>
+       <x>388</x>
+       <y>83</y>
+       <width>41</width>
+       <height>21</height>
+      </rect>
+     </property>
+     <property name="text">
+      <string>y:</string>
+     </property>
+    </widget>
+    <widget class="QLabel" name="label_4">
+     <property name="geometry">
+      <rect>
+       <x>390</x>
+       <y>44</y>
+       <width>41</width>
+       <height>21</height>
+      </rect>
+     </property>
+     <property name="text">
+      <string>x:</string>
+     </property>
+    </widget>
+    <widget class="QLineEdit" name="lineEdit_1_x">
+     <property name="geometry">
+      <rect>
+       <x>450</x>
+       <y>37</y>
+       <width>141</width>
+       <height>31</height>
+      </rect>
+     </property>
+    </widget>
+    <widget class="QLineEdit" name="lineEdit_1_y">
+     <property name="geometry">
+      <rect>
+       <x>450</x>
+       <y>80</y>
+       <width>141</width>
+       <height>31</height>
+      </rect>
+     </property>
+    </widget>
+   </widget>
+   <widget class="QGroupBox" name="groupBox_2">
+    <property name="geometry">
+     <rect>
+      <x>50</x>
+      <y>193</y>
+      <width>731</width>
+      <height>171</height>
+     </rect>
+    </property>
+    <property name="title">
+     <string>经纬度转相对</string>
+    </property>
+    <widget class="QGroupBox" name="groupBox_4">
+     <property name="geometry">
+      <rect>
+       <x>10</x>
+       <y>30</y>
+       <width>191</width>
+       <height>131</height>
+      </rect>
+     </property>
+     <property name="title">
+      <string>基准点</string>
+     </property>
+     <widget class="QLabel" name="label_5">
+      <property name="geometry">
+       <rect>
+        <x>4</x>
+        <y>28</y>
+        <width>51</width>
+        <height>31</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>经度:</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_6">
+      <property name="geometry">
+       <rect>
+        <x>4</x>
+        <y>62</y>
+        <width>51</width>
+        <height>31</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>纬度:</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_7">
+      <property name="geometry">
+       <rect>
+        <x>4</x>
+        <y>93</y>
+        <width>51</width>
+        <height>31</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>航向:</string>
+      </property>
+     </widget>
+     <widget class="QLineEdit" name="lineEdit_2_Lon">
+      <property name="geometry">
+       <rect>
+        <x>70</x>
+        <y>29</y>
+        <width>113</width>
+        <height>31</height>
+       </rect>
+      </property>
+     </widget>
+     <widget class="QLineEdit" name="lineEdit_2_Lat">
+      <property name="geometry">
+       <rect>
+        <x>70</x>
+        <y>62</y>
+        <width>113</width>
+        <height>31</height>
+       </rect>
+      </property>
+     </widget>
+     <widget class="QLineEdit" name="lineEdit_2_Heading">
+      <property name="geometry">
+       <rect>
+        <x>70</x>
+        <y>95</y>
+        <width>113</width>
+        <height>31</height>
+       </rect>
+      </property>
+     </widget>
+    </widget>
+    <widget class="QGroupBox" name="groupBox_5">
+     <property name="geometry">
+      <rect>
+       <x>220</x>
+       <y>30</y>
+       <width>191</width>
+       <height>131</height>
+      </rect>
+     </property>
+     <property name="title">
+      <string>测量点</string>
+     </property>
+     <widget class="QLabel" name="label_8">
+      <property name="geometry">
+       <rect>
+        <x>4</x>
+        <y>28</y>
+        <width>51</width>
+        <height>31</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>经度:</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_9">
+      <property name="geometry">
+       <rect>
+        <x>4</x>
+        <y>62</y>
+        <width>51</width>
+        <height>31</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>纬度:</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_10">
+      <property name="geometry">
+       <rect>
+        <x>4</x>
+        <y>93</y>
+        <width>51</width>
+        <height>31</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>航向:</string>
+      </property>
+     </widget>
+     <widget class="QLineEdit" name="lineEdit_2_Lon2">
+      <property name="geometry">
+       <rect>
+        <x>70</x>
+        <y>29</y>
+        <width>113</width>
+        <height>31</height>
+       </rect>
+      </property>
+     </widget>
+     <widget class="QLineEdit" name="lineEdit_2_Lat2">
+      <property name="geometry">
+       <rect>
+        <x>70</x>
+        <y>62</y>
+        <width>113</width>
+        <height>31</height>
+       </rect>
+      </property>
+     </widget>
+     <widget class="QLineEdit" name="lineEdit_2_Heading2">
+      <property name="geometry">
+       <rect>
+        <x>70</x>
+        <y>95</y>
+        <width>113</width>
+        <height>31</height>
+       </rect>
+      </property>
+     </widget>
+    </widget>
+    <widget class="QPushButton" name="pushButton_LonLatConvertRel">
+     <property name="geometry">
+      <rect>
+       <x>430</x>
+       <y>80</y>
+       <width>71</width>
+       <height>51</height>
+      </rect>
+     </property>
+     <property name="text">
+      <string>转换</string>
+     </property>
+    </widget>
+    <widget class="QPlainTextEdit" name="plainTextEdit_Rel">
+     <property name="geometry">
+      <rect>
+       <x>520</x>
+       <y>30</y>
+       <width>201</width>
+       <height>131</height>
+      </rect>
+     </property>
+    </widget>
+   </widget>
+   <widget class="QGroupBox" name="groupBox_3">
+    <property name="geometry">
+     <rect>
+      <x>50</x>
+      <y>402</y>
+      <width>731</width>
+      <height>171</height>
+     </rect>
+    </property>
+    <property name="title">
+     <string>相对转经纬度</string>
+    </property>
+    <widget class="QGroupBox" name="groupBox_6">
+     <property name="geometry">
+      <rect>
+       <x>10</x>
+       <y>30</y>
+       <width>191</width>
+       <height>131</height>
+      </rect>
+     </property>
+     <property name="title">
+      <string>基准点</string>
+     </property>
+     <widget class="QLabel" name="label_11">
+      <property name="geometry">
+       <rect>
+        <x>4</x>
+        <y>28</y>
+        <width>51</width>
+        <height>31</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>经度:</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_12">
+      <property name="geometry">
+       <rect>
+        <x>4</x>
+        <y>62</y>
+        <width>51</width>
+        <height>31</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>纬度:</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_13">
+      <property name="geometry">
+       <rect>
+        <x>4</x>
+        <y>93</y>
+        <width>51</width>
+        <height>31</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>航向:</string>
+      </property>
+     </widget>
+     <widget class="QLineEdit" name="lineEdit_3_Lon">
+      <property name="geometry">
+       <rect>
+        <x>70</x>
+        <y>29</y>
+        <width>113</width>
+        <height>31</height>
+       </rect>
+      </property>
+     </widget>
+     <widget class="QLineEdit" name="lineEdit_3_Lat">
+      <property name="geometry">
+       <rect>
+        <x>70</x>
+        <y>62</y>
+        <width>113</width>
+        <height>31</height>
+       </rect>
+      </property>
+     </widget>
+     <widget class="QLineEdit" name="lineEdit_3_Heading">
+      <property name="geometry">
+       <rect>
+        <x>70</x>
+        <y>95</y>
+        <width>113</width>
+        <height>31</height>
+       </rect>
+      </property>
+     </widget>
+    </widget>
+    <widget class="QGroupBox" name="groupBox_7">
+     <property name="geometry">
+      <rect>
+       <x>220</x>
+       <y>30</y>
+       <width>191</width>
+       <height>131</height>
+      </rect>
+     </property>
+     <property name="title">
+      <string>相对点</string>
+     </property>
+     <widget class="QLabel" name="label_14">
+      <property name="geometry">
+       <rect>
+        <x>4</x>
+        <y>28</y>
+        <width>51</width>
+        <height>31</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>x:</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_15">
+      <property name="geometry">
+       <rect>
+        <x>4</x>
+        <y>62</y>
+        <width>51</width>
+        <height>31</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>y:</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_16">
+      <property name="geometry">
+       <rect>
+        <x>4</x>
+        <y>93</y>
+        <width>51</width>
+        <height>31</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>hdg:</string>
+      </property>
+     </widget>
+     <widget class="QLineEdit" name="lineEdit_3_x">
+      <property name="geometry">
+       <rect>
+        <x>70</x>
+        <y>29</y>
+        <width>113</width>
+        <height>31</height>
+       </rect>
+      </property>
+     </widget>
+     <widget class="QLineEdit" name="lineEdit_3_y">
+      <property name="geometry">
+       <rect>
+        <x>70</x>
+        <y>62</y>
+        <width>113</width>
+        <height>31</height>
+       </rect>
+      </property>
+     </widget>
+     <widget class="QLineEdit" name="lineEdit_3_hdg">
+      <property name="geometry">
+       <rect>
+        <x>70</x>
+        <y>95</y>
+        <width>113</width>
+        <height>31</height>
+       </rect>
+      </property>
+     </widget>
+    </widget>
+    <widget class="QPushButton" name="pushButton_RelConvertLonLat">
+     <property name="geometry">
+      <rect>
+       <x>430</x>
+       <y>80</y>
+       <width>71</width>
+       <height>51</height>
+      </rect>
+     </property>
+     <property name="text">
+      <string>转换</string>
+     </property>
+    </widget>
+    <widget class="QPlainTextEdit" name="plainTextEdit_LonLat">
+     <property name="geometry">
+      <rect>
+       <x>520</x>
+       <y>30</y>
+       <width>201</width>
+       <height>131</height>
+      </rect>
+     </property>
+    </widget>
+   </widget>
+  </widget>
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>838</width>
+     <height>27</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 28 - 0
src/tool/tool_calcgps/tool_calcgps.pro

@@ -0,0 +1,28 @@
+QT       += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+CONFIG += c++17
+
+# You can make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+    ../../common/common/math/gnss_coordinate_convert.cpp \
+    main.cpp \
+    mainwindow.cpp
+
+HEADERS += \
+    ../../common/common/math/gnss_coordinate_convert.h \
+    mainwindow.h
+
+FORMS += \
+    mainwindow.ui
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
+
+INCLUDEPATH += $$PWD/../../common/common