Prechádzať zdrojové kódy

change map_lanetoxodr,complete bridge.

yuchuli 2 rokov pred
rodič
commit
415edfc4d0

+ 66 - 0
src/common/common/xodr/OpenDrive/ObjectSignal.cpp

@@ -68,6 +68,72 @@ void Objects_bridge::Settype(std::string type)
     mstrtype = type;
 }
 
+
+vector<Object_laneValidity> * Objects_bridge::GetObjectlaneValidityVector()
+{
+    return &mObject_laneValidity;
+}
+
+Object_laneValidity* Objects_bridge::GetObjectlaneValidity(unsigned int i)
+{
+    if ((mObject_laneValidity.size()>0)&&(i<(mObject_laneValidity.size())))
+        return &(mObject_laneValidity.at(i));
+    else
+        return NULL;
+}
+
+unsigned int Objects_bridge::GetObjectlaneValidityCount()
+{
+    return static_cast<unsigned int>(mObject_laneValidity.size());
+}
+
+Object_laneValidity*			Objects_bridge::GetLastObjectlaneValidity()
+{
+    if (mObject_laneValidity.size()>0)
+        return &mObject_laneValidity.at(mObject_laneValidity.size()-1);
+    else
+        return NULL;
+}
+
+Object_laneValidity*			Objects_bridge::GetLastAddedObjectlaneValidity()
+{
+    if(mLastAddedObjectlaneValidity<mObject_laneValidity.size())
+        return &mObject_laneValidity.at(mLastAddedObjectlaneValidity);
+    else
+        return NULL;
+}
+
+unsigned int Objects_bridge::AddObjectlaneValidity(int fromLane, int toLane)
+{
+    mObject_laneValidity.push_back(Object_laneValidity(fromLane,toLane));
+    mLastAddedObjectlaneValidity = static_cast<unsigned int>(mObject_laneValidity.size()-1) ;
+    return mLastAddedObjectlaneValidity;
+}
+
+unsigned int Objects_bridge::CloneObjectlaneValidity(unsigned int index)
+{
+    if(index<(mObject_laneValidity.size()-1))
+        mObject_laneValidity.insert(mObject_laneValidity.begin()+index+1, mObject_laneValidity[index]);
+    else if(index==mObject_laneValidity.size()-1)
+        mObject_laneValidity.push_back(mObject_laneValidity[index]);
+    mLastAddedObjectlaneValidity=index+1;
+    return mLastAddedObjectlaneValidity;
+}
+void Objects_bridge::DeleteObjectlaneValidity(unsigned int index)
+{
+    mObject_laneValidity.erase(mObject_laneValidity.begin()+index);
+}
+
+bool Objects_bridge::CheckInterval(double s_check)
+{
+    if (s_check>=mS)
+        return true;
+    else
+        return false;
+}
+
+
+
 Object_laneValidity::Object_laneValidity(int fromLane,int toLane)
 {
     mfromLane = fromLane;

+ 16 - 0
src/common/common/xodr/OpenDrive/ObjectSignal.h

@@ -9,6 +9,7 @@ using std::string;
 
 
 class Object_markings_marking_cornerReference;
+class Object_laneValidity;
 
 
 class Objects_bridge
@@ -20,6 +21,10 @@ private:
     std::string mstrid;
     std::string mstrtype;
 
+    vector<Object_laneValidity> mObject_laneValidity;
+
+    unsigned int mLastAddedObjectlaneValidity;
+
 public:
     Objects_bridge(double s,double length,std::string strid,std::string strtype);
     double GetS();
@@ -34,6 +39,17 @@ public:
     void Resetname();
     void Setid(std::string id);
     void Settype(std::string type);
+
+    vector<Object_laneValidity> * GetObjectlaneValidityVector();
+    Object_laneValidity* GetObjectlaneValidity(unsigned int i);
+    unsigned int GetObjectlaneValidityCount();
+    Object_laneValidity*			GetLastObjectlaneValidity();
+    Object_laneValidity*			GetLastAddedObjectlaneValidity();
+    unsigned int AddObjectlaneValidity(int fromLane,int toLane);
+    unsigned int CloneObjectlaneValidity(unsigned int index);
+    void DeleteObjectlaneValidity(unsigned int index);
+
+    bool CheckInterval(double s_check);
 };
 
 class Object_laneValidity

+ 63 - 0
src/common/common/xodr/OpenDrive/OpenDriveXmlParser.cpp

@@ -1245,6 +1245,12 @@ bool OpenDriveXmlParser::ReadObjects (Road* road, TiXmlElement *node)
     {
         ReadObject(road, subNode);
         subNode=subNode->NextSiblingElement("object");
+    }
+    subNode = node->FirstChildElement("bridge");
+    while (subNode)
+    {
+        ReadObjectsBridge(road, subNode);
+        subNode=subNode->NextSiblingElement("bridge");
     }
 	return true;
 }
@@ -1828,6 +1834,45 @@ bool OpenDriveXmlParser::ReadObjectOutlinesOutlinecornerLocal(Object_outlines_ou
     return true;
 }
 
+bool OpenDriveXmlParser::ReadObjectsBridge(Road * road,TiXmlElement * node)
+{
+    double s;
+    double length;
+    string id;
+    string type;
+    string name;
+
+    int checker=TIXML_SUCCESS;
+    checker+=node->QueryDoubleAttribute("s",&s);
+    checker+=node->QueryDoubleAttribute("length",&length);
+    checker+=node->QueryStringAttribute("id",&id);
+    checker+=node->QueryStringAttribute("type",&type);
+
+    if (checker!=TIXML_SUCCESS)
+    {
+        cout<<"Error parsing Objects Bridge attributes"<<endl;
+        return false;
+    }
+
+    road->AddObjectsBridge(s,length,id,type);
+
+    Objects_bridge * pObjects_bridge = road->GetLastAddedObjectsBridge();
+
+    if(node->QueryStringAttribute("name",&name) == TIXML_SUCCESS)
+    {
+       pObjects_bridge->Setname(name);
+    }
+
+    TiXmlElement *subNode = node->FirstChildElement("validity");
+    while (subNode)
+    {
+        ReadBridgevalidity(pObjects_bridge,subNode);
+        subNode = subNode->NextSiblingElement("validity");
+    }
+
+    return true;
+}
+
 //--------------
 
 bool OpenDriveXmlParser::ReadObject(Road *road, TiXmlElement *node)
@@ -2005,6 +2050,24 @@ bool OpenDriveXmlParser::ReadObjectvalidity(Object * pObject,TiXmlElement * node
     return true;
 }
 
+bool OpenDriveXmlParser::ReadBridgevalidity(Objects_bridge * pBridge,TiXmlElement * node)
+{
+    int fromLane,toLane;
+    int checker=TIXML_SUCCESS;
+    checker+=node->QueryIntAttribute("fromLane",&fromLane);
+    checker+=node->QueryIntAttribute("toLane",&toLane);
+
+    if (checker!=TIXML_SUCCESS)
+    {
+        cout<<"Error parsing Object bridge validity attributes"<<endl;
+        return false;
+    }
+
+    pBridge->AddObjectlaneValidity(fromLane,toLane);
+
+    return true;
+}
+
 //--------------
 
 bool OpenDriveXmlParser::ReadRoadBorrows(Road *road, TiXmlElement *node)

+ 2 - 0
src/common/common/xodr/OpenDrive/OpenDriveXmlParser.h

@@ -89,6 +89,7 @@ public:
     bool ReadSignal(Road * road,TiXmlElement * node);
     bool ReadSignal_positionInertial(Signal * pSignal, TiXmlElement *node);
     bool ReadSignal_laneValidity(Signal * pSignal,TiXmlElement * node);
+    bool ReadObjectsBridge(Road * road,TiXmlElement * node);
     bool ReadObject(Road * road,TiXmlElement * node);
     bool ReadObjectMarkings(Object * pObject,TiXmlElement * node);
     bool ReadObjectMarkingsMarking(Object_markings * pObject_Markings,TiXmlElement * node);
@@ -97,6 +98,7 @@ public:
     bool ReadObjectBordersBorder(Object_borders * pObject_Borders,TiXmlElement * node);
     bool ReadObjectBordersBordercornerReference(Object_borders_border * pObject_Border,TiXmlElement * node);
     bool ReadObjectvalidity(Object * pObject,TiXmlElement * node);
+    bool ReadBridgevalidity(Objects_bridge * pBridge,TiXmlElement * node);
 
 	//--------------
 

+ 31 - 0
src/common/common/xodr/OpenDrive/OpenDriveXmlWriter.cpp

@@ -1232,9 +1232,40 @@ bool OpenDriveXmlWriter::WriteObjects (TiXmlElement *node, Road* road)
         WriteObject(nodeObjects, road->GetObject(i));
     }
 
+    unsigned int lObjectsBridgeCount = road->GetObjectsBridgeCount();
+    for(unsigned int i=0; i<lObjectsBridgeCount; i++)
+    {
+        WriteObjectsBridge(nodeObjects, road->GetObjectsBridge(i));
+    }
+
 	return true;
 }
 //--------------
+bool OpenDriveXmlWriter::WriteObjectsBridge(TiXmlElement * node, Objects_bridge * pObjectsBridge)
+{
+    TiXmlElement* nodeObjectsBridge = new TiXmlElement("bridge");
+    node->LinkEndChild(nodeObjectsBridge);
+
+    nodeObjectsBridge->SetDoubleAttribute("s",pObjectsBridge->GetS());
+    nodeObjectsBridge->SetDoubleAttribute("length",pObjectsBridge->Getlength());
+    nodeObjectsBridge->SetAttribute("id",pObjectsBridge->Getid());
+    nodeObjectsBridge->SetAttribute("type",pObjectsBridge->Gettype());
+
+    std::string strname;
+    if(pObjectsBridge->GetName(strname) == 1)
+    {
+        nodeObjectsBridge->SetAttribute("name",strname);
+    }
+
+    unsigned int llaneValidityCount = pObjectsBridge->GetObjectlaneValidityCount();
+    for(unsigned int i=0; i<llaneValidityCount; i++)
+    {
+        WriteObjectlaneValidity(nodeObjectsBridge, pObjectsBridge->GetObjectlaneValidity(i));
+    }
+
+    return true;
+}
+//--------------
 bool OpenDriveXmlWriter::WriteObject(TiXmlElement *node, Object *pObject)
 {
     TiXmlElement* nodeObject = new TiXmlElement("object");

+ 2 - 1
src/common/common/xodr/OpenDrive/OpenDriveXmlWriter.h

@@ -74,8 +74,9 @@ public:
     bool WriteRoadNoavoids(TiXmlElement *node, Road* road);
     bool WriteRoadNoavoid(TiXmlElement *node,RoadNoavoid * pRoadNoavoid);
     bool WriteRoadBorrows(TiXmlElement *node, Road* road);
-    bool WriteRoadBorrow(TiXmlElement *node,RoadBorrow * pRoadBorrow);
+    bool WriteRoadBorrow(TiXmlElement *node,RoadBorrow * pRoadBorrow);   
 	bool WriteObjects (TiXmlElement *node, Road* road);
+    bool WriteObjectsBridge(TiXmlElement * node, Objects_bridge * pObjectsBridge);
     bool WriteObject(TiXmlElement * node, Object * pObject);
     bool WriteObjectParkingSpace(TiXmlElement * node,Object_parkingSpace * pObject_parkingSpace);
     bool WriteObjectrepeat(TiXmlElement * node,Object_repeat * pObject_repeat);

+ 74 - 1
src/common/common/xodr/OpenDrive/Road.cpp

@@ -306,6 +306,27 @@ unsigned int Road::GetLaneOffsetCount()
 {
     return mLaneOffsetVector.size();
 }
+
+//Road Bridge records
+
+vector<Objects_bridge> *Road::GetObjectsBridgeVector()
+{
+    return  &mObjectsBridgeVector;
+}
+
+Objects_bridge*	Road::GetObjectsBridge(unsigned int i)
+{
+    if ((mObjectsBridgeVector.size()>0)&&(i<mObjectsBridgeVector.size()))
+        return &mObjectsBridgeVector.at(i);
+    else
+        return NULL;
+}
+
+unsigned int Road::GetObjectsBridgeCount()
+{
+    return  static_cast<unsigned int>(mObjectsBridgeVector.size()) ;
+}
+
 // Road object records
 vector<Object> *Road::GetObjectVector()
 {
@@ -424,6 +445,13 @@ LaneSection*	Road::GetLastLaneSection()
 	else
 		return NULL;
 }
+Objects_bridge* Road::GetLastObjectsBridge()
+{
+    if (mObjectsBridgeVector.size()>0)
+        return &mObjectsBridgeVector.at(mObjectsBridgeVector.size()-1);
+    else
+        return NULL;
+}
 Object*	Road::GetLastObject()
 {	
 	if (mObjectsVector.size()>0)
@@ -500,6 +528,13 @@ LaneSection* Road::GetLastAddedLaneSection()
 	else
 		return NULL;
 }
+Objects_bridge* Road::GetLastAddedObjectsBridge()
+{
+    if(mLastAddedObjectsBridge<mObjectsBridgeVector.size())
+        return &mObjectsBridgeVector.at(mLastAddedObjectsBridge);
+    else
+        return NULL;
+}
 Object* Road::GetLastAddedObject()
 {
 	if(mLastAddedObject<mObjectsVector.size())
@@ -726,7 +761,15 @@ unsigned int Road::AddRoadNoavoid(double s, double length)
     mLastAddedRoadNoavoid=index;
     return index;
 }
-
+//-------------
+unsigned int Road::AddObjectsBridge(double s,double length,string id,string type)
+{
+    unsigned int index = static_cast<unsigned int>(CheckRoadObjectsBridgeInterval(s)+1) ;
+    if(index>=GetObjectsBridgeCount()) mObjectsBridgeVector.push_back(Objects_bridge(s,length,id,type));
+    else mObjectsBridgeVector.insert(mObjectsBridgeVector.begin()+index, Objects_bridge(s,length,id,type));
+    mLastAddedObjectsBridge=index;
+    return index;
+}
 //-------------
 unsigned int Road::AddObject(string id,double s,double t,double zOffset)
 {	
@@ -905,6 +948,16 @@ unsigned int Road::CloneLaneSectionEnd(unsigned int index)
 	mLastAddedLaneSection=index+1;
 	return mLastAddedLaneSection;
 }
+unsigned int Road::CloneObjectsBridge(unsigned int index)
+{
+
+    if(index<mObjectsBridgeVector.size()-1)
+        mObjectsBridgeVector.insert(mObjectsBridgeVector.begin()+index+1, mObjectsBridgeVector[index]);
+    else if(index==mObjectsBridgeVector.size()-1)
+        mObjectsBridgeVector.push_back(mObjectsBridgeVector[index]);
+    mLastAddedObjectsBridge=index+1;
+    return mLastAddedObjectsBridge;
+}
 unsigned int Road::CloneObject(unsigned int index)
 {
 	// Check the first method in the group for details
@@ -981,6 +1034,10 @@ void Road::DeleteLaneOffset(unsigned int index)
 {
     mLaneOffsetVector.erase(mLaneOffsetVector.begin()+index);
 }
+void Road::DeleteObjectsBridge(unsigned int index)
+{
+    mObjectsBridgeVector.erase(mObjectsBridgeVector.begin()+index);
+}
 void Road::DeleteObject(unsigned int index)
 {
 	mObjectsVector.erase(mObjectsVector.begin()+index);
@@ -1356,6 +1413,22 @@ int Road::CheckRoadNoavoidInterval(double s_check)
     }
     return res;		//return the result: 0 to MaxInt as the index to the record containing s_check or -1 if nothing found
 
+}
+//-----------
+int Road::CheckRoadObjectsBridgeInterval(double s_check)
+{
+    int res=-1;
+    //Go through all the lane section records
+    for (unsigned int i=0;i<mObjectsBridgeVector.size();i++)
+    {
+        //check if the s_check belongs to the current record
+        if (mObjectsBridgeVector.at(i).CheckInterval(s_check))
+            res=static_cast<int>(i);	//assign it to the result id
+        else
+            break;	//if not, break;
+    }
+    return res;		//return the result: 0 to MaxInt as the index to the record containing s_check or -1 if nothing found
+
 }
 //-----------
 int Road::CheckLaneOffsetInterval(double s_check)

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

@@ -75,6 +75,8 @@ private:
 	vector<LaneSection> mLaneSectionsVector;
     // Lane offset vector
     vector<LaneOffset> mLaneOffsetVector;
+    //bridge vector
+    vector<Objects_bridge> mObjectsBridgeVector;
 	// Objects vectors
 	vector<Object> mObjectsVector;
 	// Signal vector
@@ -96,6 +98,7 @@ private:
 	unsigned int mLastAddedCrossfall;
 	unsigned int mLastAddedLaneSection;
     unsigned int mLastAddedLaneOffset;
+    unsigned int mLastAddedObjectsBridge;
 	unsigned int mLastAddedObject;
 	unsigned int mLastAddedSignal;
     unsigned int mLastAddedRoadBorrow;
@@ -180,6 +183,10 @@ public:
 	vector<Object> *GetObjectVector();
 	Object*	GetObject(unsigned int i);
 	unsigned int GetObjectCount();
+    // Road bridge records
+    vector<Objects_bridge> *GetObjectsBridgeVector();
+    Objects_bridge*	GetObjectsBridge(unsigned int i);
+    unsigned int GetObjectsBridgeCount();
 	// Road signal records
 	vector<Signal> *GetSignalVector();
 	Signal*	GetSignal(unsigned int i);
@@ -206,6 +213,7 @@ public:
 	SuperElevation*	GetLastSuperElevation();
 	Crossfall*		GetLastCrossfall();
 	LaneSection*	GetLastLaneSection();
+    Objects_bridge* GetLastObjectsBridge();
 	Object*			GetLastObject();
 	Signal*			GetLastSignal();
     RoadBorrow *    GetLastRoadBorrow();
@@ -220,6 +228,7 @@ public:
 	SuperElevation*	GetLastAddedSuperElevation();
 	Crossfall*		GetLastAddedCrossfall();
 	LaneSection*	GetLastAddedLaneSection();
+    Objects_bridge* GetLastAddedObjectsBridge();
 	Object*			GetLastAddedObject();
 	Signal*			GetLastAddedSignal();
     RoadBorrow*     GetLastAddedRoadBorrow();
@@ -265,6 +274,7 @@ public:
 	unsigned int AddCrossfall (string side, double s, double a, double b, double c, double d);
 	unsigned int AddLaneSection(double s);
     unsigned int AddLaneOffset(double s,double a,double b,double c,double d);
+    unsigned int AddObjectsBridge(double s,double length,string id,string type);
     unsigned int AddObject(string id,double s,double t,double zOffset);
     unsigned int AddSignal(double s,double t,string id,string name,bool dynamic,string orientation,double zOffset,string type,string country,string countryRevision,
                            string subtype,double hOffset,double pitch,double roll ,double height,double width);
@@ -280,6 +290,7 @@ public:
 	unsigned int CloneCrossfall(unsigned int index);
 	unsigned int CloneLaneSection(unsigned int index);
 	unsigned int CloneLaneSectionEnd(unsigned int index);
+    unsigned int CloneObjectsBridge(unsigned int index);
 	unsigned int CloneObject(unsigned int index);
 	unsigned int CloneSignal(unsigned int index);
     unsigned int CloneRoadBorrow(unsigned int index);
@@ -295,6 +306,7 @@ public:
 	void DeleteCrossfall(unsigned int index);
 	void DeleteLaneSection(unsigned int index);
     void DeleteLaneOffset(unsigned int index);
+    void DeleteObjectsBridge(unsigned int index);
 	void DeleteObject(unsigned int index);
 	void DeleteSignal(unsigned int index);
     void DeleteRoadBorrow(unsigned int index);
@@ -350,6 +362,8 @@ public:
     int CheckRoadBorrowInterval(double s_check);
 
     int CheckRoadNoavoidInterval(double s_check);
+
+    int CheckRoadObjectsBridgeInterval(double s_check);
 	
 	//-------------------------------------------------