QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
Loading...
Searching...
No Matches
qgswmsrenderer.h
Go to the documentation of this file.
1/***************************************************************************
2 qgswmsrendrer.h
3 -------------------
4 begin : May 14, 2006
5 copyright : (C) 2006 by Marco Hugentobler
6 (C) 2017 by David Marteau
7 email : marco dot hugentobler at karto dot baug dot ethz dot ch
8 david dot marteau at 3liz dot com
9 ***************************************************************************/
10
11/***************************************************************************
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. *
17 * *
18 ***************************************************************************/
19
20#ifndef QGSWMSRENDERER_H
21#define QGSWMSRENDERER_H
22
23#include "qgslayoutatlas.h"
24#include "qgsserversettings.h"
25#include "qgswmsparameters.h"
26#include "qgswmsrendercontext.h"
27#include "qgsfeaturefilter.h"
29#include "qgseditformconfig.h"
30#include <QDomDocument>
31#include <QMap>
32#include <QString>
33
35class QgsPrintLayout;
36class QgsFeature;
37class QgsLayout;
38class QgsMapLayer;
40class QgsMapSettings;
41class QgsPointXY;
42class QgsRasterLayer;
43class QgsRectangle;
45class QgsVectorLayer;
47class QgsDxfExport;
49class QgsLayerTree;
53
54class QImage;
55class QPaintDevice;
56class QPainter;
58
59namespace QgsWms
60{
61
68 {
69 public:
70
76 QgsRenderer( const QgsWmsRenderContext &context );
77
82
90 QImage *getLegendGraphics( QgsLayerTreeModel &model );
91
100
109 QJsonObject getLegendGraphicsAsJson( QgsLayerTreeModel &model, const Qgis::LegendJsonRenderFlags &jsonRenderFlags = Qgis::LegendJsonRenderFlags() );
110
119 QJsonObject getLegendGraphicsAsJson( QgsLayerTreeModelLegendNode &legendNode, const Qgis::LegendJsonRenderFlags &jsonRenderFlags = Qgis::LegendJsonRenderFlags() );
120
121
122 typedef QSet<QString> SymbolSet;
123 typedef QHash<QgsVectorLayer *, SymbolSet> HitTest;
124
130
136 QImage *getMap();
137
142 std::unique_ptr<QgsDxfExport> getDxf();
143
150 std::unique_ptr<QgsMapRendererTask> getPdf( const QString &tmpFileName );
151
156 QByteArray getPrint();
157
162 QByteArray getFeatureInfo( const QString &version = "1.3.0" );
163
167 void configureLayers( QList<QgsMapLayer *> &layers, QgsMapSettings *settings = nullptr );
168
169 private:
170 QgsLegendSettings legendSettings();
171
172 // Build and returns highlight layers
173 QList<QgsMapLayer *> highlightLayers( QList<QgsWmsParametersHighlightLayer> params );
174
175 // Rendering step for layers
176 QPainter *layersRendering( const QgsMapSettings &mapSettings, QImage &image ) const;
177
178 // Rendering step for annotations
179 void annotationsRendering( QPainter *painter, const QgsMapSettings &mapSettings ) const;
180
181 // Set layer opacity
182 void setLayerOpacity( QgsMapLayer *layer, int opacity ) const;
183
184 // Set layer filter and dimension
185 void setLayerFilter( QgsMapLayer *layer, const QList<QgsWmsParametersFilter> &filters );
186
187 QStringList dimensionFilter( QgsVectorLayer *layer ) const;
188
189 // Set layer python filter
190 void setLayerAccessControlFilter( QgsMapLayer *layer ) const;
191
192 // Set layer selection
193 void setLayerSelection( QgsMapLayer *layer, const QStringList &fids ) const;
194
195 // Combine map extent with layer extent
196 void updateExtent( const QgsMapLayer *layer, QgsMapSettings &mapSettings ) const;
197
198 // Scale image with WIDTH/HEIGHT if necessary
199 QImage *scaleImage( const QImage *image ) const;
200
207 QImage *createImage( const QSize &size ) const;
208
216 void configureMapSettings( const QPaintDevice *paintDevice, QgsMapSettings &mapSettings, bool mandatoryCrsParam = true );
217
224 QgsRenderContext configureDefaultRenderContext( QPainter *painter = nullptr );
225
226 QDomDocument featureInfoDocument( QList<QgsMapLayer *> &layers, const QgsMapSettings &mapSettings,
227 const QImage *outputImage, const QString &version ) const;
228
244 bool featureInfoFromVectorLayer( QgsVectorLayer *layer,
245 const QgsPointXY *infoPoint,
246 int nFeatures,
247 QDomDocument &infoDocument,
248 QDomElement &layerElement,
249 const QgsMapSettings &mapSettings,
250 QgsRenderContext &renderContext,
251 const QString &version,
252 QgsRectangle *featureBBox = nullptr,
253 QgsGeometry *filterGeom = nullptr ) const;
254
266 void writeAttributesTabGroup( const QgsAttributeEditorElement *group, QgsVectorLayer *layer, const QgsFields &fields, QgsAttributes &featureAttributes, QDomDocument &doc, QDomElement &featureElem, QgsRenderContext &renderContext, QStringList *attributes = nullptr ) const;
267
279 void writeAttributesTabLayout( QgsEditFormConfig &config, QgsVectorLayer *layer, const QgsFields &fields, QgsAttributes &featureAttributes, QDomDocument &doc, QDomElement &featureElem, QgsRenderContext &renderContext, QStringList *attributes = nullptr ) const;
280
292 void writeVectorLayerAttribute( int attributeIndex, QgsVectorLayer *layer, const QgsFields &fields, QgsAttributes &featureAttributes, QDomDocument &doc, QDomElement &featureElem, QgsRenderContext &renderContext, QStringList *attributes = nullptr ) const;
293
295 bool featureInfoFromRasterLayer( QgsRasterLayer *layer,
296 const QgsMapSettings &mapSettings,
297 const QgsPointXY *infoPoint,
298 const QgsRenderContext &renderContext,
299 QDomDocument &infoDocument,
300 QDomElement &layerElement,
301 const QString &version ) const;
302
304 void runHitTest( const QgsMapSettings &mapSettings, HitTest &hitTest ) const;
306 void runHitTestLayer( QgsVectorLayer *vl, SymbolSet &usedSymbols, QgsRenderContext &context ) const;
307
312 bool testFilterStringSafety( const QString &filter ) const;
314 static void groupStringList( QStringList &list, const QString &groupString );
315
317 void convertFeatureInfoToSia2045( QDomDocument &doc ) const;
318
320 QByteArray convertFeatureInfoToHtml( const QDomDocument &doc ) const;
321
323 QByteArray convertFeatureInfoToText( const QDomDocument &doc ) const;
324
326 QByteArray convertFeatureInfoToJson( const QList<QgsMapLayer *> &layers, const QDomDocument &doc ) const;
327
328 QDomElement createFeatureGML(
329 const QgsFeature *feat,
330 QgsVectorLayer *layer,
331 QDomDocument &doc,
333 const QgsMapSettings &mapSettings,
334 const QString &typeName,
335 bool withGeom,
336 int version,
337 QStringList *attributes = nullptr ) const;
338
340 static QString replaceValueMapAndRelation( QgsVectorLayer *vl, int idx, const QVariant &attributeVal );
342 QgsRectangle featureInfoSearchRect( QgsVectorLayer *ml, const QgsMapSettings &ms, const QgsRenderContext &rct, const QgsPointXY &infoPoint ) const;
343
351 bool configurePrintLayout( QgsPrintLayout *c, const QgsMapSettings &mapSettings, QgsLayoutAtlas *atlas );
352
353 void removeTemporaryLayers();
354
355 void handlePrintErrors( const QgsLayout *layout ) const;
356
357 void setLayerStyle( QgsMapLayer *layer, const QString &style ) const;
358
359 void setLayerSld( QgsMapLayer *layer, const QDomElement &sld ) const;
360
361 QgsWmsParameters mWmsParameters;
362
363 QgsFeatureFilter mFeatureFilter;
364
365 const QgsProject *mProject = nullptr;
366 QList<QgsMapLayer *> mTemporaryLayers;
367 const QgsWmsRenderContext &mContext;
368
370 bool mIsTemporal = false;
371 };
372
373} // namespace QgsWms
374
375#endif
A helper class that centralizes restrictions given by all the access control filter plugins.
This is an abstract base class for any elements of a drag and drop form.
A vector of attributes.
This class represents a coordinate reference system (CRS).
Exports QGIS layers to the DXF format.
Contains configuration settings for an editor form.
A feature filter provider allowing to set filter expressions on a per-layer basis.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:56
Container of fields for a vector layer.
Definition qgsfields.h:45
A geometry is the spatial representation of a feature.
Layer tree group node serves as a container for layers and further groups.
The QgsLegendRendererItem class is abstract interface for legend items returned from QgsMapLayerLegen...
The QgsLayerTreeModel class is model implementation for Qt item views framework.
Namespace with helper functions for layer tree operations.
Class used to render QgsLayout as an atlas, by iterating over the features from an associated vector ...
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition qgslayout.h:49
The QgsLegendSettings class stores the appearance and layout settings for legend drawing with QgsLege...
Base class for all map layer types.
Definition qgsmaplayer.h:75
QgsTask task which draws a map to an image file or a painter as a background task.
The QgsMapSettings class contains configuration for rendering of the map.
A class to represent a 2D point.
Definition qgspointxy.h:60
Print layout, a QgsLayout subclass for static or atlas-based layouts.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:107
Represents a raster layer.
A rectangle specified with double values.
Contains information about the context of a rendering operation.
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins.
Represents a vector layer which manages a vector based data sets.
Map renderer for WMS requests.
QHash< QgsVectorLayer *, SymbolSet > HitTest
QByteArray getPrint()
Returns printed page as binary.
HitTest symbols()
Returns the hit test according to the current context.
std::unique_ptr< QgsDxfExport > getDxf()
Returns the map as DXF data.
QSet< QString > SymbolSet
void configureLayers(QList< QgsMapLayer * > &layers, QgsMapSettings *settings=nullptr)
Configures layers for rendering optionally considering the map settings.
std::unique_ptr< QgsMapRendererTask > getPdf(const QString &tmpFileName)
Returns a configured pdf export task.
QByteArray getFeatureInfo(const QString &version="1.3.0")
Creates an xml document that describes the result of the getFeatureInfo request.
QImage * getLegendGraphics(QgsLayerTreeModel &model)
Returns the map legend as an image (or nullptr in case of error).
QJsonObject getLegendGraphicsAsJson(QgsLayerTreeModel &model, const Qgis::LegendJsonRenderFlags &jsonRenderFlags=Qgis::LegendJsonRenderFlags())
Returns the map legend as a JSON object.
QImage * getMap()
Returns the map as an image (or nullptr in case of error).
~QgsRenderer()
Destructor for QgsRenderer.
Provides an interface to retrieve and manipulate WMS parameters received from the client.
Rendering context for the WMS renderer.
Median cut implementation.
QgsLayerTreeModelLegendNode * legendNode(const QString &rule, QgsLayerTreeModel &model)
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
const QgsCoordinateReferenceSystem & crs
const QString & typeName
bool withGeom