Explorar o código

change tool_calcgps, add Radius Calcutation.

yuchuli hai 1 ano
pai
achega
73033c7059

+ 5 - 0
src/tool/tool_calcgps/calcgps.qrc

@@ -0,0 +1,5 @@
+<RCC>
+    <qresource prefix="/">
+        <file>fonts/SIMYOU.TTF</file>
+    </qresource>
+</RCC>

BIN=BIN
src/tool/tool_calcgps/fonts/SIMYOU.TTF


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

@@ -1,10 +1,29 @@
 #include "mainwindow.h"
 
 #include <QApplication>
+//#include <QFontDatabase>
+
+#include <iostream>
 
 int main(int argc, char *argv[])
 {
     QApplication a(argc, argv);
+
+//    int fontId = QFontDatabase::addApplicationFont(QStringLiteral(":/fonts/SIMYOU.TTF"));
+//    QStringList fontFamilies = QFontDatabase::applicationFontFamilies(fontId);
+//   // qDebug()<<"fontfamilies:"<<fontFamilies;
+//    if (fontFamilies.size() > 0)
+//    {
+//        QFont font;
+//        font.setFamily(fontFamilies[0]);//设置全局字体
+//        a.setFont(font);
+//    }
+//    else
+//    {
+//        std::cout<<" load font fail. "<<std::endl;
+//    }
+
+
     MainWindow w;
     w.show();
     return a.exec();

+ 20 - 1
src/tool/tool_calcgps/mainwindow.cpp

@@ -50,6 +50,8 @@ void MainWindow::on_pushButton_LonLatConvertRel_clicked()
     double x_rel,y_rel,hdg_rel;
     double x_rel_raw,y_rel_raw;
 
+    double fDis;
+
     lon_base = ui->lineEdit_2_Lon->text().toDouble();
     lat_base = ui->lineEdit_2_Lat->text().toDouble();
     heading_base = ui->lineEdit_2_Heading->text().toDouble();
@@ -62,6 +64,8 @@ void MainWindow::on_pushButton_LonLatConvertRel_clicked()
     GaussProjCal(lon_base,lat_base,&x_base,&y_base);
     GaussProjCal(lon_test,lat_test,&x_test,&y_test);
 
+    fDis = sqrt(pow(x_test - x_base,2) +  pow(y_test - y_base,2));
+
     x_rel_raw = x_test - x_base;
     y_rel_raw = y_test - y_base;
 
@@ -79,7 +83,7 @@ void MainWindow::on_pushButton_LonLatConvertRel_clicked()
 
     char strout[1000];
     char strtem[100];
-    snprintf(strout,1000,"Rel Value:\n");
+    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);
@@ -87,6 +91,21 @@ void MainWindow::on_pushButton_LonLatConvertRel_clicked()
     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);
 
+    snprintf(strtem,100,"\n Point Distance:\n");strncat(strout,strtem,1000);
+    snprintf(strtem,100,"Distance:%6.3f\n",fDis);strncat(strout,strtem,1000);
+
+    double R;
+
+    double theta = hdg_rel;
+    if(theta >M_PI) theta = 2.0*M_PI - theta;
+    theta = theta/2.0;
+    if(sin(theta)>0)
+    {
+        R = fDis/(2.0*sin(theta));
+        snprintf(strtem,100,"\n R:\n");strncat(strout,strtem,1000);
+        snprintf(strtem,100,"R:%6.3f\n",R);strncat(strout,strtem,1000);
+    }
+
     ui->plainTextEdit_Rel->setPlainText(strout);
 
 }

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

@@ -26,3 +26,5 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
 !isEmpty(target.path): INSTALLS += target
 
 INCLUDEPATH += $$PWD/../../common/common
+
+RESOURCES +=