No Description

gispoi.h 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #ifndef GISPOI_H
  2. #define GISPOI_H
  3. #include <QString>
  4. #include <iostream>
  5. #include <QDebug>
  6. #include <cmath>
  7. #include <QPointF>
  8. using namespace std;
  9. const double EARTH_RADIUS = 6372.8;
  10. const double TWOPI = 2 * acos(-1);
  11. ///
  12. /// \brief deg2rad
  13. /// \~English
  14. /// \param deg angle in degrees
  15. /// \return angle in radians
  16. /// \~Spanish
  17. /// \param deg ángulo en grados
  18. /// \return angle ángulo en radianes
  19. ///
  20. inline double deg2rad(double deg) {
  21. return deg/360.0 * TWOPI;
  22. }
  23. ///
  24. /// \brief This class is for representing GIS points of interests.
  25. ///
  26. class GISPOI {
  27. private:
  28. QString name;
  29. double lat, lon;
  30. public:
  31. /// \fn GISPOI()
  32. /// \~English
  33. /// \brief default constructor
  34. /// \~Spanish
  35. /// \brief constructor por defecto
  36. ///
  37. GISPOI(){};
  38. /// \fn GISPOI(const QString &s, double latitude, double longitude)
  39. /// \~English
  40. /// \brief constructor that sets all the data members.
  41. /// \~Spanish
  42. /// \brief constructor que asigna valores a los miembros de data.
  43. ///
  44. GISPOI(const QString &s, double latitude, double longitude)
  45. {name = s; lat = latitude; lon = longitude;}
  46. /// \fn double getLat()
  47. /// \~English
  48. /// \brief getter for the latitude
  49. /// \return the latitude value
  50. /// \~Spanish
  51. /// \brief "getter" para el valor de latitud
  52. /// \return el valor de la latitud
  53. ///
  54. double getLat() const {return lat;}
  55. /// \fn double getLon()
  56. /// \~English
  57. /// \brief getter for the longitude
  58. /// \return the longitude value
  59. /// \~Spanish
  60. /// \brief "getter" para el valor de longitud
  61. /// \return el valor de la longitud
  62. ///
  63. double getLon() const {return lon;}
  64. /// \fn QString getName()
  65. /// \~English
  66. /// \brief getter for the name
  67. /// \return a copy of the name
  68. /// \~Spanish
  69. /// \brief "getter" para el nombre
  70. /// \return una copia del nombre
  71. ///
  72. QString getName() const {return name;}
  73. /// \fn setAll(const QString &s, double latitude, double longitude)
  74. /// \~English
  75. /// \brief setter for all data members
  76. /// \~Spanish
  77. /// \brief "setter" para todos los miembros de datos
  78. ///
  79. void setAll(QString s, double latitude, double longitude)
  80. {name = s; lat = latitude; lon = longitude;}
  81. /// \fn setAll(const string &s, double latitude, double longitude)
  82. /// \~English
  83. /// \brief setter for all data members
  84. /// \~Spanish
  85. /// \brief "setter" para todos los miembros de datos
  86. ///
  87. void setAll(string s, double latitude, double longitude)
  88. {name = QString::fromStdString(s); lat = latitude; lon = longitude;}
  89. /// \fn print()
  90. /// \~English
  91. /// \brief a utility function to print the data members
  92. /// \~Spanish
  93. /// \brief imprime los valores de los miembros de datos
  94. ///
  95. void print() {
  96. qDebug() << name << " " << lat << " "
  97. << lon << endl;
  98. }
  99. /// \fn print()
  100. /// \~English
  101. /// \brief Given two objects A and B of class GISPOI, uses their
  102. /// longitudes and latitudes to compute and return their orthodromic
  103. /// distance in kilometers.
  104. /// \returns orthodromic distance in kilometers
  105. /// \~Spanish
  106. /// \brief Dados dos objetos A y B de clase GISPOI, usa sus
  107. /// longitudes and latitudes para determinar y devolver distancia
  108. /// ortodrómica en kilómetros.
  109. /// \returns distancia ortodrómica en kilómetros
  110. ///
  111. double odDistance(const GISPOI &B) const;
  112. };
  113. #endif // GISPOI_H