Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix default reference time (current) not UTC for mesh layer
  • Loading branch information
vcloarec authored and nyalldawson committed Aug 7, 2020
1 parent a29b3aa commit 51bd48f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -5566,7 +5566,7 @@ QgsMeshLayer *QgisApp::addMeshLayerPrivate( const QString &url, const QString &b

QDateTime referenceTime = QgsProject::instance()->timeSettings()->temporalRange().begin();
if ( !referenceTime.isValid() ) // If project reference time is invalid, use current date
referenceTime = QDateTime( QDate::currentDate(), QTime( 0, 0, 0, Qt::UTC ) );
referenceTime = QDateTime( QDate::currentDate(), QTime( 0, 0, 0, Qt::UTC ), Qt::UTC );

if ( ! layer || ( !layer->isValid() && layer->subLayers().isEmpty() ) )
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/mesh/qgsmeshlayer.cpp
Expand Up @@ -201,7 +201,7 @@ bool QgsMeshLayer::addDatasets( const QString &path, const QDateTime &defaultRef
{
QDateTime referenceTime = defaultReferenceTime;
if ( !defaultReferenceTime.isValid() ) // If project reference time is invalid, use current date
referenceTime = QDateTime( QDate::currentDate(), QTime( 0, 0, 0, Qt::UTC ) );
referenceTime = QDateTime( QDate::currentDate(), QTime( 0, 0, 0, Qt::UTC ), Qt::UTC );
temporalProperties->setReferenceTime( referenceTime, dataProvider()->temporalCapabilities() );
}

Expand Down
3 changes: 2 additions & 1 deletion src/providers/mdal/qgsmdalprovider.cpp
Expand Up @@ -443,7 +443,6 @@ void QgsMdalProvider::addGroupToTemporalCapabilities( int indexGroup )
QgsMeshDataProviderTemporalCapabilities *tempCap = temporalCapabilities();
QgsMeshDatasetGroupMetadata dsgMetadata = datasetGroupMetadata( indexGroup );
QDateTime refTime = dsgMetadata.referenceTime();
refTime.setTimeSpec( Qt::UTC ); //For now provider doesn't support time zone and return always in local time, force UTC
tempCap->addGroupReferenceDateTime( indexGroup, refTime );
int dsCount = datasetCount( indexGroup );

Expand Down Expand Up @@ -694,6 +693,8 @@ QgsMeshDatasetGroupMetadata QgsMdalProvider::datasetGroupMetadata( int groupInde
}

QString referenceTimeString( MDAL_G_referenceTime( group ) );
if ( !referenceTimeString.isEmpty() )
referenceTimeString.append( 'Z' );//For now provider doesn't support time zone and return always in local time, force UTC
QDateTime referenceTime = QDateTime::fromString( referenceTimeString, Qt::ISODate );

bool isTemporal = MDAL_G_isTemporal( group );
Expand Down

0 comments on commit 51bd48f

Please sign in to comment.