Skip to content

Commit

Permalink
Fix handling of constraints when starting a new track to avoid data loss
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Jan 17, 2025
1 parent eb47018 commit f3d6eb3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/core/tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ void Tracker::trackPosition()
return;
}

if ( !qgsDoubleNear( mMaximumDistance, 0.0 ) && mCurrentDistance > mMaximumDistance )
if ( mRubberbandModel->vertexCount() > 1 && !qgsDoubleNear( mMaximumDistance, 0.0 ) && mCurrentDistance > mMaximumDistance )
{
// Simple logic to avoid getting stuck in an infinite erroneous distance having somehow actually moved beyond the safeguard threshold
if ( ++mMaximumDistanceFailuresCount < MAXIMUM_DISTANCE_FAILURES )
Expand Down Expand Up @@ -190,7 +190,7 @@ void Tracker::positionReceived()
return;
}

if ( !qgsDoubleNear( mMinimumDistance, 0.0 ) || !qgsDoubleNear( mMaximumDistance, 0.0 ) )
if ( mRubberbandModel->vertexCount() > 1 && ( !qgsDoubleNear( mMinimumDistance, 0.0 ) || !qgsDoubleNear( mMaximumDistance, 0.0 ) ) )
{
QVector<QgsPointXY> points = mRubberbandModel->flatPointSequence( QgsProject::instance()->crs() );

Expand All @@ -210,7 +210,7 @@ void Tracker::positionReceived()

if ( !qgsDoubleNear( mMinimumDistance, 0.0 ) )
{
mMinimumDistanceFulfilled = mCurrentDistance >= mMinimumDistance;
mMinimumDistanceFulfilled = mRubberbandModel->vertexCount() == 1 || mCurrentDistance >= mMinimumDistance;

if ( !mConjunction && mMinimumDistanceFulfilled )
{
Expand All @@ -221,7 +221,7 @@ void Tracker::positionReceived()

if ( !qgsDoubleNear( mTimeInterval, 0.0 ) )
{
mTimeIntervalFulfilled = ( mLastDevicePositionTimestamp.toMSecsSinceEpoch() - mLastVertexPositionTimestamp.toMSecsSinceEpoch() ) >= mTimeInterval * 1000;
mTimeIntervalFulfilled = mRubberbandModel->vertexCount() == 1 || ( ( mLastDevicePositionTimestamp.toMSecsSinceEpoch() - mLastVertexPositionTimestamp.toMSecsSinceEpoch() ) >= mTimeInterval * 1000 );

if ( !mConjunction && mTimeIntervalFulfilled )
{
Expand Down

0 comments on commit f3d6eb3

Please sign in to comment.