Merge branch 'uiFixing/ResultDialog'
[speedfreak] / Client / maemo5location.cpp
1 /*
2  * Maemo5Location
3  *
4  * @author     Toni Jussila <toni.jussila@fudeco.com>
5  * @copyright  (c) 2010 Speed Freak team
6  * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
7  */
8
9 //#ifdef Q_WS_MAEMO_5
10 #include "maemo5locationprivate.h"
11 #include "maemo5location.h"
12
13 /**
14   *Default constructor of this class.
15   *@param QObject pointer to parent object. By default the value is NULL.
16   */
17 Maemo5Location::Maemo5Location(QObject* parent):QObject(parent)
18 {
19     ptr = new Maemo5LocationPrivate(this);
20
21     connect(ptr, SIGNAL(agnss()), this, SIGNAL(agnss()));
22     connect(ptr, SIGNAL(awcp()), this, SIGNAL(awcp()));
23     connect(ptr, SIGNAL(locationUpdated()), this, SIGNAL(locationUpdated()));
24     connect(ptr, SIGNAL(gps_connected()), this, SIGNAL(gps_connected()));
25     connect(ptr, SIGNAL(gps_disconnected()), this, SIGNAL(gps_disconnected()));
26     connect(ptr, SIGNAL(gps_error(int)), this, SIGNAL(gps_error(int)));
27     connect(ptr, SIGNAL(gpsd_running()), this, SIGNAL(gpsd_running()));
28     connect(ptr, SIGNAL(gpsd_stopped()), this, SIGNAL(gpsd_stopped()));
29 }
30
31 /**
32   *Destructor of this class. Should be used to release all allocated resources.
33   */
34 Maemo5Location::~Maemo5Location()
35 {
36     delete ptr;
37 }
38
39 /**
40   *Start polling gps.
41   */
42 void Maemo5Location::startPollingGPS()
43 {
44     ptr->get_agnss();
45 }
46
47 /**
48   *Stop polling gps.
49   */
50 void Maemo5Location::stopPollingGPS()
51 {
52     ptr->stop();
53 }
54
55 /**
56   *Returns number of satellites in use.
57   */
58 int Maemo5Location::getSatellitesInUse()
59 {
60     return ptr->get_satellites_in_use();
61 }
62
63 /**
64   *Returns number of satellites in view.
65   */
66 int Maemo5Location::getSatellitesInView()
67 {
68     return ptr->get_satellites_in_view();
69 }
70
71 /**
72   *Returns average signal strength of satellites which are in use.
73   */
74 int Maemo5Location::getSignalStrength()
75 {
76     return ptr->get_signal_strength();
77 }
78
79 /**
80   *Returns gps online.
81   */
82 bool Maemo5Location::getGpsOnline()
83 {
84     return ptr->get_gps_online();
85 }
86
87 /**
88   *Returns latitude.
89   */
90 double Maemo5Location::getLatitude()
91 {
92     return ptr->get_lat();
93 }
94
95 /**
96   *Returns longitude.
97   */
98 double Maemo5Location::getLongitude()
99 {
100     return ptr->get_lon();
101 }
102
103 /**
104   *Returns timestamp of the update in seconds.
105   */
106 double Maemo5Location::getTime()
107 {
108     return ptr->get_time();
109 }
110
111 /**
112   *Returns time accuracy in seconds.
113   */
114 double Maemo5Location::getEpt()
115 {
116     return ptr->get_ept();
117 }
118
119 /**
120   *Returns horizontal position accuracy in cm.
121   */
122 double Maemo5Location::getEph()
123 {
124     return ptr->get_eph();
125 }
126
127 /**
128   *Returns fix altitude in meters.
129   */
130 double Maemo5Location::getAltitude()
131 {
132     return ptr->get_altitude();
133 }
134
135 /**
136   *Returns altitude accuracy in meters.
137   */
138 double Maemo5Location::getEpv()
139 {
140     return ptr->get_epv();
141 }
142
143 /**
144   *Returns direction of motion in degrees(0-359).
145   */
146 double Maemo5Location::getTrack()
147 {
148     return ptr->get_track();
149 }
150
151 /**
152   *Returns track accuracy in degrees.
153   */
154 double Maemo5Location::getEpd()
155 {
156     return ptr->get_epd();
157 }
158
159 /**
160   *Returns current speed in km/h.
161   */
162 double Maemo5Location::getSpeed()
163 {
164     return ptr->get_speed();
165 }
166
167 /**
168   *Returns speed accuracy in km/h.
169   */
170 double Maemo5Location::getEps()
171 {
172     return ptr->get_eps();
173 }
174
175 /**
176   *Returns current rate of climb in m/s.
177   */
178 double Maemo5Location::getClimb()
179 {
180     return ptr->get_climb();
181 }
182
183 /**
184   *Returns climb accuracy in m/s.
185   */
186 double Maemo5Location::getEpc()
187 {
188     return ptr->get_epc();
189 }
190
191 /**
192   *Returns distance between two points in kilometers.
193   *@param latitude of first point
194   *@param longitude of first point
195   *@param latitude of second point
196   *@param longitude of second point
197   */
198 double Maemo5Location::distance_between_two_points(double latitude_s, double longitude_s, double latitude_f, double longitude_f)
199 {
200     return ptr->distance_between_two_points(latitude_s, longitude_s, latitude_f, longitude_f);
201 }