File indexing completed on 2024-04-14 03:48:01

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2007 Andrew Manson <g.real.ate@gmail.com>
0004 // SPDX-FileCopyrightText: 2009 Eckhart Wörner <ewoerner@kde.org>
0005 // SPDX-FileCopyrightText: 2010 Thibaut Gridel <tgridel@free.fr>
0006 //
0007 
0008 #ifndef MARBLE_POSITIONTRACKING_H
0009 #define MARBLE_POSITIONTRACKING_H
0010 
0011 #include "marble_export.h"
0012 #include "PositionProviderPluginInterface.h"
0013 
0014 #include <QObject>
0015 
0016 namespace Marble
0017 {
0018 
0019 class GeoDataAccuracy;
0020 class GeoDataCoordinates;
0021 class GeoDataTreeModel;
0022 class PositionProviderPlugin;
0023 class PositionTrackingPrivate;
0024 
0025 class MARBLE_EXPORT PositionTracking : public QObject
0026 {
0027     Q_OBJECT
0028 
0029     Q_PROPERTY( PositionProviderPlugin* positionProviderPlugin READ positionProviderPlugin WRITE setPositionProviderPlugin NOTIFY positionProviderPluginChanged )
0030 
0031 public:
0032     explicit PositionTracking( GeoDataTreeModel* model );
0033     ~PositionTracking() override;
0034 
0035     /**
0036       * Change the position provider to use. You can provide 0 to disable
0037       * position tracking. Ownership of the provided plugin is taken.
0038       */
0039     void setPositionProviderPlugin( PositionProviderPlugin* plugin );
0040 
0041     /** @brief Returns the current position provider plugin, or 0 if none is in use */
0042     PositionProviderPlugin* positionProviderPlugin();
0043 
0044     /**
0045       * @brief gives the error message from the current position provider
0046       */
0047     QString error() const;
0048 
0049     /**
0050      * @brief provides speed of the gps device
0051      */
0052     qreal speed() const;
0053 
0054     /**
0055      * @brief provides direction of the gps device in degrees with geographical north
0056      */
0057     qreal direction() const;
0058 
0059     /**
0060      * @brief Returns the timestamp of last recent tracking point.
0061      */
0062     QDateTime timestamp() const;
0063 
0064     /** @brief Returns the estimated accuracy of the current position */
0065     GeoDataAccuracy accuracy() const;
0066 
0067     /**
0068      * @brief provides the visibility of the Position Tracking document
0069      */
0070     bool trackVisible() const;
0071 
0072     /** @brief Returns the current position, if any */
0073     GeoDataCoordinates currentLocation() const;
0074 
0075     /** @brief Returns the status of the current position provider plugin, if any */
0076     PositionProviderStatus status() const;
0077 
0078     /** @brief Returns true if there is no position in the track */
0079     bool isTrackEmpty() const;
0080 
0081     /**
0082      * @brief Returns the total track length
0083      * @param planetRadius Scale factor, usually the radius of the underlying planet
0084      * @return Length of all track segments on the unit sphere scaled by planetRadius
0085      */
0086     qreal length( qreal planetRadius ) const;
0087 
0088     void readSettings();
0089 
0090     void writeSettings();
0091 
0092 public Q_SLOTS:
0093     /**
0094       * Toggles the visibility of the Position Tracking document
0095       */
0096     void setTrackVisible ( bool visible );
0097 
0098     /**
0099       * Saves the track document to file
0100       */
0101     bool saveTrack( const QString& fileName );
0102 
0103     /**
0104       * Removes all track segments which were recorded
0105       */
0106     void clearTrack();
0107 
0108 Q_SIGNALS:
0109     void  gpsLocation( const GeoDataCoordinates&, qreal );
0110 
0111     void statusChanged( PositionProviderStatus status );
0112 
0113     /**
0114      * @brief emits positionProviderPluginChanged(0) when provider is disabled
0115      */
0116     void positionProviderPluginChanged( PositionProviderPlugin *activePlugin );
0117 
0118  private:
0119     Q_PRIVATE_SLOT( d, void updatePosition() )
0120     Q_PRIVATE_SLOT( d, void updateStatus() )
0121 
0122     friend class PositionTrackingPrivate;
0123     PositionTrackingPrivate* const d;
0124 };
0125 
0126 }
0127 
0128 
0129 
0130 #endif