Skip to content

Commit

Permalink
Respect project "avoid tile artefacts" setting when rendering
Browse files Browse the repository at this point in the history
a project using WMS services

Fixes #37679
  • Loading branch information
nyalldawson committed Feb 12, 2021
1 parent 04d6ea9 commit 4b921d9
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 0 deletions.
15 changes: 15 additions & 0 deletions python/server/auto_generated/qgsserverprojectutils.sip.in
Expand Up @@ -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 );
Expand Down
5 changes: 5 additions & 0 deletions src/server/qgsserverprojectutils.cpp
Expand Up @@ -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 );
}
14 changes: 14 additions & 0 deletions src/server/qgsserverprojectutils.h
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/server/services/wms/qgswmsrendercontext.cpp
Expand Up @@ -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 );
Expand Down
11 changes: 11 additions & 0 deletions src/server/services/wms/qgswmsrendercontext.h
Expand Up @@ -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.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/server/services/wms/qgswmsrenderer.cpp
Expand Up @@ -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() );
}
Expand Down

0 comments on commit 4b921d9

Please sign in to comment.