Implemented GeoCoordinate::convertFrom, iterated unit tests
[situare] / src / coordinates / geocoordinate.h
1 /*
2     Situare - A location system for Facebook
3     Copyright (C) 2010  Ixonos Plc. Authors:
4
5         Sami Rämö - sami.ramo@ixonos.com
6
7     Situare is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License
9     version 2 as published by the Free Software Foundation.
10
11     Situare is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with Situare; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
19     USA.
20 */
21
22
23 #ifndef GEOCOORDINATE_H
24 #define GEOCOORDINATE_H
25
26 #include <QDebug>
27 #include <QMetaType>
28
29 class SceneCoordinate;
30
31 /**
32 * @brief Geographic coordinate
33 *
34 * @author Sami Rämö - sami.ramo@ixonos.com
35 */
36 class GeoCoordinate
37 {
38 public:
39     /**
40     * @brief Constructs a null coordinate
41     */
42     GeoCoordinate();
43
44     /**
45     * @brief Constructs a coordinate with given latitude and longitude values
46     *
47     * @param latitude Latitude value
48     * @param longitude Longitude value
49     */
50     GeoCoordinate(double latitude, double longitude);
51
52     /**
53     * @brief Constructs a coordinate with values converted from the given SceneCoordinate
54     *
55     * @param coordinate Scene coordinate
56     */
57     GeoCoordinate(SceneCoordinate &coordinate);
58
59 /*******************************************************************************
60  * MEMBER FUNCTIONS AND SLOTS
61  ******************************************************************************/
62 public:
63     /**
64     * @brief Check if coordinate is (0.0, 0.0)
65     *
66     * @returns True if both latitude and longitude are 0.0, otherwise false
67     */
68     bool isNull() const;
69
70     /**
71     * @brief Returns the latitude value
72     *
73     * @returns latitude
74     */
75     double latitude() const;
76
77     /**
78     * @brief Returns the longitude value
79     *
80     * @returns longitude
81     */
82     double longitude() const;
83
84     /**
85     * @brief Sets the latitude
86     *
87     * @param latitude Latitude value
88     */
89     void setLatitude(double latitude);
90
91     /**
92     * @brief Sets the longitude
93     *
94     * @param longitude Longitude value
95     */
96     void setLongitude(double longitude);
97
98 private:
99     /**
100      * @brief Convert values from SceneCoordinate
101      *
102      * @param coordinate Scene coordinate
103      */
104     void convertFrom(const SceneCoordinate &coordinate);
105
106 /*******************************************************************************
107  * DATA MEMBERS
108  ******************************************************************************/
109 private:
110     double m_latitude;      ///< Latitude value
111     double m_longitude;     ///< Longitude value
112 };
113
114 QDebug operator<<(QDebug dbg, const GeoCoordinate &c);
115
116 Q_DECLARE_METATYPE(GeoCoordinate)
117
118 #endif // GEOCOORDINATE_H