[Marble-commits] branches/KDE/4.5/kdeedu/marble/src

Dennis Nienhüser earthwings at gentoo.org
Sat Sep 11 16:19:38 CEST 2010


SVN commit 1174219 by nienhueser:

- The position marker is a bit hard to spot on the N900 when there's only time for a quick glance at the screen. To improve that paint a half-transparent red circle at the current position (all versions). To give it a right to exist other than enhanced visibility, its size depends on the accuracy of the current position. The circle can be interpreted "the device is pretty sure that the real position is within the colored circle".
RB: 5168
Use a less transparent color and a minimum circle size for small screen devices to enhance the visibility of the position marker there. Backport of commit 1170361.
- Non-inline ctor. Backport of commit 1174217.
- Hopefully fix the build of the GpsdPositionProviderPlugin (builds at least on SUSE 11.2 right now). Backport of commit 1173799.


 A             lib/geodata/data/GeoDataAccuracy.cpp   [License: LGPL]
 M  +5 -5      lib/geodata/data/GeoDataAccuracy.h  
 M  +54 -0     lib/gps/PositionTracking.cpp  
 M  +4 -0      lib/gps/PositionTracking.h  
 M  +12 -3     plugins/positionprovider/gpsd/GpsdPositionProviderPlugin.cpp  
 M  +2 -4      plugins/positionprovider/maemo/MaemoPositionProviderPlugin.cpp  


--- branches/KDE/4.5/kdeedu/marble/src/lib/geodata/data/GeoDataAccuracy.h #1174218:1174219
@@ -12,14 +12,14 @@
 #ifndef MARBLE_GEODATAACCURACY_H
 #define MARBLE_GEODATAACCURACY_H
 
+#include <marble_export.h>
+
 #include <QtCore/QObject>
 
-
-
 namespace Marble
 {
 
-class GeoDataAccuracy
+class MARBLE_EXPORT GeoDataAccuracy
 {
  public:
     /**
@@ -44,10 +44,10 @@
      * @brief Vertical accuracy in meters.
      */
     qreal vertical;
+
+    GeoDataAccuracy();
 };
 
 }
 
-
-
 #endif
--- branches/KDE/4.5/kdeedu/marble/src/lib/gps/PositionTracking.cpp #1174218:1174219
@@ -20,6 +20,8 @@
 #include "MarbleMath.h"
 #include "MarbleDebug.h"
 #include "ViewParams.h"
+#include "ViewportParams.h"
+#include "AbstractProjection.h"
 
 #include <QtXml/QXmlInputSource>
 #include <QtXml/QXmlSimpleReader>
@@ -105,6 +107,7 @@
             dirty |= rect ;
         }
 
+        dirty |= accuracyIndicatorRegion( viewParams ).toRect();
         return dirty;
 }
 
@@ -181,12 +184,38 @@
     construct( canvasSize, viewParams );
 
     painter->save();
+    
+    QRectF accuracyIndicator;
+    if ( m_gpsCurrentPosition && accuracy().horizontal > 0 && accuracy().horizontal < 1000 ) {
+        // Paint a red circle indicating the position accuracy
+        QColor transparentRed = QColor::fromRgb( 226, 8, 0 );
+        if ( MarbleGlobal::getInstance()->profiles() & MarbleGlobal::SmallScreen ) {
+            transparentRed.setAlpha( 80 );
+        } else {
+            transparentRed.setAlpha( 40 );
+        }
+
+        painter->setPen( transparentRed );
+        painter->setBrush( transparentRed );
+        accuracyIndicator = accuracyIndicatorRegion( viewParams );
+        painter->drawEllipse( accuracyIndicator );
+    }
+    
+    
     painter->setPen( Qt::black );
     painter->setBrush( Qt::white );
     painter->drawPolygon( m_currentDraw );
     painter->restore();
     m_previousDraw = m_currentDraw;
+    
+    // Make a combined polygon of the previous position and the accuracy indicator circle
+    // This is ok as they are painted at the same position. It avoids adding another class
+    // member (which had to be static for ABI compatibility)
+    if ( !accuracyIndicator.isNull() ) {
+        m_previousDraw << accuracyIndicator.topLeft() << accuracyIndicator.topRight();
+        m_previousDraw << accuracyIndicator.bottomLeft() << accuracyIndicator.bottomRight();
 }
+}
 
 void PositionTracking::setPositionProviderPlugin( PositionProviderPlugin* plugin )
 {
@@ -210,4 +239,29 @@
     return m_positionProvider ? m_positionProvider->error() : QString();
 }
 
+GeoDataAccuracy PositionTracking::accuracy() const
+{
+    return m_positionProvider ? m_positionProvider->accuracy() : GeoDataAccuracy();
+}
+
+QRectF PositionTracking::accuracyIndicatorRegion( ViewParams *viewParams ) const
+{
+    QRectF result;
+    if ( m_gpsCurrentPosition ) {
+        qreal width = qRound( accuracy().horizontal * viewParams->viewport()->radius() / EARTH_RADIUS );
+        if ( MarbleGlobal::getInstance()->profiles() & MarbleGlobal::SmallScreen ) {
+            qreal arrowSize = qMax<qreal>( m_currentDraw.boundingRect().width(), m_currentDraw.boundingRect().height() );
+            width = qMax<qreal>( width, arrowSize + 10 );
+        }
+        
+        qreal x(0), y(0);
+        AbstractProjection * projection = viewParams->viewport()->currentProjection();
+        if ( projection->screenCoordinates( m_gpsCurrentPosition->position(), viewParams->viewport(), x, y ) ) {
+            result = QRectF( x - width / 2.0, y - width / 2.0, width, width );
+        }
+    }
+    
+    return result;
+}  
+
 #include "PositionTracking.moc"
--- branches/KDE/4.5/kdeedu/marble/src/lib/gps/PositionTracking.h #1174218:1174219
@@ -90,6 +90,8 @@
 
     QString error() const;
 
+    GeoDataAccuracy accuracy() const;
+
  public slots:
     void  notifyPosition( GeoDataCoordinates );
 
@@ -101,6 +103,8 @@
  private:
     void updateSpeed( TrackPoint* previous, TrackPoint* next );
 
+    QRectF accuracyIndicatorRegion( ViewParams *viewParams ) const;
+
     qreal               m_speed;
     //used to draw the arrow in gps tracking
     QPointF             m_relativeTip;
--- branches/KDE/4.5/kdeedu/marble/src/plugins/positionprovider/gpsd/GpsdPositionProviderPlugin.cpp #1174218:1174219
@@ -64,10 +64,19 @@
         m_position.set( data.fix.longitude, data.fix.latitude,
                         data.fix.altitude, GeoDataCoordinates::Degree );
         m_accuracy.level = GeoDataAccuracy::Detailed;
-        // FIXME: Add real values here
-        m_accuracy.horizontal = 5;
-        m_accuracy.vertical = 5;
+#if defined( GPSD_API_MAJOR_VERSION ) && ( GPSD_API_MAJOR_VERSION >= 3 )
+         if ( !isnan( data.fix.epx ) && !isnan( data.fix.epy ) ) {
+             m_accuracy.horizontal = qMax( data.fix.epx, data.fix.epy );
     }
+#else
+        if ( !isnan( data.fix.eph ) ) {
+            m_accuracy.horizontal = data.fix.eph;
+        }
+#endif
+        if ( !isnan( data.fix.epv ) ) {
+            m_accuracy.vertical = data.fix.epv;
+        }
+    }
     if (m_status != oldStatus)
         emit statusChanged( m_status );
     // FIXME: Check whether position has changed first
--- branches/KDE/4.5/kdeedu/marble/src/plugins/positionprovider/maemo/MaemoPositionProviderPlugin.cpp #1174218:1174219
@@ -98,12 +98,10 @@
 {
     GeoDataAccuracy result;
 
-    // FIXME: I'm not sure what is expected here, the documentation in
-    // Marble is a bit coarse and I did not find any class using it
     if ( status() == PositionProviderStatusAvailable ) {
         result.level = GeoDataAccuracy::Detailed;
-        result.horizontal = d->m_device->fix->eph; // horizontal position accuracy in centimeter
-        result.vertical = d->m_device->fix->epv; // vertical position accuracy in meter
+        result.horizontal = d->m_device->fix->eph / 100.0; // cm => meter
+        result.vertical = d->m_device->fix->epv; // meter
     }
     else {
         result.level = GeoDataAccuracy::none;


More information about the Marble-commits mailing list