Browse Source

Documenting doxygen style. Removed census.h and census.cpp

Director Ciencia de Computos 9 years ago
parent
commit
d8892ba2e8
6 changed files with 157 additions and 91 deletions
  1. 0
    49
      census.cpp
  2. 0
    19
      census.h
  3. 1
    4
      country.cpp
  4. 48
    6
      country.h
  5. 17
    3
      doublepoint.h
  6. 91
    10
      gispoi.h

+ 0
- 49
census.cpp View File

@@ -1,49 +0,0 @@
1
-#include "census.h"
2
-#include <QFile>
3
-#include <QJsonDocument>
4
-#include <QJsonArray>
5
-#include <QJsonObject>
6
-#include <qDebug>
7
-
8
-
9
-///
10
-/// \brief
11
-/// Census::readDataFromFile - Populates the Census object with data from a file.
12
-/// at the end we should have Map with (key,value) = (city name, some metric).
13
-/// \param fileName: name of the JSON file
14
-/// \return true if the file was openned and read
15
-///
16
-bool Census::readDataFromFile(QString fileName) {
17
-    QFile loadFile(fileName);
18
-
19
-    if (!loadFile.open(QIODevice::ReadOnly)) {
20
-        qWarning("Couldn't open save file.");
21
-        return false;
22
-    }
23
-
24
-    QByteArray saveData = loadFile.readAll();
25
-    QJsonDocument loadDoc(QJsonDocument::fromJson(saveData));
26
-    QJsonArray topLevelArray = loadDoc.array();
27
-
28
-    int ctr = 1;
29
-
30
-    minValue = maxValue = topLevelArray[0].toObject()["percent_change"].toDouble();
31
-
32
-    foreach(QJsonValue obj, topLevelArray) {
33
-        double value = obj.toObject()["percent_change"].toDouble();
34
-        (*this)[obj.toObject()["city"].toString()] =  value;
35
-        if (value > maxValue) maxValue = value;
36
-        if (value < minValue) minValue = value;
37
-
38
-        ctr++;
39
-    }
40
-
41
-    Census::iterator it = this->begin();
42
-
43
-    for (; it != this->end(); ++it)
44
-        qDebug() << it.key() << it.value();
45
-
46
-    factor = 128.0 / (maxValue - minValue) ;
47
-
48
-}
49
-

+ 0
- 19
census.h View File

@@ -1,19 +0,0 @@
1
-#ifndef CENSUS_H
2
-#define CENSUS_H
3
-
4
-#include <QString>
5
-#include <QMap>
6
-
7
-///
8
-/// \brief The Census class
9
-///
10
-class Census : public QMap<QString, double> {
11
-
12
-public:
13
-    bool readDataFromFile(QString fileName);
14
-    double minValue, maxValue, factor, negFactor;
15
-};
16
-
17
-
18
-
19
-#endif // CENSUS_H

+ 1
- 4
country.cpp View File

@@ -8,9 +8,6 @@
8 8
 void Country::limits(){
9 9
     QMap<QString,City*>::iterator it = Cities.begin();
10 10
 
11
-
12
-
13
-
14 11
     minX = maxX = Cities.begin().value()->geometry->at(0).x;
15 12
     minY = maxY = Cities.begin().value()->geometry->at(0).y;
16 13
 
@@ -50,7 +47,7 @@ void Country::topLeft(QString &st, DoublePoint &p ) {
50 47
     }
51 48
 }
52 49
 unsigned long  *colorMap;
53
-bool Country::readInfoFromJSON(QString fileName) {
50
+bool Country::readInfoFromJSON(const QString &fileName) {
54 51
     QFile loadFile(fileName);
55 52
 
56 53
     if (!loadFile.open(QIODevice::ReadOnly)) {

+ 48
- 6
country.h View File

@@ -6,19 +6,61 @@
6 6
 #include <QMap>
7 7
 
8 8
 
9
-///
10
-/// \brief The Country class
11
-///        A map of (city name, city structure)
12
-///
9
+/// A class to display a map of a country, given the coordinates
10
+/// that define its limits.
11
+
13 12
 class Country {
13
+private:
14 14
 public:
15 15
     QMap<QString,City*> Cities;
16
-
17 16
     double minX, minY, maxX, maxY;
17
+
18
+    /// \fn Country()
19
+    /// \~English
20
+    /// \brief default constructor
21
+    /// \~Spanish
22
+    /// \brief default constructor
23
+    ///
18 24
     Country() {}
19
-    bool readInfoFromJSON(QString fileName);
25
+
26
+    /// \fn bool readInfoFromJSON(QString fileName)
27
+    /// \~English
28
+    /// \brief Reads a json file that contains the polygons for the
29
+    ///        various parts of the country (e.g., cities)
30
+    /// \param fileName name of the json file
31
+    /// \~Spanish
32
+    /// \brief Lee un archivo en formato json que contiene los polígonos
33
+    ///        the los componentes del mapa del pais (e.g. las ciuidades)
34
+    /// \param fileName nombre del archivo en formato json
35
+    ///
36
+    bool readInfoFromJSON(const QString &fileName);
37
+
38
+    /// \fn topLeft(QString &st, DoublePoint &p );
39
+    /// \~English
40
+    /// \brief ??
41
+    /// \param ??
42
+    /// \~Spanish
43
+    /// \brief ??
44
+    /// \param ??
45
+    ///
20 46
     void topLeft(QString &st, DoublePoint &p );
47
+
48
+    /// \fn void limits();
49
+    /// \~English
50
+    /// \brief ??
51
+    /// \param ??
52
+    /// \~Spanish
53
+    /// \brief ??
54
+    /// \param ??
55
+    ///
21 56
     void limits();
57
+
58
+    /// \fn QMap<QString,City*> getCities()
59
+    /// \~English
60
+    /// \brief gets the Cities map structure.
61
+    /// \~Spanish
62
+    /// \brief consigue la estructura de mapa de Cities.
63
+    ///
22 64
     QMap<QString,City*> getCities() { return Cities;}
23 65
     //~Country() { delete Cities; }
24 66
 };

+ 17
- 3
doublepoint.h View File

@@ -1,14 +1,28 @@
1 1
 #ifndef DOUBLEPOINT_H
2 2
 #define DOUBLEPOINT_H
3 3
 
4
+/// A class to display to store an x, y coordinate of type double.
5
+///
4 6
 class DoublePoint {
5 7
 public:
6 8
     double x, y;
9
+
10
+    /// \fn DoublePoint()
11
+    /// \~English
12
+    /// \brief default constructor
13
+    /// \~Spanish
14
+    /// \brief constructor por defecto
15
+    ///
7 16
     DoublePoint() {x = 0; y = 0;}
8
-    DoublePoint(double a, double b) {
9
-        x = a; y = b;
10
-    }
11 17
 
18
+
19
+    /// \fn DoublePoint(double xp, double yp)
20
+    /// \~English
21
+    /// \brief constructor that sets the coordinates
22
+    /// \~Spanish
23
+    /// \brief constructor que setea las coordenadas
24
+    ///
25
+    DoublePoint(double xp, double yp) { x = xp; y = yp; }
12 26
 };
13 27
 
14 28
 #endif // DOUBLEPOINT_H

+ 91
- 10
gispoi.h View File

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