Commit c6c2ad73 authored by Sanjiban Bairagya's avatar Sanjiban Bairagya Committed by Sanjiban Bairagya

Fix for Route Simulation position provider plugin

not working for route-navigation
parent 7c490323
...@@ -107,7 +107,7 @@ RouteSimulationPositionProviderPlugin::RouteSimulationPositionProviderPlugin( Ma ...@@ -107,7 +107,7 @@ RouteSimulationPositionProviderPlugin::RouteSimulationPositionProviderPlugin( Ma
m_direction( 0.0 ), m_direction( 0.0 ),
m_directionWithNoise(0.0) m_directionWithNoise(0.0)
{ {
// nothing to do connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(update()));
} }
RouteSimulationPositionProviderPlugin::~RouteSimulationPositionProviderPlugin() RouteSimulationPositionProviderPlugin::~RouteSimulationPositionProviderPlugin()
...@@ -116,13 +116,8 @@ RouteSimulationPositionProviderPlugin::~RouteSimulationPositionProviderPlugin() ...@@ -116,13 +116,8 @@ RouteSimulationPositionProviderPlugin::~RouteSimulationPositionProviderPlugin()
void RouteSimulationPositionProviderPlugin::initialize() void RouteSimulationPositionProviderPlugin::initialize()
{ {
m_currentIndex = -1; updateRoute();
m_lineString = m_lineStringInterpolated = m_marbleModel->routingManager()->routingModel()->route().path(); connect(m_marbleModel->routingManager()->routingModel(), SIGNAL(currentRouteChanged()), this, SLOT(updateRoute()));
m_speed = 0; //initialize speed to be around 25 m/s;
m_status = m_lineString.isEmpty() ? PositionProviderStatusUnavailable : PositionProviderStatusAcquiring;
if ( !m_lineString.isEmpty() ) {
QTimer::singleShot( 1000.0 / c_frequency, this, SLOT(update()) );
}
} }
bool RouteSimulationPositionProviderPlugin::isInitialized() const bool RouteSimulationPositionProviderPlugin::isInitialized() const
...@@ -145,6 +140,18 @@ QDateTime RouteSimulationPositionProviderPlugin::timestamp() const ...@@ -145,6 +140,18 @@ QDateTime RouteSimulationPositionProviderPlugin::timestamp() const
return m_currentDateTime; return m_currentDateTime;
} }
void RouteSimulationPositionProviderPlugin::updateRoute(){
m_currentIndex = -1;
m_lineString = m_lineStringInterpolated = m_marbleModel->routingManager()->routingModel()->route().path();
m_speed = 0; //initialize speed to be around 25 m/s;
m_status = m_lineString.isEmpty() ? PositionProviderStatusUnavailable : PositionProviderStatusAcquiring;
if ( !m_lineString.isEmpty() ) {
m_updateTimer.start(1000.0 / c_frequency);
} else {
m_updateTimer.stop();
}
}
void RouteSimulationPositionProviderPlugin::update() void RouteSimulationPositionProviderPlugin::update()
{ {
if ( m_currentIndex >= 0 && m_currentIndex < m_lineStringInterpolated.size() ) { if ( m_currentIndex >= 0 && m_currentIndex < m_lineStringInterpolated.size() ) {
...@@ -251,8 +258,6 @@ void RouteSimulationPositionProviderPlugin::update() ...@@ -251,8 +258,6 @@ void RouteSimulationPositionProviderPlugin::update()
emit statusChanged( PositionProviderStatusUnavailable ); emit statusChanged( PositionProviderStatusUnavailable );
} }
} }
QTimer::singleShot( 1000.0 / c_frequency, this, SLOT(update()) );
} }
GeoDataCoordinates RouteSimulationPositionProviderPlugin::addNoise(const Marble::GeoDataCoordinates &position, const Marble::GeoDataAccuracy &accuracy ) const GeoDataCoordinates RouteSimulationPositionProviderPlugin::addNoise(const Marble::GeoDataCoordinates &position, const Marble::GeoDataAccuracy &accuracy ) const
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "GeoDataLineString.h" #include "GeoDataLineString.h"
#include <QDateTime> #include <QDateTime>
#include <QTimer>
namespace Marble namespace Marble
{ {
...@@ -59,6 +60,7 @@ public: ...@@ -59,6 +60,7 @@ public:
private Q_SLOTS: private Q_SLOTS:
/** Regular (each second) position and status update */ /** Regular (each second) position and status update */
void update(); void update();
void updateRoute();
private: private:
GeoDataCoordinates addNoise(const Marble::GeoDataCoordinates &,const Marble::GeoDataAccuracy &) const; GeoDataCoordinates addNoise(const Marble::GeoDataCoordinates &,const Marble::GeoDataAccuracy &) const;
...@@ -75,6 +77,7 @@ private: ...@@ -75,6 +77,7 @@ private:
qreal m_speed; qreal m_speed;
qreal m_direction; qreal m_direction;
qreal m_directionWithNoise; qreal m_directionWithNoise;
QTimer m_updateTimer;
}; };
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment