2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Jussi Laitinen - jussi.laitinen@ixonos.com
6 Sami Rämö - sami.ramo@ixonos.com
8 Situare is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 version 2 as published by the Free Software Foundation.
12 Situare is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Situare; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
24 #ifndef GEOCOORDINATE_H
25 #define GEOCOORDINATE_H
30 class SceneCoordinate;
33 * @brief Geographic coordinate
35 * @author Jussi Laitinen - jussi.laitinen@ixonos.com
36 * @author Sami Rämö - sami.ramo@ixonos.com
42 * @brief Constructs a null coordinate
47 * @brief Constructs a coordinate with given latitude and longitude values
49 * @param latitude Latitude value
50 * @param longitude Longitude value
52 GeoCoordinate(double latitude, double longitude);
55 * @brief Constructs a coordinate with values converted from the given SceneCoordinate
57 * @param coordinate Scene coordinate
59 GeoCoordinate(const SceneCoordinate &coordinate);
61 /*******************************************************************************
62 * MEMBER FUNCTIONS AND SLOTS
63 ******************************************************************************/
66 * @brief Check if coordinate is (0.0, 0.0)
68 * @returns True if both latitude and longitude are 0.0, otherwise false
73 * @brief Check if coordinate is valid.
75 * Latitude and longitude values must be set, latitude must be -90..90 and longitude must
76 * be -180..180 for valid coordinate.
78 * @return true if coordinate is valid, false otherwise
83 * @brief Returns the latitude value
87 double latitude() const;
90 * @brief Returns the longitude value
94 double longitude() const;
97 * @brief Sets the latitude
99 * @param latitude Latitude value
101 void setLatitude(double latitude);
104 * @brief Sets the longitude
106 * @param longitude Longitude value
108 void setLongitude(double longitude);
112 * @brief Convert values from SceneCoordinate
114 * @param coordinate Scene coordinate
116 void convertFrom(const SceneCoordinate &coordinate);
119 * @brief Register meta type and stream operators for using the class with QVariant and QSetting
121 * Registering is done only once at the first time the GeoCoordinate object is constructed.
123 void registerMetaType();
125 /*******************************************************************************
127 ******************************************************************************/
132 * @brief Flag values for coordinate validity
135 NoCoordinatesSet = 0x0,
140 static bool m_metaTypeIsRegistered; ///< Is the meta type already registered?
141 double m_latitude; ///< Latitude value
142 double m_longitude; ///< Longitude value
143 int m_validityFlags; ///< Coordinate validity flags
145 /*******************************************************************************
147 ******************************************************************************/
150 * @brief Output operator
152 * @param out Output stream
153 * @param coordinate Coordinate object which is written to the stream
155 friend QDataStream &operator<<(QDataStream &out, const GeoCoordinate &coordinate);
158 * @brief Input operator
160 * @param in Input stream
161 * @param coordinate Object where the values from the stream are saved
163 friend QDataStream &operator>>(QDataStream &in, GeoCoordinate &coordinate);
166 QDebug operator<<(QDebug dbg, const GeoCoordinate &coordinate);
168 Q_DECLARE_METATYPE(GeoCoordinate)
170 #endif // GEOCOORDINATE_H