瀏覽代碼

change map_lanetoxodr. completing 1.6 statandard.

yuchuli 2 年之前
父節點
當前提交
a48fca217a

+ 3 - 2
src/common/common/xodr/OpenDrive/ObjectSignal.cpp

@@ -2800,15 +2800,16 @@ void Signal::SetlaneValidity(int fromLane, int toLane)
     }
 }
 
-void Signal::SetpositionRoad(double s, double t, double zOffset, double hOffset)
+void Signal::SetpositionRoad(std::string roadid,double s, double t, double zOffset, double hOffset)
 {
     if(mpsignal_positionRoad == 0)
     {
-        mpsignal_positionRoad = new signal_positionRoad("",s,t,zOffset,hOffset);
+        mpsignal_positionRoad = new signal_positionRoad(roadid,s,t,zOffset,hOffset);
 
     }
     else
     {
+        mpsignal_positionRoad->Setroadid(roadid);
         mpsignal_positionRoad->Sets(s);
         mpsignal_positionRoad->Sett(t);
         mpsignal_positionRoad->SetzOffset(zOffset);

+ 1 - 1
src/common/common/xodr/OpenDrive/ObjectSignal.h

@@ -897,7 +897,7 @@ public:
     void Setheight(double height);
     void Setwidth(double width);
     void SetlaneValidity(int fromLane, int toLane);
-    void SetpositionRoad(double s,double t, double zOffset,double hOffset);
+    void SetpositionRoad(std::string roadid, double s,double t, double zOffset,double hOffset);
     void SetpositionInertial(double x,double y, double z, double hdg);
 
     vector<signal_laneValidity> * GetlaneValidityVector();

+ 46 - 0
src/common/common/xodr/OpenDrive/OpenDrive.cpp

@@ -61,6 +61,15 @@ unsigned int OpenDrive::AddJunction(string name, string id)
 	mLastAddedJunction=index;
 	return index;
 }
+unsigned int OpenDrive::AddController(string id)
+{
+    unsigned int index=GetControllerCount();
+    // Adds the new controller to the end of the vector
+    mControllerVector.push_back(Controller(id));
+    // Saves the index of the newly added controller
+    mLastAddedController=index;
+    return index;
+}
 
 /**
  * Methods used to delete records from the respective vectors
@@ -73,6 +82,11 @@ void OpenDrive::DeleteJunction(unsigned int index)
 {
 	mJunctionVector.erase(mJunctionVector.begin()+index);
 }
+void OpenDrive::DeleteController(unsigned int index)
+{
+    mControllerVector.erase(mControllerVector.begin()+index);
+}
+
 
 //-------------------------------------------------
 
@@ -93,6 +107,13 @@ Junction* OpenDrive::GetLastJunction()
 	else
 		return NULL;
 }
+Controller* OpenDrive::GetLastController()
+{
+    if (mControllerVector.size()>0)
+        return &(mControllerVector.at(mControllerVector.size()-1));
+    else
+        return NULL;
+}
 
 /**
  * Getters for the last added records in their respective vectors
@@ -105,6 +126,14 @@ Road* OpenDrive::GetLastAddedRoad()
 		return NULL;
 }
 
+Controller* OpenDrive::GetLastAddedController()
+{
+    if(mLastAddedController<mControllerVector.size())
+        return &mControllerVector.at(mLastAddedController);
+    else
+        return NULL;
+}
+
 /**
  * Getter for the OpenDrive header
  */
@@ -147,6 +176,22 @@ unsigned int OpenDrive::GetJunctionCount()
 {	
 	return mJunctionVector.size();	
 }
+//Controller records
+vector<Controller> * OpenDrive::GetControllerVector()
+{
+    return &mControllerVector;
+}
+Controller* OpenDrive::GetController(unsigned int i)
+{
+    if (i < mControllerVector.size())
+            return &(mControllerVector.at(i));
+        else
+            return NULL;
+}
+unsigned int OpenDrive::GetControllerCount()
+{
+    return  static_cast<unsigned int >(mControllerVector.size());
+}
 //-------------------------------------------------
 
 /**
@@ -156,6 +201,7 @@ void OpenDrive::Clear()
 {
 	mRoadVector.clear();
 	mJunctionVector.clear();
+    mControllerVector.clear();
 }
 
 OpenDrive::OpenDrive (const OpenDrive& openDrive)

+ 11 - 0
src/common/common/xodr/OpenDrive/OpenDrive.h

@@ -5,6 +5,7 @@
 #include <string>
 
 #include "Road.h"
+#include "controller.h"
 //--Prototypes--
 //main
 class Header;
@@ -35,12 +36,14 @@ private:
 	 */
 	vector<Road> mRoadVector;
 	vector<Junction> mJunctionVector;
+    vector<Controller> mControllerVector;
 	
 	/**
 	 * Indices of the last added records
 	 */
 	unsigned int mLastAddedRoad;
 	unsigned int mLastAddedJunction;
+    unsigned int mLastAddedController;
 
 //	//-------------------------------------------------
 
@@ -77,12 +80,14 @@ public:
 	 */
 	unsigned int AddRoad(string name, double length, string id, string junction);
 	unsigned int AddJunction(string name, string id);
+    unsigned int AddController(string id);
 
 	/**
 	 * Methods used to delete records from the respective vectors
 	 */
 	void DeleteRoad(unsigned int index);
 	void DeleteJunction(unsigned int index);
+    void DeleteController(unsigned int index);
 
 	//-------------------------------------------------
 
@@ -91,11 +96,13 @@ public:
 	 */
 	Road* GetLastRoad();
 	Junction* GetLastJunction();
+    Controller* GetLastController();
 
 	/**
 	 * Getters for the last added records in their respective vectors
 	 */
 	Road* GetLastAddedRoad();
+    Controller* GetLastAddedController();
 
 	/**
 	 * Getter for the OpenDrive header
@@ -113,6 +120,10 @@ public:
 	vector<Junction> * GetJunctionVector();
 	Junction* GetJunction(unsigned int i);
 	unsigned int GetJunctionCount();
+    //Controller records
+    vector<Controller> * GetControllerVector();
+    Controller* GetController(unsigned int i);
+    unsigned int GetControllerCount();
 	
 	//-------------------------------------------------
 

+ 2 - 0
src/common/common/xodr/OpenDrive/OpenDrive.pri

@@ -8,6 +8,7 @@ HEADERS += \
     $$PWD/OtherStructures.h \
     $$PWD/Road.h \
     $$PWD/RoadGeometry.h \
+    $$PWD/controller.h \
     $$PWD/userData.h
 
 SOURCES += \
@@ -20,4 +21,5 @@ SOURCES += \
     $$PWD/OtherStructures.cpp \
     $$PWD/Road.cpp \
     $$PWD/RoadGeometry.cpp \
+    $$PWD/controller.cpp \
     $$PWD/userData.cpp

+ 218 - 3
src/common/common/xodr/OpenDrive/OpenDriveXmlParser.cpp

@@ -2307,11 +2307,68 @@ bool OpenDriveXmlParser::ReadSignals (Road* road, TiXmlElement *node)
         ReadSignal(road, subNode);
         subNode=subNode->NextSiblingElement("signal");
     }
+
+    subNode = node->FirstChildElement("signalReference");
+    while (subNode)
+    {
+        ReadSignals_signalReference(road, subNode);
+        subNode=subNode->NextSiblingElement("signalReference");
+    }
+
     return true;
 
 
 }
 
+bool OpenDriveXmlParser::ReadSignals_signalReference(Road * road,TiXmlElement * node)
+{
+    double s,t;
+    std::string id,orientation;
+    int checker=TIXML_SUCCESS;
+    checker+=node->QueryDoubleAttribute("s",&s);
+    checker+=node->QueryDoubleAttribute("t",&t);
+    checker+=node->QueryStringAttribute("id",&id);
+    checker+=node->QueryStringAttribute("orientation",&orientation);
+
+    if (checker!=TIXML_SUCCESS)
+    {
+        cout<<"Error parsing signals signalReference attributes"<<endl;
+        return false;
+    }
+
+    road->AddSignalReference(s,t,id,orientation);
+
+    signals_signalReference * psignalReference = road->GetLastAddedSignalReference();
+
+    TiXmlElement * subNode;
+
+    subNode=node->FirstChildElement("validity");
+    while (subNode)
+    {
+        ReadSignals_signalReference_laneValidity(psignalReference, subNode);
+        subNode=node->NextSiblingElement("validity");
+    }
+
+    return true;
+
+}
+
+bool OpenDriveXmlParser::ReadSignals_signalReference_laneValidity(signals_signalReference * pSignals_signalReference,TiXmlElement * node)
+{
+    int fromLane;
+    int toLane;
+    int checker=TIXML_SUCCESS;
+    checker+=node->QueryIntAttribute("fromLane",&fromLane);
+    checker+=node->QueryIntAttribute("toLane",&toLane);
+    if (checker!=TIXML_SUCCESS)
+    {
+        cout<<"Error parsing laneValidity attributes"<<endl;
+        return false;
+    }
+    pSignals_signalReference->AddlaneValidity(fromLane,toLane);
+    return true;
+}
+
 bool OpenDriveXmlParser::ReadSignal(Road *road, TiXmlElement *node)
 {
     double s;
@@ -2366,15 +2423,33 @@ bool OpenDriveXmlParser::ReadSignal(Road *road, TiXmlElement *node)
     TiXmlElement * subNode;
     //Proceed to Signals
     subNode=node->FirstChildElement("validity");
-    if (subNode)
+    while (subNode)
     {
         ReadSignal_laneValidity(pSignal, subNode);
+        subNode=node->NextSiblingElement("validity");
     }
     subNode=node->FirstChildElement("positionInertial");
     if(subNode)
     {
         ReadSignal_positionInertial(pSignal,subNode);
     }
+    subNode=node->FirstChildElement("positionRoad");
+    if(subNode)
+    {
+        ReadSignal_positionRoad(pSignal,subNode);
+    }
+    subNode = node->FirstChildElement("dependency");
+    while(subNode)
+    {
+        ReadSignal_dependency(pSignal,node);
+        subNode = subNode->NextSiblingElement("dependency");
+    }
+    subNode = node->FirstChildElement("reference");
+    while(subNode)
+    {
+        ReadSignal_reference(pSignal,node);
+        subNode = subNode->NextSiblingElement("reference");
+    }
     return true;
 }
 
@@ -2390,7 +2465,81 @@ bool OpenDriveXmlParser::ReadSignal_laneValidity(Signal *pSignal, TiXmlElement *
         cout<<"Error parsing laneValidity attributes"<<endl;
         return false;
     }
-    pSignal->SetlaneValidity(fromLane,toLane);
+    pSignal->AddlaneValidity(fromLane,toLane);
+    return true;
+}
+
+bool OpenDriveXmlParser::ReadSignal_dependency(Signal * pSignal,TiXmlElement * node)
+{
+    std::string id,type;
+    int checker=TIXML_SUCCESS;
+    checker+=node->QueryStringAttribute("id",&id);
+    if(checker!= TIXML_SUCCESS)
+    {
+        cout<<"Error parsing dependency attributes"<<endl;
+        return false;
+    }
+    pSignal->AddDependency(id);
+    signal_dependency * pdependency = pSignal->GetLastAddedDependency();
+    if(node->QueryStringAttribute("type",&type) == TIXML_SUCCESS)
+    {
+        pdependency->Settype(type);
+    }
+    return true;
+}
+
+bool OpenDriveXmlParser::ReadSignal_reference(Signal * pSignal,TiXmlElement * node)
+{
+    std::string elementType,elementId;
+    std::string type;
+    int checker=TIXML_SUCCESS;
+    checker+=node->QueryStringAttribute("elementType",&elementType);
+    checker+=node->QueryStringAttribute("elementId",&elementId);
+    if(checker!= TIXML_SUCCESS)
+    {
+        cout<<"Error parsing reference attributes"<<endl;
+        return false;
+    }
+    signal_reference * preference = pSignal->GetLastAddedReference();
+
+    if(node->QueryStringAttribute("type",&type) == TIXML_SUCCESS)
+    {
+        preference->Settype(type);
+    }
+    return true;
+
+}
+
+bool OpenDriveXmlParser::ReadSignal_positionRoad(Signal * pSignal,TiXmlElement * node)
+{
+    std::string roadid;
+    double s,t,zOffset,hOffset;
+    double pitch,roll;
+
+    int checker=TIXML_SUCCESS;
+    checker+=node->QueryStringAttribute("roadid",&roadid);
+    checker+=node->QueryDoubleAttribute("s",&s);
+    checker+=node->QueryDoubleAttribute("t",&t);
+    checker+=node->QueryDoubleAttribute("zOffset",&zOffset);
+    checker+=node->QueryDoubleAttribute("hOffset",&hOffset);
+
+    if (checker!=TIXML_SUCCESS)
+    {
+        cout<<"Error parsing positionRoad attributes"<<endl;
+        return false;
+    }
+    pSignal->SetpositionRoad(roadid,s,t,zOffset,hOffset);
+
+    if(node->QueryDoubleAttribute("pitch",&pitch) == TIXML_SUCCESS)
+    {
+        pSignal->Setpitch(pitch);
+    }
+
+    if(node->QueryDoubleAttribute("roll",&roll) == TIXML_SUCCESS)
+    {
+        pSignal->Setroll(roll);
+    }
+
     return true;
 }
 
@@ -2433,7 +2582,73 @@ bool OpenDriveXmlParser::ReadSurface (Road* road, TiXmlElement *node)
 //--------------
 
 bool OpenDriveXmlParser::ReadController (TiXmlElement *node)
-{	return true;	}
+{
+    string name;
+    string id;
+    int sequence;
+
+    int checker=TIXML_SUCCESS;
+
+    checker+=node->QueryStringAttribute("id",&id);
+
+    if (checker!=TIXML_SUCCESS)
+    {
+        cout<<"Error parsing Controller attributes"<<endl;
+        return false;
+    }
+
+    mOpenDrive->AddController(id);
+    Controller* controller = mOpenDrive->GetLastAddedController();
+
+    if(node->QueryStringAttribute("name",&name) == TIXML_SUCCESS)
+    {
+        controller->Setname(name);
+    }
+
+    if(node->QueryIntAttribute("sequence",&sequence) != TIXML_SUCCESS)
+    {
+        controller->Setsequence(static_cast<unsigned int>(sequence));
+    }
+    //fill in
+
+    TiXmlElement * subNode;
+    subNode = node->FirstChildElement("control");
+    while(subNode)
+    {
+        ReadController_Control(controller,node);
+        subNode = subNode->NextSiblingElement("control");
+    }
+
+    return true;
+}
+
+//--------------
+
+bool OpenDriveXmlParser::ReadController_Control(Controller * pController,TiXmlElement * node)
+{
+
+    string signalId,type;
+
+    int checker=TIXML_SUCCESS;
+
+    checker+=node->QueryStringAttribute("signalId",&signalId);
+
+    if (checker!=TIXML_SUCCESS)
+    {
+        cout<<"Error parsing control attributes"<<endl;
+        return false;
+    }
+
+    pController->AddControl(signalId);
+    Controller_control * pControl = pController->GetLastAddedControl();
+
+    if(node->QueryStringAttribute("type",&type) == TIXML_SUCCESS)
+    {
+        pControl->Settype(type);
+    }
+
+    return true;
+}
 //--------------
 
 bool OpenDriveXmlParser::ReadJunction (TiXmlElement *node)

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

@@ -86,9 +86,14 @@ public:
     bool ReadObjectOutlinesOutlinecornerRoad(Object_outlines_outline * pObject_outline,TiXmlElement * node);
     bool ReadObjectOutlinesOutlinecornerLocal(Object_outlines_outline * pObject_outline,TiXmlElement * node);
 	bool ReadSignals (Road* road, TiXmlElement *node);
+    bool ReadSignals_signalReference(Road * road,TiXmlElement * node);
+    bool ReadSignals_signalReference_laneValidity(signals_signalReference * pSignals_signalReference,TiXmlElement * node);
     bool ReadSignal(Road * road,TiXmlElement * node);
+    bool ReadSignal_positionRoad(Signal * pSignal,TiXmlElement * node);
     bool ReadSignal_positionInertial(Signal * pSignal, TiXmlElement *node);
     bool ReadSignal_laneValidity(Signal * pSignal,TiXmlElement * node);
+    bool ReadSignal_dependency(Signal * pSignal,TiXmlElement * node);
+    bool ReadSignal_reference(Signal * pSignal,TiXmlElement * node);
     bool ReadObjectsBridge(Road * road,TiXmlElement * node);
     bool ReadObjectsTunnel(Road * road,TiXmlElement * node);
     bool ReadObjectsObjectReference(Road * road,TiXmlElement * node);
@@ -110,6 +115,7 @@ public:
 	//--------------
 
 	bool ReadController (TiXmlElement *node);
+    bool ReadController_Control(Controller * pController,TiXmlElement * node);
 	//--------------
 
 	bool ReadJunction (TiXmlElement *node);

+ 61 - 2
src/common/common/xodr/OpenDrive/OpenDriveXmlWriter.cpp

@@ -2136,8 +2136,60 @@ bool OpenDriveXmlWriter::WriteSurface (TiXmlElement *node, Road* road)
 }
 //--------------
 
-bool OpenDriveXmlWriter::WriteController (TiXmlElement *node)
-{	return true;	}
+bool OpenDriveXmlWriter::WriteController (TiXmlElement *node,Controller* controller)
+{
+    //A controller must have at least one control
+    if(controller->GetControlCount() == 0)return false;
+
+    string id;
+    id = controller->Getid();
+
+    TiXmlElement * nodeController = new TiXmlElement("controller");
+    node->LinkEndChild(nodeController);
+
+    nodeController->SetAttribute("id",id);
+
+    std::string name;
+    unsigned int sequence;
+    if(controller->Getname(name) == 1)
+    {
+        nodeController->SetAttribute("name",name);
+    }
+    if(controller->Getsequence(sequence) == 1)
+    {
+        nodeController->SetAttribute("sequence",static_cast<int>(sequence));
+    }
+
+    unsigned int lControlCount = controller->GetControlCount();
+    for(unsigned int i=0;i<lControlCount;i++)
+    {
+        WriteController_Control(nodeController,controller->GetControl(i));
+    }
+
+    return true;
+}
+
+//--------------
+
+bool OpenDriveXmlWriter::WriteController_Control(TiXmlElement *node,Controller_control* control)
+{
+
+    TiXmlElement * nodeControl = new TiXmlElement("control");
+    node->LinkEndChild(nodeControl);
+
+    std::string signalId = control->GetsignalId();
+
+    nodeControl->SetAttribute("signalId",signalId);
+
+    std::string type;
+    if(control->Gettype(type) == 1)
+    {
+        nodeControl->SetAttribute("type",type);
+    }
+
+    return true;
+}
+
 //--------------
 
 bool OpenDriveXmlWriter::WriteJunction (TiXmlElement *node, Junction *junction)
@@ -2297,6 +2349,13 @@ bool OpenDriveXmlWriter::WriteFile(std::string fileName)
 		WriteJunction(rootNode, mOpenDrive->GetJunction(i));
 	}
 
+    //Write controller
+    unsigned int controllerCount = mOpenDrive->GetControllerCount();
+    for(unsigned int i=0;i<controllerCount; i++)
+    {
+        WriteController(rootNode,mOpenDrive->GetController(i));
+    }
+
 	// Saves the XML structure to the file
     return doc.SaveFile( fileName );
 

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

@@ -108,7 +108,8 @@ public:
 	bool WriteSurface (TiXmlElement *node, Road* road);
 	//--------------
 
-	bool WriteController (TiXmlElement *node);
+    bool WriteController (TiXmlElement *node,Controller* controller);
+    bool WriteController_Control(TiXmlElement *node,Controller_control* control);
 	//--------------
 
 	bool WriteJunction (TiXmlElement *node, Junction *junction);

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

@@ -455,6 +455,24 @@ unsigned int Road::GetRoadNoavoidCount()
     return mRoadNoavoidVector.size();
 }
 //-------------------------------------------------
+vector<surface> *Road::GetSurfaceVector()
+{
+    return &mSurfaceVector;
+}
+
+surface*	Road::GetSurface(unsigned int i)
+{
+    if((mSurfaceVector.size()>0)&&(i<mSurfaceVector.size()))
+        return &mSurfaceVector.at(i);
+    else
+        return NULL;
+}
+
+unsigned int Road::GetSurfaceCount()
+{
+    return static_cast<unsigned int>(mSurfaceVector.size());
+}
+//-------------------------------------------------
 
 /**
  * Getters for the last child records in their respective vectors
@@ -563,6 +581,14 @@ RoadNoavoid* Road::GetLastRoadNoavoid()
         return NULL;
 }
 
+surface *       Road::GetLastSurface()
+{
+    if(mSurfaceVector.size()>0)
+        return &mSurfaceVector.at(mSurfaceVector.size()-1);
+    else
+        return NULL;
+}
+
 
 /**
  * Getters for the last added child records in their respective vectors
@@ -669,6 +695,13 @@ RoadNoavoid* Road::GetLastAddedRoadNoavoid()
     else
         return NULL;
 }
+surface*        Road::GetLastAddedSurface()
+{
+    if(mLastAddedSurface<mSurfaceVector.size())
+        return &mSurfaceVector.at(mLastAddedSurface);
+    else
+        return NULL;
+}
 //-------------------------------------------------
 
 /**
@@ -867,6 +900,14 @@ unsigned int Road::AddRoadNoavoid(double s, double length)
     mLastAddedRoadNoavoid=index;
     return index;
 }
+
+unsigned int Road::AddSurface()
+{
+    mSurfaceVector.push_back(surface());
+    mLastAddedSurface = static_cast<unsigned int >( mSurfaceVector.size()-1);
+    return mLastAddedSurface;
+}
+
 //-------------
 unsigned int Road::AddObjectsTunnel(double s,double length,string id,string type)
 {
@@ -1160,6 +1201,16 @@ unsigned int Road::CloneRoadNoavoid(unsigned int index)
     return mLastAddedRoadNoavoid;
 }
 
+unsigned int Road::CloneSurface(unsigned int index)
+{
+    if(index<mSurfaceVector.size()-1)
+        mSurfaceVector.insert(mSurfaceVector.begin()+index+1, mSurfaceVector[index]);
+    else if(index==mSurfaceVector.size()-1)
+        mSurfaceVector.push_back(mSurfaceVector[index]);
+    mLastAddedSurface=index+1;
+    return mLastAddedSurface;
+}
+
 
 /**
  * Methods used to delete child records from the respective vectors
@@ -1229,6 +1280,11 @@ void Road::DeleteRoadNoavoid(unsigned int index)
     mRoadNoavoidVector.erase(mRoadNoavoidVector.begin()+index);
 }
 
+void Road::DeleteSurface(unsigned int index)
+{
+    mSurfaceVector.erase(mSurfaceVector.begin()+index);
+}
+
 //-------------------------------------------------
 // EVALUATION METHODS
 
@@ -2005,3 +2061,268 @@ void Crossfall::SetSide(string side)
 	mSide=side;
 }
 
+
+//***********************************************************************************
+//Surface Record
+//***********************************************************************************
+
+surface_CRG::surface_CRG(std::string file,double sStart,double sEnd,std::string orientation,std::string mode)
+{
+    mfile = file;
+    msStart = sStart;
+    msEnd = sEnd;
+    morientation = orientation;
+    mmode = mode;
+}
+
+std::string surface_CRG::Getfile()
+{
+    return mfile;
+}
+
+double surface_CRG::GetsStart()
+{
+    return msStart;
+}
+
+double surface_CRG::GetsEnd()
+{
+    return msEnd;
+}
+
+std::string surface_CRG::Getorientation()
+{
+    return morientation;
+}
+
+std::string surface_CRG::Getmode()
+{
+    return mmode;
+}
+
+int surface_CRG::Getpurpose(std::string & purpose)
+{
+    if(mpurpose.size() == 0)return  0;
+    purpose = mpurpose[0];
+    return 1;
+}
+
+int surface_CRG::GetsOffset(double & sOffset)
+{
+    if(msOffset.size() == 0)return  0;
+    sOffset = msOffset[0];
+    return 1;
+}
+
+int surface_CRG::GettOffset(double & tOffset)
+{
+    if(mtOffset.size() == 0)return 0;
+    tOffset = mtOffset[0];
+    return  1;
+}
+
+int surface_CRG::GetzOffset(double & zOffset)
+{
+    if(mzOffset.size() == 0)return  0;
+    zOffset = mzOffset[0];
+    return 1;
+}
+
+int surface_CRG::GetzScale(double & zScale)
+{
+    if(mzScale.size() == 0)return  0;
+    zScale = mzScale[0];
+    return 1;
+}
+
+int surface_CRG::GethOffset(double & hOffset)
+{
+    if(mhOffset.size() == 0)return 0;
+    hOffset = mhOffset[0];
+    return  1;
+}
+
+void surface_CRG::Setfile(std::string file)
+{
+    mfile = file;
+}
+
+void surface_CRG::SetsStart(double sStart)
+{
+    msStart = sStart;
+}
+
+void surface_CRG::SetsEnd(double sEnd)
+{
+    msEnd = sEnd;
+}
+
+void surface_CRG::Setorientation(std::string orientation)
+{
+    morientation = orientation;
+}
+
+void surface_CRG::Setmode(std::string mode)
+{
+    mmode = mode;
+}
+
+void surface_CRG::Setpurpose(std::string purpose)
+{
+    if(mpurpose.size() > 0)mpurpose.clear();
+    mpurpose.push_back(purpose);
+}
+
+void surface_CRG::SetsOffset(double sOffset)
+{
+    if(msOffset.size()>0)msOffset.clear();
+    msOffset.push_back(sOffset);
+}
+
+void surface_CRG::SettOffset(double tOffset)
+{
+    if(mtOffset.size()>0)mtOffset.clear();
+    mtOffset.push_back(tOffset);
+}
+
+void surface_CRG::SetzOffset(double zOffset)
+{
+    if(mzOffset.size()>0)mzOffset.clear();
+    mzOffset.push_back(zOffset);
+}
+
+void surface_CRG::SetzScale(double zScale)
+{
+    if(mzScale.size()>0)mzScale.clear();
+    mzScale.push_back(zScale);
+}
+
+void surface_CRG::SethOffset(double hOffset)
+{
+    if(mhOffset.size()>0)mhOffset.clear();
+    mhOffset.push_back(hOffset);
+}
+
+void surface_CRG::Resetpurpose()
+{
+    if(mpurpose.size()>0)mpurpose.clear();
+}
+
+void surface_CRG::ResetsOffset()
+{
+    if(msOffset.size()>0)msOffset.clear();
+}
+
+void surface_CRG::ResettOffset()
+{
+    if(mtOffset.size()>0)mtOffset.clear();
+}
+
+void surface_CRG::ResetzOffset()
+{
+    if(mzOffset.size()>0)mzOffset.clear();
+}
+
+void surface_CRG::ResetzScale()
+{
+    if(mzScale.size()>0)mzScale.clear();
+}
+
+void surface_CRG::ResethOffset()
+{
+    if(mhOffset.size()>0)mhOffset.clear();
+}
+
+bool surface_CRG::CheckInterval(double s_check)
+{
+    if (s_check>=msStart)
+        return true;
+    else
+        return false;
+}
+
+
+
+surface::surface()
+{
+
+}
+
+vector<surface_CRG> * surface::GetCRGVector()
+{
+    return &mCRG;
+}
+
+surface_CRG* surface::GetCRG(unsigned int i)
+{
+    if ((mCRG.size()>0)&&(i<(mCRG.size())))
+        return &(mCRG.at(i));
+    else
+        return NULL;
+}
+
+unsigned int surface::GetCRGCount()
+{
+    return static_cast<unsigned int >(mCRG.size()) ;
+}
+
+surface_CRG*			surface::GetLastCRG()
+{
+    if (mCRG.size()>0)
+        return &mCRG.at(mCRG.size()-1);
+    else
+        return NULL;
+}
+
+surface_CRG*			surface::GetLastAddedCRG()
+{
+    if(mLastAddedCRG<mCRG.size())
+        return &mCRG.at(mLastAddedCRG);
+    else
+        return NULL;
+}
+
+unsigned int surface::AddCRG(std::string file,double sStart,double sEnd,std::string orientation,std::string mode)
+{
+
+    // Check the first method in the group for details
+
+    unsigned int index = static_cast<unsigned int>(CheckCRGInterval(sStart)+1) ;
+    if(index>=GetCRGCount()) mCRG.push_back(surface_CRG(file,sStart,sEnd,orientation,mode));
+    else mCRG.insert(mCRG.begin()+index, surface_CRG(file,sStart,sEnd,orientation,mode));
+    mLastAddedCRG=index;
+    return index;
+}
+
+unsigned int surface::CloneCRG(unsigned int index)
+{
+    if(index<(mCRG.size()-1))
+        mCRG.insert(mCRG.begin()+index+1, mCRG[index]);
+    else if(index==mCRG.size()-1)
+        mCRG.push_back(mCRG[index]);
+    mLastAddedCRG=index+1;
+    return mLastAddedCRG;
+}
+
+void surface::DeleteCRG(unsigned int index)
+{
+    mCRG.erase(mCRG.begin()+index);
+}
+
+int surface::CheckCRGInterval(double s_check)
+{
+    int res=-1;
+    //Go through all the tunnel records
+    for (unsigned int i=0;i<mCRG.size();i++)
+    {
+        //check if the s_check belongs to the current record
+        if (mCRG.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
+}
+
+
+

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

@@ -22,6 +22,7 @@ class GeometryBlock;
 class Elevation;
 class SuperElevation;
 class Crossfall;
+class surface;
 //lanes
 class LaneSection;
 class LaneSectionSample;
@@ -29,6 +30,7 @@ class LaneOffset;
 //objects, signals
 class Object;
 class Signal;
+
 //--------------
 
 using std::vector;
@@ -95,6 +97,8 @@ private:
 
     vector<RoadNoavoid> mRoadNoavoidVector;
 
+    vector<surface> mSurfaceVector;
+
 	/**
 	 * Indices of the last added child records
 	 */
@@ -113,6 +117,7 @@ private:
     unsigned int mLastAddedSignalReference;
     unsigned int mLastAddedRoadBorrow;
     unsigned int mLastAddedRoadNoavoid;
+    unsigned int mLastAddedSurface;
 
 public:
 	/**
@@ -223,6 +228,10 @@ public:
     RoadNoavoid*	GetRoadNoavoid(unsigned int i);
     unsigned int GetRoadNoavoidCount();
 
+    vector<surface> *GetSurfaceVector();
+    surface*	GetSurface(unsigned int i);
+    unsigned int GetSurfaceCount();
+
 
     vector<string> * GetUserData();
 	//-------------------------------------------------
@@ -244,6 +253,7 @@ public:
     signals_signalReference* GetLastSignalReference();
     RoadBorrow *    GetLastRoadBorrow();
     RoadNoavoid *   GetLastRoadNoavoid();
+    surface *       GetLastSurface();
 
 	/**
 	 * Getters for the last added child records in their respective vectors
@@ -262,6 +272,7 @@ public:
     signals_signalReference* GetLastAddedSignalReference();
     RoadBorrow*     GetLastAddedRoadBorrow();
     RoadNoavoid*    GetLastAddedRoadNoavoid();
+    surface*        GetLastAddedSurface();
 
 	//-------------------------------------------------
 
@@ -313,6 +324,7 @@ public:
 
     unsigned int AddRoadBorrow(double s,double length,string mode);
     unsigned int AddRoadNoavoid(double s,double length);
+    unsigned int AddSurface();
 	/**
 	 * Methods used to clone child records in the respective vectors
 	 */
@@ -330,6 +342,7 @@ public:
     unsigned int CloneSignalReference(unsigned int index);
     unsigned int CloneRoadBorrow(unsigned int index);
     unsigned int CloneRoadNoavoid(unsigned int index);
+    unsigned int CloneSurface(unsigned int index);
 
 	/**
 	 * Methods used to delete child records from the respective vectors
@@ -349,6 +362,7 @@ public:
     void DeleteSignalReference(unsigned int index);
     void DeleteRoadBorrow(unsigned int index);
     void DeleteRoadNoavoid(unsigned int index);
+    void DeleteSurface(unsigned int index);
 	
 	//-------------------------------------------------
 
@@ -666,4 +680,86 @@ public:
 //----------------------------------------------------------------------------------
 
 
+class surface_CRG
+{
+private:
+    std::string mfile;
+    double msStart;
+    double msEnd;
+    std::string morientation;
+    std::string mmode;
+    std::vector<std::string> mpurpose;
+    std::vector<double> msOffset;
+    std::vector<double> mtOffset;
+    std::vector<double> mzOffset;
+    std::vector<double> mzScale;
+    std::vector<double> mhOffset;
+
+public:
+    surface_CRG(std::string file,double sStart,double sEnd,std::string orientation,std::string mode);
+
+    std::string Getfile();
+    double GetsStart();
+    double GetsEnd();
+    std::string Getorientation();
+    std::string Getmode();
+    int Getpurpose(std::string & purpose);
+    int GetsOffset(double & sOffset);
+    int GettOffset(double & tOffset);
+    int GetzOffset(double & zOffset);
+    int GetzScale(double & zScale);
+    int GethOffset(double & hOffset);
+
+    void Setfile(std::string file);
+    void SetsStart(double sStart);
+    void SetsEnd(double sEnd);
+    void Setorientation(std::string orientation);
+    void Setmode(std::string mode);
+    void Setpurpose(std::string purpose);
+    void SetsOffset(double sOffset);
+    void SettOffset(double tOffset);
+    void SetzOffset(double zOffset);
+    void SetzScale(double zScale);
+    void SethOffset(double hOffset);
+
+    void Resetpurpose();
+    void ResetsOffset();
+    void ResettOffset();
+    void ResetzOffset();
+    void ResetzScale();
+    void ResethOffset();
+
+    bool CheckInterval(double s_check);
+
+};
+
+//----------------------------------------------------------------------------------
+
+class surface
+{
+private:
+    vector<surface_CRG> mCRG;
+    unsigned int mLastAddedCRG;
+
+public:
+    surface();
+
+    vector<surface_CRG> * GetCRGVector();
+    surface_CRG* GetCRG(unsigned int i);
+    unsigned int GetCRGCount();
+    surface_CRG*			GetLastCRG();
+    surface_CRG*			GetLastAddedCRG();
+    unsigned int AddCRG(std::string file,double sStart,double sEnd,std::string orientation,std::string mode);
+    unsigned int CloneCRG(unsigned int index);
+    void DeleteCRG(unsigned int index);
+
+    int CheckCRGInterval(double s_check);
+
+
+
+
+};
+
+
+//----------------------------------------------------------------------------------
 #endif

+ 143 - 0
src/common/common/xodr/OpenDrive/controller.cpp

@@ -0,0 +1,143 @@
+#include "controller.h"
+
+Controller::Controller(std::string id)
+{
+    mid = id;
+}
+
+void Controller::Setid(std::string id)
+{
+    mid = id;
+}
+
+void Controller::Setname(std::string name)
+{
+    if(mname.size()>0)mname.clear();
+    mname.push_back(name);
+}
+
+void Controller::Setsequence(unsigned int sequence)
+{
+    if(msequence.size()>0)msequence.clear();
+    msequence.push_back(sequence);
+}
+
+std::string Controller::Getid()
+{
+    return mid;
+}
+
+int Controller::Getname(std::string & name)
+{
+    if(mname.size() == 0)return 0;
+    name = mname[0];
+    return 1;
+}
+
+int Controller::Getsequence(unsigned int & sequence)
+{
+    if(msequence.size() == 0)return 0;
+    sequence = msequence[0];
+    return 1;
+}
+
+void Controller::Resetname()
+{
+    if(mname.size()>0)mname.clear();
+}
+
+void Controller::Resetsequence()
+{
+    if(msequence.size()>0)msequence.clear();
+}
+
+vector<Controller_control> * Controller::GetControlVector()
+{
+    return  &mcontrol;
+}
+
+Controller_control* Controller::GetControl(unsigned int i)
+{
+    if ((mcontrol.size()>0)&&(i<(mcontrol.size())))
+        return &(mcontrol.at(i));
+    else
+        return NULL;
+}
+
+unsigned int Controller::GetControlCount()
+{
+    return static_cast<unsigned int >(mcontrol.size()) ;
+}
+
+Controller_control*			Controller::GetLastControl()
+{
+    if (mcontrol.size()>0)
+        return &mcontrol.at(mcontrol.size()-1);
+    else
+        return NULL;
+}
+
+Controller_control*			Controller::GetLastAddedControl()
+{
+    if(mLastAddedControl<mcontrol.size())
+        return &mcontrol.at(mLastAddedControl);
+    else
+        return NULL;
+}
+
+unsigned int Controller::AddControl(std::string signalId)
+{
+    mcontrol.push_back(Controller_control(signalId));
+    mLastAddedControl = static_cast<unsigned int>(mcontrol.size()-1) ;
+    return mLastAddedControl;
+}
+
+unsigned int Controller::CloneControl(unsigned int index)
+{
+    if(index<(mcontrol.size()-1))
+        mcontrol.insert(mcontrol.begin()+index+1, mcontrol[index]);
+    else if(index==mcontrol.size()-1)
+        mcontrol.push_back(mcontrol[index]);
+    mLastAddedControl=index+1;
+    return mLastAddedControl;
+}
+
+void Controller::DeleteControl(unsigned int index)
+{
+    mcontrol.erase(mcontrol.begin()+index);
+}
+
+
+
+Controller_control::Controller_control(std::string signalId)
+{
+    msignalId = signalId;
+}
+
+void Controller_control::SetsignalId(std::string signalId)
+{
+    msignalId = signalId;
+}
+
+void Controller_control::Settype(std::string type)
+{
+    if(mtype.size()>0)mtype.clear();
+    mtype.push_back(type);
+}
+
+std::string Controller_control::GetsignalId()
+{
+    return msignalId;
+}
+
+int Controller_control::Gettype(std::string & type)
+{
+    if(mtype.size() == 0)return 0;
+    type = mtype[0];
+    return 1;
+}
+
+void Controller_control::Resettype()
+{
+    if(mtype.size()>0)mtype.clear();
+}

+ 66 - 0
src/common/common/xodr/OpenDrive/controller.h

@@ -0,0 +1,66 @@
+#ifndef CONTROLLER_H
+#define CONTROLLER_H
+
+#include <string>
+#include <vector>
+
+
+using std::vector;
+using std::string;
+
+class Controller_control;
+
+class Controller
+{
+private:
+    std::string mid;
+    std::vector<std::string> mname;
+    std::vector<unsigned int> msequence;
+
+    std::vector<Controller_control> mcontrol;
+    unsigned int mLastAddedControl;
+
+
+public:
+    Controller(std::string id);
+
+    void Setid(std::string id);
+    void Setname(std::string name);
+    void Setsequence(unsigned int sequence);
+
+    std::string Getid();
+    int Getname(std::string & name);
+    int Getsequence(unsigned int & sequence);
+
+    void Resetname();
+    void Resetsequence();
+
+    vector<Controller_control> * GetControlVector();
+    Controller_control* GetControl(unsigned int i);
+    unsigned int GetControlCount();
+    Controller_control*			GetLastControl();
+    Controller_control*			GetLastAddedControl();
+    unsigned int AddControl(std::string signalId);
+    unsigned int CloneControl(unsigned int index);
+    void DeleteControl(unsigned int index);
+};
+
+class Controller_control
+{
+private:
+    std::string msignalId;
+    std::vector<std::string> mtype;
+
+public:
+    Controller_control(std::string signalId);
+
+    void SetsignalId(std::string signalId);
+    void Settype(std::string type);
+
+    std::string GetsignalId();
+    int Gettype(std::string & type);
+
+    void Resettype();
+};
+
+#endif // CONTROLLER_H