Selaa lähdekoodia

change driver_map_xodrload for fix two road have same satart and end point.

yuchuli 4 vuotta sitten
vanhempi
commit
bb1e4058af

+ 1 - 0
src/common/ivchart/ivchart_impl.cpp

@@ -1,5 +1,6 @@
 #include "ivchart_impl.h"
 
+
 namespace  iv {
 
 

+ 22 - 2
src/driver/driver_map_xodrload/xodrdijkstra.cpp

@@ -171,6 +171,10 @@ xodrdijkstra::xodrdijkstra(OpenDrive  * pxodr)
                 {
                     fseclen = px->GetRoadLength() - px->GetLaneSection(j)->GetS();
                 }
+//                if((px->GetRoadId() == "10019")||(px->GetRoadId() == "10020"))
+//                {
+//                    int axy = 1;
+//                }
                 roadedge xroad(atoi(px->GetRoadId().data()),atoi(px->GetRoadJunction().data()),fseclen,2,j,px);
 
 //                roadedge xroad(atoi(px->GetRoadId().data()),atoi(px->GetRoadJunction().data()),px->GetRoadLength(),2,j,px);
@@ -1254,6 +1258,8 @@ std::vector<int> xodrdijkstra::getpath(int srcroadid, int nsrclr, int dstroadid,
     {
         givlog->debug("%d %d %d %d",i,mroadedge[rtnpath[rtnpath.size()-1-i]].mroadid,mroadedge[rtnpath[rtnpath.size()-1-i]].mnleftright,
                 mroadedge[rtnpath[rtnpath.size()-1-i]].mnsectionid);
+//        qDebug("%d %d %d %d",i,mroadedge[rtnpath[rtnpath.size()-1-i]].mroadid,mroadedge[rtnpath[rtnpath.size()-1-i]].mnleftright,
+//                mroadedge[rtnpath[rtnpath.size()-1-i]].mnsectionid);
         rtnpath2.push_back(rtnpath[rtnpath.size()-1-i]);
     }
 
@@ -1273,12 +1279,26 @@ int xodrdijkstra::getroadedgefromvertex(int nstart, int nend)
 {
     int i;
     int nrtn = -1;
+    double flen = -1;
+//    int nlast = -1;
     for(i=0;i<mroadedge.size();i++)
     {
         if((nstart == mroadedge[i].mvertexstart)&&(nend == mroadedge[i].mvertexend))
         {
-            nrtn = i;
-            break;
+            if(flen >0)
+            {
+                if(mroadedge[i].mlen < flen)
+                {
+                    flen = mroadedge[i].mlen;
+                    nrtn = i;
+                }
+            }
+            else
+            {
+                flen = mroadedge[i].mlen;
+                nrtn = i;
+            }
+ //           break;
         }
     }
     return nrtn;

+ 1 - 1
src/test/testivchart/main.cpp

@@ -15,7 +15,7 @@ void testthread(std::string varname,int ninter,double fratio,double foff)
     while(gbrun)
     {
         givchart->chartvalue(varname,foff + fratio*sin(index*2.0*M_PI/100),-1,1);
-        index = index + 10;
+        index = index + 1;
         std::this_thread::sleep_for(std::chrono::milliseconds(ninter));
     }
 }

+ 7 - 1
src/tool/view_ivchart/ivchartproc.cpp

@@ -1,5 +1,7 @@
 #include "ivchartproc.h"
 
+#include "functional"
+
 ivchartproc::ivchartproc()
 {
     bool bconnect = QDBusConnection::sessionBus().connect(QString(),"/catarc/adc",  "adciv.interface", "ivchart",this,SLOT(onChartMsg(QByteArray)));
@@ -26,11 +28,14 @@ void ivchartproc::run()
             {
                 bool bhave = false;
                 int j;
+                std::hash<std::string > h;
+                size_t hash_unit = h(xvectorivarray[i].xivchartunit(k).strvarname());
                 mMutex.lock();
+
                 int ncucount = mvectorCU.size();
                 for(j=0;j<ncucount;j++)
                 {
-                    if(xvectorivarray[i].xivchartunit(k).strvarname() == mvectorCU[j].strname)
+                    if(hash_unit == mvectorCU[j].hash_name)
                     {
                         mvectorCU[j].mvectorchartunit.push_back(xvectorivarray[i].xivchartunit(k));
                         bhave = true;
@@ -42,6 +47,7 @@ void ivchartproc::run()
                     ChartUnit xcu;
                     xcu.strname = xvectorivarray[i].xivchartunit(k).strvarname();
                     xcu.mvectorchartunit.push_back(xvectorivarray[i].xivchartunit(k));
+                    xcu.hash_name = hash_unit;
                     mvectorCU.push_back(xcu);
                 }
 

+ 1 - 0
src/tool/view_ivchart/ivchartproc.h

@@ -15,6 +15,7 @@ class ChartUnit
 {
 public:
     std::string strname;
+    size_t hash_name;
     std::vector<iv::ivchart::ivchartunit> mvectorchartunit;
 };
 

+ 7 - 1
src/tool/view_ivchart/mainwindow.cpp

@@ -1,5 +1,7 @@
 #include "mainwindow.h"
 #include "ui_mainwindow.h"
+#include <functional>
+#include <iostream>
 
 MainWindow::MainWindow(QWidget *parent)
     : QMainWindow(parent)
@@ -7,6 +9,10 @@ MainWindow::MainWindow(QWidget *parent)
 {
     ui->setupUi(this);
 
+    std::hash<std::string> h;
+    size_t n = h("Just fucking google it");
+    std::cout << n << std::endl;
+
     m_chart = new QChart();
     m_chart->setTheme(QChart::ChartThemeLight);//设置白色主题
     m_chart->setDropShadowEnabled(true);//背景阴影    m_chart->setAutoFillBackground(true);  //设置背景自动填充
@@ -127,7 +133,7 @@ void MainWindow::on_actionSelect_Data_triggered()
             //创建X轴和Y轴
             QValueAxis *axisX = new QValueAxis;
             axisX->setRange(-3000,0);    //默认则坐标为动态计算大小的
-            axisX->setLabelFormat("%dS");
+            axisX->setLabelFormat("%dms");
             QValueAxis *axisY = new QValueAxis;
             axisY->setRange(-1,1);    //默认则坐标为动态计算大小的
             axisY->setTitleText("value值");