|
@@ -0,0 +1,83 @@
|
|
|
+#include "service_roi_xodr.h"
|
|
|
+
|
|
|
+#include <iostream>
|
|
|
+#include "gnss_coordinate_convert.h"
|
|
|
+
|
|
|
+service_roi_xodr::service_roi_xodr()
|
|
|
+{
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void service_roi_xodr::SetXODR(OpenDrive *pxodr)
|
|
|
+{
|
|
|
+ mpxodr = pxodr;
|
|
|
+ updateroadarea();
|
|
|
+}
|
|
|
+
|
|
|
+int service_roi_xodr::GetROI(std::shared_ptr<iv::roi::request> xreq_ptr, std::shared_ptr<iv::roi::resultarray> &xres_prt)
|
|
|
+{
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+void service_roi_xodr::updateroadarea()
|
|
|
+{
|
|
|
+ OpenDrive * pxodr = mpxodr;
|
|
|
+ mvectorarea.clear();
|
|
|
+ unsigned int nroadcount = pxodr->GetRoadCount();
|
|
|
+ unsigned int i;
|
|
|
+ const double fstep = 0.1;
|
|
|
+ for(i=0;i<nroadcount;i++)
|
|
|
+ {
|
|
|
+ Road * pRoad = pxodr->GetRoad(i);
|
|
|
+ if(pRoad == NULL)
|
|
|
+ {
|
|
|
+ std::cout<<" Warning: OpenDrive Road "<<i<<" is NULL"<<std::endl;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ iv::roi::roadarea xroadarea = GetRoadArea(pRoad,fstep);
|
|
|
+ mvectorarea.push_back(xroadarea);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+iv::roi::roadarea service_roi_xodr::GetRoadArea(Road *pRoad, const double fstep)
|
|
|
+{
|
|
|
+ iv::roi::roadarea xroadarea;
|
|
|
+ xroadarea.fRoadLen = pRoad->GetRoadLength();
|
|
|
+ unsigned int nSectionCount = pRoad->GetLaneSectionCount();
|
|
|
+ unsigned int i;
|
|
|
+ if(nSectionCount == 0)
|
|
|
+ {
|
|
|
+ std::cout<<"Warning. Road"<<pRoad->GetRoadId()<<" not have lanesection."<<std::endl;
|
|
|
+ }
|
|
|
+ double snow= 0;
|
|
|
+ for(i=0;i<nSectionCount;i++)
|
|
|
+ {
|
|
|
+ LaneSection * pLS = pRoad->GetLaneSection(i);
|
|
|
+ if(pLS == NULL)
|
|
|
+ {
|
|
|
+ std::cout<<"Warning. LaneSection is NULL."<<std::endl;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ snow = pLS->GetS();
|
|
|
+ double endS;
|
|
|
+ if(i == (nSectionCount -1))
|
|
|
+ {
|
|
|
+ endS = pRoad->GetRoadLength();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ endS = pRoad->GetLaneSection(i+1)->GetS();
|
|
|
+ }
|
|
|
+
|
|
|
+ while(snow < endS)
|
|
|
+ {
|
|
|
+// double fleftwidth = pRoad->GetRoadLeftWidth(snow);
|
|
|
+// double frigthwidth = pRoad->GetRoadRightWidth(snow);
|
|
|
+// std::cout<<" road : "<<pRoad->GetRoadId()<<" s: "<<snow<<" left: "<<fleftwidth<<" right:"<<frigthwidth<<std::endl;
|
|
|
+ snow = snow + fstep;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return xroadarea;
|
|
|
+}
|
|
|
+
|