Forráskód Böngészése

change tool/map_lanetoxodr. changing Object.

yuchuli 3 éve
szülő
commit
fb956cc60d

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

@@ -2,6 +2,209 @@
 
 
 #include <iostream>
 #include <iostream>
 
 
+
+Object::Object(std::string id, double s, double t, double zOffset)
+{
+    mid = id;
+    ms = s;
+    mt = t;
+    mzOffset = zOffset;
+}
+
+double Object::Gett()
+{
+    return mt;
+}
+
+double Object::GetzOffset()
+{
+    return mzOffset;
+}
+
+string Object::Gettype()
+{
+    return mtype;
+}
+
+int Object::GetvalidLength(double &validLength)
+{
+    if(mvalidLength.size()<1)return 0;
+    validLength = mvalidLength[0];
+    return 1;
+}
+
+string Object::Getorientation()
+{
+    return morientation;
+}
+
+string Object::Getsubtype()
+{
+    return msubtype;
+}
+
+string Object::Getdynamic()
+{
+    return mdynamic;
+}
+
+int Object::Gethdg(double &hdg)
+{
+    if(mhdg.size()<1)return 0;
+    hdg = mhdg[0];
+    return 1;
+}
+
+string Object::Getname()
+{
+    return mname;
+}
+
+int Object::Getpitch(double &pitch)
+{
+    if(mpitch.size()<1)return 0;
+    pitch = mpitch[0];
+    return 1;
+}
+
+string Object::Getid()
+{
+    return mid;
+}
+
+int Object::Getroll(double &roll)
+{
+    if(mroll.size()<1)return 0;
+    roll = mroll[0];
+    return 1;
+}
+
+int Object::Getheight(double &height)
+{
+    if(mheight.size()<1)return 0;
+    height = mheight[0];
+    return 1;
+}
+
+double Object::Gets()
+{
+    return ms;
+}
+
+int Object::Getlength(double &length)
+{
+    if(mlength.size()<1)return 0;
+    length = mlength[0];
+    return 1;
+}
+
+int Object::Getwidth(double &width)
+{
+    if(mwidth.size()<1)return 0;
+    width = mwidth[0];
+    return 1;
+}
+
+int Object::Getradius(double &radius)
+{
+    if(mradius.size()<1)return 0;
+    radius = mradius[0];
+    return 1;
+}
+
+void Object::Sett(double t)
+{
+    mt = t;
+}
+
+void Object::SetzOffset(double zOffset)
+{
+    mzOffset = zOffset;
+}
+void Object::Settype(string type)
+{
+    mtype = type;
+}
+
+void Object::SetvalidLength(double  validLength)
+{
+    if(mvalidLength.size() > 0)mvalidLength.clear();
+    mvalidLength.push_back(validLength);
+}
+
+void Object::Setorientation(string orientation)
+{
+    morientation = orientation;
+}
+
+void Object::Setsubtype(string subtype)
+{
+    msubtype = subtype;
+}
+
+void Object::Setdynamic(string dynamic)
+{
+    mdynamic = dynamic;
+}
+
+void Object::Sethdg(double  hdg)
+{
+    if(mhdg.size()>0)mhdg.clear();
+    mhdg.push_back(hdg);
+}
+
+void Object::Setname(string name)
+{
+    mname = name;
+}
+
+void Object::Setpitch(double pitch)
+{
+    if(mpitch.size()>0)mpitch.clear();
+    mpitch.push_back(pitch);
+}
+
+void Object::Setid(string id)
+{
+    mid = id;
+}
+
+void Object::Setroll(double  roll)
+{
+    if(mroll.size()>0)mroll.clear();
+    mroll.push_back(roll);
+}
+
+void Object::Setheight(double height)
+{
+    if(mheight.size()>0)mheight.clear();
+    mheight.push_back(height);
+}
+
+void Object::Sets(double s)
+{
+    ms = s;
+}
+
+void Object::Setlength(double length)
+{
+    if(mlength.size()>0)mlength.clear();
+    mlength.push_back(length);
+}
+
+void Object::Setwidth(double width)
+{
+    if(mwidth.size()>0)mwidth.clear();
+    mwidth.push_back(width);
+}
+
+void Object::Setradius(double radius)
+{
+    if(mradius.size()>0)mradius.clear();
+    mradius.push_back(radius);
+}
+
+
 signal_positionRoad::signal_positionRoad(double s, double t, double zOffset, double hOffset, double pitch, double roll)
 signal_positionRoad::signal_positionRoad(double s, double t, double zOffset, double hOffset, double pitch, double roll)
 {
 {
     ms = s;
     ms = s;

+ 56 - 1
src/tool/map_lanetoxodr/OpenDrive/ObjectSignal.h

@@ -13,8 +13,63 @@ using std::string;
 //***********************************************************************************
 //***********************************************************************************
 class Object
 class Object
 {
 {
+private:
+    double mt;
+    double mzOffset;
+    string mtype;
+    vector<double> mvalidLength;
+    string morientation;
+    string msubtype;
+    string mdynamic;
+    vector<double> mhdg;
+    string mname;
+    vector<double> mpitch;
+    string mid;
+    vector<double> mroll;
+    vector<double> mheight;
+    double ms;
+    vector<double> mlength;
+    vector<double> mwidth;
+    vector<double> mradius;
 public:
 public:
-	Object(){}
+
+    Object(string id,double s,double t, double zOffset);
+
+    double Gett();
+    double GetzOffset();
+    string Gettype();
+    int GetvalidLength(double & validLength);
+    string Getorientation();
+    string Getsubtype();
+    string Getdynamic();
+    int Gethdg(double & hdg);
+    string Getname();
+    int Getpitch(double & pitch);
+    string Getid();
+    int Getroll(double & roll);
+    int Getheight(double & height);
+    double Gets();
+    int Getlength(double & length);
+    int Getwidth(double & width);
+    int Getradius(double & radius);
+
+    void Sett(double t);
+    void SetzOffset(double zOffset);
+    void Settype(string type);
+    void SetvalidLength(double  validLength);
+    void Setorientation(string orientation);
+    void Setsubtype(string subtype);
+    void Setdynamic(string dynamic);
+    void Sethdg(double  hdg);
+    void Setname(string name);
+    void Setpitch(double pitch);
+    void Setid(string id);
+    void Setroll(double  roll);
+    void Setheight(double height);
+    void Sets(double s);
+    void Setlength(double length);
+    void Setwidth(double width);
+    void Setradius(double radius);
 };
 };
 //----------------------------------------------------------------------------------
 //----------------------------------------------------------------------------------
 
 

+ 114 - 0
src/tool/map_lanetoxodr/OpenDrive/OpenDriveXmlParser.cpp

@@ -1104,10 +1104,124 @@ bool OpenDriveXmlParser::ReadLaneHeight(Lane* lane, TiXmlElement *node)
 
 
 bool OpenDriveXmlParser::ReadObjects (Road* road, TiXmlElement *node)
 bool OpenDriveXmlParser::ReadObjects (Road* road, TiXmlElement *node)
 {
 {
+    TiXmlElement *subNode = node->FirstChildElement("object");
+    while (subNode)
+    {
+        ReadObject(road, subNode);
+        subNode=subNode->NextSiblingElement("object");
+    }
 	return true;
 	return true;
 }
 }
 //--------------
 //--------------
 
 
+bool OpenDriveXmlParser::ReadObject(Road *road, TiXmlElement *node)
+{
+    double t;
+    double zOffset;
+    string type;
+    double validLength;
+    string orientation;
+    string subtype;
+    string dynamic;
+    double hdg;
+    string name;
+    double pitch;
+    string id;
+    double roll;
+    double height;
+    double s;
+    double length;
+    double width;
+    double radius;
+
+    string strtem;
+
+    int checker=TIXML_SUCCESS;
+    checker+=node->QueryDoubleAttribute("s",&s);
+    checker+=node->QueryDoubleAttribute("t",&t);
+    checker+=node->QueryStringAttribute("id",&id);
+    checker+=node->QueryDoubleAttribute("zOffset",&zOffset);
+
+    if (checker!=TIXML_SUCCESS)
+    {
+        cout<<"Error parsing Object attributes"<<endl;
+        return false;
+    }
+
+    road->AddObject(id,s,t,zOffset);
+
+    Object * pobject = road->GetLastAddedObject();
+
+    if(node->QueryStringAttribute("type",&type) == TIXML_SUCCESS)
+    {
+        pobject->Settype(type);
+    }
+
+    if(node->QueryDoubleAttribute("validLength",&validLength) == TIXML_SUCCESS)
+    {
+        pobject->SetvalidLength(validLength);
+    }
+
+    if(node->QueryStringAttribute("orientation",&orientation) == TIXML_SUCCESS)
+    {
+        pobject->Setorientation(orientation);
+    }
+
+    if(node->QueryStringAttribute("subtype",&subtype) == TIXML_SUCCESS)
+    {
+        pobject->Setsubtype(subtype);
+    }
+
+    if(node->QueryStringAttribute("dynamic",&dynamic) == TIXML_SUCCESS)
+    {
+        pobject->Setdynamic(dynamic);
+    }
+
+    if(node->QueryDoubleAttribute("hdg",&hdg) == TIXML_SUCCESS)
+    {
+        pobject->Sethdg(hdg);
+    }
+
+    if(node->QueryStringAttribute("name",&name) == TIXML_SUCCESS)
+    {
+        pobject->Setname(name);
+    }
+
+    if(node->QueryDoubleAttribute("pitch",&pitch) == TIXML_SUCCESS)
+    {
+        pobject->Setpitch(pitch);
+    }
+
+    if(node->QueryDoubleAttribute("roll",&roll) == TIXML_SUCCESS)
+    {
+        pobject->Setroll(roll);
+    }
+
+    if(node->QueryDoubleAttribute("height",&height) == TIXML_SUCCESS)
+    {
+        pobject->Setheight(height);
+    }
+
+    if(node->QueryDoubleAttribute("length",&length) == TIXML_SUCCESS)
+    {
+        pobject->Setlength(length);
+    }
+
+    if(node->QueryDoubleAttribute("width",&width) == TIXML_SUCCESS)
+    {
+        pobject->Setwidth(width);
+    }
+
+    if(node->QueryDoubleAttribute("radius",&radius) == TIXML_SUCCESS)
+    {
+        pobject->Setradius(radius);
+    }
+
+    return true;
+}
+
+//--------------
+
 bool OpenDriveXmlParser::ReadSignals (Road* road, TiXmlElement *node)
 bool OpenDriveXmlParser::ReadSignals (Road* road, TiXmlElement *node)
 {
 {
 
 

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

@@ -71,6 +71,7 @@ public:
     bool ReadSignal(Road * road,TiXmlElement * node);
     bool ReadSignal(Road * road,TiXmlElement * node);
     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 ReadObject(Road * road,TiXmlElement * node);
 	//--------------
 	//--------------
 
 
 	bool ReadSurface (Road* road, TiXmlElement *node);
 	bool ReadSurface (Road* road, TiXmlElement *node);

+ 2 - 2
src/tool/map_lanetoxodr/OpenDrive/Road.cpp

@@ -637,12 +637,12 @@ unsigned int Road::AddLaneOffset(double s, double a, double b, double c, double
 }
 }
 
 
 //-------------
 //-------------
-unsigned int Road::AddObject()
+unsigned int Road::AddObject(string id,double s,double t,double zOffset)
 {	
 {	
 	// Check the first method in the group for details
 	// Check the first method in the group for details
 
 
 	unsigned int index=GetObjectCount();
 	unsigned int index=GetObjectCount();
-	mObjectsVector.push_back(Object());
+    mObjectsVector.push_back(Object(id,s,t,zOffset));
 	mLastAddedObject=index;
 	mLastAddedObject=index;
 	return index;
 	return index;
 }
 }

+ 1 - 1
src/tool/map_lanetoxodr/OpenDrive/Road.h

@@ -241,7 +241,7 @@ public:
 	unsigned int AddCrossfall (string side, double s, double a, double b, double c, double d);
 	unsigned int AddCrossfall (string side, double s, double a, double b, double c, double d);
 	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 AddObject();
+    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);