dialogcalcs.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "dialogcalcs.h"
  2. #include "ui_dialogcalcs.h"
  3. #include "xodrfunc.h"
  4. #include "gnss_coordinate_convert.h"
  5. DialogCalcS::DialogCalcS(OpenDrive * pxodr,double xlon0,double xlat0, QWidget *parent) :
  6. QDialog(parent),
  7. ui(new Ui::DialogCalcS)
  8. {
  9. ui->setupUi(this);
  10. mpxodr = pxodr;
  11. mlon0 = xlon0;
  12. mlat0 = xlat0;
  13. setWindowTitle("Calculate S in Road");
  14. }
  15. DialogCalcS::~DialogCalcS()
  16. {
  17. delete ui;
  18. }
  19. void DialogCalcS::on_pushButton_Calculate_clicked()
  20. {
  21. double flon = ui->lineEdit_Lon->text().toDouble();
  22. double flat = ui->lineEdit_Lat->text().toDouble();
  23. double x0,y0;
  24. GaussProjCal(mlon0,mlat0,&x0,&y0);
  25. double x,y;
  26. GaussProjCal(flon,flat,&x,&y);
  27. double rel_x,rel_y;
  28. rel_x = x - x0;
  29. rel_y = y - y0;
  30. Road * pRoad = 0;
  31. GeometryBlock * pgeob;
  32. double fdis,nearx,neary,hdg;
  33. double fs;
  34. int nlane;
  35. if(xodrfunc::GetNearPoint(rel_x,rel_y,mpxodr,&pRoad,&pgeob,fdis,nearx,neary,hdg,50,&fs,&nlane) == 0)
  36. {
  37. char strout[256];
  38. snprintf(strout,256,"Road %s S:%f",pRoad->GetRoadId().data(),fs);
  39. ui->lineEdit_Res->setText(strout);
  40. }
  41. else
  42. {
  43. ui->lineEdit_Res->setText("not found");
  44. }
  45. }