Skip to content
Permalink
Browse files

Respect project "avoid tile artefacts" setting when rendering

a project using WMS services

Fixes #37679
  • Loading branch information
nyalldawson committed Feb 12, 2021
1 parent 04d6ea9 commit 4b921d9ee9ff1c121a559fad2c8f172a6a0452f6
@@ -165,6 +165,21 @@ Returns the tile buffer in pixels for WMS images defined in a QGIS project.
:return: tile buffer if defined in project, 0 otherwise.

.. versionadded:: 3.10
%End

bool wmsRenderMapTiles( const QgsProject &project );
%Docstring
Returns ``True`` if WMS requests should use the QgsMapSettings.RenderMapTile flag,
so that no visible artefacts are visible between adjacent tiles.

This flag can slow down rendering considerably, so it is only used if the corresponding
setting is enabled in the project.

:param project: the QGIS project

:return: ``True`` if the flag should be used, or ``False`` if not.

.. versionadded:: 3.18
%End

int wmsMaxAtlasFeatures( const QgsProject &project );
@@ -389,3 +389,8 @@ QString QgsServerProjectUtils::wmtsServiceUrl( const QgsProject &project )
{
return project.readEntry( QStringLiteral( "WMTSUrl" ), QStringLiteral( "/" ), "" );
}

bool QgsServerProjectUtils::wmsRenderMapTiles( const QgsProject &project )
{
return project.readBoolEntry( QStringLiteral( "RenderMapTile" ), QStringLiteral( "/" ), false );
}
@@ -171,6 +171,20 @@ namespace QgsServerProjectUtils
*/
SERVER_EXPORT int wmsTileBuffer( const QgsProject &project );

/**
* Returns TRUE if WMS requests should use the QgsMapSettings::RenderMapTile flag,
* so that no visible artefacts are visible between adjacent tiles.
*
* This flag can slow down rendering considerably, so it is only used if the corresponding
* setting is enabled in the project.
*
* \param project the QGIS project
* \returns TRUE if the flag should be used, or FALSE if not.
*
* \since QGIS 3.18
*/
SERVER_EXPORT bool wmsRenderMapTiles( const QgsProject &project );

/**
* Returns the maximum number of atlas features which can be printed in a request
* \param project the QGIS project
@@ -150,6 +150,11 @@ int QgsWmsRenderContext::tileBuffer() const
return tileBuffer;
}

bool QgsWmsRenderContext::renderMapTiles() const
{
return QgsServerProjectUtils::wmsRenderMapTiles( *mProject );
}

int QgsWmsRenderContext::precision() const
{
int precision = QgsServerProjectUtils::wmsFeatureInfoPrecision( *mProject );
@@ -156,6 +156,17 @@ namespace QgsWms
*/
int tileBuffer() const;

/**
* Returns TRUE if WMS requests should use the QgsMapSettings::RenderMapTile flag,
* so that no visible artefacts are visible between adjacent tiles.
*
* This flag can slow down rendering considerably, so it is only used if the corresponding
* if explicitly opted in.
*
* \since QGIS 3.18
*/
bool renderMapTiles() const;

/**
* Returns the precision to use according to the current configuration.
*/
@@ -1165,6 +1165,8 @@ namespace QgsWms
// enable rendering optimization
mapSettings.setFlag( QgsMapSettings::UseRenderingOptimization );

mapSettings.setFlag( QgsMapSettings::RenderMapTile, mContext.renderMapTiles() );

// set selection color
mapSettings.setSelectionColor( mProject->selectionColor() );
}

0 comments on commit 4b921d9

Please sign in to comment.