瀏覽代碼

change map_lanetoxor. fix signal.

yuchuli 2 年之前
父節點
當前提交
614d85d988

+ 149 - 44
src/common/common/xodr/OpenDrive/ObjectSignal.cpp

@@ -2170,14 +2170,19 @@ void Object::DeleteObjectlaneValidity(unsigned int index)
 }
 
 
-signal_positionRoad::signal_positionRoad(double s, double t, double zOffset, double hOffset, double pitch, double roll)
+signal_positionRoad::signal_positionRoad(std::string roadid,double s, double t, double zOffset, double hOffset)
 {
+    mroadid = roadid;
     ms = s;
     mt = t;
     mzOffset = zOffset;
     mhOffset = hOffset;
-    mpitch = pitch;
-    mroll = roll;
+
+}
+
+std::string signal_positionRoad::Getroadid()
+{
+    return  mroadid;
 }
 
 double signal_positionRoad::Gets()
@@ -2200,14 +2205,23 @@ double signal_positionRoad::GethOffset()
     return mhOffset;
 }
 
-double signal_positionRoad::Getpitch()
+int signal_positionRoad::Getpitch(double & pitch)
 {
-    return mpitch;
+    if(mpitch.size() == 0)return 0;
+    pitch = mpitch[0];
+    return 1;
 }
 
-double signal_positionRoad::Getroll()
+int signal_positionRoad::Getroll(double & roll)
 {
-    return mroll;
+    if(mroll.size() == 0)return 0;
+    roll = mroll[0];
+    return 1;
+}
+
+void signal_positionRoad::Setroadid(std::string roadid)
+{
+    mroadid = roadid;
 }
 
 void signal_positionRoad::Sets(double s)
@@ -2232,22 +2246,32 @@ void signal_positionRoad::SethOffset(double hOffset)
 
 void signal_positionRoad::Setpitch(double pitch)
 {
-    mpitch = pitch;
+    if(mpitch.size()>0)mpitch.clear();
+    mpitch.push_back(pitch);
 }
 
 void signal_positionRoad::Setroll(double roll)
 {
-    mroll = roll;
+    if(mroll.size()>0)mroll.clear();
+    mroll.push_back(roll);
+}
+
+void signal_positionRoad::Resetpitch()
+{
+    if(mpitch.size()>0)mpitch.clear();
+}
+
+void signal_positionRoad::Resetroll()
+{
+    if(mroll.size()>0)mroll.clear();
 }
 
-signal_positionInertial::signal_positionInertial(double x, double y,double z, double hdg, double pitch, double roll)
+signal_positionInertial::signal_positionInertial(double x, double y,double z, double hdg)
 {
     mx = x;
     my = y;
     mz = z;
     mhdg = hdg;
-    mpitch = pitch;
-    mroll = roll;
 }
 
 double signal_positionInertial::Getx()
@@ -2270,14 +2294,18 @@ double signal_positionInertial::Gethdg()
     return mhdg;
 }
 
-double signal_positionInertial::Getpitch()
+int signal_positionInertial::Getpitch(double & pitch)
 {
-    return mpitch;
+    if(mpitch.size() == 0)return 0;
+    pitch = mpitch[0];
+    return 1;
 }
 
-double signal_positionInertial::Getroll()
+int signal_positionInertial::Getroll(double & roll)
 {
-    return mroll;
+    if(mroll.size() == 0)return 0;
+    roll = mroll[0];
+    return 1;
 }
 
 void signal_positionInertial::Setx(double x)
@@ -2302,12 +2330,24 @@ void signal_positionInertial::Sethdg(double hdg)
 
 void signal_positionInertial::Setpitch(double pitch)
 {
-    mpitch = pitch;
+    if(mpitch.size() > 0)mpitch.clear();
+    mpitch.push_back(pitch);
 }
 
 void signal_positionInertial::Setroll(double roll)
 {
-    mroll = roll;
+    if(mroll.size() > 0)mroll.clear();
+    mroll.push_back(roll);
+}
+
+void signal_positionInertial::Resetpitch()
+{
+    if(mpitch.size() > 0)mpitch.clear();
+}
+
+void signal_positionInertial::Resetroll()
+{
+    if(mroll.size() > 0)mroll.clear();
 }
 
 
@@ -2436,7 +2476,7 @@ Signal::Signal(double s, double t, std::string id, std::string name, bool dynami
     mwidth = width;
     mpsignal_laneValidity = 0;
     mpsignal_positionInertial = 0;
-    mpsignal_positionRoad = new signal_positionRoad(s,t,zOffset,hOffset,pitch,roll);
+    mpsignal_positionRoad = new signal_positionRoad("",s,t,zOffset,hOffset);
 }
 
 Signal::Signal()
@@ -2479,17 +2519,41 @@ Signal& Signal::operator=(const Signal& x)
             this->mpsignal_positionInertial = new signal_positionInertial(x.mpsignal_positionInertial->Getx(),
                                                                       x.mpsignal_positionInertial->Gety(),
                                                                       x.mpsignal_positionInertial->Getz(),
-                                                                      x.mpsignal_positionInertial->Gethdg(),
-                                                                      x.mpsignal_positionInertial->Getpitch(),
-                                                                      x.mpsignal_positionInertial->Getroll());
+                                                                      x.mpsignal_positionInertial->Gethdg());
+            double pitch,roll;
+            if(x.mpsignal_positionInertial->Getpitch(pitch) == 1)
+            {
+                this->mpsignal_positionInertial->Setpitch(pitch);
+            }
+            if(x.mpsignal_positionInertial->Getroll(roll) == 1)
+            {
+                this->mpsignal_positionInertial->Setroll(roll);
+            }
         }
-        this->mpsignal_laneValidity = 0;
-        if(x.mpsignal_laneValidity != 0)
+        if(x.mpsignal_positionRoad != 0)
         {
-            this->mpsignal_laneValidity = new signal_laneValidity(x.mpsignal_laneValidity->GetfromLane(),
-                                                              x.mpsignal_laneValidity->GettoLane());
+            this->mpsignal_positionRoad = new signal_positionRoad(x.mpsignal_positionRoad->Getroadid(),
+                                                                  x.mpsignal_positionRoad->Gets(),
+                                                                  x.mpsignal_positionRoad->Gett(),
+                                                                  x.mpsignal_positionRoad->GetzOffset(),
+                                                                  x.mpsignal_positionRoad->GethOffset());
+            double pitch,roll;
+            if(x.mpsignal_positionRoad->Getpitch(pitch) == 1)
+            {
+                this->mpsignal_positionRoad->Setpitch(pitch);
+            }
+            if(x.mpsignal_positionRoad->Getroll(roll) == 1)
+            {
+                this->mpsignal_positionRoad->Setroll(roll);
+            }
         }
-        this->mpsignal_positionRoad = new signal_positionRoad(ms,mt,mzOffset,mhOffset,mpitch,mroll);
+        this->mlaneValidity = x.mlaneValidity;
+        this->mLastAddedlaneValidity = x.mLastAddedlaneValidity;
+        this->mdependency = x.mdependency;
+        this->mLastAddedDependency = x.mLastAddedDependency;
+        this->mreference = x.mreference;
+        this->mLastAddedReference = x.mLastAddedReference;
+
     }
     return *this;
 }
@@ -2512,23 +2576,45 @@ Signal::Signal(const Signal &x)
     mroll = x.mroll;
     mheight = x.mheight;
     mwidth = x.mwidth;
-    this->mpsignal_positionInertial = 0;
     if(x.mpsignal_positionInertial != 0)
     {
         this->mpsignal_positionInertial = new signal_positionInertial(x.mpsignal_positionInertial->Getx(),
                                                                   x.mpsignal_positionInertial->Gety(),
                                                                   x.mpsignal_positionInertial->Getz(),
-                                                                  x.mpsignal_positionInertial->Gethdg(),
-                                                                  x.mpsignal_positionInertial->Getpitch(),
-                                                                  x.mpsignal_positionInertial->Getroll());
+                                                                  x.mpsignal_positionInertial->Gethdg());
+        double pitch,roll;
+        if(x.mpsignal_positionInertial->Getpitch(pitch) == 1)
+        {
+            this->mpsignal_positionInertial->Setpitch(pitch);
+        }
+        if(x.mpsignal_positionInertial->Getroll(roll) == 1)
+        {
+            this->mpsignal_positionInertial->Setroll(roll);
+        }
     }
-    this->mpsignal_laneValidity = 0;
-    if(x.mpsignal_laneValidity != 0)
+    if(x.mpsignal_positionRoad != 0)
     {
-        this->mpsignal_laneValidity = new signal_laneValidity(x.mpsignal_laneValidity->GetfromLane(),
-                                                          x.mpsignal_laneValidity->GettoLane());
+        this->mpsignal_positionRoad = new signal_positionRoad(x.mpsignal_positionRoad->Getroadid(),
+                                                              x.mpsignal_positionRoad->Gets(),
+                                                              x.mpsignal_positionRoad->Gett(),
+                                                              x.mpsignal_positionRoad->GetzOffset(),
+                                                              x.mpsignal_positionRoad->GethOffset());
+        double pitch,roll;
+        if(x.mpsignal_positionRoad->Getpitch(pitch) == 1)
+        {
+            this->mpsignal_positionRoad->Setpitch(pitch);
+        }
+        if(x.mpsignal_positionRoad->Getroll(roll) == 1)
+        {
+            this->mpsignal_positionRoad->Setroll(roll);
+        }
     }
-    mpsignal_positionRoad = new signal_positionRoad(ms,mt,mzOffset,mhOffset,mpitch,mroll);
+    this->mlaneValidity = x.mlaneValidity;
+    this->mLastAddedlaneValidity = x.mLastAddedlaneValidity;
+    this->mdependency = x.mdependency;
+    this->mLastAddedDependency = x.mLastAddedDependency;
+    this->mreference = x.mreference;
+    this->mLastAddedReference = x.mLastAddedReference;
 }
 
 double Signal::Gets()
@@ -2714,11 +2800,12 @@ void Signal::SetlaneValidity(int fromLane, int toLane)
     }
 }
 
-void Signal::SetpositionRoad(double s, double t, double zOffset, double hOffset, double pitch,double roll)
+void Signal::SetpositionRoad(double s, double t, double zOffset, double hOffset)
 {
     if(mpsignal_positionRoad == 0)
     {
-        mpsignal_positionRoad = new signal_positionRoad(s,t,zOffset,hOffset,pitch,roll);
+        mpsignal_positionRoad = new signal_positionRoad("",s,t,zOffset,hOffset);
+
     }
     else
     {
@@ -2726,16 +2813,17 @@ void Signal::SetpositionRoad(double s, double t, double zOffset, double hOffset,
         mpsignal_positionRoad->Sett(t);
         mpsignal_positionRoad->SetzOffset(zOffset);
         mpsignal_positionRoad->SethOffset(hOffset);
-        mpsignal_positionRoad->Setpitch(pitch);
-        mpsignal_positionRoad->Setroll(roll);
+
     }
+    mpsignal_positionInertial = NULL;
 }
 
-void Signal::SetpositionInertial(double x, double y, double z, double hdg, double pitch, double roll)
+void Signal::SetpositionInertial(double x, double y, double z, double hdg)
 {
     if(mpsignal_positionInertial == 0)
     {
-        mpsignal_positionInertial = new signal_positionInertial(x,y,z,hdg,pitch,roll);
+        mpsignal_positionInertial = new signal_positionInertial(x,y,z,hdg);
+
     }
     else
     {
@@ -2743,9 +2831,9 @@ void Signal::SetpositionInertial(double x, double y, double z, double hdg, doubl
         mpsignal_positionInertial->Sety(y);
         mpsignal_positionInertial->Setz(z);
         mpsignal_positionInertial->Sethdg(hdg);
-        mpsignal_positionInertial->Setpitch(pitch);
-        mpsignal_positionInertial->Setroll(roll);
+
     }
+    mpsignal_positionRoad = NULL;
 }
 
 vector<signal_laneValidity> * Signal::GetlaneValidityVector()
@@ -2879,6 +2967,15 @@ unsigned int Signal::GetReferenceCount()
         return static_cast<unsigned int >(mreference.size()) ;
 }
 
+bool Signal::CheckInterval(double s_check)
+{
+    if (s_check>=ms)
+        return true;
+    else
+        return false;
+}
+
+
 signal_reference*			Signal::GetLastReference()
 {
     if (mreference.size()>0)
@@ -3026,3 +3123,11 @@ void signals_signalReference::DeletelaneValidity(unsigned int index)
 {
     mlaneValidity.erase(mlaneValidity.begin()+index);
 }
+
+bool signals_signalReference::CheckInterval(double s_check)
+{
+    if (s_check>=ms)
+        return true;
+    else
+        return false;
+}

+ 22 - 13
src/common/common/xodr/OpenDrive/ObjectSignal.h

@@ -714,26 +714,31 @@ public:
 class signal_positionRoad
 {
 private:
+    std::string mroadid;
     double ms;
     double mt;
     double mzOffset;
     double mhOffset;
-    double mpitch;
-    double mroll;
+    std::vector<double> mpitch;
+    std::vector<double> mroll;
 public:
-    signal_positionRoad(double s,double t,double zOffset,double hOffset, double pitch,double roll);
+    signal_positionRoad(std::string roadid, double s,double t,double zOffset,double hOffset);
+    std::string Getroadid();
     double Gets();
     double Gett();
     double GetzOffset();
     double GethOffset();
-    double Getpitch();
-    double Getroll();
+    int Getpitch(double & pitch);
+    int Getroll(double & roll);
+    void Setroadid(std::string roadid);
     void Sets(double s);
     void Sett(double t);
     void SetzOffset(double zOffset);
     void SethOffset(double hOffset);
     void Setpitch(double pitch);
     void Setroll(double roll);
+    void Resetpitch();
+    void Resetroll();
 };
 
 class signal_positionInertial
@@ -743,22 +748,24 @@ private:
     double my;
     double mz;
     double mhdg;
-    double mpitch;
-    double mroll;
+    std::vector<double> mpitch;
+    std::vector<double> mroll;
 public:
-    signal_positionInertial(double x,double y,double z,double hdg,double pitch,double roll );
+    signal_positionInertial(double x,double y,double z,double hdg );
     double Getx();
     double Gety();
     double Getz();
     double Gethdg();
-    double Getpitch();
-    double Getroll();
+    int Getpitch(double & pitch);
+    int Getroll(double & roll);
     void Setx(double x);
     void Sety(double y);
     void Setz(double z);
     void Sethdg(double hdg);
     void Setpitch(double pitch);
     void Setroll(double roll);
+    void Resetpitch();
+    void Resetroll();
 };
 
 class signal_laneValidity
@@ -890,8 +897,8 @@ 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,double pitch,double roll);
-    void SetpositionInertial(double x,double y, double z, double hdg,double pitch,double roll);
+    void SetpositionRoad(double s,double t, double zOffset,double hOffset);
+    void SetpositionInertial(double x,double y, double z, double hdg);
 
     vector<signal_laneValidity> * GetlaneValidityVector();
     signal_laneValidity* GetlaneValidity(unsigned int i);
@@ -920,7 +927,7 @@ public:
     unsigned int CloneReference(unsigned int index);
     void DeleteReference(unsigned int index);
 
-
+    bool CheckInterval(double s_check);
 
 };
 //----------------------------------------------------------------------------------
@@ -961,6 +968,8 @@ public:
     unsigned int AddlaneValidity(int fromLane, int toLane);
     unsigned int ClonelaneValidity(unsigned int index);
     void DeletelaneValidity(unsigned int index);
+
+    bool CheckInterval(double s_check);
 };
 
 #endif

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

@@ -2402,14 +2402,24 @@ bool OpenDriveXmlParser::ReadSignal_positionInertial(Signal *pSignal, TiXmlEleme
     checker+=node->QueryDoubleAttribute("y",&y);
     checker+=node->QueryDoubleAttribute("z",&z);
     checker+=node->QueryDoubleAttribute("hdg",&hdg);
-    checker+=node->QueryDoubleAttribute("pitch",&pitch);
-    checker+=node->QueryDoubleAttribute("roll",&roll);
+
     if (checker!=TIXML_SUCCESS)
     {
         cout<<"Error parsing positionInertial attributes"<<endl;
         return false;
     }
-    pSignal->SetpositionInertial(x,y,z,hdg,pitch,roll);
+    pSignal->SetpositionInertial(x,y,z,hdg);
+
+    signal_positionInertial * psignal_positionInertial = pSignal->GetpositionInertial();
+    if(node->QueryDoubleAttribute("pitch",&pitch) == TIXML_SUCCESS)
+    {
+        psignal_positionInertial->Setpitch(pitch);
+    }
+    if(node->QueryDoubleAttribute("roll",&roll) == TIXML_SUCCESS)
+    {
+        psignal_positionInertial->Setroll(roll);
+    }
+
     return true;
 }
 

+ 133 - 9
src/common/common/xodr/OpenDrive/OpenDriveXmlWriter.cpp

@@ -1933,9 +1933,37 @@ bool OpenDriveXmlWriter::WriteSignals (TiXmlElement *node, Road* road)
         WriteSignal(nodeSignals, road->GetSignal(i));
     }
 
+    unsigned int lSignalReferenceCount = road->GetSignalReferencCount();
+    for(unsigned int i=0; i<lSignalReferenceCount; i++)
+    {
+        WriteSignalReference(nodeSignals,road->GetSignalReference(i));
+    }
+
 	return true;
 }
 
+//--------------
+
+bool OpenDriveXmlWriter::WriteSignalReference(TiXmlElement * node, signals_signalReference * pSignalReference)
+{
+    TiXmlElement* nodeSignalReference = new TiXmlElement("signalReference");
+    node->LinkEndChild(nodeSignalReference);
+
+    nodeSignalReference->SetDoubleAttribute("s",pSignalReference->Gets());
+    nodeSignalReference->SetDoubleAttribute("t",pSignalReference->Gett());
+    nodeSignalReference->SetAttribute("id",pSignalReference->Getid());
+    nodeSignalReference->SetAttribute("orientation",pSignalReference->Getorientation());
+
+    unsigned int llaneValidityCount = pSignalReference->GetlaneValidityCount();
+    for(unsigned int i =0;i<llaneValidityCount;i++)
+    {
+        WriteSignal_laneValidity(nodeSignalReference,pSignalReference->GetlaneValidity(i));
+    }
+
+}
+
+//--------------
+
 bool OpenDriveXmlWriter::WriteSignal(TiXmlElement *node, Signal * pSignal)
 {
     TiXmlElement* nodeSignal = new TiXmlElement("signal");
@@ -1961,10 +1989,28 @@ bool OpenDriveXmlWriter::WriteSignal(TiXmlElement *node, Signal * pSignal)
     nodeSignal->SetDoubleAttribute("height",pSignal->Getheight());
     nodeSignal->SetDoubleAttribute("width",pSignal->Getwidth());
 
-    signal_laneValidity * psignal_lanevalidity = pSignal->GetlaneValidity();
-    if(psignal_lanevalidity != 0)
+//    signal_laneValidity * psignal_lanevalidity = pSignal->GetlaneValidity();
+//    if(psignal_lanevalidity != 0)
+//    {
+//        WriteSignal_laneValidity(nodeSignal,psignal_lanevalidity);
+//    }
+
+    unsigned int llaneValidityCount = pSignal->GetlaneValidityCount();
+    for(unsigned int i=0;i<llaneValidityCount;i++)
     {
-        WriteSignal_laneValidity(nodeSignal,psignal_lanevalidity);
+        WriteSignal_laneValidity(nodeSignal,pSignal->GetlaneValidity(i));
+    }
+
+    unsigned int ldependencyCount = pSignal->GetDependencyCount();
+    for(unsigned int i=0;i<ldependencyCount;i++)
+    {
+        WriteSignal_dependency(nodeSignal,pSignal->GetDependency(i));
+    }
+
+    unsigned int lreferencyCount = pSignal->GetReferenceCount();
+    for(unsigned int i=0;i<lreferencyCount;i++)
+    {
+        WriteSignal_referency(nodeSignal,pSignal->GetReference(i));
     }
 
     signal_positionInertial * psignal_positionInertial = pSignal->GetpositionInertial();
@@ -1973,24 +2019,65 @@ bool OpenDriveXmlWriter::WriteSignal(TiXmlElement *node, Signal * pSignal)
         WriteSignal_positionInertial(nodeSignal,psignal_positionInertial);
     }
 
+    signal_positionRoad * psignal_positionRoad = pSignal->GetpositionRoad();
+    if(psignal_positionRoad != NULL)
+    {
+        WriteSignal_positionRoad(nodeSignal,psignal_positionRoad);
+    }
+
+    return true;
+}
+//--------------
+
+bool OpenDriveXmlWriter::WriteSignal_positionRoad(TiXmlElement * node, signal_positionRoad * pSignal_positionRoad)
+{
+    TiXmlElement* nodepositionRoad = new TiXmlElement("positionRoad");
+
+    node->LinkEndChild(nodepositionRoad);
+
+    nodepositionRoad->SetAttribute("roadId",pSignal_positionRoad->Getroadid());
+    nodepositionRoad->SetDoubleAttribute("s",pSignal_positionRoad->Gets());
+    nodepositionRoad->SetDoubleAttribute("t",pSignal_positionRoad->Gett());
+    nodepositionRoad->SetDoubleAttribute("zOffset",pSignal_positionRoad->GetzOffset());
+    nodepositionRoad->SetDoubleAttribute("hOffset",pSignal_positionRoad->GethOffset());
+
+    double pitch,roll;
+    if(pSignal_positionRoad->Getpitch(pitch) == 1)
+    {
+        nodepositionRoad->SetDoubleAttribute("pitch",pitch);
+    }
+    if(pSignal_positionRoad->Getroll(roll) == 1)
+    {
+        nodepositionRoad->SetDoubleAttribute("roll",roll);
+    }
+
     return true;
 }
 
+//--------------
 bool OpenDriveXmlWriter::WriteSignal_positionInertial(TiXmlElement *node, signal_positionInertial *pSignal_positionInertial)
 {
     TiXmlElement* nodepositionInertial = new TiXmlElement("positionInertial");
 
     node->LinkEndChild(nodepositionInertial);
 
-    nodepositionInertial->SetAttribute("x",pSignal_positionInertial->Getx());
-    nodepositionInertial->SetAttribute("y",pSignal_positionInertial->Gety());
-    nodepositionInertial->SetAttribute("z",pSignal_positionInertial->Getz());
-    nodepositionInertial->SetAttribute("hdg",pSignal_positionInertial->Gethdg());
-    nodepositionInertial->SetAttribute("pitch",pSignal_positionInertial->Getpitch());
-    nodepositionInertial->SetAttribute("roll",pSignal_positionInertial->Getroll());
+    nodepositionInertial->SetDoubleAttribute("x",pSignal_positionInertial->Getx());
+    nodepositionInertial->SetDoubleAttribute("y",pSignal_positionInertial->Gety());
+    nodepositionInertial->SetDoubleAttribute("z",pSignal_positionInertial->Getz());
+    nodepositionInertial->SetDoubleAttribute("hdg",pSignal_positionInertial->Gethdg());
+    double pitch,roll;
+    if(pSignal_positionInertial->Getpitch(pitch) == 1)
+    {
+        nodepositionInertial->SetDoubleAttribute("pitch",pitch);
+    }
+    if(pSignal_positionInertial->Getroll(roll) == 1)
+    {
+        nodepositionInertial->SetDoubleAttribute("roll",roll);
+    }
 
     return true;
 }
+//--------------
 
 bool OpenDriveXmlWriter::WriteSignal_laneValidity(TiXmlElement *node, signal_laneValidity *pSignal_laneValidity)
 {
@@ -2003,6 +2090,43 @@ bool OpenDriveXmlWriter::WriteSignal_laneValidity(TiXmlElement *node, signal_lan
 
     return true;
 }
+//--------------
+bool OpenDriveXmlWriter::WriteSignal_dependency(TiXmlElement * node, signal_dependency * pSignal_dependency)
+{
+    TiXmlElement* nodedependency = new TiXmlElement("dependency");
+
+    node->LinkEndChild(nodedependency);
+
+    nodedependency->SetAttribute("id",pSignal_dependency->Getid());
+
+    std::string strtype;
+    if(pSignal_dependency->Gettype(strtype) == 1)
+    {
+        nodedependency->SetAttribute("type",strtype);
+    }
+
+    return true;
+}
+
+//--------------
+
+bool OpenDriveXmlWriter::WriteSignal_referency(TiXmlElement * node, signal_reference * pSignal_Referency)
+{
+    TiXmlElement* nodereferency = new TiXmlElement("reference");
+
+    node->LinkEndChild(nodereferency);
+
+    nodereferency->SetAttribute("elementType",pSignal_Referency->GetelementType());
+    nodereferency->SetAttribute("elementId",pSignal_Referency->GetelementId());
+
+    std::string strtype;
+    if(pSignal_Referency->Gettype(strtype) == 1)
+    {
+        nodereferency->SetAttribute("type",strtype);
+    }
+
+    return true;
+}
 
 //--------------
 

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

@@ -89,8 +89,12 @@ public:
     bool WriteObjectOutlinesOutlinecornerLocal(TiXmlElement * node,Object_outlines_outline_cornerLocal * pObject_outlines_outline_cornerLocal);
 	bool WriteSignals (TiXmlElement *node, Road* road);
     bool WriteSignal(TiXmlElement * node, Signal * pSignal);
+    bool WriteSignalReference(TiXmlElement * node, signals_signalReference * pSignalReference);
     bool WriteSignal_positionInertial(TiXmlElement * node, signal_positionInertial * pSignal_positionInertial);
+    bool WriteSignal_positionRoad(TiXmlElement * node, signal_positionRoad * pSignal_positionRoad);
     bool WriteSignal_laneValidity(TiXmlElement * node, signal_laneValidity * pSignal_laneValidity);
+    bool WriteSignal_dependency(TiXmlElement * node, signal_dependency * pSignal_dependency);
+    bool WriteSignal_referency(TiXmlElement * node, signal_reference * pSignal_Referency);
     bool WriteObjectMarkings(TiXmlElement * node,Object_markings * pObject_markings);
     bool WriteObjectMarkingsMarking(TiXmlElement * node,Object_markings_marking * pObject_markings_marking);
     bool WriteObjectMarkingsMarkingcornerReference(TiXmlElement * node,Object_markings_marking_cornerReference * pObject_markings_marking_cornerReference);

+ 99 - 9
src/common/common/xodr/OpenDrive/Road.cpp

@@ -403,8 +403,27 @@ Signal*	Road::GetSignal(unsigned int i)
 }
 unsigned int Road::GetSignalCount()
 {
-	return mSignalsVector.size();
+    return static_cast<unsigned int >(mSignalsVector.size()) ;
 }
+
+// Road signal Reference records
+vector<signals_signalReference> *Road::GetSignalReferenceVector()
+{
+    return  &mSignalReferenceVector;
+}
+signals_signalReference*	Road::GetSignalReference(unsigned int i)
+{
+    if ((mSignalReferenceVector.size()>0)&&(i<mSignalReferenceVector.size()))
+        return &mSignalReferenceVector.at(i);
+    else
+        return NULL;
+}
+unsigned int Road::GetSignalReferencCount()
+{
+    return static_cast<unsigned int >(mSignalReferenceVector.size()) ;
+}
+
+
 unsigned int Road::GetRoadBorrowCount()
 {
     return mRoadBorrowVector.size();
@@ -519,6 +538,15 @@ Signal*	Road::GetLastSignal()
 	else
 		return NULL;
 }
+
+signals_signalReference* Road::GetLastSignalReference()
+{
+    if (mSignalReferenceVector.size()>0)
+        return &mSignalReferenceVector.at(mSignalReferenceVector.size()-1);
+    else
+        return NULL;
+}
+
 RoadBorrow* Road::GetLastRoadBorrow()
 {
     if(mRoadBorrowVector.size()>0)
@@ -623,6 +651,17 @@ RoadBorrow* Road::GetLastAddedRoadBorrow()
     else
         return NULL;
 }
+
+signals_signalReference* Road::GetLastAddedSignalReference()
+{
+    if(mLastAddedSignalReference<mSignalReferenceVector.size())
+    {
+        return &mSignalReferenceVector.at(mLastAddedSignalReference);
+    }
+    else
+        return NULL;
+}
+
 RoadNoavoid* Road::GetLastAddedRoadNoavoid()
 {
     if(mLastAddedRoadNoavoid<mRoadNoavoidVector.size())
@@ -871,18 +910,26 @@ unsigned int Road::AddSignal(double s,double t,string id,string name,bool dynami
 {
 	// Check the first method in the group for details
 
-	unsigned int index=GetSignalCount();
-    Signal x(s,t,id,name,dynamic,orientation,zOffset,type,country,countryRevision,
-             subtype,hOffset,pitch,roll,height,width);
-    mSignalsVector.push_back(x);
+    unsigned int index = static_cast<unsigned int>(CheckSignalInterval(s)+1) ;
+    if(index>=GetSignalCount()) mSignalsVector.push_back(    Signal(s,t,id,name,dynamic,orientation,zOffset,type,country,countryRevision,
+                                                                      subtype,hOffset,pitch,roll,height,width));
+    else mSignalsVector.insert(mSignalsVector.begin()+index, Signal(s,t,id,name,dynamic,orientation,zOffset,type,country,countryRevision,
+                                                                    subtype,hOffset,pitch,roll,height,width));
+    mLastAddedSignal=index;
+    return index;
 
-//    mSignalsVector.push_back(Signal(s,t,id,name,dynamic,orientation,zOffset,type,country,countryRevision,
-//                                    subtype,hOffset,pitch,roll,height,width));
-	mLastAddedSignal=index;
-	return index;
 }
 //-----------
 
+unsigned int Road::AddSignalReference(double s,double t,std::string id,std::string orientation)
+{
+    unsigned int index = static_cast<unsigned int>(CheckSignalReferencInterval(s)+1) ;
+    if(index>=GetSignalReferencCount()) mSignalReferenceVector.push_back(signals_signalReference(s,t,id,orientation));
+    else mSignalReferenceVector.insert(mSignalReferenceVector.begin()+index, signals_signalReference(s,t,id,orientation));
+    mLastAddedSignalReference=index;
+    return index;
+}
+//-----------
 
 /**
  * Methods used to clone child records in the respective vectors
@@ -1082,6 +1129,15 @@ unsigned int Road::CloneSignal(unsigned int index)
 	mLastAddedSignal=index+1;
 	return mLastAddedSignal;
 }
+unsigned int Road::CloneSignalReference(unsigned int index)
+{
+    if(index<mSignalReferenceVector.size()-1)
+        mSignalReferenceVector.insert(mSignalReferenceVector.begin()+index+1, mSignalReferenceVector[index]);
+    else if(index==mSignalReferenceVector.size()-1)
+        mSignalReferenceVector.push_back(mSignalReferenceVector[index]);
+    mLastAddedSignalReference=index+1;
+    return mLastAddedSignalReference;
+}
 unsigned int Road::CloneRoadBorrow(unsigned int index)
 {
     // Check the first method in the group for details
@@ -1156,6 +1212,10 @@ void Road::DeleteSignal(unsigned int index)
 {
 	mSignalsVector.erase(mSignalsVector.begin()+index);
 }
+void Road::DeleteSignalReference(unsigned int index)
+{
+    mSignalReferenceVector.erase(mSignalReferenceVector.begin()+index);
+}
 
 void Road::DeleteRoadBorrow(unsigned int index)
 {
@@ -1572,6 +1632,36 @@ int Road::CheckRoadObjectsObjectReferenceInterval(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::CheckSignalInterval(double s_check)
+{
+    int res=-1;
+    //Go through all the tunnel records
+    for (unsigned int i=0;i<mSignalsVector.size();i++)
+    {
+        //check if the s_check belongs to the current record
+        if (mSignalsVector.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::CheckSignalReferencInterval(double s_check)
+{
+    int res=-1;
+    //Go through all the tunnel records
+    for (unsigned int i=0;i<mSignalReferenceVector.size();i++)
+    {
+        //check if the s_check belongs to the current record
+        if (mSignalReferenceVector.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 res=-1;

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

@@ -86,6 +86,9 @@ private:
 	// Signal vector
 	vector<Signal> mSignalsVector;
 
+    //Signal Reference
+    vector<signals_signalReference> mSignalReferenceVector;
+
     vector<string> muserDataVector;
 
     vector<RoadBorrow> mRoadBorrowVector;
@@ -107,6 +110,7 @@ private:
     unsigned int mLastAddedObjectsObjectReference;
 	unsigned int mLastAddedObject;
 	unsigned int mLastAddedSignal;
+    unsigned int mLastAddedSignalReference;
     unsigned int mLastAddedRoadBorrow;
     unsigned int mLastAddedRoadNoavoid;
 
@@ -206,6 +210,11 @@ public:
 	Signal*	GetSignal(unsigned int i);
 	unsigned int GetSignalCount();
 
+    // Road signal Reference records
+    vector<signals_signalReference> *GetSignalReferenceVector();
+    signals_signalReference*	GetSignalReference(unsigned int i);
+    unsigned int GetSignalReferencCount();
+
     vector<RoadBorrow> *GetRoadBorrowVector();
     RoadBorrow*	GetRoadBorrow(unsigned int i);
     unsigned int GetRoadBorrowCount();
@@ -232,6 +241,7 @@ public:
     Objects_objectReference* GetLastObjectsObjectReference();
 	Object*			GetLastObject();
 	Signal*			GetLastSignal();
+    signals_signalReference* GetLastSignalReference();
     RoadBorrow *    GetLastRoadBorrow();
     RoadNoavoid *   GetLastRoadNoavoid();
 
@@ -249,6 +259,7 @@ public:
     Objects_objectReference* GetLastAddedObjectsObjectReference();
 	Object*			GetLastAddedObject();
 	Signal*			GetLastAddedSignal();
+    signals_signalReference* GetLastAddedSignalReference();
     RoadBorrow*     GetLastAddedRoadBorrow();
     RoadNoavoid*    GetLastAddedRoadNoavoid();
 
@@ -298,6 +309,7 @@ public:
     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);
+    unsigned int AddSignalReference(double s,double t,std::string id,std::string orientation);
 
     unsigned int AddRoadBorrow(double s,double length,string mode);
     unsigned int AddRoadNoavoid(double s,double length);
@@ -315,6 +327,7 @@ public:
     unsigned int CloneObjectsObjectReference(unsigned int index);
 	unsigned int CloneObject(unsigned int index);
 	unsigned int CloneSignal(unsigned int index);
+    unsigned int CloneSignalReference(unsigned int index);
     unsigned int CloneRoadBorrow(unsigned int index);
     unsigned int CloneRoadNoavoid(unsigned int index);
 
@@ -333,6 +346,7 @@ public:
     void DeleteObjectsObjectReference(unsigned int index);
 	void DeleteObject(unsigned int index);
 	void DeleteSignal(unsigned int index);
+    void DeleteSignalReference(unsigned int index);
     void DeleteRoadBorrow(unsigned int index);
     void DeleteRoadNoavoid(unsigned int index);
 	
@@ -392,6 +406,10 @@ public:
     int CheckRoadObjectsTunnelInterval(double s_check);
 
     int CheckRoadObjectsObjectReferenceInterval(double s_check);
+
+    int CheckSignalReferencInterval(double s_check);
+
+    int CheckSignalInterval(double s_check);
 	
 	//-------------------------------------------------
 

+ 18 - 5
src/tool/map_lanetoxodr/ui/trafficlightpositiondialog.cpp

@@ -30,14 +30,18 @@ TrafficLightpositionDialog::TrafficLightpositionDialog(Signal * pSignal,double l
         double head0 = (M_PI/2.0 - hdg)*180.0/M_PI;
         if(head0<0)head0 = head0 + 360.0;
         double z = pSignal_positionInertial->Getz();
-        double pitch = pSignal_positionInertial->Getpitch();
-        double roll = pSignal_positionInertial->Getroll();
+        double pitch;
+        int nhavepitch = pSignal_positionInertial->Getpitch(pitch);
+        double roll;
+        int nhaveroll = pSignal_positionInertial->Getroll(roll);
         ui->lineEdit_Lon->setText(QString::number(lon,'f',7));
         ui->lineEdit_Lat->setText(QString::number(lat,'f',7));
         ui->lineEdit_Height->setText(QString::number(z,'f',2));
         ui->lineEdit_hdg->setText(QString::number(head0));
-        ui->lineEdit_pitch->setText(QString::number(pitch));
-        ui->lineEdit_roll->setText(QString::number(roll));
+        if(nhavepitch == 1)ui->lineEdit_pitch->setText(QString::number(pitch));
+        else ui->lineEdit_pitch->setText("");
+        if(nhaveroll == 1)ui->lineEdit_roll->setText(QString::number(roll));
+        else ui->lineEdit_roll->setText(QString::number(roll));
     }
 
 }
@@ -70,7 +74,16 @@ void TrafficLightpositionDialog::on_pushButton_Update_clicked()
     GaussProjCal(lon,lat,&x,&y);
     double hdg = (90-head)*M_PI/180.0;
     if(hdg<0)hdg = hdg +M_PI*2.0;
-    mpSignal->SetpositionInertial(x-x0,y-y0,z,hdg,pitch,roll);
+    mpSignal->SetpositionInertial(x-x0,y-y0,z,hdg);
+    signal_positionInertial * psignal_positionInertial = mpSignal->GetpositionInertial();
+    if(ui->lineEdit_pitch->text().length()>0)
+    {
+        psignal_positionInertial->Setpitch(pitch);
+    }
+    if(ui->lineEdit_roll->text().length()>0)
+    {
+        psignal_positionInertial->Setroll(roll);
+    }
 
 
 }