Kaynağa Gözat

change tool/map_lanetoxodr. add road rule attr.

yuchuli 3 yıl önce
ebeveyn
işleme
b5a459ec89

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

@@ -72,6 +72,8 @@ bool OpenDriveXmlParser::ReadRoad(TiXmlElement *node)
 	double length;
 	double length;
 	string id;
 	string id;
 	string junction;
 	string junction;
+    string rule;
+    bool bHaverule = false;
 
 
 	int checker=TIXML_SUCCESS;
 	int checker=TIXML_SUCCESS;
 	
 	
@@ -86,6 +88,11 @@ bool OpenDriveXmlParser::ReadRoad(TiXmlElement *node)
 		return false;
 		return false;
 	}
 	}
 
 
+    if(node->QueryStringAttribute("rule",&rule) == TIXML_SUCCESS)
+    {
+        bHaverule = true;
+    }
+
     if(node->QueryStringAttribute("name",&name) != TIXML_SUCCESS)
     if(node->QueryStringAttribute("name",&name) != TIXML_SUCCESS)
     {
     {
         name = "";
         name = "";
@@ -93,6 +100,12 @@ bool OpenDriveXmlParser::ReadRoad(TiXmlElement *node)
 	//fill in
 	//fill in
 	mOpenDrive->AddRoad(name, length, id, junction);
 	mOpenDrive->AddRoad(name, length, id, junction);
 	Road* road = mOpenDrive->GetLastAddedRoad();
 	Road* road = mOpenDrive->GetLastAddedRoad();
+
+    if(bHaverule)
+    {
+        road->SetRoadRule(rule);
+    }
+
 	TiXmlElement* subNode;
 	TiXmlElement* subNode;
 
 
 
 

+ 40 - 0
src/tool/map_lanetoxodr/OpenDrive/OpenDriveXmlWriter.cpp

@@ -86,11 +86,13 @@ bool OpenDriveXmlWriter::WriteRoad(TiXmlElement *node, Road *road)
 	double length;
 	double length;
 	string id;
 	string id;
 	string junction;
 	string junction;
+    string rule;
 
 
 	name = road->GetRoadName();
 	name = road->GetRoadName();
 	length = road->GetRoadLength();
 	length = road->GetRoadLength();
 	id = road->GetRoadId();
 	id = road->GetRoadId();
 	junction = road->GetRoadJunction();
 	junction = road->GetRoadJunction();
+    rule = road->GetRoadRule();
 
 
 	TiXmlElement *nodeRoad = new TiXmlElement("road");
 	TiXmlElement *nodeRoad = new TiXmlElement("road");
 	node->LinkEndChild(nodeRoad);
 	node->LinkEndChild(nodeRoad);
@@ -101,6 +103,10 @@ bool OpenDriveXmlWriter::WriteRoad(TiXmlElement *node, Road *road)
 	nodeRoad->SetAttribute("length",slength.str());
 	nodeRoad->SetAttribute("length",slength.str());
 	nodeRoad->SetAttribute("id",id);
 	nodeRoad->SetAttribute("id",id);
 	nodeRoad->SetAttribute("junction",junction);
 	nodeRoad->SetAttribute("junction",junction);
+    if(rule != "")
+    {
+        nodeRoad->SetAttribute("rule",rule);
+    }
 
 
 	//Fill in
 	//Fill in
 
 
@@ -531,6 +537,12 @@ bool OpenDriveXmlWriter::WriteLanes (TiXmlElement *node, Road* road)
 		WriteLaneSections(nodeLanes, road->GetLaneSection(i));
 		WriteLaneSections(nodeLanes, road->GetLaneSection(i));
 	}
 	}
 
 
+    unsigned int lLaneOffsetCount = road->GetLaneOffsetCount();
+    for(unsigned int i=0; i<lLaneOffsetCount; i++)
+    {
+        WriteLaneOffset(nodeLanes, road->GetLaneOffset(i));
+    }
+
 	return true;
 	return true;
 }
 }
 //--------------
 //--------------
@@ -590,6 +602,34 @@ bool OpenDriveXmlWriter::WriteLaneSections (TiXmlElement *node, LaneSection *lan
 }
 }
 //--------------
 //--------------
 
 
+bool OpenDriveXmlWriter::WriteLaneOffset(TiXmlElement *node, LaneOffset *laneOffset)
+{
+    double s;
+    s=laneOffset->GetS();
+
+    TiXmlElement* nodeLaneSection = new TiXmlElement("laneOffset");
+    node->LinkEndChild(nodeLaneSection);
+
+    std::stringstream ss;
+    ss << setprecision(16) << setiosflags (ios_base::scientific) << s;
+    nodeLaneSection->SetAttribute("s",ss.str());
+
+    ss << setprecision(16) << setiosflags (ios_base::scientific) << laneOffset->Geta();
+    nodeLaneSection->SetAttribute("a",ss.str());
+
+    ss << setprecision(16) << setiosflags (ios_base::scientific) << laneOffset->Getb();
+    nodeLaneSection->SetAttribute("b",ss.str());
+
+    ss << setprecision(16) << setiosflags (ios_base::scientific) << laneOffset->Getc();
+    nodeLaneSection->SetAttribute("c",ss.str());
+
+    ss << setprecision(16) << setiosflags (ios_base::scientific) << laneOffset->Getd();
+    nodeLaneSection->SetAttribute("d",ss.str());
+
+    return true;
+}
+//--------------
+
 bool OpenDriveXmlWriter::WriteLane (TiXmlElement *node, Lane* lane)
 bool OpenDriveXmlWriter::WriteLane (TiXmlElement *node, Lane* lane)
 {
 {
 	//Write Lane attributes
 	//Write Lane attributes

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

@@ -61,6 +61,7 @@ public:
 	bool WriteLaneSpeed(TiXmlElement *node, LaneSpeed* laneSpeed);
 	bool WriteLaneSpeed(TiXmlElement *node, LaneSpeed* laneSpeed);
 	bool WriteLaneAccess(TiXmlElement *node, LaneAccess* laneAccess);
 	bool WriteLaneAccess(TiXmlElement *node, LaneAccess* laneAccess);
 	bool WriteLaneHeight(TiXmlElement *node, LaneHeight* laneHeight);
 	bool WriteLaneHeight(TiXmlElement *node, LaneHeight* laneHeight);
+    bool WriteLaneOffset (TiXmlElement *node, LaneOffset *laneOffset);
 	//--------------
 	//--------------
 
 
 	bool WriteObjects (TiXmlElement *node, Road* road);
 	bool WriteObjects (TiXmlElement *node, Road* road);

+ 8 - 0
src/tool/map_lanetoxodr/OpenDrive/Road.cpp

@@ -159,6 +159,10 @@ string Road::GetRoadJunction() const
 {
 {
 	return mJunction;
 	return mJunction;
 }
 }
+string Road::GetRoadRule() const
+{
+    return mRule;
+}
 
 
 /**
 /**
  * Getters for the linking properties of the road
  * Getters for the linking properties of the road
@@ -472,6 +476,10 @@ void Road::SetRoadJunction(string junction)
 {
 {
 	mJunction=junction;
 	mJunction=junction;
 }
 }
+void Road::SetRoadRule(std::string rule)
+{
+    mRule=rule;
+}
 
 
 /**
 /**
  * Setters for the linking road properties
  * Setters for the linking road properties

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

@@ -47,6 +47,7 @@ private:
 	double mLength;
 	double mLength;
 	string mId;
 	string mId;
 	string mJunction;
 	string mJunction;
+    string mRule;
 
 
 	// Linking complex properties (have multiple sub-properties)
 	// Linking complex properties (have multiple sub-properties)
 	RoadLink* mPredecessor;
 	RoadLink* mPredecessor;
@@ -124,6 +125,7 @@ public:
 	double GetRoadLength() const;
 	double GetRoadLength() const;
 	string GetRoadId() const;
 	string GetRoadId() const;
 	string GetRoadJunction() const;
 	string GetRoadJunction() const;
+    string GetRoadRule() const;
 	
 	
 	/**
 	/**
 	 * Getters for the linking properties of the road
 	 * Getters for the linking properties of the road
@@ -207,6 +209,7 @@ public:
 	void SetRoadLength(double length);
 	void SetRoadLength(double length);
 	void SetRoadId(string roadId);
 	void SetRoadId(string roadId);
 	void SetRoadJunction(string junction);
 	void SetRoadJunction(string junction);
+    void SetRoadRule(string rule);
 
 
 	/**
 	/**
 	 * Setters for the linking road properties
 	 * Setters for the linking road properties

+ 1 - 1
src/tool/map_lanetoxodr/mainwindow.cpp

@@ -5126,7 +5126,7 @@ void MainWindow::UpdateScene()
     std::vector<RoadDigit> xvectorrd;
     std::vector<RoadDigit> xvectorrd;
     for(i=0;i<nsize;i++)
     for(i=0;i<nsize;i++)
     {
     {
-        RoadDigit xrd(mxodr.GetRoad(i),10.0);
+        RoadDigit xrd(mxodr.GetRoad(i),5.0);
         xvectorrd.push_back(xrd);
         xvectorrd.push_back(xrd);
  //       UpdateSceneRoad(mxodr.GetRoad(i));
  //       UpdateSceneRoad(mxodr.GetRoad(i));
 //        qDebug("update road %d",i);
 //        qDebug("update road %d",i);