00001 /* 00002 Situare - A location system for Facebook 00003 Copyright (C) 2010 Ixonos Plc. Authors: 00004 00005 Jussi Laitinen - jussi.laitinen@ixonos.com 00006 Sami Rämö - sami.ramo@ixonos.com 00007 00008 Situare is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU General Public License 00010 version 2 as published by the Free Software Foundation. 00011 00012 Situare is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with Situare; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 00020 USA. 00021 */ 00022 00023 00024 #ifndef GEOCOORDINATE_H 00025 #define GEOCOORDINATE_H 00026 00027 #include <QDebug> 00028 #include <QMetaType> 00029 00030 class SceneCoordinate; 00031 00038 class GeoCoordinate 00039 { 00040 public: 00044 GeoCoordinate(); 00045 00052 GeoCoordinate(double latitude, double longitude); 00053 00059 GeoCoordinate(const SceneCoordinate &coordinate); 00060 00061 /******************************************************************************* 00062 * MEMBER FUNCTIONS AND SLOTS 00063 ******************************************************************************/ 00064 public: 00075 qreal distanceTo(const GeoCoordinate &other) const; 00076 00082 bool isNull() const; 00083 00092 bool isValid(); 00093 00099 double latitude() const; 00100 00106 double longitude() const; 00107 00113 void setLatitude(double latitude); 00114 00120 void setLongitude(double longitude); 00121 00122 private: 00128 void convertFrom(const SceneCoordinate &coordinate); 00129 00135 void registerMetaType(); 00136 00137 /******************************************************************************* 00138 * DATA MEMBERS 00139 ******************************************************************************/ 00140 private: 00146 enum ValidityFlag { 00147 NoCoordinatesSet = 0x0, 00148 LatitudeSet = 0x1, 00149 LongitudeSet = 0x2 00150 }; 00151 00152 static bool m_metaTypeIsRegistered; 00153 double m_latitude; 00154 double m_longitude; 00155 int m_validityFlags; 00156 00157 /******************************************************************************* 00158 * OPERATORS 00159 ******************************************************************************/ 00160 public: 00167 friend const GeoCoordinate operator-(const GeoCoordinate &coordinate1, 00168 const GeoCoordinate &coordinate2); 00169 00176 friend QDataStream &operator<<(QDataStream &out, const GeoCoordinate &coordinate); 00177 00184 friend QDataStream &operator>>(QDataStream &in, GeoCoordinate &coordinate); 00185 }; 00186 00187 QDebug operator<<(QDebug dbg, const GeoCoordinate &coordinate); 00188 00189 Q_DECLARE_METATYPE(GeoCoordinate) 00190 00191 #endif // GEOCOORDINATE_H