Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Possibility to set pdf export map themes and predefined scales in req…
…uest
  • Loading branch information
mhugent committed Apr 20, 2023
1 parent 74969ff commit 18976bb
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 4 deletions.
31 changes: 31 additions & 0 deletions src/server/services/wms/qgswmsparameters.cpp
Expand Up @@ -2331,6 +2331,37 @@ namespace QgsWms
return useOgcGeoreferencing;
}

QStringList QgsWmsParameters::pdfExportMapThemes() const
{
QStringList themes;
const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
if ( options.contains( PdfFormatOption::EXPORT_THEMES ) )
{
themes = options[PdfFormatOption::EXPORT_THEMES].split( "," );
}
return themes;
}

QVector<qreal> QgsWmsParameters::pdfPredefinedMapScales() const
{
QVector<qreal> scales;
const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
if ( options.contains( PdfFormatOption::PREDEFINED_MAP_SCALES ) )
{
QStringList scaleList = options[PdfFormatOption::PREDEFINED_MAP_SCALES].split( "," );
for ( const auto &it : scaleList )
{
bool ok = false;
qreal scale = it.toDouble( &ok );
if ( ok )
{
scales.append( scale );
}
}
}
return scales;
}

QMap<QString, QString> QgsWmsParameters::dimensionValues() const
{
QMap<QString, QString> dimValues;
Expand Down
12 changes: 12 additions & 0 deletions src/server/services/wms/qgswmsparameters.h
Expand Up @@ -1440,6 +1440,18 @@ namespace QgsWms
*/
bool pdfUseOgcBestPracticeFormatGeoreferencing() const;

/**
* Returns map themes for GeoPDF export
* \since QGIS 3.32
*/
QStringList pdfExportMapThemes() const;

/**
* Returns list of map scales
* \since QGIS 3.32
*/
QVector<qreal> pdfPredefinedMapScales() const;

QString version() const override;

QString request() const override;
Expand Down
20 changes: 16 additions & 4 deletions src/server/services/wms/qgswmsrenderer.cpp
Expand Up @@ -630,10 +630,22 @@ namespace QgsWms
exportSettings.flags |= QgsLayoutRenderContext::FlagDrawSelection;
// Print as raster
exportSettings.rasterizeWholeImage = layout->customProperty( QStringLiteral( "rasterize" ), false ).toBool();
// Set scales
exportSettings.predefinedMapScales = QgsLayoutUtils::predefinedScales( layout.get( ) );

// Settings from format options request parameters
// Set scales. 1. Prio: request, 2. Prio: predefined mapscales in layout
QVector<qreal> requestMapScales = mWmsParameters.pdfPredefinedMapScales();
if ( requestMapScales.size() > 0 )
{
exportSettings.predefinedMapScales = requestMapScales;
}
else
{
exportSettings.predefinedMapScales = QgsLayoutUtils::predefinedScales( layout.get( ) );
}
// Export themes
QStringList exportThemes = mWmsParameters.pdfExportMapThemes();
if ( exportThemes.size() > 0 )
{
exportSettings.exportThemes = exportThemes;
}
exportSettings.writeGeoPdf = mWmsParameters.writeGeoPdf();
exportSettings.textRenderFormat = mWmsParameters.pdfTextRenderFormat();
exportSettings.forceVectorOutput = mWmsParameters.pdfForceVectorOutput();
Expand Down

0 comments on commit 18976bb

Please sign in to comment.