#include "odtolanelet.h" #include #include "gaussprojector.h" namespace iv { } odtolanelet::odtolanelet(std::string strxodrfile) { mstrxodrfile = strxodrfile; } int odtolanelet::ConvertToLanelet(std::string strlanelet2file) { OpenDrive * pxodr = new OpenDrive(); //because add to xodr,so don't delete OpenDriveXmlParser x(pxodr); if(!x.ReadFile(mstrxodrfile)) { std::cout<<"Can't load xodr file."<(); unsigned int nroadnum = pxodr->GetRoadCount(); unsigned int i; for(i=0;iGetRoad(i); lanelet::Lanelet let; if(Road2Lanelet(pRoad,laneletMap) == 0) { } } lanelet::Origin origin2({39.1364713, 117.0866293, 0}); lanelet::write(strlanelet2file,*laneletMap,GaussProjector(origin2)); std::cout<<"convert complete."< pSample_ptr = std::shared_ptr(new iv::RoadSample(pRoad)); // iv::RoadSample * pSample = new iv::RoadSample(pRoad); std::vector * pvectorRoadPoint = pSample_ptr->GetRoadPointVector(); unsigned int nRPSize = static_cast(pvectorRoadPoint->size()); unsigned int i; std::vector xvectorlinestring; std::vector xvectorPoint; std::vector xvectorLastPoint; unsigned int ncenterlanepos = 0; for(i=0;iat(i).nSecNum != pvectorRoadPoint->at(i-1).nSecNum) { //Create LaneLet linetolet(laneletMap,xvectorlinestring,ncenterlanepos); bNewLet = true; } } if(bNewLet) { xvectorlinestring.clear(); unsigned int nlanesize = static_cast(pvectorRoadPoint->at(i).mvectorLanePoint.size()); unsigned int j; for(j=0;jat(i).mvectorLanePoint[j],xline); xvectorlinestring.push_back(xline); if(pvectorRoadPoint->at(i).mvectorLanePoint[j].nLane == 0) { ncenterlanepos = j; } } if(i== 0) { LanePointToPoint3D(pvectorRoadPoint->at(i).mvectorLanePoint,xvectorPoint); unsigned int nlanesize = static_cast(pvectorRoadPoint->at(i).mvectorLanePoint.size()); unsigned int j; for(j=0;jat(i).mvectorLanePoint,xvectorPoint,xvectorLastPoint); unsigned int nlanesize = static_cast(pvectorRoadPoint->at(i).mvectorLanePoint.size()); unsigned int j; for(j=0;jat(i).mvectorLanePoint,xvectorPoint); unsigned int nlanesize = static_cast(pvectorRoadPoint->at(i).mvectorLanePoint.size()); unsigned int j; for(j=0;jat(i).mvectorLanePoint } if(xvectorlinestring.size()>0) { linetolet(laneletMap,xvectorlinestring,ncenterlanepos); } return 0; } void odtolanelet::odtypetolettype(iv::LanePoint & xLanePoint, lanelet::LineString3d & xlinestring) { if(xLanePoint.mstrroadmarkcolor.size()>0) { xlinestring.setAttribute("color",lanelet::Attribute(xLanePoint.mstrroadmarkcolor)); } if(xLanePoint.mstrroadmarktype == "none") { xlinestring.setAttribute("type",lanelet::Attribute("virtual")); return; } if(xLanePoint.mstrroadmarktype == "solid") { xlinestring.setAttribute("type",lanelet::Attribute("line_thin")); xlinestring.setAttribute("subtype",lanelet::Attribute("solid")); return; } if(xLanePoint.mstrroadmarktype == "broken") { xlinestring.setAttribute("type",lanelet::Attribute("line_thin")); xlinestring.setAttribute("subtype",lanelet::Attribute("solid")); return; } if(xLanePoint.mstrroadmarktype == "broken") { xlinestring.setAttribute("type",lanelet::Attribute("line_thin")); xlinestring.setAttribute("subtype",lanelet::Attribute("dashed")); return; } if(xLanePoint.mstrroadmarktype == "solid solid") { xlinestring.setAttribute("type",lanelet::Attribute("line_thin")); xlinestring.setAttribute("subtype",lanelet::Attribute("solid_solid")); return; } if(xLanePoint.mstrroadmarktype == "solid broken") { xlinestring.setAttribute("type",lanelet::Attribute("line_thin")); xlinestring.setAttribute("subtype",lanelet::Attribute("solid_dashed")); return; } if(xLanePoint.mstrroadmarktype == "broken solid") { xlinestring.setAttribute("type",lanelet::Attribute("line_thin")); xlinestring.setAttribute("subtype",lanelet::Attribute("dashed_solid")); return; } if(xLanePoint.mstrroadmarktype == "curb") { xlinestring.setAttribute("type",lanelet::Attribute("curbstone")); xlinestring.setAttribute("subtype",lanelet::Attribute("high")); return; } if(xLanePoint.mstrroadmarktype == "edge") { xlinestring.setAttribute("type",lanelet::Attribute("road_border")); return; } xlinestring.setAttribute("type",lanelet::Attribute("virtual")); return; } void odtolanelet::LanePointToPoint3D(std::vector & xvectorLanePoint, std::vector & xvectorPoint3D) { xvectorPoint3D.clear(); unsigned int i; unsigned int nLPsize = static_cast(xvectorLanePoint.size()); for(i=0;i & xvectorLanePoint, std::vector & xvectorPoint3D, std::vector & xvectorPoint3DLast) { xvectorPoint3D.clear(); unsigned int i; unsigned int nLPsize = static_cast(xvectorLanePoint.size()); for(i=0;i(xvectorPoint3DLast.size()); bool bUseOld = false; for(j=0;j & xvectorlinestring, unsigned int ncenterlane) { unsigned int i; unsigned int nsize = static_cast(xvectorlinestring.size()) ; for(i=0;iadd(xlet); } for(i=ncenterlane;i<(nsize-1);i++) { lanelet::Lanelet xlet(mid,xvectorlinestring[i],xvectorlinestring[i+1]); mid++; laneletMap->add(xlet); } } int odtolanelet::InvertLine(lanelet::LineString3d & xinvert,lanelet::LineString3d & xraw) { xinvert.setId(mid);mid++; if(xraw.hasAttribute("color"))xinvert.setAttribute("color",xraw.attribute("color")); if(xraw.hasAttribute("subtype"))xinvert.setAttribute("subtype",xraw.attribute("subtype")); if(xraw.hasAttribute("type"))xinvert.setAttribute("type",xraw.attribute("type")); xinvert.clear(); unsigned int npointssize = static_cast(xraw.size()); unsigned int i; for(i=0;i