Skip to content
Permalink
Browse files

Correctly store absolute/relative paths for point clouds in projects

Fixes #42114
  • Loading branch information
nyalldawson committed Mar 11, 2021
1 parent 2884e07 commit 5c101e7aab82183185fd3702b2186be1524a9a8e
@@ -98,6 +98,10 @@ QgsPointCloudLayer cannot be copied.

virtual void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, bool loadDefaultStyleFlag = false );

virtual QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const;

virtual QString decodedSource( const QString &source, const QString &dataProvider, const QgsReadWriteContext &context ) const;

virtual QString loadDefaultStyle( bool &resultFlag /Out/ ) ${SIP_FINAL};

virtual QString htmlMetadata() const;
@@ -360,6 +360,34 @@ void QgsPointCloudLayer::setDataSource( const QString &dataSource, const QString
triggerRepaint();
}

QString QgsPointCloudLayer::encodedSource( const QString &source, const QgsReadWriteContext &context ) const
{
QVariantMap parts = QgsProviderRegistry::instance()->decodeUri( providerType(), source );
if ( parts.contains( QStringLiteral( "path" ) ) )
{
parts.insert( QStringLiteral( "path" ), context.pathResolver().writePath( parts.value( QStringLiteral( "path" ) ).toString() ) );
return QgsProviderRegistry::instance()->encodeUri( providerType(), parts );
}
else
{
return source;
}
}

QString QgsPointCloudLayer::decodedSource( const QString &source, const QString &dataProvider, const QgsReadWriteContext &context ) const
{
QVariantMap parts = QgsProviderRegistry::instance()->decodeUri( dataProvider, source );
if ( parts.contains( QStringLiteral( "path" ) ) )
{
parts.insert( QStringLiteral( "path" ), context.pathResolver().readPath( parts.value( QStringLiteral( "path" ) ).toString() ) );
return QgsProviderRegistry::instance()->encodeUri( dataProvider, parts );
}
else
{
return source;
}
}

void QgsPointCloudLayer::onPointCloudIndexGenerationStateChanged( QgsPointCloudDataProvider::PointCloudIndexGenerationState state )
{
if ( state == QgsPointCloudDataProvider::Indexed )
@@ -129,6 +129,8 @@ class CORE_EXPORT QgsPointCloudLayer : public QgsMapLayer

void setTransformContext( const QgsCoordinateTransformContext &transformContext ) override;
void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, bool loadDefaultStyleFlag = false ) override;
QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const override;
QString decodedSource( const QString &source, const QString &dataProvider, const QgsReadWriteContext &context ) const override;
QString loadDefaultStyle( bool &resultFlag SIP_OUT ) FINAL;
QString htmlMetadata() const override;
QgsMapLayerElevationProperties *elevationProperties() override;

0 comments on commit 5c101e7

Please sign in to comment.