Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/positioning/internalgnssreceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void InternalGnssReceiver::handleSatellitesInUseUpdated( const QList<QGeoSatelli
mSatellitesInfo, 0, 0, 0,
mLastGnssPositionInformation.hacc(),
mLastGnssPositionInformation.vacc(),
mLastGnssPositionInformation.utcDateTime(),
mLastGnssPositionInformation.utcDateTime().isValid() ? mLastGnssPositionInformation.utcDateTime() : QDateTime::currentDateTimeUtc(),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is repeated a bunch of times. That makes me wonder:

  • should it be a procedure?
  • why check if datetime is not valid, but use hacc/vacc unconditionally? Is there really a situation with vllid accuracy but not valid time?

It seems clear something tricky is going on, but I don't understand it from the comments you didn't add, and I don't understand it from the commit message. Maybe GNSS data should not be used at all if the associated datetime is not valid, and that's the real bug.

QChar(), 0, -1, static_cast<int>( mSatellitesID.size() ), QChar( 'A' ), mSatellitesID, mSatelliteInformationValid,
mLastGnssPositionInformation.verticalSpeed(),
mLastGnssPositionInformation.magneticVariation(),
Expand Down
2 changes: 1 addition & 1 deletion src/core/positioning/positioningsource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ void PositioningSource::lastGnssPositionInformationChanged( const GnssPositionIn
lastGnssPositionInformation.vdop(),
lastGnssPositionInformation.hacc(),
lastGnssPositionInformation.vacc(),
lastGnssPositionInformation.utcDateTime().isValid() ? lastGnssPositionInformation.utcDateTime() : QDateTime::currentDateTimeUtc(),
lastGnssPositionInformation.utcDateTime(),
lastGnssPositionInformation.fixMode(),
lastGnssPositionInformation.fixType(),
lastGnssPositionInformation.quality(),
Expand Down
7 changes: 4 additions & 3 deletions src/core/tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,16 +306,17 @@ void Tracker::processPositionInformation( const GnssPositionInformation &positio
if ( !mIsActive && !mIsReplaying )
return;

mLastDevicePositionTimestampMSecsSinceEpoch = positionInformation.utcDateTime().toMSecsSinceEpoch();
mLastDevicePositionTimestampMSecsSinceEpoch = positionInformation.utcDateTime().isValid() ? positionInformation.utcDateTime().toMSecsSinceEpoch() : QDateTime::currentDateTimeUtc().toMSecsSinceEpoch();

double measureValue = 0.0;
switch ( mMeasureType )
{
case Tracker::SecondsSinceStart:
measureValue = positionInformation.utcDateTime().toSecsSinceEpoch() - mStartPositionTimestamp.toSecsSinceEpoch();
if ( positionInformation.utcDateTime().isValid() && mStartPositionTimestamp.isValid() )
measureValue = positionInformation.utcDateTime().toSecsSinceEpoch() - mStartPositionTimestamp.toSecsSinceEpoch();
break;
case Tracker::Timestamp:
measureValue = positionInformation.utcDateTime().toSecsSinceEpoch();
measureValue = positionInformation.utcDateTime().isValid() ? positionInformation.utcDateTime().toSecsSinceEpoch() : QDateTime::currentDateTimeUtc().toSecsSinceEpoch();
break;
case Tracker::GroundSpeed:
measureValue = positionInformation.speed();
Expand Down
4 changes: 3 additions & 1 deletion src/core/utils/expressioncontextutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ QgsExpressionContextScope *ExpressionContextUtils::positionScope( const GnssPosi
const QgsGeometry point = QgsGeometry( new QgsPoint( positionInformation.longitude(), positionInformation.latitude(), positionInformation.elevation() ) );

addPositionVariable( scope, QStringLiteral( "coordinate" ), QVariant::fromValue<QgsGeometry>( point ), positionLocked );
addPositionVariable( scope, QStringLiteral( "timestamp" ), positionInformation.utcDateTime(), positionLocked );
addPositionVariable( scope, QStringLiteral( "timestamp" ),
positionInformation.utcDateTime().isValid() ? positionInformation.utcDateTime() : QDateTime::currentDateTimeUtc(),
positionLocked );
addPositionVariable( scope, QStringLiteral( "direction" ), positionInformation.direction(), positionLocked ); // Speed direction
addPositionVariable( scope, QStringLiteral( "ground_speed" ), positionInformation.speed(), positionLocked );
addPositionVariable( scope, QStringLiteral( "orientation" ), positionInformation.orientation(), positionLocked ); // Compass/magnetometer orientation
Expand Down
8 changes: 6 additions & 2 deletions src/core/utils/fileutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,12 @@ void FileUtils::addImageMetadata( const QString &imagePath, const GnssPositionIn
metadata["Exif.GPSInfo.GPSSpeedRef"] = "K";
}

metadata["Exif.GPSInfo.GPSDateStamp"] = positionInformation.utcDateTime().date();
metadata["Exif.GPSInfo.GPSTimeStamp"] = positionInformation.utcDateTime().time();
// slight change in behaviour, but more correct
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to see changes in commit messages, and comments in the code describe how it is. I find "slight change in behavior" unhelpful, and it will not age well. Change from when? Why? What actual change?

if ( positionInformation.utcDateTime().isValid() )
{
metadata["Exif.GPSInfo.GPSDateStamp"] = positionInformation.utcDateTime().date();
metadata["Exif.GPSInfo.GPSTimeStamp"] = positionInformation.utcDateTime().time();
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you're doing, but elsewhere you are using system time instead of gnss time if gnss time is not valid. Why is this different? I'm not saying you don't have a reason but that reason is what should be in the comment.

Are you finding that there is a valid position but not valid time in gnss data?


metadata["Exif.GPSInfo.GPSSatellites"] = QString::number( positionInformation.satellitesUsed() ).rightJustified( 2, '0' );

Expand Down
2 changes: 1 addition & 1 deletion src/core/utils/positioningutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ GnssPositionInformation PositioningUtils::averagedPositionInformation( const QLi
double verticalSpeed = std::numeric_limits<double>::quiet_NaN();
double magneticVariation = std::numeric_limits<double>::quiet_NaN();

QDateTime utcDateTime = positionsInformation.last().utcDateTime();
QDateTime utcDateTime = positionsInformation.last().utcDateTime().isValid() ? positionsInformation.last().utcDateTime() : QDateTime::currentDateTimeUtc();

QList<QgsSatelliteInfo> satellitesInView = positionsInformation.at( 0 ).satellitesInView();
int satellitesUsed = satellitesInView.size();
Expand Down
Loading