Added signal strength indicator to detail screen. Changed speed treshold to change...
[jspeed] / src / location.cpp
index f22c7c8..3b5ee32 100644 (file)
@@ -73,6 +73,39 @@ void Location::end()
     started_ = false;
 }
 
+bool Location::hasFix() const
+{
+    if(!started_)
+    {
+        return false;
+    }
+
+    return (device_->status == LOCATION_GPS_DEVICE_STATUS_FIX);
+}
+
+double Location::getSignalStrength() const
+{
+    if(!hasFix())
+    {
+        qDebug() << "No fix";
+        return 0.0;
+    }
+
+    if(device_->satellites_in_view == 0)
+    {
+        return 0.0;
+    }
+
+    double val = (device_->satellites_in_use / static_cast<double>(device_->satellites_in_view)) * 100.0;
+
+    if(val > 100.0)
+    {
+        val = 100.0;
+    }
+
+    return val;
+}
+
 void Location::setUnit(Location::Unit unit)
 {
     unit_ = unit;