瀏覽代碼

change driver_map_lanetoxodr. fix change lane problem.

yuchuli 3 年之前
父節點
當前提交
24ac8c778a
共有 2 個文件被更改,包括 132 次插入36 次删除
  1. 113 35
      src/driver/driver_map_xodrload/xodrdijkstra.cpp
  2. 19 1
      src/tool/map_lanetoxodr/autoconnect.cpp

+ 113 - 35
src/driver/driver_map_xodrload/xodrdijkstra.cpp

@@ -1442,6 +1442,7 @@ std::vector<pathsection> xodrdijkstra::getgpspoint(int srcroadid, int nsrclr, in
         xps.msectionid = mroadedge[xvectorpath[i]].mnsectionid;
         xps.mnroadedgeid = xvectorpath[i];
         xps.mpRoad = pRoad;
+        xps.secondsel = xps.mainsel;
         xpathsection.push_back(xps);
     }
 
@@ -1456,60 +1457,101 @@ std::vector<pathsection> xodrdijkstra::getgpspoint(int srcroadid, int nsrclr, in
         Lane * pLane2 = xodrfunc::GetLaneByID(pLS2,xpathsection[i-1].mainsel);
 
         int nlr = mroadedge[xvectorpath[i]].mnleftright;
+        int nlr2 = mroadedge[xvectorpath[i-1]].mnleftright;
 
         bool bNeedChangeLane = true;
         if(nlr == 2)
         {
-            if(pLane2->IsSuccessorSet())
-            {
-                if(pLane2->GetSuccessor() != xpathsection[i].mainsel)
+
+                if((pLane2->IsSuccessorSet()) &&(nlr2 == 2))
                 {
-                    bool bfindgood = false;
-                    int ngoodlane = 0;
-                    int j;
-                    for(j=0;j<pLS2->GetLaneCount();j++)
+                    if(pLane2->GetSuccessor() != xpathsection[i].mainsel)
                     {
-                        if(pLS2->GetLane(j)->IsSuccessorSet())
+                        bool bfindgood = false;
+                        int ngoodlane = 0;
+                        int j;
+                        for(j=0;j<pLS2->GetLaneCount();j++)
                         {
-                            if(pLS2->GetLane(j)->GetSuccessor() == xpathsection[i].mainsel)
+                            if(pLS2->GetLane(j)->IsSuccessorSet())
                             {
-                                ngoodlane = pLS2->GetLane(j)->GetId();
-                                bfindgood = true;
-                                break;
+                                if(pLS2->GetLane(j)->GetSuccessor() == xpathsection[i].mainsel)
+                                {
+                                    ngoodlane = pLS2->GetLane(j)->GetId();
+                                    bfindgood = true;
+                                    break;
+                                }
                             }
                         }
+                        if(bfindgood)
+                        {
+                            xpathsection[i-1].mainsel = ngoodlane;
+                            xpathsection[i-1].mnStartLaneSel = ngoodlane;
+                            xpathsection[i-1].mnEndLaneSel = ngoodlane;
+                            bNeedChangeLane = false;
+                        }
                     }
-                    if(bfindgood)
+                    else
                     {
-                        xpathsection[i-1].mainsel = ngoodlane;
-                        xpathsection[i-1].mnStartLaneSel = ngoodlane;
-                        xpathsection[i-1].mnEndLaneSel = ngoodlane;
                         bNeedChangeLane = false;
                     }
                 }
                 else
                 {
-                    bNeedChangeLane = false;
-                }
-            }
-            else
-            {
-                if(pLane->IsPredecessorSet())
-                {
-                    if(pLane->GetPredecessor() != xpathsection[i-1].mainsel)
+                    if((pLane2->IsPredecessorSet()) &&(nlr2 == 1))
                     {
-                        xpathsection[i-1].mainsel = pLane->GetPredecessor();
-                        xpathsection[i-1].mnStartLaneSel = pLane->GetPredecessor();
-                        xpathsection[i-1].mnEndLaneSel = pLane->GetPredecessor();
-                        bNeedChangeLane = false;
+                        if(pLane2->GetPredecessor() != xpathsection[i].mainsel)
+                        {
+                            bool bfindgood = false;
+                            int ngoodlane = 0;
+                            int j;
+                            for(j=0;j<pLS2->GetLaneCount();j++)
+                            {
+                                if(pLS2->GetLane(j)->IsPredecessorSet())
+                                {
+                                    if(pLS2->GetLane(j)->GetPredecessor() == xpathsection[i].mainsel)
+                                    {
+                                        ngoodlane = pLS2->GetLane(j)->GetId();
+                                        bfindgood = true;
+                                        break;
+                                    }
+                                }
+                            }
+                            if(bfindgood)
+                            {
+                                xpathsection[i-1].mainsel = ngoodlane;
+                                xpathsection[i-1].mnStartLaneSel = ngoodlane;
+                                xpathsection[i-1].mnEndLaneSel = ngoodlane;
+                                bNeedChangeLane = false;
+                            }
+                        }
+                        else
+                        {
+                            bNeedChangeLane = false;
+                        }
+                    }
+                    else
+                    {
+                        if(pLane->IsPredecessorSet())
+                        {
+                            if(pLane->GetPredecessor() != xpathsection[i-1].mainsel)
+                            {
+                                xpathsection[i-1].mainsel = pLane->GetPredecessor();
+                                xpathsection[i-1].mnStartLaneSel = pLane->GetPredecessor();
+                                xpathsection[i-1].mnEndLaneSel = pLane->GetPredecessor();
+                                bNeedChangeLane = false;
+                            }
+
+                        }
                     }
 
                 }
-            }
+
+
+
         }
         else
         {
-            if(pLane2->IsPredecessorSet())
+            if((pLane2->IsPredecessorSet())&&(nlr2 == 1))
             {
                 if(pLane2->GetPredecessor() != xpathsection[i].mainsel)
                 {
@@ -1543,16 +1585,52 @@ std::vector<pathsection> xodrdijkstra::getgpspoint(int srcroadid, int nsrclr, in
             }
             else
             {
-                if(pLane->IsSuccessorSet())
+                if((pLane2->IsSuccessorSet())&&(nlr2 == 2))
+
                 {
-                    if(pLane->GetSuccessor() != xpathsection[i-1].mainsel)
+                    if(pLane2->GetSuccessor() != xpathsection[i].mainsel)
+                    {
+                        bool bfindgood = false;
+                        int ngoodlane = 0;
+                        int j;
+                        for(j=0;j<pLS2->GetLaneCount();j++)
+                        {
+                            if(pLS2->GetLane(j)->IsSuccessorSet())
+                            {
+                                if(pLS2->GetLane(j)->GetSuccessor() == xpathsection[i].mainsel)
+                                {
+                                    ngoodlane = pLS2->GetLane(j)->GetId();
+                                    bfindgood = true;
+                                    break;
+                                }
+                            }
+                        }
+                        if(bfindgood)
+                        {
+                            xpathsection[i-1].mainsel = ngoodlane;
+                            xpathsection[i-1].mnStartLaneSel = ngoodlane;
+                            xpathsection[i-1].mnEndLaneSel = ngoodlane;
+                            bNeedChangeLane = false;
+                        }
+                    }
+                    else
                     {
-                        xpathsection[i-1].mainsel = pLane->GetSuccessor();
-                        xpathsection[i-1].mnStartLaneSel = pLane->GetSuccessor();
-                        xpathsection[i-1].mnEndLaneSel = pLane->GetSuccessor();
                         bNeedChangeLane = false;
                     }
+                }
+                else
+                {
+                    if(pLane->IsSuccessorSet())
+                    {
+                        if(pLane->GetSuccessor() != xpathsection[i-1].mainsel)
+                        {
+                            xpathsection[i-1].mainsel = pLane->GetSuccessor();
+                            xpathsection[i-1].mnStartLaneSel = pLane->GetSuccessor();
+                            xpathsection[i-1].mnEndLaneSel = pLane->GetSuccessor();
+                            bNeedChangeLane = false;
+                        }
 
+                    }
                 }
             }
 

+ 19 - 1
src/tool/map_lanetoxodr/autoconnect.cpp

@@ -839,7 +839,7 @@ static Road * GetRoadByID(OpenDrive * pxodr,int nroadid)
 
 static void ChangeOpenDrive(OpenDrive * pxodr,std::vector<iv::ivjunction> * pxvectorivjunction,std::vector<iv::roadconnect> * pxvectorroadconn)
 {
-    int i;
+    unsigned int i;
     for(i=0;i<pxvectorivjunction->size();i++)
     {
         bool bnewjunction = true;
@@ -917,6 +917,16 @@ static void ChangeOpenDrive(OpenDrive * pxodr,std::vector<iv::ivjunction> * pxve
         {
             string strpre = QString::number(pxvectorivjunction->at(pr->nprejunctionindex).nopid).toStdString();
             proad->SetPredecessor("junction",strpre,"start");
+
+            LaneSection * pLS = proad->GetLaneSection(0);
+            unsigned int k;
+            for(k=0;k<pLS->GetLaneCount();k++)
+            {
+                if(pLS->GetLane(k)->IsPredecessorSet())
+                {
+                    pLS->GetLane(k)->RemovePredecessor();
+                }
+            }
         }
         else
         {
@@ -951,6 +961,14 @@ static void ChangeOpenDrive(OpenDrive * pxodr,std::vector<iv::ivjunction> * pxve
         {
             string strnxt = QString::number(pxvectorivjunction->at(pr->nnxtjunctionindex).nopid).toStdString();
             proad->SetSuccessor("junction",strnxt,"end");
+
+            LaneSection * pLS = proad->GetLastLaneSection();
+            unsigned int k;
+            for(k=0;k<pLS->GetLaneCount();k++)
+            {
+                if(pLS->GetLane(k)->IsSuccessorSet())
+                    pLS->GetLane(k)->RemoveSuccessor();
+            }
         }
         else
         {