QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgswmsgetlegendgraphics.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgswmsgetlegendgraphics.cpp
3  -------------------------
4  begin : December 20 , 2016
5  copyright : (C) 2007 by Marco Hugentobler (original code)
6  (C) 2014 by Alessandro Pasotti (original code)
7  (C) 2016 by David Marteau
8  email : marco dot hugentobler at karto dot baug dot ethz dot ch
9  a dot pasotti at itopen dot it
10  david dot marteau at 3liz dot com
11  ***************************************************************************/
12 
13 /***************************************************************************
14  * *
15  * This program is free software; you can redistribute it and/or modify *
16  * it under the terms of the GNU General Public License as published by *
17  * the Free Software Foundation; either version 2 of the License, or *
18  * (at your option) any later version. *
19  * *
20  ***************************************************************************/
21 #include "qgslayertree.h"
22 #include "qgslegendrenderer.h"
23 #include "qgsvectorlayer.h"
25 #include "qgssymbollayerutils.h"
26 #include "qgsmaplayerlegend.h"
27 
28 #include "qgswmsutils.h"
29 #include "qgswmsserviceexception.h"
31 #include "qgswmsrenderer.h"
32 
33 #include <QImage>
34 #include <QJsonObject>
35 #include <QJsonDocument>
36 
37 namespace QgsWms
38 {
39  void writeGetLegendGraphics( QgsServerInterface *serverIface, const QgsProject *project,
40  const QString &, const QgsServerRequest &request,
41  QgsServerResponse &response )
42  {
43  // get parameters from query
44  QgsWmsParameters parameters( QUrlQuery( request.url() ) );
45 
46  // check parameters validity
47  // FIXME fail with png + mode
48  checkParameters( parameters );
49 
50  // init render context
51  QgsWmsRenderContext context( project, serverIface );
54  context.setParameters( parameters );
55 
56  // get the requested output format
57  QgsWmsParameters::Format format = parameters.format();
58 
59  // parameters.format() returns NONE if the requested format is image/png with a
60  // mode (e.g. image/png;mode=16bit), so in that case we use parseImageFormat to
61  // give the requested format another chance
62 
63  QString imageSaveFormat;
64  QString imageContentType;
65  if ( format == QgsWmsParameters::Format::PNG )
66  {
67  imageContentType = "image/png";
68  imageSaveFormat = "PNG";
69  }
70  else if ( format == QgsWmsParameters::Format::JPG )
71  {
72  imageContentType = "image/jpeg";
73  imageSaveFormat = "JPEG";
74  }
75  else if ( format == QgsWmsParameters::Format::NONE )
76  {
77  switch ( parseImageFormat( parameters.formatAsString() ) )
78  {
79  case PNG:
80  case PNG8:
81  case PNG16:
82  case PNG1:
84  imageContentType = "image/png";
85  imageSaveFormat = "PNG";
86  break;
87  default:
88  break;
89  }
90  }
91 
92  if ( format == QgsWmsParameters::Format::NONE )
93  {
95  QStringLiteral( "Output format '%1' is not supported in the GetLegendGraphic request" ).arg( parameters.formatAsString() ) );
96  }
97 
98  // Get cached image
99 #ifdef HAVE_SERVER_PYTHON_PLUGINS
100  QgsAccessControl *accessControl = serverIface->accessControls();
101  QgsServerCacheManager *cacheManager = serverIface->cacheManager();
102  if ( cacheManager && !imageSaveFormat.isEmpty() )
103  {
104  QImage image;
105  QByteArray content = cacheManager->getCachedImage( project, request, accessControl );
106  if ( !content.isEmpty() && image.loadFromData( content ) )
107  {
108  response.setHeader( QStringLiteral( "Content-Type" ), imageContentType );
109  image.save( response.io(), qPrintable( imageSaveFormat ) );
110  return;
111  }
112  }
113 #endif
114  QgsRenderer renderer( context );
115 
116  // retrieve legend settings and model
117  std::unique_ptr<QgsLayerTree> tree( layerTree( context ) );
118  std::unique_ptr<QgsLayerTreeModel> model( legendModel( context, *tree.get() ) );
119 
120  // rendering
121  if ( format == QgsWmsParameters::Format::JSON )
122  {
123  QJsonObject result;
124  if ( !parameters.rule().isEmpty() )
125  {
127  QStringLiteral( "RULE cannot be used with JSON format" ) );
128  }
129  else
130  {
131  result = renderer.getLegendGraphicsAsJson( *model.get() );
132  }
133  tree->clear();
134  response.setHeader( QStringLiteral( "Content-Type" ), parameters.formatAsString() );
135  QJsonDocument doc( result );
136  response.write( doc.toJson( QJsonDocument::Compact ) );
137  }
138  else
139  {
140  std::unique_ptr<QImage> result;
141  if ( !parameters.rule().isEmpty() )
142  {
143  QgsLayerTreeModelLegendNode *node = legendNode( parameters.rule(), *model.get() );
144  if ( ! node )
145  {
146  throw QgsException( QStringLiteral( "Could not get a legend node for the requested RULE" ) );
147  }
148  result.reset( renderer.getLegendGraphics( *node ) );
149  }
150  else
151  {
152  result.reset( renderer.getLegendGraphics( *model.get() ) );
153  }
154  tree->clear();
155  if ( result )
156  {
157  writeImage( response, *result, parameters.formatAsString(), context.imageQuality() );
158 #ifdef HAVE_SERVER_PYTHON_PLUGINS
159  if ( cacheManager )
160  {
161  QByteArray content = response.data();
162  if ( !content.isEmpty() )
163  cacheManager->setCachedImage( &content, project, request, accessControl );
164  }
165 #endif
166  }
167  else
168  {
169  throw QgsException( QStringLiteral( "Failed to compute GetLegendGraphics image" ) );
170  }
171  }
172  }
173 
174  void checkParameters( QgsWmsParameters &parameters )
175  {
176  if ( parameters.allLayersNickname().isEmpty() )
177  {
179  parameters[QgsWmsParameter::LAYERS] );
180  }
181 
182  if ( parameters.format() == QgsWmsParameters::Format::NONE )
183  {
185  parameters[QgsWmsParameter::FORMAT] );
186  }
187 
188  if ( ! parameters.bbox().isEmpty() && !parameters.rule().isEmpty() )
189  {
191  QStringLiteral( "BBOX parameter cannot be combined with RULE." ) );
192  }
193 
194  if ( ! parameters.bbox().isEmpty() && parameters.bboxAsRectangle().isEmpty() )
195  {
197  parameters[QgsWmsParameter::BBOX] );
198  }
199  // If we have a contextual legend (BBOX is set)
200  // make sure (SRC)WIDTH and (SRC)HEIGHT are set, default to 800px width
201  // height is calculated from that value, respecting the aspect
202  if ( ! parameters.bbox().isEmpty() )
203  {
204  // Calculate ratio from bbox
205  QgsRectangle bbox { parameters.bboxAsRectangle() };
206  QString crs = parameters.crs();
207  if ( crs.compare( QStringLiteral( "CRS:84" ), Qt::CaseInsensitive ) == 0 )
208  {
209  bbox.invert();
210  }
212  if ( parameters.versionAsNumber() >= QgsProjectVersion( 1, 3, 0 ) &&
214  {
215  bbox.invert();
216  }
217  const double ratio { bbox.width() / bbox.height() };
218  int defaultHeight { static_cast<int>( 800 / ratio ) };
219  if ( parameters.width().isEmpty() && parameters.srcWidth().isEmpty() )
220  {
221  parameters.set( QgsWmsParameter::SRCWIDTH, 800 );
222  }
223  if ( parameters.height().isEmpty() && parameters.srcHeight().isEmpty() )
224  {
225  parameters.set( QgsWmsParameter::SRCHEIGHT, defaultHeight );
226  }
227  }
228  }
229 
231  {
232 
233  const QgsWmsParameters parameters = context.parameters();
234  std::unique_ptr<QgsLayerTreeModel> model( new QgsLayerTreeModel( &tree ) );
235  std::unique_ptr<QgsMapSettings> mapSettings;
236 
237  if ( context.scaleDenominator() > 0 )
238  {
239  model->setLegendFilterByScale( context.scaleDenominator() );
240  }
241 
242  // content based legend
243  if ( ! parameters.bbox().isEmpty() )
244  {
245  mapSettings = qgis::make_unique<QgsMapSettings>();
246  mapSettings->setOutputSize( context.mapSize() );
247  // Inverted axis?
248  QgsRectangle bbox { parameters.bboxAsRectangle() };
249  QString crs = parameters.crs();
250  if ( crs.compare( QStringLiteral( "CRS:84" ), Qt::CaseInsensitive ) == 0 )
251  {
252  bbox.invert();
253  }
255  if ( parameters.versionAsNumber() >= QgsProjectVersion( 1, 3, 0 ) &&
257  {
258  bbox.invert();
259  }
260  mapSettings->setDestinationCrs( outputCrs );
261  mapSettings->setExtent( bbox );
262  QgsRenderer renderer( context );
263  QList<QgsMapLayer *> layers = context.layersToRender();
264  renderer.configureLayers( layers, mapSettings.get() );
265  mapSettings->setLayers( context.layersToRender() );
266  model->setLegendFilterByMap( mapSettings.get() );
267  }
268 
269  // if legend is not based on rendering rules
270  if ( parameters.rule().isEmpty() )
271  {
272  QList<QgsLayerTreeNode *> children = tree.children();
273  QString ruleLabel = parameters.ruleLabel();
274  for ( QgsLayerTreeNode *node : children )
275  {
276  if ( ! QgsLayerTree::isLayer( node ) )
277  continue;
278 
279  QgsLayerTreeLayer *nodeLayer = QgsLayerTree::toLayer( node );
280 
281  // layer titles - hidden or not
283  // rule item titles
284  if ( !parameters.ruleLabelAsBool() )
285  {
286  for ( QgsLayerTreeModelLegendNode *legendNode : model->layerLegendNodes( nodeLayer ) )
287  {
288  // empty string = no override, so let's use one space
289  legendNode->setUserLabel( QStringLiteral( " " ) );
290  }
291  }
292  else if ( ruleLabel.compare( QStringLiteral( "AUTO" ), Qt::CaseInsensitive ) == 0 )
293  {
294  for ( QgsLayerTreeModelLegendNode *legendNode : model->layerLegendNodes( nodeLayer ) )
295  {
296  //clearing label for single symbol
299  }
300  }
301  }
302  }
303 
304  return model.release();
305  }
306 
308  {
309  std::unique_ptr<QgsLayerTree> tree( new QgsLayerTree() );
310 
311  QList<QgsVectorLayerFeatureCounter *> counters;
312  for ( QgsMapLayer *ml : context.layersToRender() )
313  {
314  QgsLayerTreeLayer *lt = tree->addLayer( ml );
315  lt->setUseLayerName( false ); // do not modify underlying layer
316 
317  // name
318  if ( !ml->title().isEmpty() )
319  lt->setName( ml->title() );
320 
321  // show feature count
322  const bool showFeatureCount = context.parameters().showFeatureCountAsBool();
323  const QString property = QStringLiteral( "showFeatureCount" );
324  lt->setCustomProperty( property, showFeatureCount );
325 
326  if ( ml->type() != QgsMapLayerType::VectorLayer || !showFeatureCount )
327  continue;
328 
329  QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( ml );
331  if ( !counter )
332  continue;
333 
334  counters.append( counter );
335  }
336 
337  for ( QgsVectorLayerFeatureCounter *counter : counters )
338  {
339  counter->waitForFinished();
340  }
341 
342  return tree.release();
343  }
344 
346  {
347  for ( QgsLayerTreeLayer *layer : model.rootGroup()->findLayers() )
348  {
349  for ( QgsLayerTreeModelLegendNode *node : model.layerLegendNodes( layer ) )
350  {
351  if ( node->data( Qt::DisplayRole ).toString().compare( rule ) == 0 )
352  return node;
353  }
354  }
355  return nullptr;
356  }
357 } // namespace QgsWms
QgsVectorLayerFeatureCounter
Counts the features in a QgsVectorLayer in task.
Definition: qgsvectorlayerfeaturecounter.h:34
QgsWms::QgsServiceException::QGIS_InvalidParameterValue
@ QGIS_InvalidParameterValue
Definition: qgswmsserviceexception.h:62
qgswmsrenderer.h
QgsWms::parseImageFormat
ImageOutputFormat parseImageFormat(const QString &format)
Parse image format parameter.
Definition: qgswmsutils.cpp:70
QgsWms::QgsWmsParameters::srcHeight
QString srcHeight() const
Returns SRCHEIGHT parameter or an empty string if not defined.
Definition: qgswmsparameters.cpp:726
QgsWms::QgsWmsParameters
Provides an interface to retrieve and manipulate WMS parameters received from the client.
Definition: qgswmsparameters.h:324
QgsLayerTreeGroup::findLayers
QList< QgsLayerTreeLayer * > findLayers() const
Find all layer nodes.
Definition: qgslayertreegroup.cpp:223
QgsWms::QgsWmsParameters::set
void set(QgsWmsParameter::Name name, const QVariant &value)
Sets a parameter value thanks to its name.
Definition: qgswmsparameters.cpp:561
QgsLegendRenderer::setNodeLegendStyle
static void setNodeLegendStyle(QgsLayerTreeNode *node, QgsLegendStyle::Style style)
Sets the style of a node.
Definition: qgslegendrenderer.cpp:898
QgsException
Defines a QGIS exception class.
Definition: qgsexception.h:35
QgsLayerTreeNode
This class is a base class for nodes in a layer tree.
Definition: qgslayertreenode.h:75
outputCrs
const QgsCoordinateReferenceSystem & outputCrs
Definition: qgswfsgetfeature.cpp:61
QgsLayerTreeModelLegendNode::isEmbeddedInParent
virtual bool isEmbeddedInParent() const
Definition: qgslayertreemodellegendnode.h:84
QgsWms::QgsWmsParameters::showFeatureCountAsBool
bool showFeatureCountAsBool() const
Returns SHOWFEATURECOUNT as a bool.
Definition: qgswmsparameters.cpp:972
QgsMapLayerType::VectorLayer
@ VectorLayer
qgswmsutils.h
QgsWms::layerTree
QgsLayerTree * layerTree(const QgsWmsRenderContext &context)
Definition: qgswmsgetlegendgraphics.cpp:307
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:51
QgsCoordinateReferenceSystem::fromOgcWmsCrs
static QgsCoordinateReferenceSystem fromOgcWmsCrs(const QString &ogcCrs)
Creates a CRS from a given OGC WMS-format Coordinate Reference System string.
Definition: qgscoordinatereferencesystem.cpp:200
QgsWms::QgsWmsParameters::crs
QString crs() const
Returns CRS or an empty string if none is defined.
Definition: qgswmsparameters.cpp:673
QgsLayerTreeLayer::setUseLayerName
void setUseLayerName(bool use=true)
Uses the layer's name if use is true, or the name manually set if false.
Definition: qgslayertreelayer.cpp:206
QgsWms::QgsWmsParameters::Format
Format
Output format for the response.
Definition: qgswmsparameters.h:331
QgsWms::QgsWmsRenderContext::setFlag
void setFlag(Flag flag, bool on=true)
Sets or unsets a rendering flag according to the on value.
Definition: qgswmsrendercontext.cpp:55
qgssymbollayerutils.h
QgsWms::QgsWmsParameters::bbox
QString bbox() const
Returns BBOX if defined or an empty string.
Definition: qgswmsparameters.cpp:696
QgsWms::QgsWmsRenderContext::setParameters
void setParameters(const QgsWmsParameters &parameters)
Sets WMS parameters.
Definition: qgswmsrendercontext.cpp:41
QgsWms::writeImage
void writeImage(QgsServerResponse &response, QImage &img, const QString &formatStr, int imageQuality)
Write image response.
Definition: qgswmsutils.cpp:107
QgsServerRequest
QgsServerRequest Class defining request interface passed to services QgsService::executeRequest() met...
Definition: qgsserverrequest.h:39
QgsCoordinateReferenceSystem::hasAxisInverted
bool hasAxisInverted() const
Returns whether axis is inverted (e.g., for WMS 1.3) for the CRS.
Definition: qgscoordinatereferencesystem.cpp:813
QgsWms::QgsWmsRenderContext
Rendering context for the WMS renderer.
Definition: qgswmsrendercontext.h:35
QgsLayerTree::toLayer
static QgsLayerTreeLayer * toLayer(QgsLayerTreeNode *node)
Cast node to a layer.
Definition: qgslayertree.h:75
QgsLayerTreeModel
The QgsLayerTreeModel class is model implementation for Qt item views framework.
Definition: qgslayertreemodel.h:54
QgsWms::QgsServiceException::OGC_InvalidFormat
@ OGC_InvalidFormat
Definition: qgswmsserviceexception.h:49
QgsWms::QgsWmsRenderContext::imageQuality
int imageQuality() const
Returns the image quality to use for rendering according to the current configuration.
Definition: qgswmsrendercontext.cpp:129
qgsvectorlayerfeaturecounter.h
QgsServerInterface::accessControls
virtual QgsAccessControl * accessControls() const =0
Gets the registered access control filters.
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:42
QgsProject
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition: qgsproject.h:95
QgsServerResponse::write
virtual void write(const QString &data)
Write string This is a convenient method that will write directly to the underlying I/O device.
Definition: qgsserverresponse.cpp:25
QgsWms::QgsWmsParameters::srcWidth
QString srcWidth() const
Returns SRCWIDTH parameter or an empty string if not defined.
Definition: qgswmsparameters.cpp:731
QgsWms::QgsWmsParameters::height
QString height() const
Returns HEIGHT parameter or an empty string if not defined.
Definition: qgswmsparameters.cpp:706
QgsWms::QgsWmsRenderContext::UseSrcWidthHeight
@ UseSrcWidthHeight
Definition: qgswmsrendercontext.h:50
QgsLayerTree
Namespace with helper functions for layer tree operations.
Definition: qgslayertree.h:33
QgsWms::PNG8
@ PNG8
Definition: qgswmsutils.h:43
QgsWms::QgsWmsRenderContext::mapSize
QSize mapSize(bool aspectRatio=true) const
Returns the size (in pixels) of the map to render, according to width and height WMS parameters as we...
Definition: qgswmsrendercontext.cpp:698
QgsWms::QgsWmsParameters::versionAsNumber
QgsProjectVersion versionAsNumber() const
Returns VERSION parameter if defined or its default value.
Definition: qgswmsparameters.cpp:756
QgsServerCacheManager
A helper class that centralizes caches accesses given by all the server cache filter plugins.
Definition: qgsservercachemanager.h:41
QgsWms::PNG16
@ PNG16
Definition: qgswmsutils.h:44
QgsLayerTreeLayer::setName
void setName(const QString &n) override
Sets the layer's name.
Definition: qgslayertreelayer.cpp:86
QgsLayerTreeLayer
Layer tree node points to a map layer.
Definition: qgslayertreelayer.h:44
QgsWms::PNG
@ PNG
Definition: qgswmsutils.h:42
QgsWms::QgsWmsParameters::ruleLabelAsBool
bool ruleLabelAsBool() const
Returns RULELABEL as a bool.
Definition: qgswmsparameters.cpp:922
QgsWms::legendModel
QgsLayerTreeModel * legendModel(const QgsWmsRenderContext &context, QgsLayerTree &tree)
Definition: qgswmsgetlegendgraphics.cpp:230
QgsWms::QgsServiceException::QGIS_MissingParameterValue
@ QGIS_MissingParameterValue
Definition: qgswmsserviceexception.h:61
QgsServerResponse::data
virtual QByteArray data() const =0
Gets the data written so far.
QgsWms::QgsWmsParameters::bboxAsRectangle
QgsRectangle bboxAsRectangle() const
Returns BBOX as a rectangle if defined and valid.
Definition: qgswmsparameters.cpp:701
qgslayertree.h
QgsLayerTreeModelLegendNode::setEmbeddedInParent
virtual void setEmbeddedInParent(bool embedded)
Definition: qgslayertreemodellegendnode.h:85
QgsWms::QgsWmsParameter::BBOX
@ BBOX
Definition: qgswmsparameters.h:112
QgsWms::QgsWmsParameters::format
Format format() const
Returns format.
Definition: qgswmsparameters.cpp:790
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:206
QgsLayerTreeModel::rootGroup
QgsLayerTree * rootGroup() const
Returns pointer to the root node of the layer tree. Always a non nullptr value.
Definition: qgslayertreemodel.cpp:519
qgswmsgetlegendgraphics.h
QgsWms::legendNode
QgsLayerTreeModelLegendNode * legendNode(const QString &rule, QgsLayerTreeModel &model)
Definition: qgswmsgetlegendgraphics.cpp:345
qgsvectorlayer.h
QgsAccessControl
A helper class that centralizes restrictions given by all the access control filter plugins.
Definition: qgsaccesscontrol.h:37
QgsWms
Median cut implementation.
Definition: qgsdxfwriter.cpp:23
QgsLayerTree::isLayer
static bool isLayer(const QgsLayerTreeNode *node)
Check whether the node is a valid layer node.
Definition: qgslayertree.h:53
QgsWms::QgsWmsRenderContext::scaleDenominator
double scaleDenominator() const
Returns the scale denominator to use for rendering according to the current configuration.
Definition: qgswmsrendercontext.cpp:227
QgsLayerTreeModelLegendNode::setUserLabel
virtual void setUserLabel(const QString &userLabel)
Definition: qgslayertreemodellegendnode.h:88
QgsWms::QgsWmsParameter::LAYERS
@ LAYERS
Definition: qgswmsparameters.h:127
QgsWms::QgsBadRequestException
Exception thrown in case of malformed request.
Definition: qgswmsserviceexception.h:214
QgsLayerTreeNode::setCustomProperty
void setCustomProperty(const QString &key, const QVariant &value)
Sets a custom property for the node. Properties are stored in a map and saved in project file.
Definition: qgslayertreenode.cpp:180
QgsWms::QgsWmsParameters::layerTitleAsBool
bool layerTitleAsBool() const
Returns LAYERTITLE as a bool or its default value if not defined.
Definition: qgswmsparameters.cpp:1215
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
QgsServerInterface::cacheManager
virtual QgsServerCacheManager * cacheManager() const =0
Gets the registered server cache filters.
QgsServerCacheManager::getCachedImage
QByteArray getCachedImage(const QgsProject *project, const QgsServerRequest &request, QgsAccessControl *accessControl) const
Returns cached image (or 0 if image not in cache) like tiles.
Definition: qgsservercachemanager.cpp:139
QgsWms::PNG1
@ PNG1
Definition: qgswmsutils.h:45
QgsMapLayer
Base class for all map layer types.
Definition: qgsmaplayer.h:83
QgsWms::writeGetLegendGraphics
void writeGetLegendGraphics(QgsServerInterface *serverIface, const QgsProject *project, const QString &, const QgsServerRequest &request, QgsServerResponse &response)
Output GetLegendGRaphics response.
Definition: qgswmsgetlegendgraphics.cpp:39
QgsWms::QgsWmsParameters::rule
QString rule() const
Returns RULE parameter or an empty string if none is defined.
Definition: qgswmsparameters.cpp:912
QgsLayerTreeNode::children
QList< QgsLayerTreeNode * > children()
Gets list of children of the node. Children are owned by the parent.
Definition: qgslayertreenode.h:112
QgsWms::QgsWmsParameter::FORMAT
@ FORMAT
Definition: qgswmsparameters.h:146
qgsmaplayerlegend.h
QgsServerResponse::io
virtual QIODevice * io()=0
Returns the underlying QIODevice.
QgsWms::QgsWmsParameter::SRCHEIGHT
@ SRCHEIGHT
Definition: qgswmsparameters.h:180
QgsServerRequest::url
QUrl url() const
Definition: qgsserverrequest.cpp:65
QgsVectorLayer::countSymbolFeatures
QgsVectorLayerFeatureCounter * countSymbolFeatures(bool storeSymbolFids=false)
Count features for symbols.
Definition: qgsvectorlayer.cpp:766
QgsWms::QgsWmsParameter::SRCWIDTH
@ SRCWIDTH
Definition: qgswmsparameters.h:179
QgsServerCacheManager::setCachedImage
bool setCachedImage(const QByteArray *img, const QgsProject *project, const QgsServerRequest &request, QgsAccessControl *accessControl) const
Updates or inserts the image in cache like tiles.
Definition: qgsservercachemanager.cpp:156
QgsWms::QgsRenderer
Map renderer for WMS requests.
Definition: qgswmsrenderer.h:64
QgsWms::QgsWmsParameters::formatAsString
QString formatAsString() const
Returns FORMAT parameter as a string.
Definition: qgswmsparameters.cpp:779
QgsLegendStyle::Hidden
@ Hidden
Special style, item is hidden including margins around.
Definition: qgslegendstyle.h:43
qgswmsserviceexception.h
QgsWms::QgsRenderer::getLegendGraphics
QImage * getLegendGraphics(QgsLayerTreeModel &model)
Returns the map legend as an image (or nullptr in case of error).
Definition: qgswmsrenderer.cpp:112
QgsLayerTreeModel::layerLegendNodes
QList< QgsLayerTreeModelLegendNode * > layerLegendNodes(QgsLayerTreeLayer *nodeLayer, bool skipNodeEmbeddedInParent=false)
Returns filtered list of active legend nodes attached to a particular layer node (by default it retur...
Definition: qgslayertreemodel.cpp:1550
QgsWms::QgsRenderer::configureLayers
void configureLayers(QList< QgsMapLayer * > &layers, QgsMapSettings *settings=nullptr)
Configures layers for rendering optionally considering the map settings.
Definition: qgswmsrenderer.cpp:3110
QgsWms::QgsWmsRenderContext::UseScaleDenominator
@ UseScaleDenominator
Definition: qgswmsrendercontext.h:40
QgsWms::QgsWmsRenderContext::layersToRender
QList< QgsMapLayer * > layersToRender() const
Returns a list of all layers to actually render according to the current configuration.
Definition: qgswmsrendercontext.cpp:217
QgsRectangle::isEmpty
bool isEmpty() const
Returns true if the rectangle is empty.
Definition: qgsrectangle.h:437
qgslegendrenderer.h
QgsLegendStyle::Subgroup
@ Subgroup
Legend subgroup title.
Definition: qgslegendstyle.h:46
QgsWms::QgsRenderer::getLegendGraphicsAsJson
QJsonObject getLegendGraphicsAsJson(QgsLayerTreeModel &model)
Returns the map legend as a JSON object.
Definition: qgswmsrenderer.cpp:182
QgsServerInterface
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins.
Definition: qgsserverinterface.h:61
QgsWms::checkParameters
void checkParameters(QgsWmsParameters &parameters)
checkParameters checks request parameters and sets SRCHEIGHT and SRCWIDTH to default values in case B...
Definition: qgswmsgetlegendgraphics.cpp:174
QgsWms::QgsWmsParameters::width
QString width() const
Returns WIDTH parameter or an empty string if not defined.
Definition: qgswmsparameters.cpp:711
QgsProjectVersion
A class to describe the version of a project.
Definition: qgsprojectversion.h:32
QgsTask::waitForFinished
bool waitForFinished(int timeout=30000)
Blocks the current thread until the task finishes or a maximum of timeout milliseconds.
Definition: qgstaskmanager.cpp:168
QgsServerResponse
QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() m...
Definition: qgsserverresponse.h:44
QgsWms::QgsWmsParameters::allLayersNickname
QStringList allLayersNickname() const
Returns nickname of layers found in LAYER and LAYERS parameters.
Definition: qgswmsparameters.cpp:1409
QgsWms::QgsWmsRenderContext::parameters
QgsWmsParameters parameters() const
Returns WMS parameters.
Definition: qgswmsrendercontext.cpp:72
QgsWms::QgsWmsParameters::ruleLabel
QString ruleLabel() const
Returns RULELABEL parameter or an empty string if none is defined.
Definition: qgswmsparameters.cpp:917
QgsServerResponse::setHeader
virtual void setHeader(const QString &key, const QString &value)=0
Set Header entry Add Header entry to the response Note that it is usually an error to set Header afte...
QgsLayerTreeModelLegendNode
The QgsLegendRendererItem class is abstract interface for legend items returned from QgsMapLayerLegen...
Definition: qgslayertreemodellegendnode.h:51