Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix reference time for memory mesh provider (#45560)
  • Loading branch information
vcloarec committed Oct 19, 2021
1 parent 7cc5533 commit 7e2b31e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/core/providers/meshmemory/qgsmeshmemorydataprovider.cpp
Expand Up @@ -262,9 +262,9 @@ bool QgsMeshMemoryDataProvider::addDatasetGroupMetadata( const QString &def, Qgs
for ( int i = 0; i < metadataLines.size(); ++i )
{
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
const QStringList keyVal = metadataLines[i].split( ':', QString::SkipEmptyParts );
const QStringList keyVal = metadataLines[i].split( QStringLiteral( ": " ), QString::SkipEmptyParts );
#else
const QStringList keyVal = metadataLines[i].split( ':', Qt::SkipEmptyParts );
const QStringList keyVal = metadataLines[i].split( QStringLiteral( ": " ), Qt::SkipEmptyParts );
#endif
if ( keyVal.size() != 2 )
{
Expand Down Expand Up @@ -405,6 +405,13 @@ void QgsMeshMemoryDataProvider::addGroupToTemporalCapabilities( int groupIndex,

if ( group.datasetCount() > 1 ) //non temporal dataset groups (count=1) have no time in the capabilities
{
QString timeReferenceString = group.extraMetadata().value( QStringLiteral( "reference_time" ) );
if ( !timeReferenceString.isEmpty() )
{
timeReferenceString.append( 'Z' );//For now provider doesn't support time zone and return always in local time, force UTC
const QDateTime referenceTime = QDateTime::fromString( timeReferenceString, Qt::ISODate );
tempCap->addGroupReferenceDateTime( groupIndex, referenceTime );
}
for ( int i = 0; i < group.memoryDatasets.count(); ++i )
if ( group.memoryDatasets.at( i ) )
tempCap->addDatasetTime( groupIndex, group.memoryDatasets.at( i )->time );
Expand Down
4 changes: 2 additions & 2 deletions src/core/providers/meshmemory/qgsmeshmemorydataprovider.h
Expand Up @@ -102,7 +102,7 @@ class CORE_EXPORT QgsMeshMemoryDataProvider final: public QgsMeshDataProvider
*
* Data string contains simple definition of datasets
* Each entry is separated by "\n" sign and section deliminer "---"
* First section defines the dataset group: Vertex/Edge/Face Vector/Scalar Name
* First section defines the dataset group: vertex/edge/face vector/scalar Name
* Second section defines the group metadata: key: value pairs
* Third section defines the datasets (timesteps). First line is time,
* other lines are values (one value on line). For vectors separated by comma
Expand All @@ -111,7 +111,7 @@ class CORE_EXPORT QgsMeshMemoryDataProvider final: public QgsMeshDataProvider
*
* \code
* QString uri(
* "Vertex Vector MyVertexVectorDataset\n" \
* "vertex vector MyVertexVectorDataset\n" \
* "---"
* "description: My great dataset \n" \
* "reference_time: Midnight \n" \
Expand Down
2 changes: 2 additions & 0 deletions tests/src/core/testqgsmeshlayer.cpp
Expand Up @@ -138,6 +138,8 @@ void TestQgsMeshLayer::initTestCase()
QCOMPARE( mMemoryLayer->datasetGroupTreeRootItem()->childCount(), 5 );
QVERIFY( mMemoryLayer->dataProvider()->temporalCapabilities()->hasTemporalCapabilities() );
QVERIFY( mMemoryLayer->temporalProperties()->isActive() );
QDateTime referenceTime = mMemoryLayer->dataProvider()->temporalCapabilities()->referenceTime();
QCOMPARE( referenceTime, QDateTime( QDate( 2017, 2, 27 ), QTime( 1, 2, 3 ), Qt::UTC ) );
QVERIFY( !mMemoryLayer->supportsEditing() );
QgsProject::instance()->addMapLayers(
QList<QgsMapLayer *>() << mMemoryLayer );
Expand Down
1 change: 1 addition & 0 deletions tests/testdata/mesh/quad_and_triangle_face_scalar.txt
@@ -1,6 +1,7 @@
Face Scalar FaceScalarDataset
---
description: Face Scalar Dataset
reference_time: 2017-02-27T01:02:03
---
0
1
Expand Down

0 comments on commit 7e2b31e

Please sign in to comment.