Added GeoPositionInfo and LiblocationWrapper classes.
[situare] / src / gps / geopositioninfo.cpp
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5        Jussi Laitinen - jussi.laitinen@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 #include <QDateTime>
23
24 #include "geopositioninfo.h"
25 #include "gpscommon.h"
26
27 GeoPositionInfo::GeoPositionInfo()
28 {
29 }
30
31 void GeoPositionInfo::setLatitude(qreal latitude)
32 {
33     m_latitude = latitude;
34 }
35
36 qreal GeoPositionInfo::latitude() const
37 {
38     return m_latitude;
39 }
40 void GeoPositionInfo::setLongitude(qreal longitude)
41 {
42     m_longitude = longitude;
43 }
44
45 qreal GeoPositionInfo::longitude() const
46 {
47     return m_longitude;
48 }
49
50 void GeoPositionInfo::setTimestamp(qreal time)
51 {
52     m_timestamp = QDateTime::fromTime_t(time);
53 }
54
55 QDateTime GeoPositionInfo::timestamp() const
56 {
57     return m_timestamp;
58 }
59
60 bool GeoPositionInfo::isValid() const
61 {
62     if ((latitude >= MIN_LATITUDE) && (latitude < MAX_LATITUDE) &&
63         (longitude >= MIN_LONGITUDE) && (longitude < MAX_LONGITUDE))
64
65         return true;
66     else
67         return false;
68 }
69
70 void GeoPositionInfo::setAttribute(Attribute attribute, qreal value)
71 {
72     if (hasAttribute(attribute))
73         m_horizontalAccuracy = value;
74 }
75
76 qreal GeoPositionInfo::attribute(Attribute attribute)
77 {
78     if (attribute == HorizontalAccuracy)
79         return m_horizontalAccuracy;
80     else
81         return GPS_ACCURACY_UNDEFINED;
82 }
83
84 bool GeoPositionInfo::hasAttribute(Attribute attribute)
85 {
86     if (attribute == HorizontalAccuracy)
87         return true;
88     else
89         return false;
90 }