123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- //#if 0
- #include "csv2buffer.h"
- #include "buffer.cpp"
- #define BUFFSIZE 100 // size of buffers
- void ultdata(Buffer<UltParkinglots> &buffer,QString &filePath)
- {
- // QString filePath = QDir::currentPath() + "/../data/UltParkinglots.csv";
- QList<QStringList> readData = QtCSV::Reader::readToList(filePath);
- unsigned dataIndex = 0;
- for(unsigned i = 0; i<BUFFSIZE; i++)
- {
- //qDebug() << readData.at(i).join(",");
- UltParkinglots ults;
- UltParkinglot ult;
- QStringList rowData = readData.at(dataIndex);
- unsigned j = rowData[0].toInt();
- ult.id = rowData[0].toInt();
- ult.low_time_stamp = rowData[1].toInt();
- ult.high_time_stamp = rowData[2].toInt();
- ult.valid_state = rowData[3].toInt();
- ult.park_type = rowData[4].toInt();
- ult.confidence = rowData[5].toDouble();
- ult.valid_state = rowData[6].toDouble();
- ult.park_length = rowData[7].toDouble();
- ult.park_width = rowData[8].toDouble();
- ult.park_direction = rowData[9].toDouble();
- Corners parkingPoints;
- parkingPoints.corners[0] = Point(rowData[10].toDouble(),rowData[11].toDouble());
- parkingPoints.corners[1] = Point(rowData[12].toDouble(),rowData[13].toDouble());
- parkingPoints.corners[2] = Point(rowData[14].toDouble(),rowData[15].toDouble());
- parkingPoints.corners[3] = Point(rowData[16].toDouble(),rowData[17].toDouble());
- ult.ParkingPoints = parkingPoints;
- ults.push_back(ult);
- j++;
- dataIndex ++;
- rowData = readData.at(dataIndex);
- j = rowData[0].toInt();
- //qDebug() <<"角点"<< ult.ParkingPoints.corners[0].x;
- while(j!=0)
- {
- //qDebug() << "进入while循环 ";
- // qDebug() << "while循环中的j "<<j;
- ult.id = rowData[0].toInt();
- ult.low_time_stamp = rowData[1].toInt();
- ult.high_time_stamp = rowData[2].toInt();
- ult.valid_state = rowData[3].toInt();
- ult.park_type = rowData[4].toInt();
- ult.confidence = rowData[5].toDouble();
- ult.valid_state = rowData[6].toDouble();
- ult.park_length = rowData[7].toDouble();
- ult.park_width = rowData[8].toDouble();
- ult.park_direction = rowData[9].toDouble();
- Corners parkingPoints;
- parkingPoints.corners[0] = Point(rowData[10].toDouble(),rowData[11].toDouble());
- parkingPoints.corners[1] = Point(rowData[12].toDouble(),rowData[13].toDouble());
- parkingPoints.corners[2] = Point(rowData[14].toDouble(),rowData[15].toDouble());
- parkingPoints.corners[3] = Point(rowData[16].toDouble(),rowData[17].toDouble());
- ult.ParkingPoints = parkingPoints;
- ults.push_back(ult);
- dataIndex++;
- rowData = readData.at(dataIndex);
- j = rowData[0].toInt();
- //qDebug() <<"while尾部j的值:"<< j;
- }
- buffer.add(ults);
- }
- //qDebug() << readData.size();
- }
- void surdata(Buffer<SurViewParkinglots> &buffer,QString &filePath)
- {
- QList<QStringList> readData =
- QtCSV::Reader::readToList(filePath);
- unsigned dataIndex = 0;
- for(unsigned i = 0; i<BUFFSIZE; i++)
- {
- // qDebug() << readData.at(i).join(",");
- SurViewParkinglots survs;
- SurViewParkinglot surv;
- QStringList rowData = readData.at(dataIndex);
- unsigned j = rowData[0].toInt();
- surv.id = rowData[0].toInt();
- surv.low_time_stamp = rowData[1].toInt();
- surv.high_time_stamp = rowData[2].toInt();
- surv.valid_state = rowData[3].toInt();
- surv.park_type = rowData[4].toInt();
- surv.confidence = rowData[5].toDouble();
- //qDebug() << surv.confidence;
- surv.park_length = rowData[6].toDouble();
- surv.park_width = rowData[7].toDouble();
- surv.park_direction = rowData[8].toDouble();
- Corners parkingPoints;
- parkingPoints.corners[0] = Point(rowData[9].toDouble(),rowData[10].toDouble());
- parkingPoints.corners[1] = Point(rowData[11].toDouble(),rowData[12].toDouble());
- parkingPoints.corners[2] = Point(rowData[13].toDouble(),rowData[14].toDouble());
- parkingPoints.corners[3] = Point(rowData[15].toDouble(),rowData[16].toDouble());
- surv.ParkingPoints = parkingPoints;
- survs.push_back(surv);
- j++;
- dataIndex++;
- rowData = readData.at(dataIndex);
- j = rowData[0].toInt();
- //qDebug() << j;
- while(j!=0)
- {
- //qDebug() << "进入while循环 ";
- surv.id = rowData[0].toInt();
- surv.low_time_stamp = rowData[1].toInt();
- surv.high_time_stamp = rowData[2].toInt();
- surv.valid_state = rowData[3].toInt();
- surv.park_type = rowData[4].toInt();
- surv.confidence = rowData[5].toDouble();
- surv.park_length = rowData[6].toDouble();
- surv.park_width = rowData[7].toDouble();
- surv.park_direction = rowData[8].toDouble();
- Corners parkingPoints;
- parkingPoints.corners[0] = Point(rowData[9].toDouble(),rowData[10].toDouble());
- parkingPoints.corners[1] = Point(rowData[11].toDouble(),rowData[12].toDouble());
- parkingPoints.corners[2] = Point(rowData[13].toDouble(),rowData[14].toDouble());
- parkingPoints.corners[3] = Point(rowData[15].toDouble(),rowData[16].toDouble());
- surv.ParkingPoints = parkingPoints;
- survs.push_back(surv);
- dataIndex++;
- rowData = readData.at(dataIndex);
- j = rowData[0].toInt();
- //qDebug() << "while循环结束 "<<j;
- }
- buffer.add(survs);
- }
- //qDebug() << readData.size();
- }
- void cardata(Buffer<CarState> &buffer, QString &filePath)
- {
- QList<QStringList> readData =
- QtCSV::Reader::readToList(filePath);
- unsigned dataIndex = 0;
- for(unsigned i = 0; i<BUFFSIZE; i++)
- {
- CarState carState;
- // SurViewParkinglots survs;
- // SurViewParkinglot surv;
- // QStringList rowData = readData.at(dataIndex);
- // unsigned j = rowData[0].toInt();
- // surv.id = rowData[0].toInt(.);
- QStringList rowData = readData.at(dataIndex);
- carState.x = rowData[0].toDouble();
- carState.y = rowData[1].toDouble();
- carState.speed = rowData[2].toDouble();
- carState.ins_heading_angle = rowData[3].toDouble();
- buffer.add(carState);
- dataIndex++;
- if(dataIndex>=readData.size())
- {
- break;
- }
- // qDebug() << readData.size();
- }
- }
- void obsdata(Buffer<Obstacles> &buffer, QString &filePath){
- QList<QStringList> readData =
- QtCSV::Reader::readToList(filePath);
- unsigned dataIndex = 0;
- for(unsigned i = 0; i<BUFFSIZE; i++){
- Obstacles obstacles;
- Obstacle obstacle;
- bool br = false;
- for(unsigned j = 0; j<3; j++){
- QStringList rowData = readData.at(dataIndex);
- obstacle.id = rowData[0].toInt();
- obstacle.type = rowData[1].toInt();
- obstacle.state = rowData[2].toInt();
- obstacle.confidence = rowData[3].toDouble();
- obstacle.valid_time = rowData[4].toDouble();
- obstacle.pos_x = rowData[5].toDouble();
- obstacle.pos_y = rowData[6].toDouble();
- obstacle.length = rowData[7].toDouble();
- obstacle.width = rowData[8].toDouble();
- obstacle.height = rowData[9].toDouble();
- obstacle.rel_speed_x = rowData[10].toDouble();
- obstacle.rel_speed_y = rowData[11].toDouble();
- obstacle.abs_speed_x = rowData[12].toDouble();
- obstacle.abs_speed_y = rowData[13].toDouble();
- obstacle.heading = rowData[14].toDouble();
- obstacles.push_back(obstacle);
- dataIndex++;
- if(dataIndex >= readData.size()){
- br = true;
- break;
- }
- }
- buffer.add(obstacles);
- if(br){
- break;
- }
- }
- }
|