@@ -297,6 +297,14 @@ const OpenDrive& OpenDrive::operator=(const OpenDrive& rhs)
mHeader = new Header(revMajor,revMinor,name,version,date,north,south,east,west,lat0,lon0,hdg0);
+ std::string strgeoref;
+ pHeader->GetgeoReference(strgeoref);
+ mHeader->SetgeoReference(strgeoref);
+
+ std::string struserdarta;
+ pHeader->GetuserData(struserdarta);
+ mHeader->SetuserData(struserdarta);
}
else
{
@@ -96,6 +96,14 @@ bool OpenDriveXmlWriter::WriteHeader(TiXmlElement *node)
nodeHeader->LinkEndChild(nodegeoReference);
+ else
+ {
+ char strgeodata[1000];
+ snprintf(strgeodata,1000,"<geoReference> <![CDATA[+lat_0=%8.7f +lon_0=%8.7f]]></geoReference>",lat0,lon0);
+ TiXmlElement * nodegeoReference = new TiXmlElement("geoReference");
+ nodegeoReference->Parse(strgeodata,0,TIXML_ENCODING_UTF8);
+ nodeHeader->LinkEndChild(nodegeoReference);
+ }
if(struserData != "")
@@ -0,0 +1,74 @@
+# This file is used to ignore files which are generated
+# ----------------------------------------------------------------------------
+*~
+*.autosave
+*.a
+*.core
+*.moc
+*.o
+*.obj
+*.orig
+*.rej
+*.so
+*.so.*
+*_pch.h.cpp
+*_resource.rc
+*.qm
+.#*
+*.*#
+core
+!core/
+tags
+.DS_Store
+.directory
+*.debug
+Makefile*
+*.prl
+*.app
+moc_*.cpp
+ui_*.h
+qrc_*.cpp
+Thumbs.db
+*.res
+*.rc
+/.qmake.cache
+/.qmake.stash
+# qtcreator generated files
+*.pro.user*
+CMakeLists.txt.user*
+# xemacs temporary files
+*.flc
+# Vim temporary files
+.*.swp
+# Visual Studio generated files
+*.ib_pdb_index
+*.idb
+*.ilk
+*.pdb
+*.sln
+*.suo
+*.vcproj
+*vcproj.*.*.user
+*.ncb
+*.sdf
+*.opensdf
+*.vcxproj
+*vcxproj.*
+# MinGW generated files
+*.Debug
+*.Release
+# Python byte code
+*.pyc
+# Binaries
+# --------
+*.dll
+*.exe
@@ -0,0 +1,11 @@
+#include "mainwindow.h"
+#include <QApplication>
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ MainWindow w;
+ w.show();
+ return a.exec();
+}
@@ -0,0 +1,22 @@
+#include "ui_mainwindow.h"
+#include "xodrtoapollohdmap.h"
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+ , ui(new Ui::MainWindow)
+ ui->setupUi(this);
+ std::string strxodrpath = "/home/yuchuli/lk.xodr";
+ std::string strhdmappath = "/home/yuchuli/lk.bin";
+ xodrtoapollohdmap * ptohdmap = new xodrtoapollohdmap(strxodrpath,strhdmappath);
+ ptohdmap->Convert();
+MainWindow::~MainWindow()
+ delete ui;
@@ -0,0 +1,23 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+#include <QMainWindow>
+QT_BEGIN_NAMESPACE
+namespace Ui {
+class MainWindow;
+QT_END_NAMESPACE
+class MainWindow : public QMainWindow
+ Q_OBJECT
+public:
+ MainWindow(QWidget *parent = nullptr);
+ ~MainWindow();
+private:
+ Ui::MainWindow *ui;
+};
+#endif // MAINWINDOW_H
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>600</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ <widget class="QWidget" name="centralwidget">
+ <widget class="QPushButton" name="pushButton">
+ <x>100</x>
+ <y>50</y>
+ <width>131</width>
+ <height>41</height>
+ <property name="text">
+ <string>PushButton</string>
+ </widget>
+ <widget class="QMenuBar" name="menubar">
+ <height>27</height>
+ <widget class="QStatusBar" name="statusbar"/>
+ <resources/>
+ <connections/>
+</ui>
@@ -0,0 +1,50 @@
+QT += core gui
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+CONFIG += c++17
+# You can make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
+SOURCES += \
+ main.cpp \
+ mainwindow.cpp \
+ xodrtoapollohdmap.cpp
+HEADERS += \
+ mainwindow.h \
+ xodrtoapollohdmap.h
+FORMS += \
+ mainwindow.ui
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
+!include(../../common/common/xodr/OpenDrive/OpenDrive.pri ) {
+ error( "Couldn't find the OpenDrive.pri file!" )
+!include(../../common/common/xodr/TinyXML/TinyXML.pri ) {
+ error( "Couldn't find the TinyXML.pri file!" )
+!include(../../common/common/xodr/odaux/odaux.pri ) {
+ error( "Couldn't find the odaux.pri file!" )
+INCLUDEPATH += $$PWD/../../common/common/xodr
+INCLUDEPATH += $$PWD/../../common/common
+INCLUDEPATH += $$PWD/../../common/common/xodr/odaux
+INCLUDEPATH += $$PWD/../../common/apollohdmapproto
+LIBS += -L$$PWD/../../../bin -lapollohdmapproto
+LIBS += -lprotobuf
@@ -0,0 +1,66 @@
+#include "OpenDrive/OpenDrive.h"
+#include "OpenDrive/OpenDriveXmlParser.h"
+xodrtoapollohdmap::xodrtoapollohdmap(std::string strxodrpath,std::string strhdmappath){
+ mstrxodrpath = strxodrpath;
+ mstrhdmappath = strhdmappath;
+int xodrtoapollohdmap::Convert(){
+ OpenDrive * pxodr = new OpenDrive(); //because add to xodr,so don't delete
+ OpenDriveXmlParser x(pxodr);
+ if(!x.ReadFile(mstrxodrpath))
+ std::cout<<"Can't load xodr file."<<std::endl;
+ return -1;
+ double flon0,flat0;
+ if(pxodr->GetHeader() != NULL)
+ pxodr->GetHeader()->GetLat0Lon0(flat0,flon0);
+ flon0 = 117.0;
+ flat0 = 39.0;
+ apollo::hdmap::Map xHdMap;
+ unsigned int nroadnum = pxodr->GetRoadCount();
+ unsigned int i;
+ for(i=0;i<nroadnum;i++)
+ Road * pRoad = pxodr->GetRoad(i);
+ std::string * pstrroadid = new std::string;
+ *pstrroadid = pRoad->GetRoadId();
+ apollo::hdmap::Road * pHdMapRoad = xHdMap.add_road();
+ apollo::hdmap::Id * proadid = new apollo::hdmap::Id();
+ proadid->set_allocated_id(pstrroadid);
+ pHdMapRoad->set_allocated_id(proadid);
+ pHdMapRoad->set_type(apollo::hdmap::Road_Type_CITY_ROAD);
+ if(pRoad->GetRoadJunction() != "-1")
+ std::string * pstrjunctionid = new std::string;
+ *pstrjunctionid = pRoad->GetRoadJunction();
+ apollo::hdmap::Id * pjunctionid = new apollo::hdmap::Id();
+ pjunctionid->set_allocated_id(pstrjunctionid);
+ pHdMapRoad->set_allocated_junction_id(pjunctionid);
+ return 0;
@@ -0,0 +1,18 @@
+#ifndef XODRTOAPOLLOHDMAP_H
+#define XODRTOAPOLLOHDMAP_H
+#include "modules/common_msgs/map_msgs/map.pb.h"
+class xodrtoapollohdmap
+ xodrtoapollohdmap(std::string strxodrpath,std::string strhdmappath);
+ int Convert();
+ std::string mstrxodrpath;
+ std::string mstrhdmappath;
+#endif // XODRTOAPOLLOHDMAP_H