QGIS API Documentation 4.3.0-Master (8c22baaae17)
Loading...
Searching...
No Matches
qgswmsrendercontext.h
Go to the documentation of this file.
1/***************************************************************************
2 qgswmsrendercontext.h
3 ---------------------
4 begin : March 22, 2019
5 copyright : (C) 2019 by Paul Blottiere
6 email : paul.blottiere@oslandia.com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSWMSRENDERCONTEXT_H
19#define QGSWMSRENDERCONTEXT_H
20
21#include "qgsproject.h"
22#include "qgsserverinterface.h"
23#include "qgswmsparameters.h"
24
25namespace QgsWms
26{
27
35 {
36 public:
54 Q_DECLARE_FLAGS( Flags, Flag )
55
57
64
69
74
78 const QgsServerSettings &settings() const;
79
83 const QgsProject *project() const;
84
88 void setFlag( Flag flag, bool on = true );
89
95 bool testFlag( Flag flag ) const;
96
100 QList<QgsMapLayer *> layers() const;
101
106 QHash<const QgsMapLayer *, QStringList> acceptableLayersToRender() const;
107
112 QList<QgsMapLayer *> layersToRender() const;
113
118 QDomElement sld( const QgsMapLayer &layer ) const;
119
124 QString style( const QgsMapLayer &layer ) const;
125
130 double scaleDenominator() const;
131
137
142 bool updateExtent() const;
143
149
154 int imageQuality() const;
155
161 int tileBuffer() const;
162
172 bool renderMapTiles() const;
173
177 int precision() const;
178
183 QString layerNickname( const QgsMapLayer &layer ) const;
184
189 QgsMapLayer *layer( const QString &nickname ) const;
190
194 bool isValidLayer( const QString &nickname ) const;
195
200 QList<QgsMapLayer *> layersFromGroup( const QString &nickname ) const;
201
205 bool isValidGroup( const QString &name ) const;
206
210 qreal dotsPerMm() const;
211
216 QStringList flattenedQueryLayers( const QStringList &layerNames ) const;
217
218#ifdef HAVE_SERVER_PYTHON_PLUGINS
219
223 QgsAccessControl *accessControl() const;
224#endif
225
230 QMap<QString, QList<QgsMapLayer *>> layerGroups() const;
231
236 double mapTileBuffer( int mapWidth ) const;
237
243 QSize mapSize( bool aspectRatio = true ) const;
244
250 bool isValidWidthHeight() const;
251
258 bool isValidWidthHeight( int width, int height ) const;
259
263 int mapWidth() const;
264
268 int mapHeight() const;
269
274 bool isExternalLayer( const QString &name ) const;
275
280 void setSocketFeedback( QgsFeedback *feedback );
281
287
288 QHash<QgsMapLayer *, QgsDateTimeRange> perLayerTemporalRange() const { return mPerLayerTemporalRange; }
289
290 private:
291 void initNicknameLayers();
292 void initRestrictedLayers();
293 void initLayerGroupsRecursive( const QgsLayerTreeGroup *group, const QString &groupName );
294
300 void initPerLayerTemporalRange( const QgsLayerTreeGroup *group, const QString &groupName );
301
302 void searchLayersToRender();
303 void searchLayersToRenderSld();
304 void searchLayersToRenderStyle();
305 void removeUnwantedLayers();
306 QHash<const QgsMapLayer *, QStringList> acceptableLayers( const QStringList &requestedLayerNames ) const;
307
312 bool addLayerToRender( QgsMapLayer *layer );
313
318 bool checkLayerReadPermissions( QgsMapLayer *layer ) const;
319
320 bool layerScaleVisibility( const QString &name ) const;
321
322 const QgsProject *mProject = nullptr;
323 QgsServerInterface *mInterface = nullptr;
324 QgsWmsParameters mParameters;
325 Flags mFlags = Flags();
326 double mScaleDenominator = -1.0;
327
328 // nickname of all layers defined within the project
329 QMultiMap<QString, QgsMapLayer *> mNicknameLayers;
330
331 // map of layers to use for rendering
332 QList<QgsMapLayer *> mLayersToRender;
333
334 // map of layers that can be rendered and for each a list of the layer names, group names, etc. requesting it
335 QHash<const QgsMapLayer *, QStringList> mAcceptableLayersToRender;
336
337 QHash<QgsMapLayer *, QgsDateTimeRange> mPerLayerTemporalRange;
338
339 // list of layers which are not usable
340 QStringList mRestrictedLayers;
341
342 QMap<QString, QList<QgsMapLayer *>> mLayerGroups;
343
344 QMap<QString, QDomElement> mSlds;
345 QMap<QString, QString> mStyles;
346
347 // list for external layers
348 QList<QgsMapLayer *> mExternalLayers;
349
350 QgsFeedback *mSocketFeedback = nullptr;
351 };
352}; // namespace QgsWms
353
354#endif
A helper class that centralizes restrictions given by all the access control filter plugins.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
Layer tree group node serves as a container for layers and further groups.
Base class for all map layer types.
Definition qgsmaplayer.h:83
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:114
Defines interfaces exposed by QGIS Server and made available to plugins.
Provides a way to retrieve settings by prioritizing according to environment variables,...
Provides an interface to retrieve and manipulate WMS parameters received from the client.
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...
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.
QStringList flattenedQueryLayers(const QStringList &layerNames) const
Returns a list of query layer names where group names are replaced by the names of their layer compon...
QgsFeedback * socketFeedback() const
Returns the response feedback if any.
QgsWmsRenderContext(const QgsProject *project, QgsServerInterface *interface)
Constructor for QgsWmsRenderContext.
QList< QgsMapLayer * > layers() const
Returns a list of all layers read from the project.
void setParameters(const QgsWmsParameters &parameters)
Sets WMS parameters.
QList< QgsMapLayer * > layersToRender() const
Returns a list of all layers to actually render according to the current configuration.
int mapWidth() const
Returns WIDTH or SRCWIDTH according to UseSrcWidthHeight flag.
QgsMapLayer * layer(const QString &nickname) const
Returns the layer corresponding to the nickname, or a nullptr if not found or if the layer do not nee...
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.
QHash< QgsMapLayer *, QgsDateTimeRange > perLayerTemporalRange() const
const QgsServerSettings & settings() const
Returns settings of the server.
void setFlag(Flag flag, bool on=true)
Sets or unsets a rendering flag according to the on value.
bool isValidWidthHeight() const
Returns true if width and height are valid according to the maximum values defined within 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.
QgsWmsParameters parameters() const
Returns WMS parameters.
void setScaleDenominator(double scaleDenominator)
Sets a custom scale denominator.
QString style(const QgsMapLayer &layer) const
Returns a style's name for a specific layer.
QMap< QString, QList< QgsMapLayer * > > layerGroups() const
Returns a map having layer group names as keys and a list of layers as values.
double mapTileBuffer(int mapWidth) const
Returns the tile buffer in geographical units for the given map width in pixels.
QString layerNickname(const QgsMapLayer &layer) const
Returns the nickname (short name, id or name) of the layer according to the current configuration.
void setSocketFeedback(QgsFeedback *feedback)
Sets the response feedback.
double scaleDenominator() const
Returns the scale denominator to use for rendering according to the current configuration.
qreal dotsPerMm() const
Returns default dots per mm according to the current configuration.
bool testFlag(Flag flag) const
Returns the status of a rendering flag.
QDomElement sld(const QgsMapLayer &layer) const
Returns a SLD document for a specific layer.
bool isValidLayer(const QString &nickname) const
Returns true if the layer has to be rendered, false otherwise.
const QgsProject * project() const
Returns the project.
int precision() const
Returns the precision to use according to the current configuration.
QHash< const QgsMapLayer *, QStringList > acceptableLayersToRender() const
Returns a hash of all the layers that can be rendered and for each a list of the layer names,...
int imageQuality() const
Returns the image quality to use for rendering according to the current configuration.
int mapHeight() const
Returns HEIGHT or SRCHEIGHT according to UseSrcWidthHeight flag.
bool renderMapTiles() const
Returns true if WMS requests should use the QgsMapSettings::RenderMapTile flag, so that no visible ar...
Flag
Available rendering options.
@ AddAllLayers
For GetPrint: add layers from LAYER(S) parameter.
Median cut implementation.