Browse Source

change opendrive. parampoly3, pRange to [0,1]

yuchuli 3 years ago
parent
commit
39be5ec2eb
2 changed files with 12 additions and 5 deletions
  1. 5 2
      src/tool/map_lanetoxodr/mainwindow.cpp
  2. 7 3
      src/tool/map_lanetoxodr/roaddigit.cpp

+ 5 - 2
src/tool/map_lanetoxodr/mainwindow.cpp

@@ -347,14 +347,17 @@ void MainWindow::ExecPainter()
                 ppp3 = (GeometryParamPoly3 * )pg;
                 int ncount = ppp3->GetLength()* mnfac;
                 double sstep;
+                double arclength = ppp3->GetLength();
                 if(ncount > 0)sstep = ppp3->GetLength()/ncount;
+
                 else sstep = 10000.0;
                 double s = 0;
                 while(s < ppp3->GetLength())
                 {
                     double xtem,ytem;
-                    xtem = ppp3->GetuA() +  ppp3->GetuB() * s +  ppp3->GetuC() * s*s +  ppp3->GetuD() * s*s*s;
-                    ytem = ppp3->GetvA() + ppp3->GetvB() * s + ppp3->GetvC() * s*s + ppp3->GetvD() * s*s*s;
+                    double pRange = s/arclength;
+                    xtem = ppp3->GetuA() +  ppp3->GetuB() * pRange +  ppp3->GetuC() * pRange*pRange +  ppp3->GetuD() * pRange*pRange*pRange;
+                    ytem = ppp3->GetvA() + ppp3->GetvB() * pRange + ppp3->GetvC() * pRange*pRange + ppp3->GetvD() * pRange*pRange*pRange;
                     x = xtem*cos(ppp3->GetHdg()) - ytem * sin(ppp3->GetHdg()) + ppp3->GetX();
                     y = xtem*sin(ppp3->GetHdg()) + ytem * cos(ppp3->GetHdg()) + ppp3->GetY();
                     x = x + mfViewMoveX;

+ 7 - 3
src/tool/map_lanetoxodr/roaddigit.cpp

@@ -303,10 +303,13 @@ void RoadDigit::CalcLine(double fspace)
             int ncount = ppp3->GetLength() /fspace;
             if(ncount < 5)ncount = 5;
             double sstep;
+            double arclength = ppp3->GetLength();
             if(ncount > 0)sstep = ppp3->GetLength()/ncount;
             else sstep = 10000.0;
             double s = 0;
             double xtem,ytem;
+            double pr;
+
             xtem = ppp3->GetuA() +  ppp3->GetuB() * s +  ppp3->GetuC() * s*s +  ppp3->GetuD() * s*s*s;
             ytem = ppp3->GetvA() + ppp3->GetvB() * s + ppp3->GetvC() * s*s + ppp3->GetvD() * s*s*s;
             x = xtem*cos(ppp3->GetHdg()) - ytem * sin(ppp3->GetHdg()) + ppp3->GetX();
@@ -323,9 +326,10 @@ void RoadDigit::CalcLine(double fspace)
             double flasty = pg->GetY();
             while(s <= ppp3->GetLength())
             {
-
-                xtem = ppp3->GetuA() +  ppp3->GetuB() * s +  ppp3->GetuC() * s*s +  ppp3->GetuD() * s*s*s;
-                ytem = ppp3->GetvA() + ppp3->GetvB() * s + ppp3->GetvC() * s*s + ppp3->GetvD() * s*s*s;
+                double pr= 1.0;
+                if(arclength > 1)pr = s/arclength;
+                xtem = ppp3->GetuA() +  ppp3->GetuB() * pr +  ppp3->GetuC() * pr*pr +  ppp3->GetuD() * pr*pr*pr;
+                ytem = ppp3->GetvA() + ppp3->GetvB() * pr + ppp3->GetvC() * pr*pr + ppp3->GetvD() * pr*pr*pr;
                 x = xtem*cos(ppp3->GetHdg()) - ytem * sin(ppp3->GetHdg()) + ppp3->GetX();
                 y = xtem*sin(ppp3->GetHdg()) + ytem * cos(ppp3->GetHdg()) + ppp3->GetY();