Browse Source

add tool_trace2vectormap. function ok, file select and folder select not complete.

yuchuli 3 years ago
parent
commit
ca1f3ac7a9

+ 4 - 4
src/ros/catkin/src/lane_planner/nodes/lane_navi/lane_navi.cpp

@@ -228,12 +228,12 @@ void ThreadTest()
 
       tablet_socket_msgs::route_cmd xc;
  tablet_socket_msgs::Waypoint p1;
-  p1.lat =60;// -14;
-  p1.lon = 3;//35;
+  p1.lat =10;//60;// -14;
+  p1.lon =0;//3;//35;
  xc.point.push_back(p1);
   tablet_socket_msgs::Waypoint p2;
-  p2.lat = 290;//-311;//-68;
-  p2.lon =  3;//-101;//37;//-155;
+  p2.lat = -361;//290;//-311;//-68;
+  p2.lon = -4;//3;//-101;//37;//-155;
   xc.point.push_back(p2);
 
   create_waypoint(xc);

+ 1 - 1
src/ros/catkin/src/map_file/launch/vector_map_loader.launch

@@ -2,7 +2,7 @@
 <launch>
   <node pkg="map_file" type="vector_map_loader" name="vector_map_loader" output="screen">
     <param name="load_mode" value="directory" />
-    <param name="map_dir" value="$(env HOME)/map/testvector" />
+    <param name="map_dir" value="$(env HOME)/map/tracevector" />
     <param name="host_name" value="133.6.148.90" />
     <param name="port" value="80" />
     <param name="user" value="" />

+ 73 - 0
src/tool/tool_trace2vectormap/.gitignore

@@ -0,0 +1,73 @@
+# 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*
+
+# 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
+

+ 11 - 0
src/tool/tool_trace2vectormap/main.cpp

@@ -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();
+}

+ 75 - 0
src/tool/tool_trace2vectormap/mainwindow.cpp

@@ -0,0 +1,75 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+#include <QMessageBox>
+
+MainWindow::MainWindow(QWidget *parent)
+    : QMainWindow(parent)
+    , ui(new Ui::MainWindow)
+{
+    ui->setupUi(this);
+    setWindowTitle("Convert Tracemap to Autoware VectorMap");
+
+    ui->lineEdit_Lat0->setText("39.1238777");
+    ui->lineEdit_Lon0->setText("117.0273054");
+    ui->lineEdit_Lcnt->setText("5");
+    ui->lineEdit_Lno->setText("3");
+    ui->lineEdit_LeftDis->setText("2.3");
+    ui->lineEdit_RIghtDis->setText("2.3");
+    ui->lineEdit_Span->setText("1.0");
+    ui->comboBox_LeftColor->addItem("White");
+    ui->comboBox_LeftColor->addItem("Yellow");
+    ui->comboBox_LeftColor->setCurrentIndex(0);
+    ui->comboBox_RIghtColor->addItem("White");
+    ui->comboBox_RIghtColor->addItem("Yellow");
+    ui->comboBox_RIghtColor->setCurrentIndex(0);
+}
+
+MainWindow::~MainWindow()
+{
+    delete ui;
+}
+
+
+void MainWindow::on_pushButton_Convert_clicked()
+{
+    iv::trace2vectormap_param xparam;
+    xparam.fLat0 = ui->lineEdit_Lat0->text().toDouble();
+    xparam.fLon0 = ui->lineEdit_Lon0->text().toDouble();
+    xparam.Lcnt = ui->lineEdit_Lcnt->text().toInt();
+    xparam.Lno = ui->lineEdit_Lno->text().toInt();
+    xparam.fDisLeft = ui->lineEdit_LeftDis->text().toDouble();
+    xparam.fDisRight = ui->lineEdit_RIghtDis->text().toDouble();
+    xparam.fSpan = ui->lineEdit_Span->text().toDouble();
+    if(ui->comboBox_LeftColor->currentText() == "White")
+    {
+        xparam.strColorLeft = "W";
+    }
+    else
+    {
+        xparam.strColorLeft = "Y";
+    }
+    if(ui->comboBox_RIghtColor->currentText() == "White")
+    {
+        xparam.strColorRight = "W";
+    }
+    else
+    {
+        xparam.strColorRight = "Y";
+    }
+    xparam.strtracefilepath = "/home/yuchuli/map/2022-1-14-9-56-44.txt";
+    xparam.stroutfolder = "/home/yuchuli/map/tracevector";
+
+    trace2vectormap xtv(xparam);
+    int nrtn = xtv.convert();
+    if(nrtn == 0)
+    {
+        QMessageBox::information(this,"Info","Convert trace to Autoware VectorMap Successfully.");
+    }
+    else
+    {
+        char strinfo[1000];
+        snprintf(strinfo,1000,"Conver Fail. error code : %d ",nrtn);
+        QMessageBox::warning(this,"Warning",strinfo);
+    }
+}

+ 26 - 0
src/tool/tool_trace2vectormap/mainwindow.h

@@ -0,0 +1,26 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+#include "trace2vectormap.h"
+
+QT_BEGIN_NAMESPACE
+namespace Ui { class MainWindow; }
+QT_END_NAMESPACE
+
+class MainWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    MainWindow(QWidget *parent = nullptr);
+    ~MainWindow();
+
+private slots:
+    void on_pushButton_Convert_clicked();
+
+private:
+    Ui::MainWindow *ui;
+};
+#endif // MAINWINDOW_H

+ 278 - 0
src/tool/tool_trace2vectormap/mainwindow.ui

@@ -0,0 +1,278 @@
+<?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>
+  </property>
+  <widget class="QWidget" name="centralwidget">
+   <widget class="QLabel" name="label">
+    <property name="geometry">
+     <rect>
+      <x>40</x>
+      <y>40</y>
+      <width>101</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Lon0</string>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineEdit_Lon0">
+    <property name="geometry">
+     <rect>
+      <x>160</x>
+      <y>40</y>
+      <width>181</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_2">
+    <property name="geometry">
+     <rect>
+      <x>450</x>
+      <y>40</y>
+      <width>101</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Lat0</string>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineEdit_Lat0">
+    <property name="geometry">
+     <rect>
+      <x>570</x>
+      <y>40</y>
+      <width>181</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_3">
+    <property name="geometry">
+     <rect>
+      <x>30</x>
+      <y>140</y>
+      <width>101</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Left Line:</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_4">
+    <property name="geometry">
+     <rect>
+      <x>190</x>
+      <y>140</y>
+      <width>101</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Dis</string>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineEdit_LeftDis">
+    <property name="geometry">
+     <rect>
+      <x>299</x>
+      <y>140</y>
+      <width>181</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_5">
+    <property name="geometry">
+     <rect>
+      <x>530</x>
+      <y>140</y>
+      <width>101</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Color</string>
+    </property>
+   </widget>
+   <widget class="QComboBox" name="comboBox_LeftColor">
+    <property name="geometry">
+     <rect>
+      <x>640</x>
+      <y>140</y>
+      <width>111</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_6">
+    <property name="geometry">
+     <rect>
+      <x>30</x>
+      <y>210</y>
+      <width>101</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Right Line</string>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineEdit_RIghtDis">
+    <property name="geometry">
+     <rect>
+      <x>299</x>
+      <y>210</y>
+      <width>181</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_7">
+    <property name="geometry">
+     <rect>
+      <x>530</x>
+      <y>210</y>
+      <width>101</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Color</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_8">
+    <property name="geometry">
+     <rect>
+      <x>190</x>
+      <y>210</y>
+      <width>101</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Dis</string>
+    </property>
+   </widget>
+   <widget class="QComboBox" name="comboBox_RIghtColor">
+    <property name="geometry">
+     <rect>
+      <x>640</x>
+      <y>210</y>
+      <width>111</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_9">
+    <property name="geometry">
+     <rect>
+      <x>30</x>
+      <y>330</y>
+      <width>71</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Span</string>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineEdit_Span">
+    <property name="geometry">
+     <rect>
+      <x>95</x>
+      <y>330</y>
+      <width>121</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineEdit_Lcnt">
+    <property name="geometry">
+     <rect>
+      <x>369</x>
+      <y>330</y>
+      <width>121</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_10">
+    <property name="geometry">
+     <rect>
+      <x>300</x>
+      <y>330</y>
+      <width>61</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Lcnt</string>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineEdit_Lno">
+    <property name="geometry">
+     <rect>
+      <x>631</x>
+      <y>330</y>
+      <width>121</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_11">
+    <property name="geometry">
+     <rect>
+      <x>560</x>
+      <y>330</y>
+      <width>61</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Lno</string>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushButton_Convert">
+    <property name="geometry">
+     <rect>
+      <x>290</x>
+      <y>430</y>
+      <width>151</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Convert</string>
+    </property>
+   </widget>
+  </widget>
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>800</width>
+     <height>28</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 39 - 0
src/tool/tool_trace2vectormap/tool_trace2vectormap.pro

@@ -0,0 +1,39 @@
+QT       += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+CONFIG += c++11
+
+# The following define makes your compiler emit warnings if you use
+# any Qt feature that has been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+    ../../common/common/math/gnss_coordinate_convert.cpp \
+    main.cpp \
+    mainwindow.cpp \
+    trace2vectormap.cpp
+
+HEADERS += \
+    ../../common/common/math/gnss_coordinate_convert.h \
+    mainwindow.h \
+    trace2vectormap.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(../../../include/common.pri ) {
+    error( "Couldn't find the common.pri file!" )
+}

+ 270 - 0
src/tool/tool_trace2vectormap/trace2vectormap.cpp

@@ -0,0 +1,270 @@
+#include "trace2vectormap.h"
+
+#include <QFile>
+#include <iostream>
+#include "math/gnss_coordinate_convert.h"
+
+trace2vectormap::trace2vectormap(iv::trace2vectormap_param xparam)
+{
+    mparam = xparam;
+}
+
+void trace2vectormap::llh2xyy(double flon, double flat, double fhead, double & x, double & y, double & fyaw, double flon0, double flat0)
+{
+    double x_o,y_o;
+    double x_now,y_now;
+    GaussProjCal(flon0,flat0,&x_o,&y_o);
+    GaussProjCal(flon,flat,&x_now,&y_now);
+    x = x_now - x_o;
+    y = y_now - y_o;
+    fyaw = (90 - fhead)*M_PI/180.0;
+}
+
+
+
+int trace2vectormap::convert()
+{
+    iv::trace2vectormap_param xparam = mparam;
+    QFile xFile;
+    xFile.setFileName(xparam.strtracefilepath.data());
+    if(!xFile.open(QIODevice::ReadOnly))
+    {
+        return -1;
+    }
+    QByteArray ba = xFile.readAll();
+    QList<QByteArray> baline =ba.split('\n');//x.split(QRegExp("\n ")) ;//ba.split('\n');
+    int nline = baline.size();
+    int i;
+    int npid = 1;
+
+    std::vector<iv::vectormap::point> xvectorpoint;
+    std::vector<iv::vectormap::node> xvectornode;
+    std::vector<iv::vectormap::lane> xvectorlane;
+    std::vector<iv::vectormap::line> xvectorline;
+    std::vector<iv::vectormap::whiteline> xvectorwhiteline;
+
+    for(i=0;i<nline;i++)
+    {
+        QString x(baline[i]);
+//         QList<QByteArray> badata = baline[i].split('\t');
+        QStringList badata = x.split(QRegExp("[\t ,;]"));
+
+        if(badata.size()>=10)
+        {
+            double flon = QString(badata[1]).toDouble();
+            double flat = QString(badata[2]).toDouble();
+            double fheading = QString(badata[5]).toDouble();
+            std::cout<<"lat: "<<flat<<" lon:"<<flon<<" heading:"<<fheading<<std::endl;
+            double x,y,fyaw;
+            llh2xyy(flon,flat,fheading,x,y,fyaw,xparam.fLon0,xparam.fLat0);
+            iv::vectormap::point xpoint;
+            xpoint.pid = npid;
+            xpoint.bx = y;
+            xpoint.ly = x;
+            xpoint.fyaw = fyaw;
+            xpoint.h = 0;
+            npid++;
+            xvectorpoint.push_back(xpoint);
+        }
+    }
+
+    int npointsize = xvectorpoint.size();
+    for(i=0;i<npointsize;i++)
+    {
+        iv::vectormap::node xnode;
+        xnode.nid = i;
+        xnode.pid = xvectorpoint[i].pid;
+        xvectornode.push_back(xnode);
+    }
+
+    int nnodesize = xvectornode.size();
+    for(i=1;i<nnodesize;i++)
+    {
+        iv::vectormap::lane xlane;
+        xlane.bnid = xvectornode[i-1].nid;
+        xlane.fnid = xvectornode[i].nid;
+        xlane.lnid = i;
+        xlane.did = i;
+        xlane.span = xparam.fSpan;
+        xlane.lcnt = xparam.Lcnt;
+        xlane.lno = xparam.Lno;
+        xlane.blid = 0;
+        xlane.flid = 0;
+        xvectorlane.push_back(xlane);
+    }
+
+    int nlanesize = xvectorlane.size();
+    for(i=1;i<nlanesize;i++)
+    {
+        xvectorlane[i-1].flid = xvectorlane[i].lnid;
+        xvectorlane[i].blid = xvectorlane[i-1].lnid;
+    }
+
+    for(i=0;i<npointsize;i++)
+    {
+       iv::vectormap::point xpoint;
+       xpoint = xvectorpoint[i];
+       xpoint.bx = xpoint.bx + xparam.fDisLeft * sin(xpoint.fyaw + M_PI/2.0);
+       xpoint.ly = xpoint.ly + xparam.fDisLeft * cos(xpoint.fyaw + M_PI/2.0);
+       xpoint.pid = npid;
+       npid++;
+       xvectorpoint.push_back(xpoint);
+    }
+
+    for(i=0;i<npointsize;i++)
+    {
+       iv::vectormap::point xpoint;
+       xpoint = xvectorpoint[i];
+       xpoint.bx = xpoint.bx + xparam.fDisLeft * sin(xpoint.fyaw - M_PI/2.0);
+       xpoint.ly = xpoint.ly + xparam.fDisLeft * cos(xpoint.fyaw - M_PI/2.0);
+       xpoint.pid = npid;
+       npid++;
+       xvectorpoint.push_back(xpoint);
+    }
+
+
+    int nnowwhiteid = 1;
+    for(i=1;i<npointsize;i++)
+    {
+        iv::vectormap::line xline;
+        xline.lid = i;
+        xline.bpid = xvectorpoint[i-1+npointsize].pid;
+        xline.fpid = xvectorpoint[i+npointsize].pid;
+        xline.blid = 0;
+        xline.flid = 0;
+        xvectorline.push_back(xline);
+        iv::vectormap::whiteline xwhiteline;
+        xwhiteline.id = nnowwhiteid;nnowwhiteid++;
+        xwhiteline.fwidth = 0.15;
+        xwhiteline.strcorlor = xparam.strColorLeft;
+        xwhiteline.lid = xline.lid;
+        xvectorwhiteline.push_back(xwhiteline);
+    }
+
+    for(i=1;i<(npointsize -1);i++)
+    {
+        xvectorline[i-1].flid = xvectorline[i].lid;
+        xvectorline[i].blid = xvectorline[i-1].lid;
+    }
+
+    for(i=1;i<npointsize;i++)
+    {
+        iv::vectormap::line xline;
+        xline.lid = i + (npointsize-1);
+        xline.bpid = xvectorpoint[i-1+npointsize*2].pid;
+        xline.fpid = xvectorpoint[i+npointsize*2].pid;
+        xline.blid = 0;
+        xline.flid = 0;
+        xvectorline.push_back(xline);
+        iv::vectormap::whiteline xwhiteline;
+        xwhiteline.id = nnowwhiteid;nnowwhiteid++;
+        xwhiteline.lid = xline.lid;
+        xwhiteline.fwidth = 0.15;
+        xwhiteline.strcorlor = xparam.strColorRight;
+        xvectorwhiteline.push_back(xwhiteline);
+    }
+
+    for(i=1;i<(npointsize -1);i++)
+    {
+        xvectorline[i-1 + npointsize-1].flid = xvectorline[i + npointsize -1].lid;
+        xvectorline[i + npointsize-1].blid = xvectorline[i-1 + npointsize -1].lid;
+    }
+
+    QString strfolder = xparam.stroutfolder.data();
+    QFile xFilePoints;
+    xFilePoints.setFileName(strfolder + "/point.csv");
+    if(!xFilePoints.open(QIODevice::ReadWrite))
+    {
+        qDebug("point file open fail.");
+        return -2;
+    }
+    char strline[1000];
+    snprintf(strline,1000,"PID,B,L,H,Bx,Ly,ReF,MCODE1,MCODE2,MCODE3\n");
+    xFilePoints.write(strline);
+    for(i=0;i<(int)xvectorpoint.size();i++)
+    {
+        snprintf(strline,1000,"%d,%d,%d,%f,%f,%f,%d,%d,%d,%d\n",
+                 xvectorpoint[i].pid,0,0,0.0,xvectorpoint[i].bx,xvectorpoint[i].ly,7,0,0,0);
+        xFilePoints.write(strline);
+    }
+    xFilePoints.close();
+
+    QFile xFileLine;
+    xFileLine.setFileName(strfolder + "/line.csv");
+    if(!xFileLine.open(QIODevice::ReadWrite))
+    {
+        qDebug("line file open fail.");
+        return -3;
+    }
+    snprintf(strline,1000,"LID,BPID,FPID,BLID,FLID\n");
+    xFileLine.write(strline);
+    int nlinesize = xvectorline.size();
+    for(i=0;i<nlinesize;i++)
+    {
+        snprintf(strline,1000,"%d,%d,%d,%d,%d\n",
+                 xvectorline[i].lid,xvectorline[i].bpid,xvectorline[i].fpid,
+                 xvectorline[i].blid,xvectorline[i].flid);
+        xFileLine.write(strline);
+    }
+    xFileLine.close();
+
+    QFile xFileWhiteLine;
+    xFileWhiteLine.setFileName(strfolder + "/whiteline.csv");
+    if(!xFileWhiteLine.open(QIODevice::ReadWrite))
+    {
+        qDebug("whiteline file open fail.");
+        return -4;
+    }
+
+    snprintf(strline,1000,"ID,LID,Width,Color,type,LinkID\n");
+    xFileWhiteLine.write(strline);
+    int nwhitelinesize = xvectorwhiteline.size();
+    for(i=0;i<nwhitelinesize;i++)
+    {
+        snprintf(strline,1000,"%d,%d,%f,%s,%d,%d\n",
+                 xvectorwhiteline[i].id,xvectorwhiteline[i].lid,0.15,xvectorwhiteline[i].strcorlor.data(),0,0);
+        xFileWhiteLine.write(strline);
+    }
+    xFileWhiteLine.close();
+
+    QFile xFileNode;
+    xFileNode.setFileName(strfolder + "/node.csv");
+    if(!xFileNode.open(QIODevice::ReadWrite))
+    {
+        qDebug(" node file open fail.");
+        return -5;
+    }
+    snprintf(strline,1000,"NID,PID\n");
+    xFileNode.write(strline);
+    for(i=0;i<(int)xvectornode.size();i++)
+    {
+        snprintf(strline,1000,"%d,%d\n",xvectornode[i].nid,xvectornode[i].pid);
+        xFileNode.write(strline);
+    }
+    xFileNode.close();
+
+    QFile xFileLane;
+    xFileLane.setFileName(strfolder + "/lane.csv");
+    if(!xFileLane.open(QIODevice::ReadWrite))
+    {
+        qDebug(" node file open fail.");
+        return -6;
+    }
+    snprintf(strline,1000,"LnID,DID,BLID,FLID,BNID,FNID,JCT,BLID2,BLID3,BLID4,FLID2,FLID3,FLID4,ClossID,Span,LCnt,Lno,LaneType,LimitVel,RefVel,RoadSecID,LaneChgFG\n");
+    xFileLane.write(strline);
+
+    for(i=0;i<(int)xvectorlane.size();i++)
+    {
+        snprintf(strline,1000,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
+                 xvectorlane[i].lnid,xvectorlane[i].did,xvectorlane[i].blid,
+                 xvectorlane[i].flid,xvectorlane[i].bnid,xvectorlane[i].fnid,
+                 0,0,0,0,
+                 0,0,0,0,
+                 1,xvectorlane[i].lcnt,xvectorlane[i].lno,0,
+                 20,20,0,0);
+        xFileLane.write(strline);
+    }
+    xFileLane.close();
+
+    return 0;
+}

+ 86 - 0
src/tool/tool_trace2vectormap/trace2vectormap.h

@@ -0,0 +1,86 @@
+#ifndef TRACE2VECTORMAP_H
+#define TRACE2VECTORMAP_H
+
+#include <string>
+
+namespace iv {
+struct trace2vectormap_param
+{
+    std::string strtracefilepath;
+    std::string stroutfolder;
+    double fLon0;
+    double fLat0;
+    int Lcnt;
+    int Lno;
+    double fSpan;
+    double fDisLeft;
+    double fDisRight;
+    std::string strColorLeft;
+    std::string strColorRight;
+};
+
+namespace vectormap {
+struct node
+{
+    int nid;
+    int pid;
+};
+
+struct point
+{
+    int pid;
+    double h;
+    double bx;
+    double ly;
+    double fyaw;
+};
+
+struct line
+{
+    int lid;
+    int bpid;
+    int fpid;
+    int blid;
+    int flid;
+};
+
+struct whiteline
+{
+    int id;
+    int lid;
+    double fwidth;
+    std::string strcorlor;
+};
+//LnID,DID,BLID,FLID,BNID,FNID,JCT,BLID2,BLID3,BLID4,FLID2,FLID3,FLID4,ClossID,Span,LCnt,Lno,LaneType,LimitVel,RefVel,RoadSecID,LaneChgFG
+struct lane
+{
+    int lnid;
+    int did;
+    int blid;
+    int flid;
+    int bnid;
+    int fnid;
+    double span;
+    int lcnt;
+    int lno;
+};
+
+}
+
+
+}
+
+class trace2vectormap
+{
+public:
+    trace2vectormap(iv::trace2vectormap_param xparam);
+
+private:
+    iv::trace2vectormap_param mparam;
+
+public:
+    int convert();
+    void llh2xyy(double flon,double flat,double fhead,double & x,double & y,double & fyaw,double flon0,double flat0);
+};
+
+#endif // TRACE2VECTORMAP_H