Skip to content

Commit

Permalink
fix mesh layer temporal properties when source layer is break
Browse files Browse the repository at this point in the history
  • Loading branch information
vcloarec committed Oct 6, 2021
1 parent 3ee6a00 commit a755ee9
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/core/mesh/qgsmeshlayer.cpp
Expand Up @@ -49,8 +49,7 @@ QgsMeshLayer::QgsMeshLayer( const QString &meshLayerPath,
const QString &providerKey,
const QgsMeshLayer::LayerOptions &options )
: QgsMapLayer( QgsMapLayerType::MeshLayer, baseName, meshLayerPath ),
mDatasetGroupStore( new QgsMeshDatasetGroupStore( this ) ),
mTemporalProperties( new QgsMeshLayerTemporalProperties( this ) )
mDatasetGroupStore( new QgsMeshDatasetGroupStore( this ) )

{
mShouldValidateCrs = !options.skipCrsValidation;
Expand Down Expand Up @@ -1158,17 +1157,9 @@ void QgsMeshLayer::setDataSourcePrivate( const QString &dataSource, const QStrin
mLayerName = baseName;
setProviderType( provider );

// if we’re given a provider type, try to create and bind one to this layer
bool ok = false;
if ( !mDataSource.isEmpty() && !provider.isEmpty() )
{
ok = setDataProvider( provider, options, flags );
}
setDataProvider( provider, options, flags );

if ( ok )
{
mTemporalProperties->setDefaultsFromDataProviderTemporalCapabilities( mDataProvider->temporalCapabilities() );
}
}

QgsPointXY QgsMeshLayer::snapOnElement( QgsMesh::ElementType elementType, const QgsPointXY &point, double searchRadius )
Expand Down Expand Up @@ -1506,6 +1497,8 @@ bool QgsMeshLayer::readXml( const QDomNode &layer_node, QgsReadWriteContext &con
else
mDatasetGroupStore->readXml( elemDatasetGroupsStore, context );

mTemporalProperties = new QgsMeshLayerTemporalProperties( this );

setDataProvider( mProviderKey, providerOptions, flags );

QString errorMsg;
Expand Down Expand Up @@ -1713,6 +1706,12 @@ bool QgsMeshLayer::setDataProvider( QString const &provider, const QgsDataProvid
return false;
}

if ( !mTemporalProperties )
{
mTemporalProperties = new QgsMeshLayerTemporalProperties( this );
mTemporalProperties->setDefaultsFromDataProviderTemporalCapabilities( dataProvider()->temporalCapabilities() );
}

mDataProvider->setTemporalUnit( mTemporalUnit );

mDatasetGroupStore->setPersistentProvider( mDataProvider, mExtraDatasetUri );
Expand Down

0 comments on commit a755ee9

Please sign in to comment.