Browse Source

change tool/map_lanetoxodr. add road speedmax support.

yuchuli 3 years ago
parent
commit
d71ba14134

+ 28 - 0
src/common/common/xodr/OpenDrive/Road.cpp

@@ -991,6 +991,34 @@ short int Road::GetGeometryCoords(double s_check, double &retX, double &retY, do
 	//if s_check does not belong to the road, return -999
 	return -999;
 }
+
+int Road::GetRoadSpeedMax(double s_check, double &fspeed)
+{
+    if(mRoadTypeVector.size() == 0)
+    {
+        return -1;
+    }
+    int indexspeed = -1;
+    unsigned int i;
+    for(i=0;i<mRoadTypeVector.size();i++)
+    {
+        if(mRoadTypeVector[i].GetS() <= s_check)
+        {
+            indexspeed = i;
+        }
+    }
+
+    if(indexspeed == -1)return -2;
+    if(mRoadTypeVector[indexspeed].GetRoadTypeSpeedCount() > 0)
+    {
+        RoadTypeSpeed * pRoadTypeSpeed = mRoadTypeVector[indexspeed].GetRoadTypeSpeed(0);
+        string strtype = pRoadTypeSpeed->Getunit();
+        fspeed = pRoadTypeSpeed->GetmaxSpeed();
+        if(strtype == "km/h")fspeed = fspeed/3.6;
+        if(strtype == "mph")fspeed = fspeed * 1.609344 /3.6;
+    }
+    return 0;
+}
 //-----------
 
 /**

+ 1 - 0
src/common/common/xodr/OpenDrive/Road.h

@@ -306,6 +306,7 @@ public:
 	short int GetGeometryCoords(double s_check, double &retX, double &retY);
 	short int GetGeometryCoords(double s_check, double &retX, double &retY, double &retHDG);
 	
+    int GetRoadSpeedMax(double s_check,double & fspeed);
 
 	/**
 	 * Other evaluation

+ 2 - 0
src/driver/driver_map_xodrload/globalplan.cpp

@@ -1638,6 +1638,8 @@ int GetLaneOriTotal(Road * pRoad, int nlane,double s,int & nori, int & ntotal,do
     ntotal = 0;
     fSpeed = -1; //if -1 no speedlimit for map
 
+    pRoad->GetRoadSpeedMax(s,fSpeed);   //Get Road Speed Limit.
+
     int nlanecount = pLS->GetLaneCount();
     for(i=0;i<nlanecount;i++)
     {