Browse Source

change tool_calcgps. and compile for web, and up to 116.63.46.168:19000. and run .

yuchuli 1 year ago
parent
commit
90d2b0c132

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

@@ -3,6 +3,8 @@
 
 #include "math/gnss_coordinate_convert.h"
 
+#include <QFileDialog>
+
 MainWindow::MainWindow(QWidget *parent)
     : QMainWindow(parent)
     , ui(new Ui::MainWindow)
@@ -10,6 +12,12 @@ MainWindow::MainWindow(QWidget *parent)
     ui->setupUi(this);
 
     setWindowTitle(tr("GPS Calculate Tool"));
+
+
+#ifndef Q_OS_WASM
+    ui->pushButton_SaveXY->setVisible(false);
+    ui->pushButton_SaveLonLat->setVisible(false);
+#endif
 }
 
 MainWindow::~MainWindow()
@@ -46,6 +54,10 @@ void MainWindow::on_pushButton_LonLatConvertRel_clicked()
     lat_base = ui->lineEdit_2_Lat->text().toDouble();
     heading_base = ui->lineEdit_2_Heading->text().toDouble();
 
+    lon_test = ui->lineEdit_2_Lon2->text().toDouble();
+    lat_test = ui->lineEdit_2_Lat2->text().toDouble();
+    heading_test = ui->lineEdit_2_Heading2->text().toDouble();
+
 
     GaussProjCal(lon_base,lat_base,&x_base,&y_base);
     GaussProjCal(lon_test,lat_test,&x_test,&y_test);
@@ -62,12 +74,72 @@ void MainWindow::on_pushButton_LonLatConvertRel_clicked()
     hdg_rel = hdg_test - hdg_base;
     normalhdg(hdg_rel);
 
+    x_rel = x_rel_raw * cos(-hdg_base) - y_rel_raw * sin(-hdg_base);
+    y_rel = x_rel_raw * sin(-hdg_base) - y_rel_raw * cos(-hdg_base);
+
+    char strout[1000];
+    char strtem[100];
+    snprintf(strout,1000,"Rel Value:\n");
+    snprintf(strtem,100,"x:%6.3f\n",x_rel);strncat(strout,strtem,1000);
+    snprintf(strtem,100,"y:%6.3f\n",y_rel);strncat(strout,strtem,1000);
+    snprintf(strtem,100,"hdg:%11.9f\n",hdg_rel);strncat(strout,strtem,1000);
+    snprintf(strtem,100,"\n Raw rel Value:\n");strncat(strout,strtem,1000);
+    snprintf(strtem,100,"x_raw:%6.3f\n",x_rel_raw);strncat(strout,strtem,1000);
+    snprintf(strtem,100,"y_raw:%6.3f\n",y_rel_raw);strncat(strout,strtem,1000);
+
+    ui->plainTextEdit_Rel->setPlainText(strout);
 
 }
 
 
 void MainWindow::on_pushButton_RelConvertLonLat_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_3_Lon->text().toDouble();
+    lat_base = ui->lineEdit_3_Lat->text().toDouble();
+    heading_base = ui->lineEdit_3_Heading->text().toDouble();
+
+    x_rel = ui->lineEdit_3_x->text().toDouble();
+    y_rel = ui->lineEdit_3_y->text().toDouble();
+    hdg_rel = ui->lineEdit_3_hdg->text().toDouble();
+
+
+    GaussProjCal(lon_base,lat_base,&x_base,&y_base);
+
+    hdg_base = (90-heading_base)*M_PI/180.0;
+    normalhdg(hdg_base);
+
+    x_rel_raw = x_rel * cos(hdg_base) - y_rel * sin(hdg_base);
+    y_rel_raw = x_rel * sin(hdg_base) - y_rel * cos(hdg_base);
+
+    hdg_test = hdg_base + hdg_rel;
+
+    heading_test = (M_PI/2.0 - hdg_test) * 180.0/M_PI;
+    normalheading(heading_test);
+
+
+    x_test = x_base + x_rel_raw;
+    y_test = y_base + y_rel_raw;
+
+    GaussProjInvCal(x_test,y_test,&lon_test,&lat_test);
+
+
+    char strout[1000];
+    char strtem[100];
+    snprintf(strout,1000,"Lon Lat:\n");
+    snprintf(strtem,100,"Lon:%11.8f\n",lon_test);strncat(strout,strtem,1000);
+    snprintf(strtem,100,"Lat:%11.8f\n",lat_test);strncat(strout,strtem,1000);
+    snprintf(strtem,100,"heading:%6.3f\n",heading_test);strncat(strout,strtem,1000);
+
+    ui->plainTextEdit_LonLat->setPlainText(strout);
 
 }
 
@@ -83,3 +155,75 @@ 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;
 }
+
+void MainWindow::on_pushButton_SaveXY_clicked()
+{
+
+    double lon_base,lat_base,heading_base;
+    double lon_test,lat_test,heading_test;
+
+
+    lon_base = ui->lineEdit_2_Lon->text().toDouble();
+    lat_base = ui->lineEdit_2_Lat->text().toDouble();
+    heading_base = ui->lineEdit_2_Heading->text().toDouble();
+
+    lon_test = ui->lineEdit_2_Lon2->text().toDouble();
+    lat_test = ui->lineEdit_2_Lat2->text().toDouble();
+    heading_test = ui->lineEdit_2_Heading2->text().toDouble();
+
+    char strbase[1000];
+    snprintf(strbase,1000,"From Value:\n   Base:%11.7f  %11.7f  %11.7f\n   Test:%11.7f  %11.7f  %11.7f\n\n",
+             lon_base,lat_base,heading_base,lon_test,lat_test,heading_test);
+
+    QByteArray ba1;
+    ba1 = QByteArray::fromRawData(strbase,strnlen(strbase,1000));
+
+
+    QString str = ui->plainTextEdit_Rel->toPlainText();
+    QByteArray ba;
+    ba = QByteArray::fromStdString(str.toStdString());
+#ifdef Q_OS_WASM
+
+    ba1.append(ba);
+    QFileDialog::saveFileContent(ba1,"xy.txt");
+#endif
+}
+
+//Qt使用Emscripten的文件系统,还提供其他API:
+
+//    QFile可以照常使用。默认情况下,存储的文件进入MEMFS。
+//    QSettings具有一个基于IndexedDB的后端;请注意,QSettings在WebAssembly上是异步的。请参阅[2]上的用法示例
+//    QFileDialog :: getOpenFileContent()打开一个本机文件对话框,用户可以在其中选择文件
+//    QFileDialog :: saveFileContent()通过文件下载将文件保存到本地文件系统
+
+void MainWindow::on_pushButton_SaveLonLat_clicked()
+{
+    double lon_base,lat_base,heading_base;
+
+    double x_rel,y_rel,hdg_rel;
+
+    lon_base = ui->lineEdit_3_Lon->text().toDouble();
+    lat_base = ui->lineEdit_3_Lat->text().toDouble();
+    heading_base = ui->lineEdit_3_Heading->text().toDouble();
+
+    x_rel = ui->lineEdit_3_x->text().toDouble();
+    y_rel = ui->lineEdit_3_y->text().toDouble();
+    hdg_rel = ui->lineEdit_3_hdg->text().toDouble();
+
+    char strbase[1000];
+    snprintf(strbase,1000,"From Value:\n   Base:%11.7f  %11.7f  %11.7f\n   Test:%11.7f  %11.7f  %11.7f\n\n",
+             lon_base,lat_base,heading_base,x_rel,y_rel,hdg_rel);
+
+    QByteArray ba1;
+    ba1 = QByteArray::fromRawData(strbase,strnlen(strbase,1000));
+
+    QString str = ui->plainTextEdit_LonLat->toPlainText();
+    QByteArray ba;
+    ba = QByteArray::fromStdString(str.toStdString());
+#ifdef Q_OS_WASM
+
+    ba1.append(ba);
+    QFileDialog::saveFileContent(ba1,"lonlat.txt");
+#endif
+}
+

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

@@ -22,6 +22,10 @@ private slots:
 
     void on_pushButton_RelConvertLonLat_clicked();
 
+    void on_pushButton_SaveXY_clicked();
+
+    void on_pushButton_SaveLonLat_clicked();
+
 private:
     Ui::MainWindow *ui;
 

File diff suppressed because it is too large
+ 540 - 514
src/tool/tool_calcgps/mainwindow.ui


Some files were not shown because too many files changed in this diff