|
@@ -9,6 +9,10 @@ namespace iv {
|
|
|
|
|
|
RoadSample::RoadSample(Road * pRoad)
|
|
|
{
|
|
|
+ mfRefX_max = 0;
|
|
|
+ mfRefY_max = 0;
|
|
|
+ mfRefX_min = 0;
|
|
|
+ mfRefY_min = 0;
|
|
|
SampleRoad(pRoad);
|
|
|
|
|
|
std::vector<RoadPoint> xvectorRoadPoint = mvectorRoadPoint;
|
|
@@ -22,6 +26,8 @@ int RoadSample::SampleRoad(Road * pRoad)
|
|
|
mstrroadid = pRoad->GetRoadId();
|
|
|
mstrroadname = pRoad->GetRoadName();
|
|
|
|
|
|
+ bool bMaxMinInit = false;
|
|
|
+
|
|
|
double fS = 0;
|
|
|
const double fStep = 0.1;
|
|
|
LaneSection * pLS;
|
|
@@ -29,6 +35,8 @@ int RoadSample::SampleRoad(Road * pRoad)
|
|
|
unsigned int i;
|
|
|
int nSec = 0;
|
|
|
|
|
|
+
|
|
|
+
|
|
|
for(i=0;i<nLSCount;i++)
|
|
|
{
|
|
|
pLS = pRoad->GetLaneSection(i);
|
|
@@ -38,6 +46,7 @@ int RoadSample::SampleRoad(Road * pRoad)
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
std::vector<double> xvectorFeaturePoint = GetFeaturePoint(pLS);
|
|
|
|
|
|
double fLastRefX,fLastRefY,fLastRefZ,fLastRefHdg,fLastOffsetValue,fLastS;
|
|
@@ -62,6 +71,7 @@ int RoadSample::SampleRoad(Road * pRoad)
|
|
|
nSec++;
|
|
|
while(fS<send_Section)
|
|
|
{
|
|
|
+
|
|
|
double fRefX,fRefY,fRefZ,fRefHdg,fOffsetValue;
|
|
|
pRoad->GetGeometryCoords(fS,fRefX,fRefY,fRefHdg);
|
|
|
fRefZ = pRoad->GetElevationValue(fS);
|
|
@@ -85,6 +95,11 @@ int RoadSample::SampleRoad(Road * pRoad)
|
|
|
if((fS - sstart_Section)>fStep*0.5)
|
|
|
bIsCrossFeature = IsCrossFeaturePoint(xvectorFeaturePoint,fS,fLastS);
|
|
|
|
|
|
+ if(bIsCrossFeature)
|
|
|
+ {
|
|
|
+ if(fS> send_Section)fS = send_Section;
|
|
|
+ }
|
|
|
+
|
|
|
RoadPoint xRP;
|
|
|
xRP.ms = fS;
|
|
|
xRP.mfRefX = fRefX;
|
|
@@ -94,8 +109,24 @@ int RoadSample::SampleRoad(Road * pRoad)
|
|
|
xRP.mfLaneOffValue = fOffsetValue;
|
|
|
xRP.nSecNum = nSec;
|
|
|
|
|
|
+ if(bMaxMinInit)
|
|
|
+ {
|
|
|
+ if(mfRefX_max<fRefX)mfRefX_max = fRefX;
|
|
|
+ if(mfRefX_min>fRefX)mfRefX_min = fRefX;
|
|
|
+ if(mfRefY_max<fRefY)mfRefY_max = fRefY;
|
|
|
+ if(mfRefY_min>fRefY)mfRefY_min = fRefY;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ mfRefX_max = fRefX;
|
|
|
+ mfRefX_min = fRefX;
|
|
|
+ mfRefY_max = fRefY;
|
|
|
+ mfRefY_min = fRefY;
|
|
|
+ bMaxMinInit = true;
|
|
|
+ }
|
|
|
+
|
|
|
std::vector<LanePoint> xvectorLanePoint;
|
|
|
- SampleLanePoint(pRoad,pLS,fS,xvectorLanePoint);
|
|
|
+ // SampleLanePoint(pRoad,pLS,fS,xvectorLanePoint);
|
|
|
|
|
|
|
|
|
bool bInserPoint = false;
|
|
@@ -112,18 +143,27 @@ int RoadSample::SampleRoad(Road * pRoad)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if((fabs((fRefHdg - fLastRefHdg)/(fS - fLastS))>0.01) ||((fS - fLastS)>=10.0))
|
|
|
+ double fHdgDiff = fRefHdg - fLastRefHdg;
|
|
|
+ if(fHdgDiff>M_PI)fHdgDiff = fHdgDiff - 2.0*M_PI;
|
|
|
+ if(fHdgDiff<-M_PI)fHdgDiff = fHdgDiff + 2.0*M_PI;
|
|
|
+ if((fabs((fHdgDiff)/(1.0))>0.05) ||((fS - fLastS)>=10.0))
|
|
|
{
|
|
|
bInserPoint = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if(mstrroadid == "10014")
|
|
|
+ {
|
|
|
+ int a = 1;
|
|
|
+ }
|
|
|
+
|
|
|
if((bInserPoint == false)&&(bHaveLast))
|
|
|
{
|
|
|
|
|
|
if(bIsCrossFeature)
|
|
|
{
|
|
|
+ SampleLanePoint(pRoad,pLS,fS,xvectorLanePoint);
|
|
|
xRP.mvectorLanePoint = xvectorLanePoint;
|
|
|
unsigned int k;
|
|
|
unsigned int ksize = static_cast<unsigned int >(xRP.mvectorLanePoint.size());
|
|
@@ -151,24 +191,41 @@ int RoadSample::SampleRoad(Road * pRoad)
|
|
|
if((bInserPoint == false)&&(bHaveLast))
|
|
|
{
|
|
|
|
|
|
- xRP.mvectorLanePoint = xvectorLanePoint;
|
|
|
- unsigned int k;
|
|
|
- unsigned int ksize = static_cast<unsigned int >(xRP.mvectorLanePoint.size());
|
|
|
- for(k=0;k<ksize;k++)
|
|
|
+ if((fS-fLastS)>1.0)
|
|
|
{
|
|
|
- if(fabs(xRP.mvectorLanePoint[k].mfLaneWidth - mvectorRoadPoint[mvectorRoadPoint.size()-1].mvectorLanePoint[k].mfLaneWidth )>0.1)
|
|
|
+ double fGradientMax = GetMaxWidthRatio(pLS,fS);
|
|
|
+ if(fabs(fGradientMax*(fS-fLastS))>0.1)
|
|
|
{
|
|
|
bInserPoint = true;
|
|
|
- break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+// xRP.mvectorLanePoint = xvectorLanePoint;
|
|
|
+// unsigned int k;
|
|
|
+// unsigned int ksize = static_cast<unsigned int >(xRP.mvectorLanePoint.size());
|
|
|
+// for(k=0;k<ksize;k++)
|
|
|
+// {
|
|
|
+// if(fabs(xRP.mvectorLanePoint[k].mfLaneWidth - mvectorRoadPoint[mvectorRoadPoint.size()-1].mvectorLanePoint[k].mfLaneWidth )>0.1)
|
|
|
+// {
|
|
|
+// bInserPoint = true;
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
if((i == (nLSCount -1))&&(fabs(fS - send_Section)<0.001))
|
|
|
{
|
|
|
bInserPoint = true;
|
|
|
}
|
|
|
|
|
|
+ if((bIsCrossFeature== false)&&bInserPoint)
|
|
|
+ {
|
|
|
+ SampleLanePoint(pRoad,pLS,fS,xvectorLanePoint);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
if(bInserPoint)
|
|
|
{
|
|
@@ -190,6 +247,8 @@ int RoadSample::SampleRoad(Road * pRoad)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ std::cout<<"Road: "<<mstrroadid<<" max "<<mfRefX_max<<" "<<mfRefY_max<<" min "<<mfRefX_min<<" "<<mfRefY_min<<std::endl;
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -367,6 +426,7 @@ std::vector<double> RoadSample::GetFeaturePoint(LaneSection * pLS)
|
|
|
xvectorFeature.push_back(xvectorS[indexmin]);
|
|
|
}
|
|
|
}
|
|
|
+ xvectorS.erase(xvectorS.begin() + indexmin);
|
|
|
}
|
|
|
|
|
|
return xvectorFeature;
|
|
@@ -388,6 +448,32 @@ bool RoadSample::IsCrossFeaturePoint(std::vector<double> & xvectorFeature,double
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+double RoadSample::GetMaxWidthRatio(LaneSection * pLS, double fS)
|
|
|
+{
|
|
|
+ unsigned int nlanecount = static_cast<unsigned int>(pLS->GetLaneCount());
|
|
|
+ unsigned int i;
|
|
|
+ double fRtn = 0.0;
|
|
|
+ for(i=0;i<nlanecount;i++)
|
|
|
+ {
|
|
|
+ Lane * pLane = pLS->GetLane(i);
|
|
|
+ if(pLane != NULL)
|
|
|
+ {
|
|
|
+ if(pLane->GetId() != 0)
|
|
|
+ {
|
|
|
+ double fGradient = pLane->GetWidthValueGradient(fS-pLS->GetS());
|
|
|
+ if(fabs(fGradient)>fabs(fRtn))
|
|
|
+ {
|
|
|
+ fRtn = fGradient;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return fRtn;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|