calc.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. *openPilot Log - A FOSS Pilot Logbook Application
  3. *Copyright (C) 2020 Felix Turowsky
  4. *
  5. *This program is free software: you can redistribute it and/or modify
  6. *it under the terms of the GNU General Public License as published by
  7. *the Free Software Foundation, either version 3 of the License, or
  8. *(at your option) any later version.
  9. *
  10. *This program is distributed in the hope that it will be useful,
  11. *but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. *GNU General Public License for more details.
  14. *
  15. *You should have received a copy of the GNU General Public License
  16. *along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. #ifndef CALC_H
  19. #define CALC_H
  20. #include "dbairport.h"
  21. #include <QDateTime>
  22. #include <cmath>
  23. #include <QDebug>
  24. /*!
  25. * \brief The calc class provides functionality for various calculations that are performed
  26. * outside of the database. This includes tasks like converting different units and formats,
  27. * or functions calculating block time or night time.
  28. */
  29. class calc
  30. {
  31. public:
  32. static QTime blocktime(QTime tofb, QTime tonb);
  33. static QString minutes_to_string(QString blockminutes);
  34. static int string_to_minutes(QString time);
  35. static int time_to_minutes(QTime time);
  36. static double radToDeg(double rad);
  37. static double degToRad(double deg);
  38. static double radToNauticalMiles(double rad);
  39. static double greatCircleDistance(double lat1, double lon1, double lat2, double lon2);
  40. static double greatCircleDistanceBetweenAirports(QString dept, QString dest);
  41. static QVector<QVector<double>> intermediatePointsOnGreatCircle(double lat1,
  42. double lon1,
  43. double lat2,
  44. double lon2,
  45. int tblk);
  46. static double solarElevation(QDateTime utc_time_point, double lat, double lon);
  47. static int calculateNightTime(QString dept, QString dest, QDateTime departureTime, int tblk);
  48. static QString formatTimeInput(QString userinput);
  49. };
  50. #endif // CALC_H