Change image color based on if got coordinates from GPS
authorSami Rämö <sami.ramo@ixonos.com>
Mon, 17 May 2010 08:58:56 +0000 (11:58 +0300)
committerSami Rämö <sami.ramo@ixonos.com>
Mon, 17 May 2010 08:58:56 +0000 (11:58 +0300)
src/gps/gpsposition.cpp
src/gps/gpsposition.h
src/map/gpslocationitem.cpp
src/map/gpslocationitem.h

index a9451d3..50281e0 100644 (file)
@@ -150,8 +150,8 @@ qreal GPSPosition::accuracy(QGeoPositionInfo positionInfo)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    qWarning() << __PRETTY_FUNCTION__ << "h: " << positionInfo.attribute(QGeoPositionInfo::HorizontalAccuracy)
-            << "v: " << positionInfo.attribute(QGeoPositionInfo::VerticalAccuracy);
+    if (!positionInfo.dateTime().isValid())
+        return GPS_ACCURACY_UNDEFINED;
 
     if (positionInfo.hasAttribute(QGeoPositionInfo::HorizontalAccuracy))
         return positionInfo.attribute(QGeoPositionInfo::HorizontalAccuracy);
index 8206b71..8509718 100644 (file)
@@ -100,7 +100,8 @@ private:
     * @brief Return horizontal accuracy
     *
     * @param positionInfo geo position info
-    * @return accuracy value, -1 if undefined
+    * @return accuracy value, -1 if undefined. Returns -1 also is timestamp is not valid
+    *         (when using network positioning)
     */
     qreal accuracy(QGeoPositionInfo positionInfo);
 
index e164366..2585513 100644 (file)
@@ -19,8 +19,6 @@
     USA.
 */
 
-const int ACCURATE_LIMIT = 50; // this and lower values (in meters) are considered as accurate
-
 #include <QDebug>
 #include <QGraphicsPixmapItem>
 
@@ -63,14 +61,16 @@ void GPSLocationItem::updatePosition(QPoint scenePosition, qreal accuracy)
 
     setPos(scenePosition);
 
-    if (accuracy != GPS_ACCURACY_UNDEFINED  // accuracy must be defined
-        && accuracy <= ACCURATE_LIMIT       // and smaller than limit
-        && m_currentAccuracy != ACCURATE) { // and accurate pixmap not yet set
+    if (accuracy == GPS_ACCURACY_UNDEFINED) { // fix is NOT accurate
+        if (m_currentAccuracy != COARSE) { // coarse pixmap not yet set
+            setPixmap(m_coarsePixmap);
+            m_currentAccuracy = COARSE;
+        }
+    }
+    else { // fix is accurate
+        if (m_currentAccuracy != ACCURATE) { // accurate pixmap not yet set
             setPixmap(m_accuratePixmap);
             m_currentAccuracy = ACCURATE;
-    }
-    else if (m_currentAccuracy != COARSE) { // coarse pixmap not yet set
-        setPixmap(m_coarsePixmap);
-        m_currentAccuracy = COARSE;
+        }
     }
 }
index 8606acd..d62ec11 100644 (file)
@@ -53,6 +53,8 @@ public:
     /**
       * @brief Update position item
       *
+      * Use yellow led image when using network positioning and green led image when using GPS.
+      *
       * @param scenePosition Scene coordinate
       * @param accuracy Accuracy of the GPS fix
       */