|
@@ -96,24 +96,24 @@ void DialogParkingSpaceFromRTK::on_pushButton_LoadData_clicked()
|
|
mvectorrtkdata = xvectorrtkdata;
|
|
mvectorrtkdata = xvectorrtkdata;
|
|
|
|
|
|
unsigned int nsize = mvectorrtkdata.size();
|
|
unsigned int nsize = mvectorrtkdata.size();
|
|
- ui->comboBox_Center_From->clear();
|
|
|
|
- ui->comboBox_Center_To->clear();
|
|
|
|
- ui->comboBox_Heading_From->clear();
|
|
|
|
- ui->comboBox_Heading_To->clear();
|
|
|
|
|
|
+ ui->comboBox_LeftUp->clear();
|
|
|
|
+ ui->comboBox_LeftDown->clear();
|
|
|
|
+ ui->comboBox_RightUp->clear();
|
|
|
|
+ ui->comboBox_RightDown->clear();
|
|
if(nsize >= 3)
|
|
if(nsize >= 3)
|
|
{
|
|
{
|
|
unsigned int i;
|
|
unsigned int i;
|
|
for(i=0;i<nsize;i++)
|
|
for(i=0;i<nsize;i++)
|
|
{
|
|
{
|
|
- ui->comboBox_Heading_From->addItem(QString::number(i));
|
|
|
|
- ui->comboBox_Heading_To->addItem(QString::number(i));
|
|
|
|
- ui->comboBox_Center_From->addItem(QString::number(i));
|
|
|
|
- ui->comboBox_Center_To->addItem(QString::number(i));
|
|
|
|
|
|
+ ui->comboBox_LeftUp->addItem(QString::number(i));
|
|
|
|
+ ui->comboBox_LeftDown->addItem(QString::number(i));
|
|
|
|
+ ui->comboBox_RightUp->addItem(QString::number(i));
|
|
|
|
+ ui->comboBox_RightDown->addItem(QString::number(i));
|
|
}
|
|
}
|
|
- ui->comboBox_Heading_From->setCurrentIndex(1);
|
|
|
|
- ui->comboBox_Heading_To->setCurrentIndex(0);
|
|
|
|
- ui->comboBox_Center_From->setCurrentIndex(0);
|
|
|
|
- ui->comboBox_Center_To->setCurrentIndex(2);
|
|
|
|
|
|
+ ui->comboBox_LeftUp->setCurrentIndex(0);
|
|
|
|
+ ui->comboBox_LeftDown->setCurrentIndex(1);
|
|
|
|
+ ui->comboBox_RightUp->setCurrentIndex(3);
|
|
|
|
+ ui->comboBox_RightDown->setCurrentIndex(2);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -121,28 +121,79 @@ void DialogParkingSpaceFromRTK::on_pushButton_LoadData_clicked()
|
|
|
|
|
|
void DialogParkingSpaceFromRTK::on_pushButton_Create_clicked()
|
|
void DialogParkingSpaceFromRTK::on_pushButton_Create_clicked()
|
|
{
|
|
{
|
|
|
|
+ Road * pRoad = mpRoad;
|
|
if(mvectorrtkdata.size()<3)
|
|
if(mvectorrtkdata.size()<3)
|
|
{
|
|
{
|
|
QMessageBox::warning(this,"Warning","At Least 3 Points.",QMessageBox::YesAll);
|
|
QMessageBox::warning(this,"Warning","At Least 3 Points.",QMessageBox::YesAll);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- int nHeadingFrom = ui->comboBox_Heading_From->currentIndex();
|
|
|
|
- int nHeadingTo = ui->comboBox_Heading_To->currentIndex();
|
|
|
|
- int nCenterFrom = ui->comboBox_Center_From->currentIndex();
|
|
|
|
- int nCenterTo = ui->comboBox_Center_To->currentIndex();
|
|
|
|
|
|
+ int nLeftDown = ui->comboBox_LeftDown->currentIndex();
|
|
|
|
+ int nLeftUp = ui->comboBox_LeftUp->currentIndex();
|
|
|
|
+ int nRightUp = ui->comboBox_RightUp->currentIndex();
|
|
|
|
+ int nRightDown = ui->comboBox_RightDown->currentIndex();
|
|
|
|
|
|
- double fHdg = xodrfunc::CalcHdg(QPointF(mvectorrtkdata[nHeadingFrom].mfrelx,mvectorrtkdata[nHeadingFrom].mfrely),
|
|
|
|
- QPointF(mvectorrtkdata[nHeadingTo].mfrelx,mvectorrtkdata[nHeadingTo].mfrely));
|
|
|
|
|
|
+ double fHdg = xodrfunc::CalcHdg(QPointF(mvectorrtkdata[nLeftDown].mfrelx,mvectorrtkdata[nLeftDown].mfrely),
|
|
|
|
+ QPointF(mvectorrtkdata[nLeftUp].mfrelx,mvectorrtkdata[nLeftUp].mfrely));
|
|
|
|
|
|
double fCenter_x,fCenter_y;
|
|
double fCenter_x,fCenter_y;
|
|
- fCenter_x = (mvectorrtkdata[nCenterFrom].mfrelx + mvectorrtkdata[nCenterTo].mfrelx)/2.0;
|
|
|
|
- fCenter_y = (mvectorrtkdata[nCenterFrom].mfrely + mvectorrtkdata[nCenterTo].mfrely)/2.0;
|
|
|
|
|
|
+ fCenter_x = (mvectorrtkdata[nLeftUp].mfrelx + mvectorrtkdata[nRightDown].mfrelx)/2.0;
|
|
|
|
+ fCenter_y = (mvectorrtkdata[nLeftUp].mfrely + mvectorrtkdata[nRightDown].mfrely)/2.0;
|
|
|
|
+
|
|
|
|
+ double fLen = sqrt(pow(mvectorrtkdata[nLeftUp].mfrelx - mvectorrtkdata[nLeftDown].mfrelx,2)
|
|
|
|
+ +pow(mvectorrtkdata[nLeftUp].mfrely - mvectorrtkdata[nLeftDown].mfrely,2));
|
|
|
|
+ double fWidth = sqrt(pow(mvectorrtkdata[nLeftDown].mfrelx - mvectorrtkdata[nRightDown].mfrelx ,2)
|
|
|
|
+ +pow(mvectorrtkdata[nLeftDown].mfrely - mvectorrtkdata[nRightDown].mfrely,2));
|
|
|
|
+
|
|
|
|
+ double fnears = 0;
|
|
|
|
+ double froadx,froady,froadhdg;
|
|
|
|
+ pRoad->GetGeometryCoords(0,froadx,froady,froadhdg);
|
|
|
|
+ double fx,fy,fh,fs;
|
|
|
|
+ fx = froadx;
|
|
|
|
+ fy = froady;
|
|
|
|
+ fh = froadhdg;
|
|
|
|
+ fs = 0;
|
|
|
|
+ double fneart = sqrt(pow(froadx - fCenter_x,2) + pow(froady - fCenter_y,2));
|
|
|
|
+ double s = 0;
|
|
|
|
+ double sstep = 0.1;
|
|
|
|
+ s = s+ sstep;
|
|
|
|
+ while(s<pRoad->GetRoadLength())
|
|
|
|
+ {
|
|
|
|
+ if(pRoad->GetGeometryCoords(s,froadx,froady,froadhdg) >= 0)
|
|
|
|
+ {
|
|
|
|
+ double fdis = sqrt(pow(froadx - fCenter_x,2) + pow(froady - fCenter_y,2));
|
|
|
|
+ if(fdis<fneart)
|
|
|
|
+ {
|
|
|
|
+ fneart = fdis;
|
|
|
|
+ fx = froadx;
|
|
|
|
+ fy = froady;
|
|
|
|
+ fh = froadhdg;
|
|
|
|
+ fs = s;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ std::cout<<"DialogParkingSpaceFromRTK::on_pushButton_Create_clicked"<<" GetGeometryCoords error. s "
|
|
|
|
+ <<s<<" Road id:"<<pRoad->GetRoadId()<<" len:"<<pRoad->GetRoadLength()<<std::endl;
|
|
|
|
+ }
|
|
|
|
+ s= s+sstep;
|
|
|
|
+ }
|
|
|
|
|
|
- double fLen = sqrt(pow(mvectorrtkdata[nHeadingFrom].mfrelx - mvectorrtkdata[nHeadingTo].mfrelx,2)
|
|
|
|
- +pow(mvectorrtkdata[nHeadingFrom].mfrely - mvectorrtkdata[nHeadingTo].mfrely,2));
|
|
|
|
- double fWidth = sqrt(pow(mvectorrtkdata[nHeadingFrom].mfrelx - mvectorrtkdata[nCenterTo].mfrelx ,2)
|
|
|
|
- +pow(mvectorrtkdata[nHeadingFrom].mfrely - mvectorrtkdata[nCenterTo].mfrely,2));
|
|
|
|
|
|
+ if(fneart > 0)
|
|
|
|
+ {
|
|
|
|
+ double fhdg2 = xodrfunc::CalcHdg(QPointF(fx,fy),QPointF(fCenter_x,fCenter_y));
|
|
|
|
+ double fhdgdiff = fhdg2 - fh;
|
|
|
|
+ while(fhdgdiff<0)fhdgdiff = fhdgdiff + 2.0*M_PI;
|
|
|
|
+ while(fhdgdiff >= 2.0*M_PI)fhdgdiff = fhdgdiff - 2.0*M_PI;
|
|
|
|
+ if(fhdgdiff > M_PI)fneart = fneart * (-1);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ pRoad->AddObject("0",fs,fneart,0);
|
|
|
|
+ Object * pObj = pRoad->GetLastAddedObject();
|
|
|
|
+ pObj->Settype("parkingSpace");
|
|
|
|
+ pObj->Sethdg(fHdg);
|
|
|
|
+ pObj->Setlength(fLen);
|
|
|
|
+ pObj->Setwidth(fWidth);
|
|
|
|
|
|
qDebug("fhdg:%f flen:%f fwidth:%f",fHdg,fLen,fWidth);
|
|
qDebug("fhdg:%f flen:%f fwidth:%f",fHdg,fLen,fWidth);
|
|
}
|
|
}
|