Browse Source

change map_lanetoxodr. add objectReference.

yuchuli 2 years ago
parent
commit
3f7355060b

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

@@ -2,6 +2,156 @@
 
 
 #include <iostream>
 #include <iostream>
 
 
+Objects_objectReference::Objects_objectReference(double s,double t,std::string id,std::string orientation)
+{
+    mS = s;
+    mt = t;
+    mstrid = id;
+    morientation = orientation;
+}
+
+double Objects_objectReference::GetS()
+{
+    return mS;
+}
+
+double Objects_objectReference::Gett()
+{
+    return mt;
+}
+
+std::string Objects_objectReference::Getid()
+{
+    return mstrid;
+}
+
+std::string Objects_objectReference::Getorientation()
+{
+    return morientation;
+}
+
+void Objects_objectReference::SetS(double s)
+{
+   mS = s;
+}
+
+void Objects_objectReference::Sett(double t)
+{
+    mt = t;
+}
+
+void Objects_objectReference::Setid(std::string id)
+{
+    mstrid = id;
+}
+
+void Objects_objectReference::Setorientation(std::string orientation)
+{
+    morientation = orientation;
+}
+
+int Objects_objectReference::GetzOffset(double & zOffset)
+{
+    if(mzOffset.size() == 0)return 0;
+    zOffset = mzOffset[0];
+    return 1;
+}
+
+int Objects_objectReference::GetvalidLength(double & validLength)
+{
+    if(mvalidLength.size() == 0)return 0;
+    validLength = mvalidLength[0];
+    return 1;
+}
+
+void Objects_objectReference::SetzOffset(double zOffset)
+{
+    if(mzOffset.size()>0)mzOffset.clear();
+    mzOffset.push_back(zOffset);
+}
+
+void Objects_objectReference::SetvalidLength(double validLength)
+{
+    if(mvalidLength.size()>0)mvalidLength.clear();
+    mvalidLength.push_back(validLength);
+}
+
+void Objects_objectReference::ResetzOffset()
+{
+    if(mzOffset.size()>0)mzOffset.clear();
+}
+
+void Objects_objectReference::ResetvalidLength()
+{
+    if(mvalidLength.size()>0)mvalidLength.clear();
+}
+
+
+vector<Object_laneValidity> * Objects_objectReference::GetObjectlaneValidityVector()
+{
+    return &mObject_laneValidity;
+}
+
+Object_laneValidity* Objects_objectReference::GetObjectlaneValidity(unsigned int i)
+{
+    if ((mObject_laneValidity.size()>0)&&(i<(mObject_laneValidity.size())))
+        return &(mObject_laneValidity.at(i));
+    else
+        return NULL;
+}
+
+unsigned int Objects_objectReference::GetObjectlaneValidityCount()
+{
+    return static_cast<unsigned int>(mObject_laneValidity.size());
+}
+
+Object_laneValidity*			Objects_objectReference::GetLastObjectlaneValidity()
+{
+    if (mObject_laneValidity.size()>0)
+        return &mObject_laneValidity.at(mObject_laneValidity.size()-1);
+    else
+        return NULL;
+}
+
+Object_laneValidity*			Objects_objectReference::GetLastAddedObjectlaneValidity()
+{
+    if(mLastAddedObjectlaneValidity<mObject_laneValidity.size())
+        return &mObject_laneValidity.at(mLastAddedObjectlaneValidity);
+    else
+        return NULL;
+}
+
+unsigned int Objects_objectReference::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_objectReference::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_objectReference::DeleteObjectlaneValidity(unsigned int index)
+{
+    mObject_laneValidity.erase(mObject_laneValidity.begin()+index);
+}
+
+bool Objects_objectReference::CheckInterval(double s_check)
+{
+    if (s_check>=mS)
+        return true;
+    else
+        return false;
+}
+
+
+
 Objects_tunnel::Objects_tunnel(double s,double length,std::string strid,std::string strtype)
 Objects_tunnel::Objects_tunnel(double s,double length,std::string strid,std::string strtype)
 {
 {
     mS = s;
     mS = s;

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

@@ -12,8 +12,58 @@ class Object_markings_marking_cornerReference;
 class Object_laneValidity;
 class Object_laneValidity;
 
 
 
 
+class Objects_objectReference
+{
+private:
+    double mS;
+    double mt;
+    std::string mstrid;
+    std::vector<double> mzOffset;
+    std::vector<double> mvalidLength;
+    std::string morientation;
+
+    vector<Object_laneValidity> mObject_laneValidity;
+
+    unsigned int mLastAddedObjectlaneValidity;
+
+public:
+    Objects_objectReference(double s,double t,std::string id,std::string orientation);
+
+    double GetS();
+    double Gett();
+    std::string Getid();
+    std::string Getorientation();
+
+    void SetS(double s);
+    void Sett(double t);
+    void Setid(std::string id);
+    void Setorientation(std::string orientation);
+
+    int GetzOffset(double & zOffset);
+    int GetvalidLength(double & validLength);
+
+    void SetzOffset(double zOffset);
+    void SetvalidLength(double validLength);
+
+    void ResetzOffset();
+    void ResetvalidLength();
+
+    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 Objects_tunnel
 class Objects_tunnel
 {
 {
+private:
     double mS;
     double mS;
     double mlength;
     double mlength;
     std::vector<std::string> mname;
     std::vector<std::string> mname;

+ 148 - 1
src/common/common/xodr/OpenDrive/OpenDriveXmlParser.cpp

@@ -1251,6 +1251,18 @@ bool OpenDriveXmlParser::ReadObjects (Road* road, TiXmlElement *node)
     {
     {
         ReadObjectsBridge(road, subNode);
         ReadObjectsBridge(road, subNode);
         subNode=subNode->NextSiblingElement("bridge");
         subNode=subNode->NextSiblingElement("bridge");
+    }
+    subNode = node->FirstChildElement("tunnel");
+    while (subNode)
+    {
+        ReadObjectsTunnel(road, subNode);
+        subNode=subNode->NextSiblingElement("tunnel");
+    }
+    subNode = node->FirstChildElement("objectReference");
+    while (subNode)
+    {
+        ReadObjectsObjectReference(road, subNode);
+        subNode=subNode->NextSiblingElement("objectReference");
     }
     }
 	return true;
 	return true;
 }
 }
@@ -1875,6 +1887,106 @@ bool OpenDriveXmlParser::ReadObjectsBridge(Road * road,TiXmlElement * node)
 
 
 //--------------
 //--------------
 
 
+bool OpenDriveXmlParser::ReadObjectsTunnel(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 Tunnel attributes"<<endl;
+        return false;
+    }
+
+    road->AddObjectsTunnel(s,length,id,type);
+
+    Objects_tunnel * pObjects_tunnel = road->GetLastAddedObjectsTunnel();
+
+    if(node->QueryStringAttribute("name",&name) == TIXML_SUCCESS)
+    {
+       pObjects_tunnel->Setname(name);
+    }
+
+    int lighting,daylight;
+    if(node->QueryIntAttribute("lighting",&lighting) == TIXML_SUCCESS)
+    {
+        pObjects_tunnel->Setlighting(lighting);
+    }
+    if(node->QueryIntAttribute("daylight",&daylight) == TIXML_SUCCESS)
+    {
+        pObjects_tunnel->Setdaylight(daylight);
+    }
+
+    TiXmlElement *subNode = node->FirstChildElement("validity");
+    while (subNode)
+    {
+        ReadTunnelvalidity(pObjects_tunnel,subNode);
+        subNode = subNode->NextSiblingElement("validity");
+    }
+
+    return true;
+}
+
+//--------------
+
+bool OpenDriveXmlParser::ReadObjectsObjectReference(Road * road,TiXmlElement * node)
+{
+    double s;
+    double t;
+    string id;
+    string 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 Objects objectReference attributes"<<endl;
+        return false;
+    }
+
+    road->AddObjectsObjectReference(s,t,id,orientation);
+
+    Objects_objectReference * pObjects_ObjectReference = road->GetLastAddedObjectsObjectReference();
+
+    double zOffset,validLength;
+
+    if(node->QueryDoubleAttribute("zOffset",&zOffset) == TIXML_SUCCESS)
+    {
+        pObjects_ObjectReference->SetzOffset(zOffset);
+    }
+
+    if(node->QueryDoubleAttribute("validLength",&validLength) == TIXML_SUCCESS)
+    {
+        pObjects_ObjectReference->SetvalidLength(validLength);
+    }
+
+
+    TiXmlElement *subNode = node->FirstChildElement("validity");
+    while (subNode)
+    {
+        ReadObjectReferencevalidity(pObjects_ObjectReference,subNode);
+        subNode = subNode->NextSiblingElement("validity");
+    }
+
+    return true;
+}
+
+//--------------
+
 bool OpenDriveXmlParser::ReadObject(Road *road, TiXmlElement *node)
 bool OpenDriveXmlParser::ReadObject(Road *road, TiXmlElement *node)
 {
 {
     double t;
     double t;
@@ -2049,7 +2161,7 @@ bool OpenDriveXmlParser::ReadObjectvalidity(Object * pObject,TiXmlElement * node
 
 
     return true;
     return true;
 }
 }
-
+//--------------
 bool OpenDriveXmlParser::ReadBridgevalidity(Objects_bridge * pBridge,TiXmlElement * node)
 bool OpenDriveXmlParser::ReadBridgevalidity(Objects_bridge * pBridge,TiXmlElement * node)
 {
 {
     int fromLane,toLane;
     int fromLane,toLane;
@@ -2067,7 +2179,42 @@ bool OpenDriveXmlParser::ReadBridgevalidity(Objects_bridge * pBridge,TiXmlElemen
 
 
     return true;
     return true;
 }
 }
+//--------------
+bool OpenDriveXmlParser::ReadTunnelvalidity(Objects_tunnel * pTunnel,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 tunnel validity attributes"<<endl;
+        return false;
+    }
+
+    pTunnel->AddObjectlaneValidity(fromLane,toLane);
+
+    return true;
+}
+//--------------
+bool OpenDriveXmlParser::ReadObjectReferencevalidity(Objects_objectReference * pObjectReference,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 reference validity attributes"<<endl;
+        return false;
+    }
+
+    pObjectReference->AddObjectlaneValidity(fromLane,toLane);
+
+    return true;
+}
 //--------------
 //--------------
 
 
 bool OpenDriveXmlParser::ReadRoadBorrows(Road *road, TiXmlElement *node)
 bool OpenDriveXmlParser::ReadRoadBorrows(Road *road, TiXmlElement *node)

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

@@ -90,6 +90,8 @@ public:
     bool ReadSignal_positionInertial(Signal * pSignal, TiXmlElement *node);
     bool ReadSignal_positionInertial(Signal * pSignal, TiXmlElement *node);
     bool ReadSignal_laneValidity(Signal * pSignal,TiXmlElement * node);
     bool ReadSignal_laneValidity(Signal * pSignal,TiXmlElement * node);
     bool ReadObjectsBridge(Road * road,TiXmlElement * node);
     bool ReadObjectsBridge(Road * road,TiXmlElement * node);
+    bool ReadObjectsTunnel(Road * road,TiXmlElement * node);
+    bool ReadObjectsObjectReference(Road * road,TiXmlElement * node);
     bool ReadObject(Road * road,TiXmlElement * node);
     bool ReadObject(Road * road,TiXmlElement * node);
     bool ReadObjectMarkings(Object * pObject,TiXmlElement * node);
     bool ReadObjectMarkings(Object * pObject,TiXmlElement * node);
     bool ReadObjectMarkingsMarking(Object_markings * pObject_Markings,TiXmlElement * node);
     bool ReadObjectMarkingsMarking(Object_markings * pObject_Markings,TiXmlElement * node);
@@ -99,6 +101,8 @@ public:
     bool ReadObjectBordersBordercornerReference(Object_borders_border * pObject_Border,TiXmlElement * node);
     bool ReadObjectBordersBordercornerReference(Object_borders_border * pObject_Border,TiXmlElement * node);
     bool ReadObjectvalidity(Object * pObject,TiXmlElement * node);
     bool ReadObjectvalidity(Object * pObject,TiXmlElement * node);
     bool ReadBridgevalidity(Objects_bridge * pBridge,TiXmlElement * node);
     bool ReadBridgevalidity(Objects_bridge * pBridge,TiXmlElement * node);
+    bool ReadTunnelvalidity(Objects_tunnel * pTunnel,TiXmlElement * node);
+    bool ReadObjectReferencevalidity(Objects_objectReference * pObjectReference,TiXmlElement * node);
 
 
 	//--------------
 	//--------------
 
 

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

@@ -1238,9 +1238,89 @@ bool OpenDriveXmlWriter::WriteObjects (TiXmlElement *node, Road* road)
         WriteObjectsBridge(nodeObjects, road->GetObjectsBridge(i));
         WriteObjectsBridge(nodeObjects, road->GetObjectsBridge(i));
     }
     }
 
 
+    unsigned int lObjectsTunnelCount = road->GetObjectsTunnelCount();
+    for(unsigned int i=0;i<lObjectsTunnelCount; i++)
+    {
+        WriteObjectsTunnel(nodeObjects, road->GetObjectsTunnel(i));
+    }
+
+    unsigned int lObjectsObjectReferenceCount = road->GetObjectsObjectReferenceCount();
+    for(unsigned int i=0;i<lObjectsObjectReferenceCount; i++)
+    {
+        WriteObjectsObjectReference(nodeObjects, road->GetObjectsObjectReference(i));
+    }
+
 	return true;
 	return true;
 }
 }
 //--------------
 //--------------
+bool OpenDriveXmlWriter::WriteObjectsTunnel(TiXmlElement * node, Objects_tunnel * pObjectsTunnel)
+{
+    TiXmlElement* nodeObjectsTunnel = new TiXmlElement("tunnel");
+    node->LinkEndChild(nodeObjectsTunnel);
+
+    nodeObjectsTunnel->SetDoubleAttribute("s",pObjectsTunnel->GetS());
+    nodeObjectsTunnel->SetDoubleAttribute("length",pObjectsTunnel->Getlength());
+    nodeObjectsTunnel->SetAttribute("id",pObjectsTunnel->Getid());
+    nodeObjectsTunnel->SetAttribute("type",pObjectsTunnel->Gettype());
+
+    std::string strname;
+    if(pObjectsTunnel->GetName(strname) == 1)
+    {
+        nodeObjectsTunnel->SetAttribute("name",strname);
+    }
+
+    int lighting,daylight;
+
+    if(pObjectsTunnel->Getlighting(lighting) == 1)
+    {
+        nodeObjectsTunnel->SetAttribute("lighting",lighting);
+    }
+
+    if(pObjectsTunnel->Getdaylight(daylight) == 1)
+    {
+        nodeObjectsTunnel->SetAttribute("daylight",daylight);
+    }
+
+    unsigned int llaneValidityCount = pObjectsTunnel->GetObjectlaneValidityCount();
+    for(unsigned int i=0; i<llaneValidityCount; i++)
+    {
+        WriteObjectlaneValidity(nodeObjectsTunnel, pObjectsTunnel->GetObjectlaneValidity(i));
+    }
+
+    return true;
+}
+//--------------
+bool OpenDriveXmlWriter::WriteObjectsObjectReference(TiXmlElement * node, Objects_objectReference * pObjectsObjectReference)
+{
+    TiXmlElement* nodeObjectsObjectReference = new TiXmlElement("objectReference");
+    node->LinkEndChild(nodeObjectsObjectReference);
+
+    nodeObjectsObjectReference->SetDoubleAttribute("s",pObjectsObjectReference->GetS());
+    nodeObjectsObjectReference->SetDoubleAttribute("t",pObjectsObjectReference->Gett());
+    nodeObjectsObjectReference->SetAttribute("id",pObjectsObjectReference->Getid());
+    nodeObjectsObjectReference->SetAttribute("orientation",pObjectsObjectReference->Getorientation());
+
+    double zOffset,validLength;
+    if(pObjectsObjectReference->GetzOffset(zOffset) == 1)
+    {
+        nodeObjectsObjectReference->SetDoubleAttribute("zOffset",zOffset);
+    }
+
+    if(pObjectsObjectReference->GetvalidLength(validLength) == 1)
+    {
+        nodeObjectsObjectReference->SetDoubleAttribute("validLength",validLength);
+    }
+
+
+    unsigned int llaneValidityCount = pObjectsObjectReference->GetObjectlaneValidityCount();
+    for(unsigned int i=0; i<llaneValidityCount; i++)
+    {
+        WriteObjectlaneValidity(nodeObjectsObjectReference, pObjectsObjectReference->GetObjectlaneValidity(i));
+    }
+
+    return true;
+}
+//--------------
 bool OpenDriveXmlWriter::WriteObjectsBridge(TiXmlElement * node, Objects_bridge * pObjectsBridge)
 bool OpenDriveXmlWriter::WriteObjectsBridge(TiXmlElement * node, Objects_bridge * pObjectsBridge)
 {
 {
     TiXmlElement* nodeObjectsBridge = new TiXmlElement("bridge");
     TiXmlElement* nodeObjectsBridge = new TiXmlElement("bridge");

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

@@ -77,6 +77,8 @@ public:
     bool WriteRoadBorrow(TiXmlElement *node,RoadBorrow * pRoadBorrow);   
     bool WriteRoadBorrow(TiXmlElement *node,RoadBorrow * pRoadBorrow);   
 	bool WriteObjects (TiXmlElement *node, Road* road);
 	bool WriteObjects (TiXmlElement *node, Road* road);
     bool WriteObjectsBridge(TiXmlElement * node, Objects_bridge * pObjectsBridge);
     bool WriteObjectsBridge(TiXmlElement * node, Objects_bridge * pObjectsBridge);
+    bool WriteObjectsTunnel(TiXmlElement * node, Objects_tunnel * pObjectsTunnel);
+    bool WriteObjectsObjectReference(TiXmlElement * node, Objects_objectReference * pObjectsObjectReference);
     bool WriteObject(TiXmlElement * node, Object * pObject);
     bool WriteObject(TiXmlElement * node, Object * pObject);
     bool WriteObjectParkingSpace(TiXmlElement * node,Object_parkingSpace * pObject_parkingSpace);
     bool WriteObjectParkingSpace(TiXmlElement * node,Object_parkingSpace * pObject_parkingSpace);
     bool WriteObjectrepeat(TiXmlElement * node,Object_repeat * pObject_repeat);
     bool WriteObjectrepeat(TiXmlElement * node,Object_repeat * pObject_repeat);

+ 143 - 2
src/common/common/xodr/OpenDrive/Road.cpp

@@ -322,11 +322,50 @@ Objects_bridge*	Road::GetObjectsBridge(unsigned int i)
         return NULL;
         return NULL;
 }
 }
 
 
+
 unsigned int Road::GetObjectsBridgeCount()
 unsigned int Road::GetObjectsBridgeCount()
 {
 {
     return  static_cast<unsigned int>(mObjectsBridgeVector.size()) ;
     return  static_cast<unsigned int>(mObjectsBridgeVector.size()) ;
 }
 }
 
 
+//Road Tunnel records
+vector<Objects_tunnel> *Road::GetObjectsTunnelVector()
+{
+    return &mObjectsTunnelVector;
+}
+
+Objects_tunnel*	Road::GetObjectsTunnel(unsigned int i)
+{
+    if ((mObjectsTunnelVector.size()>0)&&(i<mObjectsTunnelVector.size()))
+        return &mObjectsTunnelVector.at(i);
+    else
+        return NULL;
+}
+
+unsigned int Road::GetObjectsTunnelCount()
+{
+    return  static_cast<unsigned int>(mObjectsTunnelVector.size()) ;
+}
+
+// Road objectReference records
+vector<Objects_objectReference> *Road::GetObjectsObjectReferenceVector()
+{
+    return &mObjectsObjectReferenceVector;
+}
+
+Objects_objectReference*	Road::GetObjectsObjectReference(unsigned int i)
+{
+    if ((mObjectsObjectReferenceVector.size()>0)&&(i<mObjectsObjectReferenceVector.size()))
+        return &mObjectsObjectReferenceVector.at(i);
+    else
+        return NULL;
+}
+
+unsigned int Road::GetObjectsObjectReferenceCount()
+{
+    return  static_cast<unsigned int>(mObjectsObjectReferenceVector.size()) ;
+}
+
 // Road object records
 // Road object records
 vector<Object> *Road::GetObjectVector()
 vector<Object> *Road::GetObjectVector()
 {
 {
@@ -452,6 +491,20 @@ Objects_bridge* Road::GetLastObjectsBridge()
     else
     else
         return NULL;
         return NULL;
 }
 }
+Objects_objectReference* Road::GetLastObjectsObjectReference()
+{
+    if (mObjectsObjectReferenceVector.size()>0)
+        return &mObjectsObjectReferenceVector.at(mObjectsObjectReferenceVector.size()-1);
+    else
+        return NULL;
+}
+Objects_tunnel* Road::GetLastObjectsTunnel()
+{
+    if (mObjectsTunnelVector.size()>0)
+        return &mObjectsTunnelVector.at(mObjectsTunnelVector.size()-1);
+    else
+        return NULL;
+}
 Object*	Road::GetLastObject()
 Object*	Road::GetLastObject()
 {	
 {	
 	if (mObjectsVector.size()>0)
 	if (mObjectsVector.size()>0)
@@ -535,6 +588,20 @@ Objects_bridge* Road::GetLastAddedObjectsBridge()
     else
     else
         return NULL;
         return NULL;
 }
 }
+Objects_tunnel* Road::GetLastAddedObjectsTunnel()
+{
+    if(mLastAddedObjectsTunnel<mObjectsTunnelVector.size())
+        return &mObjectsTunnelVector.at(mLastAddedObjectsTunnel);
+    else
+        return NULL;
+}
+Objects_objectReference* Road::GetLastAddedObjectsObjectReference()
+{
+    if(mLastAddedObject<mObjectsObjectReferenceVector.size())
+        return &mObjectsObjectReferenceVector.at(mLastAddedObject);
+    else
+        return NULL;
+}
 Object* Road::GetLastAddedObject()
 Object* Road::GetLastAddedObject()
 {
 {
 	if(mLastAddedObject<mObjectsVector.size())
 	if(mLastAddedObject<mObjectsVector.size())
@@ -762,6 +829,24 @@ unsigned int Road::AddRoadNoavoid(double s, double length)
     return index;
     return index;
 }
 }
 //-------------
 //-------------
+unsigned int Road::AddObjectsTunnel(double s,double length,string id,string type)
+{
+    unsigned int index = static_cast<unsigned int>(CheckRoadObjectsTunnelInterval(s)+1) ;
+    if(index>=GetObjectsTunnelCount()) mObjectsTunnelVector.push_back(Objects_tunnel(s,length,id,type));
+    else mObjectsTunnelVector.insert(mObjectsTunnelVector.begin()+index, Objects_tunnel(s,length,id,type));
+    mLastAddedObjectsTunnel=index;
+    return index;
+}
+//-------------
+unsigned int Road::AddObjectsObjectReference(double s,double t,string id,string orientation)
+{
+    unsigned int index = static_cast<unsigned int>(CheckRoadObjectsTunnelInterval(s)+1) ;
+    if(index>=GetObjectsObjectReferenceCount()) mObjectsObjectReferenceVector.push_back(Objects_objectReference(s,t,id,orientation));
+    else mObjectsObjectReferenceVector.insert(mObjectsObjectReferenceVector.begin()+index, Objects_objectReference(s,t,id,orientation));
+    mLastAddedObjectsObjectReference=index;
+    return index;
+}
+//-------------
 unsigned int Road::AddObjectsBridge(double s,double length,string id,string type)
 unsigned int Road::AddObjectsBridge(double s,double length,string id,string type)
 {
 {
     unsigned int index = static_cast<unsigned int>(CheckRoadObjectsBridgeInterval(s)+1) ;
     unsigned int index = static_cast<unsigned int>(CheckRoadObjectsBridgeInterval(s)+1) ;
@@ -950,7 +1035,6 @@ unsigned int Road::CloneLaneSectionEnd(unsigned int index)
 }
 }
 unsigned int Road::CloneObjectsBridge(unsigned int index)
 unsigned int Road::CloneObjectsBridge(unsigned int index)
 {
 {
-
     if(index<mObjectsBridgeVector.size()-1)
     if(index<mObjectsBridgeVector.size()-1)
         mObjectsBridgeVector.insert(mObjectsBridgeVector.begin()+index+1, mObjectsBridgeVector[index]);
         mObjectsBridgeVector.insert(mObjectsBridgeVector.begin()+index+1, mObjectsBridgeVector[index]);
     else if(index==mObjectsBridgeVector.size()-1)
     else if(index==mObjectsBridgeVector.size()-1)
@@ -958,6 +1042,24 @@ unsigned int Road::CloneObjectsBridge(unsigned int index)
     mLastAddedObjectsBridge=index+1;
     mLastAddedObjectsBridge=index+1;
     return mLastAddedObjectsBridge;
     return mLastAddedObjectsBridge;
 }
 }
+unsigned int Road::CloneObjectsTunnel(unsigned int index)
+{
+    if(index<mObjectsTunnelVector.size()-1)
+        mObjectsTunnelVector.insert(mObjectsTunnelVector.begin()+index+1, mObjectsTunnelVector[index]);
+    else if(index==mObjectsTunnelVector.size()-1)
+        mObjectsTunnelVector.push_back(mObjectsTunnelVector[index]);
+    mLastAddedObjectsTunnel=index+1;
+    return mLastAddedObjectsTunnel;
+}
+unsigned int Road::CloneObjectsObjectReference(unsigned int index)
+{
+    if(index<mObjectsObjectReferenceVector.size()-1)
+        mObjectsObjectReferenceVector.insert(mObjectsObjectReferenceVector.begin()+index+1, mObjectsObjectReferenceVector[index]);
+    else if(index==mObjectsObjectReferenceVector.size()-1)
+        mObjectsObjectReferenceVector.push_back(mObjectsObjectReferenceVector[index]);
+    mLastAddedObjectsObjectReference=index+1;
+    return mLastAddedObjectsObjectReference;
+}
 unsigned int Road::CloneObject(unsigned int index)
 unsigned int Road::CloneObject(unsigned int index)
 {
 {
 	// Check the first method in the group for details
 	// Check the first method in the group for details
@@ -1038,6 +1140,14 @@ void Road::DeleteObjectsBridge(unsigned int index)
 {
 {
     mObjectsBridgeVector.erase(mObjectsBridgeVector.begin()+index);
     mObjectsBridgeVector.erase(mObjectsBridgeVector.begin()+index);
 }
 }
+void Road::DeleteObjectsTunnel(unsigned int index)
+{
+    mObjectsTunnelVector.erase(mObjectsTunnelVector.begin()+index);
+}
+void Road::DeleteObjectsObjectReference(unsigned int index)
+{
+    mObjectsObjectReferenceVector.erase(mObjectsObjectReferenceVector.begin()+index);
+}
 void Road::DeleteObject(unsigned int index)
 void Road::DeleteObject(unsigned int index)
 {
 {
 	mObjectsVector.erase(mObjectsVector.begin()+index);
 	mObjectsVector.erase(mObjectsVector.begin()+index);
@@ -1418,7 +1528,7 @@ int Road::CheckRoadNoavoidInterval(double s_check)
 int Road::CheckRoadObjectsBridgeInterval(double s_check)
 int Road::CheckRoadObjectsBridgeInterval(double s_check)
 {
 {
     int res=-1;
     int res=-1;
-    //Go through all the lane section records
+    //Go through all the bridge records
     for (unsigned int i=0;i<mObjectsBridgeVector.size();i++)
     for (unsigned int i=0;i<mObjectsBridgeVector.size();i++)
     {
     {
         //check if the s_check belongs to the current record
         //check if the s_check belongs to the current record
@@ -1431,6 +1541,37 @@ int Road::CheckRoadObjectsBridgeInterval(double s_check)
 
 
 }
 }
 //-----------
 //-----------
+int Road::CheckRoadObjectsTunnelInterval(double s_check)
+{
+    int res=-1;
+    //Go through all the tunnel records
+    for (unsigned int i=0;i<mObjectsTunnelVector.size();i++)
+    {
+        //check if the s_check belongs to the current record
+        if (mObjectsTunnelVector.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::CheckRoadObjectsObjectReferenceInterval(double s_check)
+{
+    int res=-1;
+    //Go through all the tunnel records
+    for (unsigned int i=0;i<mObjectsObjectReferenceVector.size();i++)
+    {
+        //check if the s_check belongs to the current record
+        if (mObjectsObjectReferenceVector.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)
 int Road::CheckLaneOffsetInterval(double s_check)
 {
 {
     int res=-1;
     int res=-1;

+ 29 - 1
src/common/common/xodr/OpenDrive/Road.h

@@ -77,6 +77,10 @@ private:
     vector<LaneOffset> mLaneOffsetVector;
     vector<LaneOffset> mLaneOffsetVector;
     //bridge vector
     //bridge vector
     vector<Objects_bridge> mObjectsBridgeVector;
     vector<Objects_bridge> mObjectsBridgeVector;
+    //tunnel vector
+    vector<Objects_tunnel> mObjectsTunnelVector;
+    //objectReference vector
+    vector<Objects_objectReference> mObjectsObjectReferenceVector;
 	// Objects vectors
 	// Objects vectors
 	vector<Object> mObjectsVector;
 	vector<Object> mObjectsVector;
 	// Signal vector
 	// Signal vector
@@ -99,6 +103,8 @@ private:
 	unsigned int mLastAddedLaneSection;
 	unsigned int mLastAddedLaneSection;
     unsigned int mLastAddedLaneOffset;
     unsigned int mLastAddedLaneOffset;
     unsigned int mLastAddedObjectsBridge;
     unsigned int mLastAddedObjectsBridge;
+    unsigned int mLastAddedObjectsTunnel;
+    unsigned int mLastAddedObjectsObjectReference;
 	unsigned int mLastAddedObject;
 	unsigned int mLastAddedObject;
 	unsigned int mLastAddedSignal;
 	unsigned int mLastAddedSignal;
     unsigned int mLastAddedRoadBorrow;
     unsigned int mLastAddedRoadBorrow;
@@ -187,6 +193,14 @@ public:
     vector<Objects_bridge> *GetObjectsBridgeVector();
     vector<Objects_bridge> *GetObjectsBridgeVector();
     Objects_bridge*	GetObjectsBridge(unsigned int i);
     Objects_bridge*	GetObjectsBridge(unsigned int i);
     unsigned int GetObjectsBridgeCount();
     unsigned int GetObjectsBridgeCount();
+    // Road tunnel records
+    vector<Objects_tunnel> *GetObjectsTunnelVector();
+    Objects_tunnel*	GetObjectsTunnel(unsigned int i);
+    unsigned int GetObjectsTunnelCount();
+    // Road objectReference records
+    vector<Objects_objectReference> *GetObjectsObjectReferenceVector();
+    Objects_objectReference*	GetObjectsObjectReference(unsigned int i);
+    unsigned int GetObjectsObjectReferenceCount();
 	// Road signal records
 	// Road signal records
 	vector<Signal> *GetSignalVector();
 	vector<Signal> *GetSignalVector();
 	Signal*	GetSignal(unsigned int i);
 	Signal*	GetSignal(unsigned int i);
@@ -210,10 +224,12 @@ public:
 	RoadType*		GetLastRoadType();
 	RoadType*		GetLastRoadType();
 	GeometryBlock*	GetLastGeometryBlock();
 	GeometryBlock*	GetLastGeometryBlock();
 	Elevation*		GetLastElevation();
 	Elevation*		GetLastElevation();
-	SuperElevation*	GetLastSuperElevation();
+    SuperElevation*	GetLastSuperElevation();
 	Crossfall*		GetLastCrossfall();
 	Crossfall*		GetLastCrossfall();
 	LaneSection*	GetLastLaneSection();
 	LaneSection*	GetLastLaneSection();
     Objects_bridge* GetLastObjectsBridge();
     Objects_bridge* GetLastObjectsBridge();
+    Objects_tunnel* GetLastObjectsTunnel();
+    Objects_objectReference* GetLastObjectsObjectReference();
 	Object*			GetLastObject();
 	Object*			GetLastObject();
 	Signal*			GetLastSignal();
 	Signal*			GetLastSignal();
     RoadBorrow *    GetLastRoadBorrow();
     RoadBorrow *    GetLastRoadBorrow();
@@ -229,6 +245,8 @@ public:
 	Crossfall*		GetLastAddedCrossfall();
 	Crossfall*		GetLastAddedCrossfall();
 	LaneSection*	GetLastAddedLaneSection();
 	LaneSection*	GetLastAddedLaneSection();
     Objects_bridge* GetLastAddedObjectsBridge();
     Objects_bridge* GetLastAddedObjectsBridge();
+    Objects_tunnel* GetLastAddedObjectsTunnel();
+    Objects_objectReference* GetLastAddedObjectsObjectReference();
 	Object*			GetLastAddedObject();
 	Object*			GetLastAddedObject();
 	Signal*			GetLastAddedSignal();
 	Signal*			GetLastAddedSignal();
     RoadBorrow*     GetLastAddedRoadBorrow();
     RoadBorrow*     GetLastAddedRoadBorrow();
@@ -275,6 +293,8 @@ public:
 	unsigned int AddLaneSection(double s);
 	unsigned int AddLaneSection(double s);
     unsigned int AddLaneOffset(double s,double a,double b,double c,double d);
     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 AddObjectsBridge(double s,double length,string id,string type);
+    unsigned int AddObjectsTunnel(double s,double length,string id,string type);
+    unsigned int AddObjectsObjectReference(double s,double t,string id,string orientation);
     unsigned int AddObject(string id,double s,double t,double zOffset);
     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,
     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);
                            string subtype,double hOffset,double pitch,double roll ,double height,double width);
@@ -291,6 +311,8 @@ public:
 	unsigned int CloneLaneSection(unsigned int index);
 	unsigned int CloneLaneSection(unsigned int index);
 	unsigned int CloneLaneSectionEnd(unsigned int index);
 	unsigned int CloneLaneSectionEnd(unsigned int index);
     unsigned int CloneObjectsBridge(unsigned int index);
     unsigned int CloneObjectsBridge(unsigned int index);
+    unsigned int CloneObjectsTunnel(unsigned int index);
+    unsigned int CloneObjectsObjectReference(unsigned int index);
 	unsigned int CloneObject(unsigned int index);
 	unsigned int CloneObject(unsigned int index);
 	unsigned int CloneSignal(unsigned int index);
 	unsigned int CloneSignal(unsigned int index);
     unsigned int CloneRoadBorrow(unsigned int index);
     unsigned int CloneRoadBorrow(unsigned int index);
@@ -307,6 +329,8 @@ public:
 	void DeleteLaneSection(unsigned int index);
 	void DeleteLaneSection(unsigned int index);
     void DeleteLaneOffset(unsigned int index);
     void DeleteLaneOffset(unsigned int index);
     void DeleteObjectsBridge(unsigned int index);
     void DeleteObjectsBridge(unsigned int index);
+    void DeleteObjectsTunnel(unsigned int index);
+    void DeleteObjectsObjectReference(unsigned int index);
 	void DeleteObject(unsigned int index);
 	void DeleteObject(unsigned int index);
 	void DeleteSignal(unsigned int index);
 	void DeleteSignal(unsigned int index);
     void DeleteRoadBorrow(unsigned int index);
     void DeleteRoadBorrow(unsigned int index);
@@ -364,6 +388,10 @@ public:
     int CheckRoadNoavoidInterval(double s_check);
     int CheckRoadNoavoidInterval(double s_check);
 
 
     int CheckRoadObjectsBridgeInterval(double s_check);
     int CheckRoadObjectsBridgeInterval(double s_check);
+
+    int CheckRoadObjectsTunnelInterval(double s_check);
+
+    int CheckRoadObjectsObjectReferenceInterval(double s_check);
 	
 	
 	//-------------------------------------------------
 	//-------------------------------------------------