Skip to content
Permalink
Browse files

Fix raster layer names in GeoPDF exports are lost

Fixes #33306

(cherry picked from commit d864dc8)
  • Loading branch information
nyalldawson committed Jun 19, 2020
1 parent f4d7c46 commit 6d9cc40bf7120e8bbf1f8a657d604fdc8c155e59
Showing with 10 additions and 1 deletion.
  1. +9 −1 src/core/qgsmaprenderertask.cpp
  2. +1 −0 src/core/qgsmaprenderertask.h
@@ -184,7 +184,8 @@ bool QgsMapRendererTask::run()
while ( !job->isFinished() )
{
QgsAbstractGeoPdfExporter::ComponentLayerDetail component;
component.name = QStringLiteral( "layer_%1" ).arg( outputLayer );

component.name = mLayerIdToLayerNameMap.value( job->currentLayerId(), QStringLiteral( "layer_%1" ).arg( outputLayer ) );
component.mapLayerId = job->currentLayerId();
component.sourcePdfPath = mGeoPdfExporter->generateTemporaryFilepath( QStringLiteral( "layer_%1.pdf" ).arg( outputLayer ) );
pdfComponents << component;
@@ -445,6 +446,13 @@ void QgsMapRendererTask::prepare()
mRenderedFeatureHandler = qgis::make_unique< QgsMapRendererTaskRenderedFeatureHandler >( static_cast< QgsMapRendererTaskGeoPdfExporter * >( mGeoPdfExporter.get() ), mMapSettings );
mMapSettings.addRenderedFeatureHandler( mRenderedFeatureHandler.get() );
}

const QList< QgsMapLayer * > layers = mMapSettings.layers();
for ( const QgsMapLayer *layer : layers )
{
mLayerIdToLayerNameMap.insert( layer->id(), layer->name() );
}

mJob.reset( new QgsMapRendererStagedRenderJob( mMapSettings, QgsMapRendererStagedRenderJob::RenderLabelsByMapLayer ) );
mJob->start();
return;
@@ -156,6 +156,7 @@ class CORE_EXPORT QgsMapRendererTask : public QgsTask

QList< QgsAnnotation * > mAnnotations;
QList< QgsMapDecoration * > mDecorations;
QMap< QString, QString> mLayerIdToLayerNameMap;

int mError = 0;

0 comments on commit 6d9cc40

Please sign in to comment.
You can’t perform that action at this time.