Selaa lähdekoodia

change map_lanetoxor.

yuchuli 2 vuotta sitten
vanhempi
commit
3bb5638d05

+ 66 - 0
src/tool/map_lanetoxodr/function/cdaproc.cpp

@@ -370,3 +370,69 @@ int CDAProc::Proc(std::string strxlsxpath,OpenDrive * pxodr)
 
     return ProcRoad(pxodr,strtype,strradius,strroadlen,strlanewidth,strlannecount,strlanemarktype,strlanemarkcolor,strlanemarktype);
 }
+
+#include <QDateTime>
+#include <OpenDrive/OpenDriveXmlWriter.h>
+int CDAProc::ProcRoads(std::string strxlsxpath,std::string stroutpath)
+{
+    void * pexcel = ServiceExcelAPI.Openxlsx(strxlsxpath);
+    std::string strtype;
+    std::string strradius;
+    std::string strroadlen;
+    std::string strlanewidth;
+    std::string strlannecount;
+    std::string strlanetype;
+    std::string strlanemarkcolor;
+    std::string strlanemarktype;
+    std::string strname;
+    bool bComplete = false;
+    int i = 4;
+    int nr = 0;
+    while(bComplete == false)
+    {
+        strtype = "";
+        strname = "";
+        ServiceExcelAPI.getcellvalue(pexcel,26,i,strname);
+        ServiceExcelAPI.getcellvalue(pexcel,119,i,strtype);
+        ServiceExcelAPI.getcellvalue(pexcel,120,i,strradius);
+        ServiceExcelAPI.getcellvalue(pexcel,121,i,strroadlen);
+        ServiceExcelAPI.getcellvalue(pexcel,122,i,strlanewidth);
+        ServiceExcelAPI.getcellvalue(pexcel,123,i,strlannecount);
+        //    ServiceExcelAPI.getcellvalue(pexcel,124,4,strlanetype);
+        ServiceExcelAPI.getcellvalue(pexcel,124,i,strlanemarkcolor);
+        ServiceExcelAPI.getcellvalue(pexcel,125,i,strlanemarktype);
+        if((strtype == "")||(strname == ""))
+        {
+            bComplete = true;
+        }
+        else
+        {
+            std::cout<<" name : "<<strname<<" type: "<<strtype<<std::endl;
+            OpenDrive xxodr;
+            int nrtn = ProcRoad(&xxodr,strtype,strradius,strroadlen,strlanewidth,strlannecount,strlanemarktype,strlanemarkcolor,strlanemarktype);
+            if(nrtn == 0)
+            {
+                if(xxodr.GetHeader() == NULL)
+                {
+                    xxodr.SetHeader(1,1,"adcmap",1.1,QDateTime::currentDateTime().toString("yyyy-MM-dd").toLatin1().data(),0,0,0,0,39,117,0);
+                    xxodr.GetHeader()->SetVendor("adc");
+                }
+                else
+                {
+                    xxodr.GetHeader()->SetVendor("adc");
+                }
+                OpenDriveXmlWriter x(&xxodr);
+                std::string  strfilepath = stroutpath + "/"+ strname+".xodr";
+                x.WriteFile(strfilepath);
+            }
+            else
+            {
+                nr = nr + nrtn;
+                std::cout<<" Convert row "<<i<<" name: "<<strname<<" fail. fail code : "<<nrtn<<std::endl;
+            }
+        }
+        i++;
+    }
+    ServiceExcelAPI.Closexlsx(pexcel);
+    return nr;
+}

+ 1 - 0
src/tool/map_lanetoxodr/function/cdaproc.h

@@ -11,6 +11,7 @@ class CDAProc
 public:
     CDAProc();
     static int Proc(std::string strxlsxpath,OpenDrive * pxodr);
+    static int ProcRoads(std::string strxlsxpath,std::string stroutpath);
     static int ProcRoad(OpenDrive * pxodr,  std::string strtype,std::string strradius,std::string strroadlen,std::string strlanewidth,
                         std::string strlannecount,std::string strlanetype,std::string strlanemarkcolor,std::string strlanemarktype);
     static int ProcLineRoad(OpenDrive * pxodr,  std::string strtype,std::string strradius,std::string strroadlen,std::string strlanewidth,

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

@@ -6052,3 +6052,31 @@ void MainWindow::on_actionDraw_Road_From_CDA_triggered()
         UpdateScene();
     }
 }
+
+void MainWindow::on_actionAdd_Roads_From_Labels_triggered()
+{
+
+    if(ServiceExcelAPI.IsLoad() == false)
+    {
+        QMessageBox::warning(this,tr("Waring"),tr("Can't load ivxlnt plugin."),QMessageBox::YesAll);
+        return;
+    }
+    QString str = QFileDialog::getOpenFileName(this,"Load xlsx",".","*.xlsx");
+    if(str.isEmpty())return;
+
+//    QString str = "/home/yuchuli/下载/Scenarios(1).xlsx";
+
+    QString strdir = QFileDialog::getExistingDirectory(this,tr("Set Save Directory"),".");
+    if(strdir.isNull())return;
+
+    int nrtn = CDAProc::ProcRoads(str.toStdString(),strdir.toStdString());
+
+    if(nrtn == 0)
+    {
+        QMessageBox::information(this,tr("Info"),tr("Successfully."),QMessageBox::YesAll);
+    }
+    else
+    {
+        QMessageBox::warning(this,tr("Warning"),tr("Some Item convert fail. Please Check."),QMessageBox::YesAll);
+    }
+}

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

@@ -246,6 +246,8 @@ private slots:
 
     void on_actionDraw_Road_From_CDA_triggered();
 
+    void on_actionAdd_Roads_From_Labels_triggered();
+
 private:
 
 

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

@@ -62,6 +62,7 @@
     <addaction name="CreateAfter"/>
     <addaction name="actionAdd_Road_From_CDA"/>
     <addaction name="actionDraw_Road_From_CDA"/>
+    <addaction name="actionAdd_Roads_From_Labels"/>
    </widget>
    <widget class="QMenu" name="menuView">
     <property name="title">
@@ -218,6 +219,11 @@
     <string>Draw Road From Label</string>
    </property>
   </action>
+  <action name="actionAdd_Roads_From_Labels">
+   <property name="text">
+    <string>Add Roads From Labels</string>
+   </property>
+  </action>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <resources>