浏览代码

change tool/map_lanetoxodr. add object repeat and material.

yuchuli 3 年之前
父节点
当前提交
193a6962c2

+ 473 - 0
src/tool/map_lanetoxodr/OpenDrive/ObjectSignal.cpp

@@ -3,6 +3,336 @@
 #include <iostream>
 
 
+Object_outlines_outline::Object_outlines_outline()
+{
+
+}
+
+Object_outlines::Object_outlines()
+{
+
+}
+
+Object_material::Object_material()
+{
+
+}
+
+int Object_material::Getsurface(string & surface)
+{
+    if(msurface.size()<1)return 0;
+    surface = msurface[0];
+    return 1;
+}
+
+int Object_material::Getfriction(double & friction)
+{
+    if(mfriction.size()<1)return 0;
+    friction = mfriction[0];
+    return 1;
+}
+
+int Object_material::Getroughness(double & roughness)
+{
+    if(mroughness.size()<1)return 0;
+    roughness = mroughness[0];
+    return 1;
+}
+
+void Object_material::Setsurface(string surface)
+{
+    if(msurface.size()>0)msurface.clear();
+    msurface.push_back(surface);
+}
+
+void Object_material::Setfriction(double friction)
+{
+    if(mfriction.size()>0)mfriction.clear();
+    mfriction.push_back(friction);
+}
+
+void Object_material::Setroughness(double roughness)
+{
+    if(mroughness.size()>0)mroughness.clear();
+    mroughness.push_back(roughness);
+}
+
+Object_repeat::Object_repeat(double s,double length,double distance,double tStart,double tEnd,double heightStart,
+              double heightEnd,double zOffsetStart,double zOffsetEnd)
+{
+    ms = s;
+    mlength = length;
+    mdistance = distance;
+    mtStart = tStart;
+    mtEnd = tEnd;
+    mheightStart = heightStart;
+    mheightEnd = heightEnd;
+    mzOffsetStart = zOffsetStart;
+    mzOffsetEnd = zOffsetEnd;
+}
+
+double Object_repeat::Gets()
+{
+    return ms;
+}
+
+double Object_repeat::Getlength()
+{
+    return mlength;
+}
+
+double Object_repeat::Getdistance()
+{
+    return mdistance;
+}
+
+double Object_repeat::GettStart()
+{
+    return mtStart;
+}
+
+double Object_repeat::GettEnd()
+{
+    return mtEnd;
+}
+
+double Object_repeat::GetheightStart()
+{
+    return mheightStart;
+}
+
+double Object_repeat::GetheightEnd()
+{
+    return mheightEnd;
+}
+
+double Object_repeat::GetzOffsetStart()
+{
+    return mzOffsetStart;
+}
+
+double Object_repeat::GetzOffsetEnd()
+{
+    return mzOffsetEnd;
+}
+
+
+void Object_repeat::Sets(double s)
+{
+    ms = s;
+}
+
+void Object_repeat::Setlength(double length)
+{
+    mlength = length;
+}
+
+void Object_repeat::Setdistance(double distance)
+{
+    mdistance = distance;
+}
+
+void Object_repeat::SettStart(double tStart)
+{
+    mtStart = tStart;
+}
+
+void Object_repeat::SettEnd(double tEnd)
+{
+    mtEnd = tEnd;
+}
+
+void Object_repeat::SetheightStart(double heightStart)
+{
+    mheightStart = heightStart;
+}
+
+void Object_repeat::SetheightEnd(double heightEnd)
+{
+    mheightEnd = heightEnd;
+}
+
+void Object_repeat::SetzOffsetStart(double zOffsetStart)
+{
+    mzOffsetStart = zOffsetStart;
+}
+
+void Object_repeat::SetzOffsetEnd(double zOffsetEnd)
+{
+    mzOffsetEnd = zOffsetEnd;
+}
+
+
+int Object_repeat::GetwidthStart(double & widthStart)
+{
+    if(mwidthStart.size() <1)return 0;
+    widthStart = mwidthStart[0];
+    return 1;
+}
+
+int Object_repeat::GetwidthEnd(double & widthEnd)
+{
+    if(mwidthEnd.size() < 1)return 0;
+    widthEnd = mwidthEnd[0];
+    return 1;
+}
+
+int Object_repeat::GetlengthStart(double & lengthStart)
+{
+    if(mlengthStart.size() < 1)return 0;
+    lengthStart = mlengthStart[0];
+    return 1;
+}
+
+int Object_repeat::GetlengthEnd(double & lengthEnd)
+{
+    if(mlengthEnd.size() < 1)return 0;
+    lengthEnd = mlengthEnd[0];
+    return 1;
+}
+
+int Object_repeat::GetradiusStart(double & radiusStart)
+{
+    if(mradiusStart.size() < 1)return 0;
+    radiusStart = mradiusStart[0];
+    return 1;
+}
+
+int Object_repeat::GetradiusEnd(double & radiusEnd)
+{
+    if(mradiusEnd.size() < 1)return 0;
+    radiusEnd = mradiusEnd[0];
+    return 1;
+}
+
+void Object_repeat::DeletewidthStart()
+{
+    if(mwidthStart.size() > 0)mwidthStart.clear();
+}
+
+void Object_repeat::DeletewidthEnd()
+{
+    if(mwidthEnd.size() > 0)mwidthEnd.clear();
+}
+
+void Object_repeat::DeletelengthStart()
+{
+    if(mlengthStart.size() > 0)mlengthStart.clear();
+}
+
+void Object_repeat::DeletelengthEnd()
+{
+    if(mlengthEnd.size() > 0)mlengthEnd.clear();
+}
+
+void Object_repeat::DeleteradiusStart()
+{
+    if(mradiusStart.size() > 0)mradiusStart.clear();
+}
+
+void Object_repeat::DeleteradiusEnd()
+{
+    if(mradiusEnd.size() > 0)mradiusEnd.clear();
+}
+
+void Object_repeat::SetwidthStart(double  widthStart)
+{
+    if(mwidthStart.size() > 0)mwidthStart.clear();
+    mwidthStart.push_back(widthStart);
+}
+
+void Object_repeat::SetwidthEnd(double  widthEnd)
+{
+    if(mwidthEnd.size() > 0)mwidthEnd.clear();
+    mwidthEnd.push_back(widthEnd);
+}
+
+void Object_repeat::SetlengthStart(double  lengthStart)
+{
+    if(mlengthStart.size() > 0)mlengthStart.clear();
+    mlengthStart.push_back(lengthStart);
+}
+
+void Object_repeat::SetlengthEnd(double  lengthEnd)
+{
+    if(mlengthEnd.size() > 0)mlengthEnd.clear();
+    mlengthEnd.push_back(lengthEnd);
+}
+
+void Object_repeat::SetradiusStart(double  radiusStart)
+{
+    if(mradiusStart.size() > 0)mradiusStart.clear();
+    mradiusStart.push_back(radiusStart);
+}
+
+void Object_repeat::SetradiusEnd(double  radiusEnd)
+{
+    if(mradiusEnd.size() > 0)mradiusEnd.clear();
+    mradiusEnd.push_back(radiusEnd);
+}
+
+/**
+* Check if the tested s-offset is inside the lane offset interval
+* @param A double s-offset value that has to be checked
+* @return Return true if the s-offset value belongs to current lane section, false otherwise
+*/
+bool Object_repeat::CheckInterval(double s_check)
+{
+    if (s_check>=ms)
+        return true;
+    else
+        return false;
+}
+
+Object_parkingSpace::Object_parkingSpace()
+{
+    maccess = "all";
+}
+
+void Object_parkingSpace::Setaccess(std::string access)
+{
+    maccess = access;
+}
+
+void Object_parkingSpace::Setrestrictions(std::string restrictions)
+{
+    mrestrictions = restrictions;
+}
+
+string Object_parkingSpace::Getaccess()
+{
+    return maccess;
+}
+
+string Object_parkingSpace::Getrestrictions()
+{
+    return mrestrictions;
+}
+
+/**
+ * Copy constructor
+ */
+Object_parkingSpace::Object_parkingSpace (const Object_parkingSpace& parkingSpace)
+{
+    if(this != &parkingSpace)
+    {
+        mrestrictions = parkingSpace.mrestrictions;
+        maccess = parkingSpace.maccess;
+    }
+}
+
+/**
+ * Assignment operator overload
+ */
+const Object_parkingSpace& Object_parkingSpace::operator=(const Object_parkingSpace& rhs)
+{
+    if (this!= &rhs)
+    {
+        mrestrictions = rhs.mrestrictions;
+        maccess = rhs.maccess;
+    }
+}
+
 Object::Object(std::string id, double s, double t, double zOffset)
 {
     mid = id;
@@ -112,6 +442,13 @@ int Object::Getradius(double &radius)
     return 1;
 }
 
+int Object::GetparkingSpace(Object_parkingSpace &parkingSpace)
+{
+    if(mObject_parkingSpace.size()<1)return 0;
+    parkingSpace = mObject_parkingSpace[0];
+    return 1;
+}
+
 void Object::Sett(double t)
 {
     mt = t;
@@ -204,6 +541,142 @@ void Object::Setradius(double radius)
     mradius.push_back(radius);
 }
 
+void Object::SetparkingSpace(Object_parkingSpace parkingSpace)
+{
+    if(mObject_parkingSpace.size()>0)mObject_parkingSpace.clear();
+    mObject_parkingSpace.push_back(parkingSpace);
+}
+
+vector<Object_repeat> * Object::GetObjectrepeatVector()
+{
+    return &mObject_repeat;
+}
+
+Object_repeat* Object::GetObjectrepeat(unsigned int i)
+{
+    if ((mObject_repeat.size()>0)&&(i<(mObject_repeat.size())))
+        return &(mObject_repeat.at(i));
+    else
+        return NULL;
+}
+
+unsigned int Object::GetObjectrepeatCount()
+{
+    return mObject_repeat.size();
+}
+
+Object_repeat*			Object::GetLastObjectrepeat()
+{
+    if (mObject_repeat.size()>0)
+        return &mObject_repeat.at(mObject_repeat.size()-1);
+    else
+        return NULL;
+}
+
+Object_repeat*			Object::GetLastAddedObjectrepeat()
+{
+    if(mLastAddedObjectrepeat<mObject_repeat.size())
+        return &mObject_repeat.at(mLastAddedObjectrepeat);
+    else
+        return NULL;
+}
+
+unsigned int Object::AddObjectrepeat(double s,double length,double distance,double tStart,double tEnd,
+                             double heightStart,double heightEnd,double zOffsetStart,double zOffsetEnd)
+{
+    unsigned int index = CheckObjectrepeatInterval(s)+1;
+    if(index>=GetObjectrepeatCount()) mObject_repeat.push_back(Object_repeat(s,length,distance,tStart,tEnd,heightStart,heightEnd,zOffsetStart,zOffsetEnd));
+    else mObject_repeat.insert(mObject_repeat.begin()+index, Object_repeat(s,length,distance,tStart,tEnd,heightStart,heightEnd,zOffsetStart,zOffsetEnd));
+    mLastAddedObjectrepeat=index;
+    return index;
+}
+
+unsigned int Object::CloneObjectrepeat(unsigned int index)
+{
+    if(index<(mObject_repeat.size()-1))
+        mObject_repeat.insert(mObject_repeat.begin()+index+1, mObject_repeat[index]);
+    else if(index==mObject_repeat.size()-1)
+        mObject_repeat.push_back(mObject_repeat[index]);
+    mLastAddedObjectrepeat=index+1;
+    return mLastAddedObjectrepeat;
+}
+
+void Object::DeleteObjectrepeat(unsigned int index)
+{
+    mObject_repeat.erase(mObject_repeat.begin()+index);
+}
+
+int Object::CheckObjectrepeatInterval(double s_check)
+{
+    int res=-1;
+    //Go through all the lane section records
+    for (unsigned int i=0;i<mObject_repeat.size();i++)
+    {
+        //check if the s_check belongs to the current record
+        if (mObject_repeat.at(i).CheckInterval(s_check))
+            res=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
+
+}
+
+vector<Object_material> * Object::GetObjectmaterialVector()
+{
+    return &mObject_material;
+}
+
+Object_material* Object::GetObjectmaterial(unsigned int i)
+{
+    if ((mObject_material.size()>0)&&(i<(mObject_material.size())))
+        return &(mObject_material.at(i));
+    else
+        return NULL;
+}
+unsigned int Object::GetObjectmaterialCount()
+{
+    return mObject_material.size();
+}
+
+Object_material*			Object::GetLastObjectmaterial()
+{
+    if (mObject_material.size()>0)
+        return &mObject_material.at(mObject_material.size()-1);
+    else
+        return NULL;
+}
+
+Object_material*			Object::GetLastAddedObjectmaterial()
+{
+    if(mLastAddedObjectmaterial<mObject_material.size())
+        return &mObject_material.at(mLastAddedObjectmaterial);
+    else
+        return NULL;
+}
+
+unsigned int Object::AddObjectmaterial()
+{
+    mObject_material.push_back(Object_material());
+    mLastAddedObjectmaterial = mObject_material.size()-1;
+    return mLastAddedObjectmaterial;
+}
+
+unsigned int Object::CloneObjectmaterial(unsigned int index)
+{
+    if(index<(mObject_material.size()-1))
+        mObject_material.insert(mObject_material.begin()+index+1, mObject_material[index]);
+    else if(index==mObject_material.size()-1)
+        mObject_material.push_back(mObject_material[index]);
+    mLastAddedObjectmaterial=index+1;
+    return mLastAddedObjectmaterial;
+}
+
+void Object::DeleteObjectmaterial(unsigned int index)
+{
+    mObject_material.erase(mObject_material.begin()+index);
+}
+
 
 signal_positionRoad::signal_positionRoad(double s, double t, double zOffset, double hOffset, double pitch, double roll)
 {

+ 168 - 0
src/tool/map_lanetoxodr/OpenDrive/ObjectSignal.h

@@ -7,6 +7,142 @@
 using std::vector;
 using std::string;
 
+class Object_outlines_outline
+{
+private:
+    vector<int> mid;
+    vector<string> mfillType;
+    vector<bool> mouter;
+    vector<bool> mclosed;
+    vector<string> mlaneTYpe;
+public:
+    Object_outlines_outline();
+};
+
+class Object_outlines
+{
+private:
+    vector<Object_outlines_outline> moutline;
+
+public:
+    Object_outlines();
+};
+
+class Object_material
+{
+private:
+    vector<string> msurface;
+    vector<double> mfriction;
+    vector<double> mroughness;
+
+public:
+    Object_material();
+
+    int Getsurface(string & surface);
+    int Getfriction(double & friction);
+    int Getroughness(double & roughness);
+
+    void Setsurface(string surface);
+    void Setfriction(double friction);
+    void Setroughness(double roughness);
+};
+
+class Object_repeat
+{
+private:
+    double ms;
+    double mlength;
+    double mdistance;
+    double mtStart;
+    double mtEnd;
+    double mheightStart;
+    double mheightEnd;
+    double mzOffsetStart;
+    double mzOffsetEnd;
+    vector<double> mwidthStart;
+    vector<double> mwidthEnd;
+    vector<double> mlengthStart;
+    vector<double> mlengthEnd;
+    vector<double> mradiusStart;
+    vector<double> mradiusEnd;
+
+public:
+    Object_repeat(double s,double length,double distance,double tStart,double tEnd,double heightStart,
+                  double heightEnd,double zOffsetStart,double zOffsetEnd);
+
+    double Gets();
+    double Getlength();
+    double Getdistance();
+    double GettStart();
+    double GettEnd();
+    double GetheightStart();
+    double GetheightEnd();
+    double GetzOffsetStart();
+    double GetzOffsetEnd();
+
+
+    void Sets(double s);
+    void Setlength(double length);
+    void Setdistance(double distance);
+    void SettStart(double tStart);
+    void SettEnd(double tEnd);
+    void SetheightStart(double heightStart);
+    void SetheightEnd(double heightEnd);
+    void SetzOffsetStart(double zOffsetStart);
+    void SetzOffsetEnd(double zOffsetEnd);
+
+
+    int GetwidthStart(double & widthStart);
+    int GetwidthEnd(double & widthEnd);
+    int GetlengthStart(double & lengthStart);
+    int GetlengthEnd(double & lengthEnd);
+    int GetradiusStart(double & radiusStart);
+    int GetradiusEnd(double & radiusEnd);
+
+    void DeletewidthStart();
+    void DeletewidthEnd();
+    void DeletelengthStart();
+    void DeletelengthEnd();
+    void DeleteradiusStart();
+    void DeleteradiusEnd();
+
+    void SetwidthStart(double  widthStart);
+    void SetwidthEnd(double  widthEnd);
+    void SetlengthStart(double  lengthStart);
+    void SetlengthEnd(double  lengthEnd);
+    void SetradiusStart(double  radiusStart);
+    void SetradiusEnd(double  radiusEnd);
+
+    bool CheckInterval(double s_check);
+
+
+};
+
+class Object_parkingSpace
+{
+private:
+    string maccess;
+    string mrestrictions;
+
+public:
+    Object_parkingSpace();
+
+    void Setaccess(string access);
+    void Setrestrictions(string restrictions);
+
+    string Getaccess();
+    string Getrestrictions();
+
+    /**
+     * Copy constructor
+     */
+    Object_parkingSpace (const Object_parkingSpace& parkingSpace);
+
+    /**
+     * Assignment operator overload
+     */
+    const Object_parkingSpace& operator=(const Object_parkingSpace& rhs);
+};
 
 //***********************************************************************************
 //Object
@@ -31,6 +167,14 @@ private:
     vector<double> mlength;
     vector<double> mwidth;
     vector<double> mradius;
+
+    vector<Object_parkingSpace> mObject_parkingSpace;
+    vector<Object_repeat> mObject_repeat;
+    vector<Object_material> mObject_material;
+
+    unsigned int mLastAddedObjectrepeat;
+    unsigned int mLastAddedObjectmaterial;
+
 public:
 
     Object(string id,double s,double t, double zOffset);
@@ -53,6 +197,8 @@ public:
     int Getwidth(double & width);
     int Getradius(double & radius);
 
+    int GetparkingSpace(Object_parkingSpace & parkingSpace);
+
     void Sett(double t);
     void SetzOffset(double zOffset);
     void Settype(string type);
@@ -70,6 +216,28 @@ public:
     void Setlength(double length);
     void Setwidth(double width);
     void Setradius(double radius);
+
+    void SetparkingSpace(Object_parkingSpace parkingSpace);
+
+    vector<Object_repeat> * GetObjectrepeatVector();
+    Object_repeat* GetObjectrepeat(unsigned int i);
+    unsigned int GetObjectrepeatCount();
+    Object_repeat*			GetLastObjectrepeat();
+    Object_repeat*			GetLastAddedObjectrepeat();
+    unsigned int AddObjectrepeat(double s,double length,double distance,double tStart,double tEnd,
+                                 double heightStart,double heightEnd,double zOffsetStart,double zOffsetEnd);
+    unsigned int CloneObjectrepeat(unsigned int index);
+    void DeleteObjectrepeat(unsigned int index);
+    int CheckObjectrepeatInterval(double s_check);
+
+    vector<Object_material> * GetObjectmaterialVector();
+    Object_material* GetObjectmaterial(unsigned int i);
+    unsigned int GetObjectmaterialCount();
+    Object_material*			GetLastObjectmaterial();
+    Object_material*			GetLastAddedObjectmaterial();
+    unsigned int AddObjectmaterial();
+    unsigned int CloneObjectmaterial(unsigned int index);
+    void DeleteObjectmaterial(unsigned int index);
 };
 //----------------------------------------------------------------------------------
 

+ 148 - 2
src/tool/map_lanetoxodr/OpenDrive/OpenDriveXmlParser.cpp

@@ -1114,6 +1114,134 @@ bool OpenDriveXmlParser::ReadObjects (Road* road, TiXmlElement *node)
 }
 //--------------
 
+bool OpenDriveXmlParser::ReadObjectMaterial(Object *pObject, TiXmlElement *node)
+{
+    pObject->AddObjectmaterial();
+
+    Object_material * pObject_material = pObject->GetLastAddedObjectmaterial();
+
+    string surface;
+    double friction;
+    double roughness;
+    if(node->QueryStringAttribute("surface",&surface) == TIXML_SUCCESS)
+    {
+        pObject_material->Setsurface(surface);
+    }
+
+    if(node->QueryDoubleAttribute("friction",&friction) == TIXML_SUCCESS)
+    {
+        pObject_material->Setfriction(friction);
+    }
+
+    if(node->QueryDoubleAttribute("roughness",&roughness) == TIXML_SUCCESS)
+    {
+        pObject_material->Setroughness(roughness);
+    }
+
+}
+//--------------
+bool OpenDriveXmlParser::ReadObjectRepeat(Object *pObject, TiXmlElement *node)
+{
+    double s;
+    double length;
+    double distance;
+    double tStart;
+    double tEnd;
+    double heightStart;
+    double heightEnd;
+    double zOffsetStart;
+    double zOffsetEnd;
+
+    double widthStart;
+    double widthEnd;
+    double lengthStart;
+    double lengthEnd;
+    double radiusStart;
+    double radiusEnd;
+
+    int checker=TIXML_SUCCESS;
+    checker+=node->QueryDoubleAttribute("s",&s);
+    checker+=node->QueryDoubleAttribute("length",&length);
+    checker+=node->QueryDoubleAttribute("distance",&distance);
+    checker+=node->QueryDoubleAttribute("tStart",&tStart);
+    checker+=node->QueryDoubleAttribute("tEnd",&tEnd);
+    checker+=node->QueryDoubleAttribute("heightStart",&heightStart);
+    checker+=node->QueryDoubleAttribute("heightEnd",&heightEnd);
+    checker+=node->QueryDoubleAttribute("zOffsetStart",&zOffsetStart);
+    checker+=node->QueryDoubleAttribute("zOffsetEnd",&zOffsetEnd);
+
+    if(checker != TIXML_SUCCESS)
+    {
+        cout<<"Error parsing Object repeat attributes"<<endl;
+        return false;
+    }
+
+    pObject->AddObjectrepeat(s,length,distance,tStart,tEnd,heightStart,heightEnd,zOffsetStart,zOffsetEnd);
+
+    Object_repeat * pObject_repeate = pObject->GetLastAddedObjectrepeat();
+
+    return true;
+
+    if(node->QueryDoubleAttribute("widthStart",&widthStart) == TIXML_SUCCESS)
+    {
+        pObject_repeate->SetwidthStart(widthStart);
+    }
+
+    if(node->QueryDoubleAttribute("widthEnd",&widthEnd) == TIXML_SUCCESS)
+    {
+        pObject_repeate->SetwidthEnd(widthEnd);
+    }
+
+    if(node->QueryDoubleAttribute("lengthStart",&lengthStart) == TIXML_SUCCESS)
+    {
+        pObject_repeate->SetlengthStart(lengthStart);
+    }
+
+    if(node->QueryDoubleAttribute("lengthEnd",&lengthEnd) == TIXML_SUCCESS)
+    {
+        pObject_repeate->SetlengthEnd(lengthEnd);
+    }
+
+    if(node->QueryDoubleAttribute("radiusStart",&radiusStart) == TIXML_SUCCESS)
+    {
+        pObject_repeate->SetradiusStart(radiusStart);
+    }
+
+    if(node->QueryDoubleAttribute("radiusEnd",&radiusEnd) == TIXML_SUCCESS)
+    {
+        pObject_repeate->SetradiusEnd(radiusEnd);
+    }
+
+    return true;
+
+
+}
+//--------------
+bool OpenDriveXmlParser::ReadObjectParkingSpace(Object *pObject, TiXmlElement *node)
+{
+    string access;
+    string restrictions;
+    int checker=TIXML_SUCCESS;
+    checker+=node->QueryStringAttribute("access",&access);
+    if(checker != TIXML_SUCCESS)
+    {
+        cout<<"Error parsing Object Parking Space attributes"<<endl;
+        return false;
+    }
+
+    Object_parkingSpace parkingSpace;
+    parkingSpace.Setaccess(access);
+    if(node->QueryStringAttribute("restrictions",&restrictions) == TIXML_SUCCESS)
+    {
+        parkingSpace.Setrestrictions(restrictions);
+    }
+    pObject->SetparkingSpace(parkingSpace);
+
+    return true;
+
+}
+//--------------
+
 bool OpenDriveXmlParser::ReadObject(Road *road, TiXmlElement *node)
 {
     double t;
@@ -1134,8 +1262,6 @@ bool OpenDriveXmlParser::ReadObject(Road *road, TiXmlElement *node)
     double width;
     double radius;
 
-    string strtem;
-
     int checker=TIXML_SUCCESS;
     checker+=node->QueryDoubleAttribute("s",&s);
     checker+=node->QueryDoubleAttribute("t",&t);
@@ -1217,6 +1343,26 @@ bool OpenDriveXmlParser::ReadObject(Road *road, TiXmlElement *node)
         pobject->Setradius(radius);
     }
 
+    TiXmlElement *subNode = node->FirstChildElement("parkingSpace");
+    if (subNode)
+    {
+        ReadObjectParkingSpace(pobject, subNode);
+    }
+
+    subNode = node->FirstChildElement("repeat");
+    while (subNode)
+    {
+        ReadObjectRepeat(pobject, subNode);
+        subNode = node->FirstChildElement("repeat");
+    }
+
+    subNode = node->FirstChildElement("material");
+    while (subNode)
+    {
+        ReadObjectMaterial(pobject, subNode);
+        subNode = node->FirstChildElement("material");
+    }
+
     return true;
 }
 

+ 3 - 0
src/tool/map_lanetoxodr/OpenDrive/OpenDriveXmlParser.h

@@ -67,6 +67,9 @@ public:
 	//--------------
 
 	bool ReadObjects (Road* road, TiXmlElement *node);
+    bool ReadObjectRepeat(Object * pObject,TiXmlElement *node);
+    bool ReadObjectMaterial(Object * pObject,TiXmlElement *node);
+    bool ReadObjectParkingSpace(Object * pObject,TiXmlElement *node);
 	bool ReadSignals (Road* road, TiXmlElement *node);
     bool ReadSignal(Road * road,TiXmlElement * node);
     bool ReadSignal_positionInertial(Signal * pSignal, TiXmlElement *node);

+ 213 - 8
src/tool/map_lanetoxodr/OpenDrive/OpenDriveXmlWriter.cpp

@@ -1091,9 +1091,214 @@ bool OpenDriveXmlWriter::WriteObjects (TiXmlElement *node, Road* road)
 	TiXmlElement* nodeObjects = new TiXmlElement("objects");
 	node->LinkEndChild(nodeObjects);
 
+    unsigned int lObjectCount = road->GetObjectCount();
+    for(unsigned int i=0; i<lObjectCount; i++)
+    {
+        WriteObject(nodeObjects, road->GetObject(i));
+    }
+
 	return true;
 }
 //--------------
+bool OpenDriveXmlWriter::WriteObject(TiXmlElement *node, Object *pObject)
+{
+    TiXmlElement* nodeObject = new TiXmlElement("object");
+    node->LinkEndChild(nodeObject);
+
+    nodeObject->SetDoubleAttribute("t",pObject->Gett());
+    nodeObject->SetDoubleAttribute("zOffset",pObject->GetzOffset());
+    if(pObject->Gettype() != "")
+    {
+        nodeObject->SetAttribute("type",pObject->Gettype());
+    }
+    double validLength;
+    if(pObject->GetvalidLength(validLength) == 1)
+    {
+        nodeObject->SetDoubleAttribute("validLength",validLength);
+    }
+    if(pObject->Getorientation() != "")
+    {
+        nodeObject->SetAttribute("orientation",pObject->Getorientation());
+    }
+    if(pObject->Getsubtype() != "")
+    {
+        nodeObject->SetAttribute("subtype",pObject->Getsubtype());
+    }
+    if(pObject->Getdynamic() != "")
+    {
+        nodeObject->SetAttribute("dynamic",pObject->Getdynamic());
+    }
+    double hdg;
+    if(pObject->Gethdg(hdg) == 1)
+    {
+        nodeObject->SetDoubleAttribute("hdg",hdg);
+    }
+    if(pObject->Getname() != "")
+    {
+        nodeObject->SetAttribute("name",pObject->Getname());
+    }
+    double pitch;
+    if(pObject->Getpitch(pitch) == 1)
+    {
+        nodeObject->SetDoubleAttribute("pitch",pitch);
+    }
+    nodeObject->SetAttribute("id",pObject->Getid());
+    double roll;
+    if(pObject->Getroll(roll) == 1)
+    {
+        nodeObject->SetDoubleAttribute("roll",roll);
+    }
+    double height;
+    if(pObject->Getheight(height) == 1)
+    {
+        nodeObject->SetDoubleAttribute("height",height);
+    }
+    nodeObject->SetDoubleAttribute("s",pObject->Gets());
+    double length;
+    if(pObject->Getlength(length) == 1)
+    {
+        nodeObject->SetDoubleAttribute("length",length);
+    }
+    double width;
+    if(pObject->Getwidth(width) == 1)
+    {
+        nodeObject->SetDoubleAttribute("width",width);
+    }
+    double radius;
+    if(pObject->Getradius(radius) == 1)
+    {
+        nodeObject->SetDoubleAttribute("radius",radius);
+    }
+
+    Object_parkingSpace parkingSpace;
+    if(pObject->GetparkingSpace(parkingSpace) == 1)
+    {
+        WriteObjectParkingSpace(nodeObject,&parkingSpace);
+    }
+
+    unsigned int i;
+
+    unsigned nrepeatcount = pObject->GetObjectrepeatCount();
+    for(i=0;i<nrepeatcount;i++)
+    {
+        Object_repeat * pObject_repeat = pObject->GetObjectrepeat(i);
+        WriteObjectrepeat(nodeObject,pObject_repeat);
+    }
+
+    unsigned nmaterialcount = pObject->GetObjectmaterialCount();
+    for(i=0;i<nmaterialcount;i++)
+    {
+        Object_material * pObject_material = pObject->GetObjectmaterial(i);
+        WriteObjectMaterial(nodeObject,pObject_material);
+    }
+
+    return true;
+}
+//--------------
+
+bool OpenDriveXmlWriter::WriteObjectrepeat(TiXmlElement * node,Object_repeat * pObject_repeat)
+{
+    double s;
+    double length;
+    double distance;
+    double tStart;
+    double tEnd;
+    double heightStart;
+    double heightEnd;
+    double zOffsetStart;
+    double zOffsetEnd;
+
+    double widthStart;
+    double widthEnd;
+    double lengthStart;
+    double lengthEnd;
+    double radiusStart;
+    double radiusEnd;
+
+    s = pObject_repeat->Gets();
+    length = pObject_repeat->Getlength();
+    distance = pObject_repeat->Getdistance();
+    tStart = pObject_repeat->GettStart();
+    tEnd = pObject_repeat->GettEnd();
+    heightStart = pObject_repeat->GetheightStart();
+    heightEnd = pObject_repeat->GetheightEnd();
+    zOffsetStart = pObject_repeat->GetzOffsetStart();
+    zOffsetEnd = pObject_repeat->GetzOffsetEnd();
+
+    TiXmlElement* nodeObjectRepeat = new TiXmlElement("repeat");
+    node->LinkEndChild(nodeObjectRepeat);
+    nodeObjectRepeat->SetDoubleAttribute("s",s);
+    nodeObjectRepeat->SetDoubleAttribute("length",length);
+    nodeObjectRepeat->SetDoubleAttribute("distance",distance);
+    nodeObjectRepeat->SetDoubleAttribute("tStart",tStart);
+    nodeObjectRepeat->SetDoubleAttribute("tEnd",tEnd);
+    nodeObjectRepeat->SetDoubleAttribute("heightStart",heightStart);
+    nodeObjectRepeat->SetDoubleAttribute("heightEnd",heightEnd);
+    nodeObjectRepeat->SetDoubleAttribute("zOffsetStart",zOffsetStart);
+    nodeObjectRepeat->SetDoubleAttribute("zOffsetEnd",zOffsetEnd);
+
+    if(pObject_repeat->GetwidthStart(widthStart) == 1)
+    {
+        nodeObjectRepeat->SetDoubleAttribute("widthStart",widthStart);
+    }
+    if(pObject_repeat->GetwidthEnd(widthEnd) == 1)
+    {
+        nodeObjectRepeat->SetDoubleAttribute("widthEnd",widthEnd);
+    }
+    if(pObject_repeat->GetlengthStart(lengthStart) == 1)
+    {
+        nodeObjectRepeat->SetDoubleAttribute("lengthStart",lengthStart);
+    }
+    if(pObject_repeat->GetlengthEnd(lengthEnd) == 1)
+    {
+        nodeObjectRepeat->SetDoubleAttribute("lengthEnd",lengthEnd);
+    }
+    if(pObject_repeat->GetradiusStart(radiusStart) == 1)
+    {
+        nodeObjectRepeat->SetDoubleAttribute("radiusStart",radiusStart);
+    }
+    if(pObject_repeat->GetradiusEnd(radiusEnd) == 1)
+    {
+        nodeObjectRepeat->SetDoubleAttribute("radiusEnd",radiusEnd);
+    }
+    return true;
+}
+//--------------
+bool OpenDriveXmlWriter::WriteObjectMaterial(TiXmlElement * node,Object_material * pObject_material)
+{
+    TiXmlElement* nodeObjectMaterial = new TiXmlElement("material");
+    node->LinkEndChild(nodeObjectMaterial);
+    string surface;
+    double friction;
+    double roughness;
+    if(pObject_material->Getsurface(surface) == 1)
+    {
+       nodeObjectMaterial->SetAttribute("surface",surface);
+    }
+    if(pObject_material->Getfriction(friction) == 1)
+    {
+       nodeObjectMaterial->SetDoubleAttribute("friction",friction);
+    }
+    if(pObject_material->Getroughness(roughness) == 1)
+    {
+       nodeObjectMaterial->SetDoubleAttribute("roughness",roughness);
+    }
+    return true;
+}
+
+//--------------
+bool OpenDriveXmlWriter::WriteObjectParkingSpace(TiXmlElement *node, Object_parkingSpace *pObject_parkingSpace)
+{
+    TiXmlElement* nodeObjectParkingSpace = new TiXmlElement("parkingSpace");
+    node->LinkEndChild(nodeObjectParkingSpace);
+    nodeObjectParkingSpace->SetAttribute("access",pObject_parkingSpace->Getaccess());
+    if(pObject_parkingSpace->Getrestrictions() != "")
+    {
+       nodeObjectParkingSpace->SetAttribute("restrictions",pObject_parkingSpace->Getrestrictions());
+    }
+    return true;
+}
+//--------------
 
 bool OpenDriveXmlWriter::WriteSignals (TiXmlElement *node, Road* road)
 {
@@ -1114,8 +1319,8 @@ bool OpenDriveXmlWriter::WriteSignal(TiXmlElement *node, Signal * pSignal)
     TiXmlElement* nodeSignal = new TiXmlElement("signal");
     node->LinkEndChild(nodeSignal);
 
-    nodeSignal->SetAttribute("s",pSignal->Gets());
-    nodeSignal->SetAttribute("t",pSignal->Gett());
+    nodeSignal->SetDoubleAttribute("s",pSignal->Gets());
+    nodeSignal->SetDoubleAttribute("t",pSignal->Gett());
     nodeSignal->SetAttribute("id",pSignal->Getid());
     nodeSignal->SetAttribute("name",pSignal->Getname());
     if(pSignal->Getdynamic() == true)
@@ -1123,16 +1328,16 @@ bool OpenDriveXmlWriter::WriteSignal(TiXmlElement *node, Signal * pSignal)
     else
         nodeSignal->SetAttribute("dynamic","no");
     nodeSignal->SetAttribute("orientation",pSignal->Getorientation());
-    nodeSignal->SetAttribute("zOffset",pSignal->GetzOffset());
+    nodeSignal->SetDoubleAttribute("zOffset",pSignal->GetzOffset());
     nodeSignal->SetAttribute("type",pSignal->Gettype());
     nodeSignal->SetAttribute("country",pSignal->Getcountry());
     nodeSignal->SetAttribute("countryRevision",pSignal->GetcountryRevision());
     nodeSignal->SetAttribute("subtype",pSignal->Getsubtype());
-    nodeSignal->SetAttribute("hOffset",pSignal->GethOffset());
-    nodeSignal->SetAttribute("pitch",pSignal->Getpitch());
-    nodeSignal->SetAttribute("roll",pSignal->Getroll());
-    nodeSignal->SetAttribute("height",pSignal->Getheight());
-    nodeSignal->SetAttribute("width",pSignal->Getwidth());
+    nodeSignal->SetDoubleAttribute("hOffset",pSignal->GethOffset());
+    nodeSignal->SetDoubleAttribute("pitch",pSignal->Getpitch());
+    nodeSignal->SetDoubleAttribute("roll",pSignal->Getroll());
+    nodeSignal->SetDoubleAttribute("height",pSignal->Getheight());
+    nodeSignal->SetDoubleAttribute("width",pSignal->Getwidth());
 
     signal_laneValidity * psignal_lanevalidity = pSignal->GetlaneValidity();
     if(psignal_lanevalidity != 0)

+ 4 - 0
src/tool/map_lanetoxodr/OpenDrive/OpenDriveXmlWriter.h

@@ -68,6 +68,10 @@ public:
 	//--------------
 
 	bool WriteObjects (TiXmlElement *node, Road* road);
+    bool WriteObject(TiXmlElement * node, Object * pObject);
+    bool WriteObjectParkingSpace(TiXmlElement * node,Object_parkingSpace * pObject_parkingSpace);
+    bool WriteObjectrepeat(TiXmlElement * node,Object_repeat * pObject_repeat);
+    bool WriteObjectMaterial(TiXmlElement * node,Object_material * pObject_material);
 	bool WriteSignals (TiXmlElement *node, Road* road);
     bool WriteSignal(TiXmlElement * node, Signal * pSignal);
     bool WriteSignal_positionInertial(TiXmlElement * node, signal_positionInertial * pSignal_positionInertial);