Browse Source

change tool/map_lanetoxodr. Change straight cotanct, if dis >= 10 use bezier geo.

yuchuli 3 years ago
parent
commit
a8949ffedb

+ 33 - 0
src/tool/map_lanetoxodr/geofit.cpp

@@ -947,6 +947,39 @@ geofit & geofit::Inst()
     return x;
 }
 
+
+std::vector<geobase> geofit::CreateBezierGeo(double startx, double starty, double starthdg, double endx, double endy, double endhdg)
+{
+    geobase xgeobezier;
+
+    int nbtype;
+    double fabc[3],fxy[2],fblen,fbhdg;
+   geofit::Inst().CreateBezier(startx,starty,starthdg,
+                 endx,endy,endhdg,
+                 0.35,0.35,xgeobezier.mfu,xgeobezier.mfv,xgeobezier.mfLen,
+                 nbtype,fabc,&fbhdg,fxy,&fblen);
+    if(nbtype == 2)
+    {
+    xgeobezier.mfHdg = starthdg;
+    xgeobezier.mfX = startx;
+    xgeobezier.mfY = starty;
+    xgeobezier.mnType = 2;
+    }
+    else
+    {
+        xgeobezier.mnType = 0; //Line
+        xgeobezier.mfHdgStart = fbhdg;
+        xgeobezier.mfHdg = fbhdg;
+        xgeobezier.mfX = fxy[0];
+        xgeobezier.mfY = fxy[1];
+        xgeobezier.mfLen = fblen;
+    }
+
+    std::vector<geobase> xvectorgeo;
+    xvectorgeo.push_back(xgeobezier);
+    return xvectorgeo;
+}
+
 std::vector<geobase> geofit::CreateLineGeo(double startx, double starty, double starthdg, double endx, double endy, double endhdg)
 {
 

+ 1 - 1
src/tool/map_lanetoxodr/geofit.h

@@ -77,7 +77,7 @@ public:
     static std::vector<geobase> CreateLineGeo(double startx,double starty,double starthdg,double endx,double endy,double endhdg);
     static std::vector<geobase> CreateTurnGeo(double startx,double starty,double starthdg,double endx,double endy,double endhdg,double R);
     static std::vector<geobase> CreateUTurnGeo(double startx,double starty,double starthdg,double endx,double endy,double endhdg,double fextend);
-
+    static std::vector<geobase> CreateBezierGeo(double startx,double starty,double starthdg,double endx,double endy,double endhdg);
 
 };
 

+ 19 - 8
src/tool/map_lanetoxodr/mainwindow.cpp

@@ -3472,7 +3472,18 @@ void MainWindow::onClickCreateRoad()
         xvectorgeo = CreateTurnGeo(startx,starty,starthdg,endx,endy,endhdg,R);
         break;
     case 1:
-        xvectorgeo = CreateLineGeo(startx,starty,starthdg,endx,endy,endhdg);
+        {
+            double fdis = sqrt(pow(startx - endx,2) +pow(starty -endy,2));
+            if((fdis<10) || (starthdg == endhdg))
+            {
+                xvectorgeo = CreateLineGeo(startx,starty,starthdg,endx,endy,endhdg);
+            }
+            else
+            {
+                xvectorgeo = geofit::CreateBezierGeo(startx,starty,starthdg,endx,endy,endhdg);
+            }
+//
+        }
         break;
     case 2:
         xvectorgeo = CreateUTurnGeo(startx,starty,starthdg,endx,endy,endhdg,R);
@@ -3540,7 +3551,7 @@ void MainWindow::onClickCreateRoad()
                 pgb->AddGeometryParamPoly3(s,pbez->mfX,pbez->mfY,
                                            pbez->mfHdg,pbez->mfLen,pbez->mfu[0],
                         pbez->mfu[1],pbez->mfu[2],pbez->mfu[3],pbez->mfv[0],
-                        pbez->mfv[1],pbez->mfv[2],pbez->mfv[3]);
+                        pbez->mfv[1],pbez->mfv[2],pbez->mfv[3],false);
                 break;
             }
             s = s + xvectorgeo[j].mfLen;
@@ -3591,7 +3602,7 @@ void MainWindow::onClickCreateRoad()
 
             pLL->AddWidthRecord(0,pa[i],pb[i],
                                 0,0);
-            pLL->AddRoadMarkRecord(0,"solid","standard","standard",0.15,"false");
+ //           pLL->AddRoadMarkRecord(0,"solid","standard","standard",0.15,"false");
 
         }
 
@@ -3632,7 +3643,7 @@ void MainWindow::onClickCreateRoad()
 
                 pLL->AddWidthRecord(0,pa[i],pb[i],
                                     0,0);
-                pLL->AddRoadMarkRecord(0,"solid","standard","standard",0.15,"false");
+  //              pLL->AddRoadMarkRecord(0,"solid","standard","standard",0.15,"false");
 
             }
         }
@@ -3773,14 +3784,14 @@ void MainWindow::onClickCreateRoad()
 
             pLL->AddWidthRecord(0,pa[i],pb[i],
                                 0,0);
-            pLL->AddRoadMarkRecord(0,"solid","standard","standard",0.15,"false");
+//            pLL->AddRoadMarkRecord(0,"solid","standard","standard",0.15,"false");
 
             pLS2->AddLane(-1,(i+1)*(-1),strvectorlanetype[i],false,false);
             pLL = pLS2->GetLane(pLS2->GetLaneCount() - 1);
 
             pLL->AddWidthRecord(0,pa[i]+pb[i]*xroadlen1 ,pb[i],
                                 0,0);
-            pLL->AddRoadMarkRecord(0,"solid","standard","standard",0.15,"false");
+//            pLL->AddRoadMarkRecord(0,"solid","standard","standard",0.15,"false");
 
         }
         int noplanecount = mvectorrc[0].mvectorlcop.size();
@@ -3820,14 +3831,14 @@ void MainWindow::onClickCreateRoad()
 
                 pLL->AddWidthRecord(0,pa[i],pb[i],
                                     0,0);
-                pLL->AddRoadMarkRecord(0,"solid","standard","standard",0.15,"false");
+ //               pLL->AddRoadMarkRecord(0,"solid","standard","standard",0.15,"false");
 
                 pLS2->AddLane(1,(i+1),strvectorlanetype[i],false,false);
                 pLL = pLS2->GetLane(pLS2->GetLaneCount() - 1);
 
                 pLL->AddWidthRecord(0,pa[i]+pb[i]*xroadlen1 ,pb[i],
                                     0,0);
-                pLL->AddRoadMarkRecord(0,"solid","standard","standard",0.15,"false");
+//                pLL->AddRoadMarkRecord(0,"solid","standard","standard",0.15,"false");
 
             }
         }