Răsfoiți Sursa

change tool/map_lanetoxodr. add outline xml parser code.

yuchuli 3 ani în urmă
părinte
comite
e8f606370a

+ 155 - 0
src/common/common/xodr/OpenDrive/OpenDriveXmlParser.cpp

@@ -1274,6 +1274,148 @@ bool OpenDriveXmlParser::ReadObjectParkingSpace(Object *pObject, TiXmlElement *n
 }
 //--------------
 
+bool OpenDriveXmlParser::ReadObjectOutlines(Object * pObject,TiXmlElement *node)
+{
+    Object_outlines xoutlines;
+
+    TiXmlElement *subNode = node->FirstChildElement("outline");
+
+    if(subNode)
+    {
+        if(ReadObjectOutlinesOutline(&xoutlines,subNode))
+        {
+            pObject->Setoutlines(xoutlines);
+            return true;
+        }
+    }
+
+    return false;
+
+}
+
+//--------------
+
+bool OpenDriveXmlParser::ReadObjectOutlinesOutline(Object_outlines * pObject_outlines,TiXmlElement *node)
+{
+    int id;
+    string fillType;
+    bool outer;
+    bool closed;
+    string laneType;
+
+    string strouter,strclosed;
+
+    Object_outlines_outline xoutline;
+
+    if(node->QueryIntAttribute("id",&id) == TIXML_SUCCESS)
+    {
+        xoutline.Setid(id);
+    }
+    if(node->QueryStringAttribute("fillType",&fillType) == TIXML_SUCCESS)
+    {
+        xoutline.SetfillType(fillType);
+    }
+    if(node->QueryStringAttribute("outer",&strouter) == TIXML_SUCCESS)
+    {
+        if(strouter == "true")
+        {
+            outer=true;
+        }
+        else
+        {
+            outer = false;
+        }
+        xoutline.Setouter(outer);
+    }
+    if(node->QueryStringAttribute("closed",&strclosed) == TIXML_SUCCESS)
+    {
+        if(strclosed == "true")
+        {
+            closed = true;
+        }
+        else
+        {
+            closed = false;
+        }
+        xoutline.Setclosed(closed);
+    }
+    if(node->QueryStringAttribute("laneType",&laneType) == TIXML_SUCCESS)
+    {
+        xoutline.SetlaneType(laneType);
+    }
+
+    pObject_outlines->SetObject_outlines_outline(xoutline);
+
+    return true;
+
+}
+
+//--------------
+
+bool OpenDriveXmlParser::ReadObjectOutlinesOutline(Object * pObject,TiXmlElement *node)
+{
+    int id;
+    string fillType;
+    bool outer;
+    bool closed;
+    string laneType;
+
+    string strouter,strclosed;
+
+    pObject->AddObjectoutline();
+
+    Object_outlines_outline * poutline = pObject->GetLastObjectoutline();
+
+    if(poutline == NULL)
+    {
+        std::cout<<"OpenDriveXmlParser::ReadObjectOutlinesOutline poutline is NULL "<<std::endl;
+        return false;
+    }
+
+    if(node->QueryIntAttribute("id",&id) == TIXML_SUCCESS)
+    {
+        poutline->Setid(id);
+    }
+    if(node->QueryStringAttribute("fillType",&fillType) == TIXML_SUCCESS)
+    {
+        poutline->SetfillType(fillType);
+    }
+    if(node->QueryStringAttribute("outer",&strouter) == TIXML_SUCCESS)
+    {
+        if(strouter == "true")
+        {
+            outer=true;
+        }
+        else
+        {
+            outer = false;
+        }
+        poutline->Setouter(outer);
+    }
+    if(node->QueryStringAttribute("closed",&strclosed) == TIXML_SUCCESS)
+    {
+        if(strclosed == "true")
+        {
+            closed = true;
+        }
+        else
+        {
+            closed = false;
+        }
+        poutline->Setclosed(closed);
+    }
+    if(node->QueryStringAttribute("laneType",&laneType) == TIXML_SUCCESS)
+    {
+        poutline->SetlaneType(laneType);
+    }
+
+
+
+    return true;
+}
+
+//--------------
+
 bool OpenDriveXmlParser::ReadObject(Road *road, TiXmlElement *node)
 {
     double t;
@@ -1395,6 +1537,19 @@ bool OpenDriveXmlParser::ReadObject(Road *road, TiXmlElement *node)
         subNode = subNode->NextSiblingElement("material");
     }
 
+    subNode = node->FirstChildElement("outlines");
+    if(subNode)
+    {
+        ReadObjectOutlines(pobject,subNode);
+    }
+
+    subNode = node->FirstChildElement("outline");
+    while (subNode)
+    {
+        ReadObjectOutlinesOutline(pobject, subNode);
+        subNode = subNode->NextSiblingElement("outline");
+    }
+
     return true;
 }
 //--------------

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

@@ -75,6 +75,9 @@ public:
     bool ReadObjectRepeat(Object * pObject,TiXmlElement *node);
     bool ReadObjectMaterial(Object * pObject,TiXmlElement *node);
     bool ReadObjectParkingSpace(Object * pObject,TiXmlElement *node);
+    bool ReadObjectOutlines(Object * pObject,TiXmlElement *node);
+    bool ReadObjectOutlinesOutline(Object_outlines * pObject_outlines,TiXmlElement *node);
+    bool ReadObjectOutlinesOutline(Object * pObject,TiXmlElement *node);
 	bool ReadSignals (Road* road, TiXmlElement *node);
     bool ReadSignal(Road * road,TiXmlElement * node);
     bool ReadSignal_positionInertial(Signal * pSignal, TiXmlElement *node);