Couple of new fields added to text element. Small fix to web page.
[jspeed] / src / location.cpp
index d8ef14c..56071f5 100644 (file)
 
 namespace
 {
-    static const double KM_MULTIPLIER = 1.0;
-    static const double MILE_MULTIPLIER = 0.621371192;
+    static double const KM_MULTIPLIER = 1.0;
+    static double const MILE_MULTIPLIER = 0.621371192;
+    static double const METER_MULTIPLIER = 1.0;
+    static double const FEET_MULTIPLIER = 3.2808399;
 }
 
 Location::Unit Location::unit_ = Location::KM;
@@ -125,6 +127,16 @@ double Location::getUnitMultiplier()
     return KM_MULTIPLIER;
 }
 
+double Location::getMeterMultiplier()
+{
+    if(unit_ == MILE)
+    {
+        return FEET_MULTIPLIER;
+    }
+
+    return METER_MULTIPLIER;
+}
+
 void Location::onChanged(LocationGPSDevice *device, gpointer data)
 {
     if(device && device->fix &&
@@ -145,7 +157,7 @@ void Location::onChanged(LocationGPSDevice *device, gpointer data)
 
         if(device->fix->fields & LOCATION_GPS_DEVICE_ALTITUDE_SET)
         {
-            fix.altitude = device->fix->altitude;
+            fix.altitude = device->fix->altitude * getMeterMultiplier();
             fix.epv = device->fix->epv;
         }