Browse Source

change tool/map_lanetoxodr. change parampoly3 road contact. and add autoroadcontact,not complete.

yuchuli 3 years ago
parent
commit
e8cb4dc8db

+ 112 - 0
src/tool/map_lanetoxodr/autoroadcontact.cpp

@@ -0,0 +1,112 @@
+#include "autoroadcontact.h"
+
+#include <math.h>
+
+AutoRoadContact::AutoRoadContact()
+{
+
+}
+
+int AutoRoadContact::CalcContact(Road *pRoad1, Road *pRoad2,int & contacttype,int & turnstraight)
+{
+    double road1_start_x,road1_start_y,road1_end_x,road1_end_y,road1_start_hdg,road1_end_hdg;
+    double road2_start_x,road2_start_y,road2_end_x,road2_end_y,road2_start_hdg,road2_end_hdg;
+    pRoad1->GetGeometryCoords(0,road1_start_x,road1_start_y,road1_start_hdg);
+    pRoad1->GetGeometryCoords(pRoad1->GetRoadLength(),road1_end_x,road1_end_y,road1_end_hdg);
+    pRoad2->GetGeometryCoords(0,road2_start_x,road2_start_y,road2_start_hdg);
+    pRoad2->GetGeometryCoords(pRoad2->GetRoadLength(),road2_end_x,road2_end_y,road2_end_hdg);
+
+    double dis_1s_2s = sqrt(pow(road1_start_x-road2_start_x,2)
+                            +pow(road1_start_y-road2_start_y,2));
+    double dis_1s_2e = sqrt(pow(road1_start_x-road2_end_x,2)
+                            +pow(road1_start_y-road2_end_y,2));
+    double dis_1e_2s = sqrt(pow(road1_end_x-road2_start_x,2)
+                            +pow(road1_end_y-road2_start_y,2));
+    double dis_1e_2e = sqrt(pow(road1_end_x-road2_end_x,2)
+                            +pow(road1_end_y-road2_end_y,2));
+    double fdis[4];
+    fdis[0] = dis_1s_2s;
+    fdis[1] = dis_1s_2e;
+    fdis[2] = dis_1e_2s;
+    fdis[3] = dis_1e_2e;
+
+    double fdismin = 100000;
+    int index = -1;
+    int i;
+    for(i=0;i<4;i++)
+    {
+        if(fdismin>fdis[i])
+        {
+            fdismin = fdis[i];
+            index = i;
+        }
+    }
+
+    contacttype = index;
+
+    if(contacttype == -1)
+    {
+        return -1;
+    }
+
+    double from_x,from_y,from_hdg,to_x,to_y,to_hdg;
+    switch (contacttype) {
+    case 0:
+        from_x = road1_start_x;
+        from_y = road1_start_y;
+        to_x = road2_start_x;
+        to_y = road2_start_y;
+        from_hdg = road1_start_hdg + M_PI;
+        to_hdg = road2_start_hdg;
+        break;
+    case 1:
+        from_x = road1_start_x;
+        from_y = road1_start_y;
+        to_x = road2_end_x;
+        to_y = road2_end_y;
+        from_hdg = road1_start_hdg + M_PI;
+        to_hdg = road2_end_hdg+ M_PI;
+        break;
+    case 2:
+        from_x = road1_end_x;
+        from_y = road1_end_y;
+        to_x = road2_start_x;
+        to_y = road2_start_y;
+        from_hdg = road1_end_hdg ;
+        to_hdg = road2_start_hdg;
+        break;
+    case 3:
+        from_x = road1_end_x;
+        from_y = road1_end_y;
+        to_x = road2_end_x;
+        to_y = road2_end_y;
+        from_hdg = road1_end_hdg ;
+        to_hdg = road2_end_hdg + M_PI;
+        break;
+    default:
+        break;
+    }
+
+    if(from_hdg >= 2.0*M_PI)from_hdg = from_hdg - 2.0*M_PI;
+    if(to_hdg >= 2.0*M_PI)to_hdg = to_hdg - 2.0*M_PI;
+
+    double hdgdiff = to_hdg - from_hdg;
+    while(hdgdiff>=2.0*M_PI)hdgdiff = hdgdiff - 2.0*M_PI;
+    while(hdgdiff<0)hdgdiff = hdgdiff + 2.0*M_PI;
+    if((hdgdiff<1.0)||(hdgdiff>(2.0*M_PI-1.0)))
+    {
+        turnstraight = 1;
+    }
+    else
+    {
+        if((hdgdiff>(M_PI-0.3))&&(hdgdiff<(M_PI+0.3)))
+        {
+            turnstraight = 2;
+        }
+        else
+        {
+            turnstraight = 0;
+        }
+    }
+
+}

+ 14 - 0
src/tool/map_lanetoxodr/autoroadcontact.h

@@ -0,0 +1,14 @@
+#ifndef AUTOROADCONTACT_H
+#define AUTOROADCONTACT_H
+
+#include "OpenDrive/OpenDrive.h"
+
+class AutoRoadContact
+{
+public:
+    AutoRoadContact();
+
+    static int CalcContact(Road * pRoad1,Road * pRoad2,int & contacttype,int & turnstraight);
+};
+
+#endif // AUTOROADCONTACT_H

+ 2 - 232
src/tool/map_lanetoxodr/dialogparkingspaceedit.ui

@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>974</width>
-    <height>571</height>
+    <width>946</width>
+    <height>645</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -82,121 +82,6 @@
     <string>Road</string>
    </property>
   </widget>
-  <widget class="QLineEdit" name="lineEdit_s">
-   <property name="geometry">
-    <rect>
-     <x>120</x>
-     <y>221</y>
-     <width>121</width>
-     <height>31</height>
-    </rect>
-   </property>
-  </widget>
-  <widget class="QLabel" name="label_4">
-   <property name="geometry">
-    <rect>
-     <x>37</x>
-     <y>226</y>
-     <width>67</width>
-     <height>17</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>s</string>
-   </property>
-  </widget>
-  <widget class="QLineEdit" name="lineEdit_t">
-   <property name="geometry">
-    <rect>
-     <x>430</x>
-     <y>221</y>
-     <width>121</width>
-     <height>31</height>
-    </rect>
-   </property>
-  </widget>
-  <widget class="QLabel" name="label_5">
-   <property name="geometry">
-    <rect>
-     <x>352</x>
-     <y>230</y>
-     <width>67</width>
-     <height>17</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>t</string>
-   </property>
-  </widget>
-  <widget class="QLineEdit" name="lineEdit_width">
-   <property name="geometry">
-    <rect>
-     <x>710</x>
-     <y>221</y>
-     <width>121</width>
-     <height>31</height>
-    </rect>
-   </property>
-  </widget>
-  <widget class="QLineEdit" name="lineEdit_length">
-   <property name="geometry">
-    <rect>
-     <x>120</x>
-     <y>280</y>
-     <width>121</width>
-     <height>31</height>
-    </rect>
-   </property>
-  </widget>
-  <widget class="QLabel" name="label_6">
-   <property name="geometry">
-    <rect>
-     <x>630</x>
-     <y>230</y>
-     <width>67</width>
-     <height>17</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>Width</string>
-   </property>
-  </widget>
-  <widget class="QLabel" name="label_7">
-   <property name="geometry">
-    <rect>
-     <x>40</x>
-     <y>280</y>
-     <width>67</width>
-     <height>41</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>Length</string>
-   </property>
-  </widget>
-  <widget class="QLineEdit" name="lineEdit_hdg">
-   <property name="geometry">
-    <rect>
-     <x>430</x>
-     <y>280</y>
-     <width>121</width>
-     <height>31</height>
-    </rect>
-   </property>
-  </widget>
-  <widget class="QLabel" name="label_8">
-   <property name="geometry">
-    <rect>
-     <x>350</x>
-     <y>290</y>
-     <width>67</width>
-     <height>17</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>Hdg</string>
-   </property>
-  </widget>
   <widget class="QPushButton" name="pushButton_add">
    <property name="geometry">
     <rect>
@@ -236,121 +121,6 @@
     <string>Change</string>
    </property>
   </widget>
-  <widget class="QLabel" name="label_9">
-   <property name="geometry">
-    <rect>
-     <x>10</x>
-     <y>346</y>
-     <width>101</width>
-     <height>21</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>validLength</string>
-   </property>
-  </widget>
-  <widget class="QLineEdit" name="lineEdit_width_2">
-   <property name="geometry">
-    <rect>
-     <x>120</x>
-     <y>340</y>
-     <width>121</width>
-     <height>31</height>
-    </rect>
-   </property>
-  </widget>
-  <widget class="QLabel" name="label_10">
-   <property name="geometry">
-    <rect>
-     <x>630</x>
-     <y>276</y>
-     <width>67</width>
-     <height>41</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>Type</string>
-   </property>
-  </widget>
-  <widget class="QComboBox" name="comboBox">
-   <property name="geometry">
-    <rect>
-     <x>710</x>
-     <y>280</y>
-     <width>181</width>
-     <height>31</height>
-    </rect>
-   </property>
-  </widget>
-  <widget class="QLabel" name="label_11">
-   <property name="geometry">
-    <rect>
-     <x>300</x>
-     <y>337</y>
-     <width>131</width>
-     <height>41</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>orientation</string>
-   </property>
-  </widget>
-  <widget class="QComboBox" name="comboBox_2">
-   <property name="geometry">
-    <rect>
-     <x>430</x>
-     <y>340</y>
-     <width>121</width>
-     <height>31</height>
-    </rect>
-   </property>
-  </widget>
-  <widget class="QLabel" name="label_12">
-   <property name="geometry">
-    <rect>
-     <x>616</x>
-     <y>336</y>
-     <width>81</width>
-     <height>31</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>subtype</string>
-   </property>
-  </widget>
-  <widget class="QLineEdit" name="lineEdit_width_3">
-   <property name="geometry">
-    <rect>
-     <x>710</x>
-     <y>340</y>
-     <width>121</width>
-     <height>31</height>
-    </rect>
-   </property>
-  </widget>
-  <widget class="QComboBox" name="comboBox_3">
-   <property name="geometry">
-    <rect>
-     <x>120</x>
-     <y>403</y>
-     <width>121</width>
-     <height>31</height>
-    </rect>
-   </property>
-  </widget>
-  <widget class="QLabel" name="label_13">
-   <property name="geometry">
-    <rect>
-     <x>14</x>
-     <y>400</y>
-     <width>91</width>
-     <height>41</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>dynamic</string>
-   </property>
-  </widget>
  </widget>
  <resources/>
  <connections/>

+ 87 - 0
src/tool/map_lanetoxodr/dialogroadobject.cpp

@@ -0,0 +1,87 @@
+#include "dialogroadobject.h"
+#include "ui_dialogroadobject.h"
+
+DialogRoadObject::DialogRoadObject(QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::DialogRoadObject)
+{
+    ui->setupUi(this);
+
+    CreateView();
+    setWindowTitle("Edit Road Object");
+}
+
+DialogRoadObject::~DialogRoadObject()
+{
+    delete ui;
+}
+
+
+QLineEdit * DialogRoadObject::CreateLE(int pos_x, int pos_y, int nLabelWidth, int nLEWidth, int nHeight, std::string strname)
+{
+    QLineEdit * pLE;
+    QLabel * pLabel;
+
+    pLabel = new QLabel(this);
+    pLabel->setGeometry(pos_x,pos_y,nLabelWidth,nHeight);
+    pLabel->setText(strname.data());
+    pLabel->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+
+    pLE = new QLineEdit(this);
+    pLE->setGeometry(pos_x+nLabelWidth+10,pos_y,nLEWidth,nHeight);
+
+    return pLE;
+}
+
+QComboBox * DialogRoadObject::CreateCB(int pos_x, int pos_y, int nLabelWidth, int nLEWidth, int nHeight, std::string strname)
+{
+    QComboBox * pCB;
+    QLabel * pLabel;
+
+    pLabel = new QLabel(this);
+    pLabel->setGeometry(pos_x,pos_y,nLabelWidth,nHeight);
+    pLabel->setText(strname.data());
+    pLabel->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+
+    pCB = new QComboBox(this);
+    pCB->setGeometry(pos_x+nLabelWidth+10,pos_y,nLEWidth,nHeight);
+
+    return pCB;
+}
+
+void DialogRoadObject::CreateView()
+{
+    int startpos_x = 30;
+    int startpos_y = 150;
+    int nSpace = 300;
+    int nLabelWidth = 100;
+    int nLEWidth = 150;
+    int nHeight = 30;
+    int nVSpace = 50;
+
+    int nVIndex = 0;
+    mpLEt = CreateLE(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"t");
+    mpLEzOffset = CreateLE(startpos_x+1*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"zOffset");
+    mpCBtype = CreateCB(startpos_x+2*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"type");
+    nVIndex++;
+    mpLEvalidLength = CreateLE(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"validLength");
+    mpCBorientation = CreateCB(startpos_x+1*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"orientation");
+    mpLEsubtype = CreateLE(startpos_x+2*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"subtype");
+    nVIndex++;
+    mpCBdynamic = CreateCB(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"dynamic");
+    mpLEhdg = CreateLE(startpos_x+1*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"hdg");
+    mpLEname = CreateLE(startpos_x+2*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"name");
+    nVIndex++;
+    mpLEpitch = CreateLE(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"pitch");
+    mpLEid = CreateLE(startpos_x+1*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"id");
+    mpLEroll = CreateLE(startpos_x+2*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"roll");
+    nVIndex++;
+    mpLEheight = CreateLE(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"height");
+    mpLEs = CreateLE(startpos_x+1*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"s");
+    mpLElength = CreateLE(startpos_x+2*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"length");
+    nVIndex++;
+    mpLEwidth = CreateLE(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"width");
+    mpLEradius = CreateLE(startpos_x+1*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"radius");
+
+
+}

+ 51 - 0
src/tool/map_lanetoxodr/dialogroadobject.h

@@ -0,0 +1,51 @@
+#ifndef DIALOGROADOBJECT_H
+#define DIALOGROADOBJECT_H
+
+#include <QDialog>
+#include <QLineEdit>
+#include <QLabel>
+#include <QComboBox>
+
+namespace Ui {
+class DialogRoadObject;
+}
+
+class DialogRoadObject : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit DialogRoadObject(QWidget *parent = nullptr);
+    ~DialogRoadObject();
+
+private:
+    Ui::DialogRoadObject *ui;
+
+private:
+    void CreateView();
+
+private:
+    QLineEdit * mpLEt;
+    QLineEdit * mpLEzOffset;
+    QComboBox * mpCBtype;
+    QLineEdit * mpLEvalidLength;
+    QComboBox * mpCBorientation;
+    QLineEdit * mpLEsubtype;
+    QComboBox * mpCBdynamic;
+    QLineEdit * mpLEhdg;
+    QLineEdit * mpLEname;
+    QLineEdit * mpLEpitch;
+    QLineEdit * mpLEid;
+    QLineEdit * mpLEroll;
+    QLineEdit * mpLEheight;
+    QLineEdit * mpLEs;
+    QLineEdit * mpLElength;
+    QLineEdit * mpLEwidth;
+    QLineEdit * mpLEradius;
+
+private:
+    QLineEdit * CreateLE(int pos_x,int pos_y,int nLabelWidth,int nLEWidth,int nHeight,std::string strname);
+    QComboBox * CreateCB(int pos_x,int pos_y,int nLabelWidth,int nLEWidth,int nHeight,std::string strname);
+};
+
+#endif // DIALOGROADOBJECT_H

+ 127 - 0
src/tool/map_lanetoxodr/dialogroadobject.ui

@@ -0,0 +1,127 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DialogRoadObject</class>
+ <widget class="QDialog" name="DialogRoadObject">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>940</width>
+    <height>660</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <widget class="QComboBox" name="comboBox_Road">
+   <property name="geometry">
+    <rect>
+     <x>180</x>
+     <y>30</y>
+     <width>231</width>
+     <height>31</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QComboBox" name="comboBox_Object">
+   <property name="geometry">
+    <rect>
+     <x>180</x>
+     <y>80</y>
+     <width>171</width>
+     <height>31</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_2">
+   <property name="geometry">
+    <rect>
+     <x>472</x>
+     <y>40</y>
+     <width>70</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Length</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_change">
+   <property name="geometry">
+    <rect>
+     <x>620</x>
+     <y>80</y>
+     <width>81</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Change</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_add">
+   <property name="geometry">
+    <rect>
+     <x>390</x>
+     <y>80</y>
+     <width>91</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Add</string>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_RoadLen">
+   <property name="geometry">
+    <rect>
+     <x>570</x>
+     <y>40</y>
+     <width>113</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label">
+   <property name="geometry">
+    <rect>
+     <x>40</x>
+     <y>40</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Road</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_delete">
+   <property name="geometry">
+    <rect>
+     <x>510</x>
+     <y>80</y>
+     <width>81</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Delete</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_3">
+   <property name="geometry">
+    <rect>
+     <x>40</x>
+     <y>90</y>
+     <width>101</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Object</string>
+   </property>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 2 - 0
src/tool/map_lanetoxodr/main.cpp

@@ -55,6 +55,8 @@ bool requestPermission() {
 int main(int argc, char *argv[])
 {
 
+    //Call License
+    //Wait
 #ifndef ANDROID
 
     RegisterIVBackTrace();

+ 141 - 10
src/tool/map_lanetoxodr/mainwindow.cpp

@@ -473,7 +473,7 @@ void MainWindow::onTimer()
 void MainWindow::CreateTab1View(QTabWidget * p)
 {
     QGroupBox * pGroup = new QGroupBox();
-    pGroup->setGeometry(0,0,mnFontHeight * 21,mnFontHeight * 110);
+    pGroup->setGeometry(0,0,mnFontHeight * 21,mnFontHeight * 160);
 
     QLabel * pLabel;
     QLineEdit * pLE;
@@ -1011,6 +1011,12 @@ void MainWindow::CreateTab1View(QTabWidget * p)
     pPB->setGeometry(nXPos,nYPos,nLEWidth,nLEHeight);
     connect(pPB,SIGNAL(clicked(bool)),this,SLOT(onClickRoadContact()));
 
+    nXPos = nXPos + nSpace;
+    pPB = new QPushButton(pGroup);
+    pPB->setText("Auto Road Contact");
+    pPB->setGeometry(nXPos,nYPos,nLEWidth*3/2,nLEHeight);
+    connect(pPB,SIGNAL(clicked(bool)),this,SLOT(onClickAutoRoadContact()));
+
     nXPos = 10;
     nYPos = nYPos + mnFontHeight * 4;
 
@@ -2999,6 +3005,114 @@ void MainWindow::onClickSave()
     mpfb->Activate(str);
 }
 
+void MainWindow::onClickAutoRoadContact()
+{
+    int ch1,ch2;
+    ch1  = mpCBRoad1->currentIndex();
+    ch2 = mpCBRoad2->currentIndex();
+    if((ch1 == -1)||(ch2 == -1))
+    {
+        return;
+    }
+//    if(ch1 == ch2)
+//    {
+//        QMessageBox::warning(this,"warn","road same");
+//        return;
+//    }
+    int ntype1,ntype2;
+    ntype1 = mpCBRC1->currentIndex();
+    ntype2 = mpCBRC2->currentIndex();
+    Road * p1 = mxodr.GetRoad(ch1);
+    Road * p2 = mxodr.GetRoad(ch2);
+
+    int contactype;
+    int turnstraight;
+    AutoRoadContact::CalcContact(p1,p2,contactype,turnstraight);
+
+    switch (contactype) {
+    case 0:
+        mpCBRC1->setCurrentIndex(0);
+        mpCBRC2->setCurrentIndex(0);
+        break;
+    case 1:
+        mpCBRC1->setCurrentIndex(0);
+        mpCBRC2->setCurrentIndex(1);
+        break;
+    case 2:
+        mpCBRC1->setCurrentIndex(1);
+        mpCBRC2->setCurrentIndex(0);
+        break;
+    case 3:
+        mpCBRC1->setCurrentIndex(1);
+        mpCBRC2->setCurrentIndex(1);
+        break;
+    default:
+        break;
+    }
+
+    ntype1 = mpCBRC1->currentIndex();
+    ntype2 = mpCBRC2->currentIndex();
+    iv::roadcontact rc;
+    rc.mnroad1id = atoi(p1->GetRoadId().data());
+    rc.mnroad2id = atoi(p2->GetRoadId().data());
+    rc.mncon1 = ntype1;
+    rc.mncon2 = ntype2;
+
+    char strname[256];
+    snprintf(strname,256,"%s_%s_%s_%s",p1->GetRoadId().data(),mpCBRC1->currentText().toLatin1().data(),
+             p2->GetRoadId().data(),mpCBRC2->currentText().toLatin1().data());
+    mpCBRoadCon->clear();
+    mpCBRoadCon->addItem(strname);
+    mpCBLane1->clear();
+    mpCBLane2->clear();
+
+
+    mpCBLane1Lane2->clear();
+    mpCBLane1Lane2op->clear();
+
+    if(p1->GetLaneSectionCount()>0)
+    {
+        LaneSection * pLS;
+        if(ntype1 == 0)
+            pLS = p1->GetLaneSection(0);
+        else
+            pLS = p1->GetLaneSection(p1->GetLaneSectionCount()-1);
+        int i;
+        for(i=0;i<pLS->GetLaneCount();i++)
+        {
+            Lane * pL = pLS->GetLane(i);
+//            if((pL->GetId() != 0)&&(strncmp(pL->GetType().data(),"driving",255)==0))
+            if(pL->GetId() != 0)
+                mpCBLane1->addItem(QString::number(pL->GetId()));
+        }
+
+    }
+
+    if(p2->GetLaneSectionCount()>0)
+    {
+        LaneSection * pLS;
+        if(ntype1 == 0)
+            pLS = p2->GetLaneSection(0);
+        else
+            pLS = p2->GetLaneSection(p2->GetLaneSectionCount()-1);
+        int i;
+        for(i=0;i<pLS->GetLaneCount();i++)
+        {
+            Lane * pL = pLS->GetLane(i);
+ //           if((pL->GetId() != 0)&&(strncmp(pL->GetType().data(),"driving",255)==0))
+            if(pL->GetId() != 0)
+                mpCBLane2->addItem(QString::number(pL->GetId()));
+        }
+
+    }
+
+    mvectorrc.clear();
+    mvectorrc.push_back(rc);
+
+    mpCBRoadType->setCurrentIndex(turnstraight);
+
+}
+
 void MainWindow::onClickRoadContact()
 {
     int ch1,ch2;
@@ -3678,6 +3792,9 @@ int MainWindow::GetEndPoint(Road *proad, double &x, double &y, double &hdg)
 
     RoadGeometry * pgeo = pblock->GetLastGeometry();
 
+    proad->GetGeometryCoords(proad->GetRoadLength(),x,y,hdg);
+    return 0;
+
 
     //0-line, 1-arc, 2-spiral 3-poly3 4-parampoly3
     switch (pgeo->GetGeomType()) {
@@ -3720,21 +3837,35 @@ int MainWindow::GetEndPoint(Road *proad, double &x, double &y, double &hdg)
         double s = ppoly3->GetLength();
 //        xtem = ppoly3->GetuA() + ppoly3->GetuB() * s  + ppoly3->GetuC() * s*s  + ppoly3->GetuD() * s*s*s ;
 //        ytem = ppoly3->GetvA() + ppoly3->GetvB() * s + ppoly3->GetvC() * s*s  + ppoly3->GetvD() * s*s*s ;
-        xtem = ppoly3->GetuA() + ppoly3->GetuB()  + ppoly3->GetuC()   + ppoly3->GetuD()  ;
-        ytem = ppoly3->GetvA() + ppoly3->GetvB() + ppoly3->GetvC()   + ppoly3->GetvD() ;
+        if(ppoly3->GetNormal())
+        {
+            xtem = ppoly3->GetuA() + ppoly3->GetuB()  + ppoly3->GetuC()   + ppoly3->GetuD()  ;
+            ytem = ppoly3->GetvA() + ppoly3->GetvB() + ppoly3->GetvC()   + ppoly3->GetvD() ;
+        }
+        else
+        {
+            xtem = ppoly3->GetuA() + ppoly3->GetuB() * s  + ppoly3->GetuC() * s*s  + ppoly3->GetuD() * s*s*s ;
+            ytem = ppoly3->GetvA() + ppoly3->GetvB() * s + ppoly3->GetvC() * s*s  + ppoly3->GetvD() * s*s*s ;
+        }
         x = xtem*cos(ppoly3->GetHdg()) - ytem * sin(ppoly3->GetHdg()) + ppoly3->GetX();
         y = xtem*sin(ppoly3->GetHdg()) + ytem * cos(ppoly3->GetHdg()) + ppoly3->GetY();
         s = ppoly3->GetLength()*0.99;
         if(s>0)
         {
             double frel = 0.99;
- //           xtem1 = ppoly3->GetuA() + ppoly3->GetuB() * s  + ppoly3->GetuC() * s*s  + ppoly3->GetuD() * s*s*s ;
- //           ytem1 = ppoly3->GetvA() + ppoly3->GetvB() * s + ppoly3->GetvC() * s*s  + ppoly3->GetvD() * s*s*s ;
-            xtem1 = ppoly3->GetuA() + ppoly3->GetuB() * frel + ppoly3->GetuC() *frel*frel   + ppoly3->GetuD()*frel*frel*frel  ;
-            ytem1 = ppoly3->GetvA() + ppoly3->GetvB()*frel + ppoly3->GetvC()*frel*frel   + ppoly3->GetvD()*frel*frel*frel ;
-            x1 = xtem*cos(ppoly3->GetHdg()) - ytem * sin(ppoly3->GetHdg()) + ppoly3->GetX();
-            y1 = xtem*sin(ppoly3->GetHdg()) + ytem * cos(ppoly3->GetHdg()) + ppoly3->GetY();
-            hdg = geofit::CalcHdg(xtem1,ytem1,x1,y1);
+            if(ppoly3->GetNormal() == false)
+            {
+                xtem1 = ppoly3->GetuA() + ppoly3->GetuB() * s  + ppoly3->GetuC() * s*s  + ppoly3->GetuD() * s*s*s ;
+                ytem1 = ppoly3->GetvA() + ppoly3->GetvB() * s + ppoly3->GetvC() * s*s  + ppoly3->GetvD() * s*s*s ;
+            }
+            else
+            {
+                xtem1 = ppoly3->GetuA() + ppoly3->GetuB() * frel + ppoly3->GetuC() *frel*frel   + ppoly3->GetuD()*frel*frel*frel  ;
+                ytem1 = ppoly3->GetvA() + ppoly3->GetvB()*frel + ppoly3->GetvC()*frel*frel   + ppoly3->GetvD()*frel*frel*frel ;
+            }
+            x1 = xtem1*cos(ppoly3->GetHdg()) - ytem1 * sin(ppoly3->GetHdg()) + ppoly3->GetX();
+            y1 = xtem1*sin(ppoly3->GetHdg()) + ytem1 * cos(ppoly3->GetHdg()) + ppoly3->GetY();
+            hdg = geofit::CalcHdg(x1,y1,x,y);
         }
         else
         {

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

@@ -74,6 +74,7 @@ using namespace Eigen;
 #include "roaddigit.h"
 
 #include "xodrscenfunc.h"
+#include "autoroadcontact.h"
 
 namespace Ui {
 class MainWindow;
@@ -138,6 +139,7 @@ private slots:
     void onClickClearRoadLane();
     void onClickAddRoad();
     void onClickRoadContact();
+    void onClickAutoRoadContact();
 
     void onClickLoad();
     void onClickSave();

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

@@ -29,6 +29,7 @@ QMAKE_LFLAGS += -no-pie
 
 SOURCES += \
     autoconnect.cpp \
+    autoroadcontact.cpp \
     dialogaddroadfromrtk.cpp \
     dialogcalcs.cpp \
     dialogeditlane.cpp \
@@ -40,6 +41,7 @@ SOURCES += \
     dialogroadmerge.cpp \
     dialogroadmirror.cpp \
     dialogroadmove.cpp \
+    dialogroadobject.cpp \
     dialogroadrotate.cpp \
     dialogroadsplit.cpp \
     filebackup.cpp \
@@ -75,6 +77,7 @@ SOURCES += \
 
 HEADERS += \
     autoconnect.h \
+    autoroadcontact.h \
     dialogaddroadfromrtk.h \
     dialogcalcs.h \
     dialogeditlane.h \
@@ -86,6 +89,7 @@ HEADERS += \
     dialogroadmerge.h \
     dialogroadmirror.h \
     dialogroadmove.h \
+    dialogroadobject.h \
     dialogroadrotate.h \
     dialogroadsplit.h \
     filebackup.h \
@@ -127,6 +131,7 @@ FORMS += \
         dialogroadmerge.ui \
         dialogroadmirror.ui \
         dialogroadmove.ui \
+        dialogroadobject.ui \
         dialogroadrotate.ui \
         dialogroadsplit.ui \
         mainwindow.ui \

+ 3 - 0
src/tool/map_lanetoxodr/roadeditdialog.cpp

@@ -645,4 +645,7 @@ void RoadEditDialog::on_pushButton_EditRoadObjects_clicked()
     return;
 #endif
 
+    DialogRoadObject roadobject(this);
+    roadobject.exec();
+
 }

+ 1 - 0
src/tool/map_lanetoxodr/roadeditdialog.h

@@ -20,6 +20,7 @@
 #include "dialogroadrotate.h"
 #include "dialogroadmirror.h"
 #include "dialoglaneoffset.h"
+#include "dialogroadobject.h"
 
 #include "roaddigit.h"
 #include "xodrscenfunc.h"