Browse Source

change map_lanetoxodr for caculate s in road.

yuchuli 3 years ago
parent
commit
0f1cfda08c

+ 57 - 0
src/tool/map_lanetoxodr/dialogcalcs.cpp

@@ -0,0 +1,57 @@
+#include "dialogcalcs.h"
+#include "ui_dialogcalcs.h"
+
+
+#include "xodrfunc.h"
+#include "gnss_coordinate_convert.h"
+
+DialogCalcS::DialogCalcS(OpenDrive * pxodr,double xlon0,double xlat0, QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::DialogCalcS)
+{
+    ui->setupUi(this);
+
+    mpxodr = pxodr;
+    mlon0 = xlon0;
+    mlat0 = xlat0;
+
+    setWindowTitle("Calculate S in Road");
+}
+
+DialogCalcS::~DialogCalcS()
+{
+    delete ui;
+}
+
+void DialogCalcS::on_pushButton_Calculate_clicked()
+{
+    double flon = ui->lineEdit_Lon->text().toDouble();
+    double flat = ui->lineEdit_Lat->text().toDouble();
+
+    double x0,y0;
+    GaussProjCal(mlon0,mlat0,&x0,&y0);
+
+    double x,y;
+    GaussProjCal(flon,flat,&x,&y);
+
+
+    double rel_x,rel_y;
+    rel_x = x - x0;
+    rel_y = y - y0;
+
+    Road * pRoad = 0;
+    GeometryBlock * pgeob;
+    double fdis,nearx,neary,hdg;
+    double fs;
+    int nlane;
+    if(xodrfunc::GetNearPoint(rel_x,rel_y,mpxodr,&pRoad,&pgeob,fdis,nearx,neary,hdg,50,&fs,&nlane) == 0)
+    {
+        char strout[256];
+        snprintf(strout,256,"Road %s S:%f",pRoad->GetRoadId().data(),fs);
+        ui->lineEdit_Res->setText(strout);
+    }
+    else
+    {
+        ui->lineEdit_Res->setText("not found");
+    }
+}

+ 30 - 0
src/tool/map_lanetoxodr/dialogcalcs.h

@@ -0,0 +1,30 @@
+#ifndef DIALOGCALCS_H
+#define DIALOGCALCS_H
+
+#include <QDialog>
+
+#include "OpenDrive/OpenDrive.h"
+
+namespace Ui {
+class DialogCalcS;
+}
+
+class DialogCalcS : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit DialogCalcS(OpenDrive * pxodr,double xlon0,double xlat0, QWidget *parent = nullptr);
+    ~DialogCalcS();
+
+private slots:
+    void on_pushButton_Calculate_clicked();
+
+private:
+    Ui::DialogCalcS *ui;
+    OpenDrive * mpxodr;
+    double mlon0;
+    double mlat0;
+};
+
+#endif // DIALOGCALCS_H

+ 88 - 0
src/tool/map_lanetoxodr/dialogcalcs.ui

@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DialogCalcS</class>
+ <widget class="QDialog" name="DialogCalcS">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>560</width>
+    <height>396</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <widget class="QLineEdit" name="lineEdit_Lon">
+   <property name="geometry">
+    <rect>
+     <x>220</x>
+     <y>40</y>
+     <width>171</width>
+     <height>41</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_Lat">
+   <property name="geometry">
+    <rect>
+     <x>220</x>
+     <y>110</y>
+     <width>171</width>
+     <height>41</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_Calculate">
+   <property name="geometry">
+    <rect>
+     <x>180</x>
+     <y>180</y>
+     <width>121</width>
+     <height>41</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Calculate</string>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_Res">
+   <property name="geometry">
+    <rect>
+     <x>90</x>
+     <y>260</y>
+     <width>361</width>
+     <height>41</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label">
+   <property name="geometry">
+    <rect>
+     <x>70</x>
+     <y>50</y>
+     <width>111</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Lon</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_2">
+   <property name="geometry">
+    <rect>
+     <x>70</x>
+     <y>110</y>
+     <width>101</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Lat</string>
+   </property>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 6 - 0
src/tool/map_lanetoxodr/mainwindow.cpp

@@ -5172,3 +5172,9 @@ void MainWindow::onViewModeChange(int index)
     mbRefresh = true;
     update();
 }
+
+void MainWindow::on_actionCalc_Road_S_triggered()
+{
+    DialogCalcS calcs(&mxodr,glon0,glat0,this);
+    calcs.exec();
+}

+ 3 - 0
src/tool/map_lanetoxodr/mainwindow.h

@@ -45,6 +45,7 @@
 #include "trafficlightdialog.h"
 #include "roadeditdialog.h"
 #include "dialogaddroadfromrtk.h"
+#include "dialogcalcs.h"
 
 #include <iostream>
 #include <map>
@@ -194,6 +195,8 @@ private slots:
 
     void onViewModeChange(int index);
 
+    void on_actionCalc_Road_S_triggered();
+
 private:
 
 

+ 6 - 0
src/tool/map_lanetoxodr/mainwindow.ui

@@ -41,6 +41,7 @@
     <addaction name="actionAutoConnect"/>
     <addaction name="actionSet_Speed"/>
     <addaction name="actionSet_Traffic_Light"/>
+    <addaction name="actionCalc_Road_S"/>
    </widget>
    <widget class="QMenu" name="menuTool">
     <property name="title">
@@ -124,6 +125,11 @@
     <string>Summary Road</string>
    </property>
   </action>
+  <action name="actionCalc_Road_S">
+   <property name="text">
+    <string>Calc Road S</string>
+   </property>
+  </action>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <resources>

+ 3 - 0
src/tool/map_lanetoxodr/map_lanetoxodr.pro

@@ -30,6 +30,7 @@ QMAKE_LFLAGS += -no-pie
 SOURCES += \
     autoconnect.cpp \
     dialogaddroadfromrtk.cpp \
+    dialogcalcs.cpp \
     dialogeditlane.cpp \
     dialogeditroadmark.cpp \
     dialoglanefromrtk.cpp \
@@ -80,6 +81,7 @@ SOURCES += \
 HEADERS += \
     autoconnect.h \
     dialogaddroadfromrtk.h \
+    dialogcalcs.h \
     dialogeditlane.h \
     dialogeditroadmark.h \
     dialoglanefromrtk.h \
@@ -125,6 +127,7 @@ HEADERS += \
 
 FORMS += \
         dialogaddroadfromrtk.ui \
+        dialogcalcs.ui \
         dialogeditlane.ui \
         dialogeditroadmark.ui \
         dialoglanefromrtk.ui \