123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #include "dialogcalcs.h"
- #include "ui_dialogcalcs.h"
- #include "xodrfunc.h"
- #include "gnss_coordinate_convert.h"
- DialogCalcS::DialogCalcS(OpenDrive * pxodr,double xlon0,double xlat0, QWidget *parent) :
- QDialog(parent),
- ui(new Ui::DialogCalcS)
- {
- ui->setupUi(this);
- mpxodr = pxodr;
- mlon0 = xlon0;
- mlat0 = xlat0;
- setWindowTitle("Calculate S in Road");
- }
- DialogCalcS::~DialogCalcS()
- {
- delete ui;
- }
- void DialogCalcS::on_pushButton_Calculate_clicked()
- {
- double flon = ui->lineEdit_Lon->text().toDouble();
- double flat = ui->lineEdit_Lat->text().toDouble();
- double x0,y0;
- GaussProjCal(mlon0,mlat0,&x0,&y0);
- double x,y;
- GaussProjCal(flon,flat,&x,&y);
- double rel_x,rel_y;
- rel_x = x - x0;
- rel_y = y - y0;
- Road * pRoad = 0;
- GeometryBlock * pgeob;
- double fdis,nearx,neary,hdg;
- double fs;
- int nlane;
- if(xodrfunc::GetNearPoint(rel_x,rel_y,mpxodr,&pRoad,&pgeob,fdis,nearx,neary,hdg,50,&fs,&nlane) == 0)
- {
- char strout[256];
- snprintf(strout,256,"Road %s S:%f",pRoad->GetRoadId().data(),fs);
- ui->lineEdit_Res->setText(strout);
- }
- else
- {
- ui->lineEdit_Res->setText("not found");
- }
- }
|