QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
QgsWms::QgsWmsRenderContext Class Reference

Rendering context for the WMS renderer. More...

#include <qgswmsrendercontext.h>

Public Types

enum  Flag {
  UseScaleDenominator = 0x01 , UseOpacity = 0x02 , UseFilter = 0x04 , UseSelection = 0x08 ,
  AddHighlightLayers = 0x10 , UpdateExtent = 0x20 , SetAccessControl = 0x40 , AddQueryLayers = 0x80 ,
  UseWfsLayersOnly = 0x100 , AddExternalLayers = 0x200 , UseSrcWidthHeight = 0x400 , UseTileBuffer = 0x800 ,
  AddAllLayers = 0x1000
}
 Available rendering options. More...
 
typedef QFlags< FlagFlags
 

Public Member Functions

 QgsWmsRenderContext (const QgsProject *project, QgsServerInterface *interface)
 Constructor for QgsWmsRenderContext.
 
 ~QgsWmsRenderContext ()
 
qreal dotsPerMm () const
 Returns default dots per mm according to the current configuration.
 
QStringList flattenedQueryLayers (const QStringList &layerNames) const
 Returns a list of query layer names where group names are replaced by the names of their layer components.
 
int imageQuality () const
 Returns the image quality to use for rendering according to the current configuration.
 
bool isExternalLayer (const QString &name) const
 Returns true if the layer is an external layer, false otherwise.
 
bool isValidGroup (const QString &name) const
 Returns true if name is a group.
 
bool isValidLayer (const QString &nickname) const
 Returns true if the layer has to be rendered, false otherwise.
 
bool isValidWidthHeight () const
 Returns true if width and height are valid according to the maximum values defined within the project, false otherwise.
 
bool isValidWidthHeight (int width, int height) const
 Returns true if width and height are valid according to the maximum image width/height.
 
QgsMapLayerlayer (const QString &nickname) const
 Returns the layer corresponding to the nickname, or a nullptr if not found or if the layer do not need to be rendered.
 
QMap< QString, QList< QgsMapLayer * > > layerGroups () const
 Returns a map having layer group names as keys and a list of layers as values.
 
QString layerNickname (const QgsMapLayer &layer) const
 Returns the nickname (short name, id or name) of the layer according to the current configuration.
 
QList< QgsMapLayer * > layers () const
 Returns a list of all layers read from the project.
 
QList< QgsMapLayer * > layersFromGroup (const QString &nickname) const
 Returns the group's layers list corresponding to the nickname, or an empty list if not found.
 
QList< QgsMapLayer * > layersToRender () const
 Returns a list of all layers to actually render according to the current configuration.
 
int mapHeight () const
 Returns HEIGHT or SRCHEIGHT according to UseSrcWidthHeight flag.
 
QSize mapSize (bool aspectRatio=true) const
 Returns the size (in pixels) of the map to render, according to width and height WMS parameters as well as the aspectRatio option.
 
double mapTileBuffer (int mapWidth) const
 Returns the tile buffer in geographical units for the given map width in pixels.
 
int mapWidth () const
 Returns WIDTH or SRCWIDTH according to UseSrcWidthHeight flag.
 
QgsWmsParameters parameters () const
 Returns WMS parameters.
 
QgsWmsParametersLayer parameters (const QgsMapLayer &layer) const
 Returns WMS parameters for a specific layer.
 
int precision () const
 Returns the precision to use according to the current configuration.
 
const QgsProjectproject () const
 Returns the project.
 
bool renderMapTiles () const
 Returns true if WMS requests should use the QgsMapSettings::RenderMapTile flag, so that no visible artifacts are visible between adjacent tiles.
 
double scaleDenominator () const
 Returns the scale denominator to use for rendering according to the current configuration.
 
void setFlag (Flag flag, bool on=true)
 Sets or unsets a rendering flag according to the on value.
 
void setParameters (const QgsWmsParameters &parameters)
 Sets WMS parameters.
 
void setScaleDenominator (double scaleDenominator)
 Sets a custom scale denominator.
 
void setSocketFeedback (QgsFeedback *feedback)
 Sets the response feedback.
 
const QgsServerSettingssettings () const
 Returns settings of the server.
 
QDomElement sld (const QgsMapLayer &layer) const
 Returns a SLD document for a specific layer.
 
QgsFeedbacksocketFeedback () const
 Returns the response feedback if any.
 
QString style (const QgsMapLayer &layer) const
 Returns a style's name for a specific layer.
 
bool testFlag (Flag flag) const
 Returns the status of a rendering flag.
 
int tileBuffer () const
 Returns the tile buffer value to use for rendering according to the current configuration.
 
bool updateExtent () const
 Returns true if the extent has to be updated before the rendering, false otherwise.
 

Detailed Description

Rendering context for the WMS renderer.

Since
QGIS 3.8

Definition at line 34 of file qgswmsrendercontext.h.

Member Typedef Documentation

◆ Flags

Definition at line 54 of file qgswmsrendercontext.h.

Member Enumeration Documentation

◆ Flag

Available rendering options.

Enumerator
UseScaleDenominator 
UseOpacity 
UseFilter 
UseSelection 
AddHighlightLayers 
UpdateExtent 
SetAccessControl 
AddQueryLayers 
UseWfsLayersOnly 
AddExternalLayers 
UseSrcWidthHeight 
UseTileBuffer 
AddAllLayers 

For GetPrint: add layers from LAYER(S) parameter.

Definition at line 38 of file qgswmsrendercontext.h.

Constructor & Destructor Documentation

◆ ~QgsWmsRenderContext()

QgsWmsRenderContext::~QgsWmsRenderContext ( )

Definition at line 35 of file qgswmsrendercontext.cpp.

◆ QgsWmsRenderContext()

QgsWmsRenderContext::QgsWmsRenderContext ( const QgsProject project,
QgsServerInterface interface 
)

Constructor for QgsWmsRenderContext.

Parameters
projectThe project to use for the rendering
interfaceThe server interface

Definition at line 28 of file qgswmsrendercontext.cpp.

Member Function Documentation

◆ dotsPerMm()

qreal QgsWmsRenderContext::dotsPerMm ( ) const

Returns default dots per mm according to the current configuration.

Definition at line 182 of file qgswmsrendercontext.cpp.

◆ flattenedQueryLayers()

QStringList QgsWmsRenderContext::flattenedQueryLayers ( const QStringList &  layerNames) const

Returns a list of query layer names where group names are replaced by the names of their layer components.

Since
QGIS 3.8

Definition at line 197 of file qgswmsrendercontext.cpp.

◆ imageQuality()

int QgsWmsRenderContext::imageQuality ( ) const

Returns the image quality to use for rendering according to the current configuration.

Definition at line 141 of file qgswmsrendercontext.cpp.

◆ isExternalLayer()

bool QgsWmsRenderContext::isExternalLayer ( const QString &  name) const

Returns true if the layer is an external layer, false otherwise.

Since
QGIS 3.16

Definition at line 906 of file qgswmsrendercontext.cpp.

◆ isValidGroup()

bool QgsWmsRenderContext::isValidGroup ( const QString &  name) const

Returns true if name is a group.

Definition at line 326 of file qgswmsrendercontext.cpp.

◆ isValidLayer()

bool QgsWmsRenderContext::isValidLayer ( const QString &  nickname) const

Returns true if the layer has to be rendered, false otherwise.

Definition at line 316 of file qgswmsrendercontext.cpp.

◆ isValidWidthHeight() [1/2]

bool QgsWmsRenderContext::isValidWidthHeight ( ) const

Returns true if width and height are valid according to the maximum values defined within the project, false otherwise.

Since
QGIS 3.8

Definition at line 712 of file qgswmsrendercontext.cpp.

◆ isValidWidthHeight() [2/2]

bool QgsWmsRenderContext::isValidWidthHeight ( int  width,
int  height 
) const

Returns true if width and height are valid according to the maximum image width/height.

Parameters
widththe image width in pixels
heightthe image height in pixels
Since
QGIS 3.22

Definition at line 717 of file qgswmsrendercontext.cpp.

◆ layer()

QgsMapLayer * QgsWmsRenderContext::layer ( const QString &  nickname) const

Returns the layer corresponding to the nickname, or a nullptr if not found or if the layer do not need to be rendered.

Definition at line 300 of file qgswmsrendercontext.cpp.

◆ layerGroups()

QMap< QString, QList< QgsMapLayer * > > QgsWmsRenderContext::layerGroups ( ) const

Returns a map having layer group names as keys and a list of layers as values.

Since
QGIS 3.8

Definition at line 681 of file qgswmsrendercontext.cpp.

◆ layerNickname()

QString QgsWmsRenderContext::layerNickname ( const QgsMapLayer layer) const

Returns the nickname (short name, id or name) of the layer according to the current configuration.

Definition at line 281 of file qgswmsrendercontext.cpp.

◆ layers()

QList< QgsMapLayer * > QgsWmsRenderContext::layers ( ) const

Returns a list of all layers read from the project.

Definition at line 242 of file qgswmsrendercontext.cpp.

◆ layersFromGroup()

QList< QgsMapLayer * > QgsWmsRenderContext::layersFromGroup ( const QString &  nickname) const

Returns the group's layers list corresponding to the nickname, or an empty list if not found.

Definition at line 321 of file qgswmsrendercontext.cpp.

◆ layersToRender()

QList< QgsMapLayer * > QgsWmsRenderContext::layersToRender ( ) const

Returns a list of all layers to actually render according to the current configuration.

Definition at line 237 of file qgswmsrendercontext.cpp.

◆ mapHeight()

int QgsWmsRenderContext::mapHeight ( ) const

Returns HEIGHT or SRCHEIGHT according to UseSrcWidthHeight flag.

Definition at line 699 of file qgswmsrendercontext.cpp.

◆ mapSize()

QSize QgsWmsRenderContext::mapSize ( bool  aspectRatio = true) const

Returns the size (in pixels) of the map to render, according to width and height WMS parameters as well as the aspectRatio option.

Since
QGIS 3.8

Definition at line 814 of file qgswmsrendercontext.cpp.

◆ mapTileBuffer()

double QgsWmsRenderContext::mapTileBuffer ( int  mapWidth) const

Returns the tile buffer in geographical units for the given map width in pixels.

Since
QGIS 3.10

Definition at line 795 of file qgswmsrendercontext.cpp.

◆ mapWidth()

int QgsWmsRenderContext::mapWidth ( ) const

Returns WIDTH or SRCWIDTH according to UseSrcWidthHeight flag.

Definition at line 686 of file qgswmsrendercontext.cpp.

◆ parameters() [1/2]

QgsWmsParameters QgsWmsRenderContext::parameters ( ) const

Returns WMS parameters.

Definition at line 82 of file qgswmsrendercontext.cpp.

◆ parameters() [2/2]

QgsWmsParametersLayer QgsWmsRenderContext::parameters ( const QgsMapLayer layer) const

Returns WMS parameters for a specific layer.

An empty instance is returned if not available.

Definition at line 123 of file qgswmsrendercontext.cpp.

◆ precision()

int QgsWmsRenderContext::precision ( ) const

Returns the precision to use according to the current configuration.

Definition at line 170 of file qgswmsrendercontext.cpp.

◆ project()

const QgsProject * QgsWmsRenderContext::project ( ) const

Returns the project.

Definition at line 92 of file qgswmsrendercontext.cpp.

◆ renderMapTiles()

bool QgsWmsRenderContext::renderMapTiles ( ) const

Returns true if WMS requests should use the QgsMapSettings::RenderMapTile flag, so that no visible artifacts 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

Definition at line 165 of file qgswmsrendercontext.cpp.

◆ scaleDenominator()

double QgsWmsRenderContext::scaleDenominator ( ) const

Returns the scale denominator to use for rendering according to the current configuration.

Definition at line 247 of file qgswmsrendercontext.cpp.

◆ setFlag()

void QgsWmsRenderContext::setFlag ( Flag  flag,
bool  on = true 
)

Sets or unsets a rendering flag according to the on value.

Definition at line 65 of file qgswmsrendercontext.cpp.

◆ setParameters()

void QgsWmsRenderContext::setParameters ( const QgsWmsParameters parameters)

Sets WMS parameters.

Definition at line 41 of file qgswmsrendercontext.cpp.

◆ setScaleDenominator()

void QgsWmsRenderContext::setScaleDenominator ( double  scaleDenominator)

Sets a custom scale denominator.

In this case, layers to render are updated according to their scale visibility.

Definition at line 263 of file qgswmsrendercontext.cpp.

◆ setSocketFeedback()

void QgsWmsRenderContext::setSocketFeedback ( QgsFeedback feedback)

Sets the response feedback.

Since
QGIS 3.36

Definition at line 938 of file qgswmsrendercontext.cpp.

◆ settings()

const QgsServerSettings & QgsWmsRenderContext::settings ( ) const

Returns settings of the server.

Definition at line 87 of file qgswmsrendercontext.cpp.

◆ sld()

QDomElement QgsWmsRenderContext::sld ( const QgsMapLayer layer) const

Returns a SLD document for a specific layer.

An empty document is returned if not available.

Definition at line 97 of file qgswmsrendercontext.cpp.

◆ socketFeedback()

QgsFeedback * QgsWmsRenderContext::socketFeedback ( ) const

Returns the response feedback if any.

Since
QGIS 3.36

Definition at line 943 of file qgswmsrendercontext.cpp.

◆ style()

QString QgsWmsRenderContext::style ( const QgsMapLayer layer) const

Returns a style's name for a specific layer.

An empty string is returned if not available.

Definition at line 110 of file qgswmsrendercontext.cpp.

◆ testFlag()

bool QgsWmsRenderContext::testFlag ( Flag  flag) const

Returns the status of a rendering flag.

Parameters
flagThe flag to test
Returns
true if the rendering option is activated, false otherwise

Definition at line 77 of file qgswmsrendercontext.cpp.

◆ tileBuffer()

int QgsWmsRenderContext::tileBuffer ( ) const

Returns the tile buffer value to use for rendering according to the current configuration.

Since
QGIS 3.10

Definition at line 153 of file qgswmsrendercontext.cpp.

◆ updateExtent()

bool QgsWmsRenderContext::updateExtent ( ) const

Returns true if the extent has to be updated before the rendering, false otherwise.

Definition at line 269 of file qgswmsrendercontext.cpp.


The documentation for this class was generated from the following files: