QGIS API Documentation  3.21.0-Master (5b68dc587e)
qgswmsgetcontext.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgswmsgetcontext.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 "qgswmsutils.h"
22 #include "qgswmsrequest.h"
23 #include "qgswmsgetcontext.h"
24 #include "qgsserverprojectutils.h"
25 
26 #include "qgslayertreenode.h"
27 #include "qgslayertreegroup.h"
28 #include "qgslayertreelayer.h"
29 #include "qgslayertree.h"
31 
32 #include "qgsexception.h"
33 
34 namespace QgsWms
35 {
36  namespace
37  {
38  void appendOwsLayerStyles( QDomDocument &doc, QDomElement &layerElem, QgsMapLayer *currentLayer );
39 
40  void appendOwsLayersFromTreeGroup( QDomDocument &doc,
41  QDomElement &parentLayer,
42  QgsServerInterface *serverIface,
43  const QgsProject *project,
44  const QgsWmsRequest &request,
45  const QgsLayerTreeGroup *layerTreeGroup,
46  QgsRectangle &combinedBBox,
47  const QString &strGroup );
48 
49  void appendOwsGeneralAndResourceList( QDomDocument &doc, QDomElement &parentElement,
50  QgsServerInterface *serverIface, const QgsProject *project,
51  const QgsWmsRequest &request );
52  }
53 
54  void writeGetContext( QgsServerInterface *serverIface, const QgsProject *project,
55  const QgsWmsRequest &request,
56  QgsServerResponse &response )
57  {
58 #ifdef HAVE_SERVER_PYTHON_PLUGINS
59  QgsAccessControl *accessControl = serverIface->accessControls();
60 #endif
61 
62  QDomDocument doc;
63  const QDomDocument *contextDocument = nullptr;
64 
65 #ifdef HAVE_SERVER_PYTHON_PLUGINS
66  QgsServerCacheManager *cacheManager = serverIface->cacheManager();
67  if ( cacheManager && cacheManager->getCachedDocument( &doc, project, request, accessControl ) )
68  {
69  contextDocument = &doc;
70  }
71  else //context xml not in cache. Create a new one
72  {
73  doc = getContext( serverIface, project, request );
74 
75  if ( cacheManager )
76  {
77  cacheManager->setCachedDocument( &doc, project, request, accessControl );
78  }
79  contextDocument = &doc;
80  }
81 #else
82  doc = getContext( serverIface, project, request );
83  contextDocument = &doc;
84 #endif
85  response.setHeader( QStringLiteral( "Content-Type" ), QStringLiteral( "text/xml; charset=utf-8" ) );
86  response.write( contextDocument->toByteArray() );
87  }
88 
89 
90  QDomDocument getContext( QgsServerInterface *serverIface,
91  const QgsProject *project,
92  const QgsWmsRequest &request )
93  {
94  QDomDocument doc;
95  const QDomProcessingInstruction xmlDeclaration = doc.createProcessingInstruction( QStringLiteral( "xml" ),
96  QStringLiteral( "version=\"1.0\" encoding=\"utf-8\"" ) );
97 
98  doc.appendChild( xmlDeclaration );
99 
100  QDomElement owsContextElem = doc.createElement( QStringLiteral( "OWSContext" ) );
101  owsContextElem.setAttribute( QStringLiteral( "xmlns" ), QStringLiteral( "http://www.opengis.net/ows-context" ) );
102  owsContextElem.setAttribute( QStringLiteral( "xmlns:ows-context" ), QStringLiteral( "http://www.opengis.net/ows-context" ) );
103  owsContextElem.setAttribute( QStringLiteral( "xmlns:context" ), QStringLiteral( "http://www.opengis.net/context" ) );
104  owsContextElem.setAttribute( QStringLiteral( "xmlns:ows" ), QStringLiteral( "http://www.opengis.net/ows" ) );
105  owsContextElem.setAttribute( QStringLiteral( "xmlns:sld" ), QStringLiteral( "http://www.opengis.net/sld" ) );
106  owsContextElem.setAttribute( QStringLiteral( "xmlns:ogc" ), QStringLiteral( "http://www.opengis.net/ogc" ) );
107  owsContextElem.setAttribute( QStringLiteral( "xmlns:gml" ), QStringLiteral( "http://www.opengis.net/gml" ) );
108  owsContextElem.setAttribute( QStringLiteral( "xmlns:kml" ), QStringLiteral( "http://www.opengis.net/kml/2.2" ) );
109  owsContextElem.setAttribute( QStringLiteral( "xmlns:xlink" ), QStringLiteral( "http://www.w3.org/1999/xlink" ) );
110  owsContextElem.setAttribute( QStringLiteral( "xmlns:ns9" ), QStringLiteral( "http://www.w3.org/2005/Atom" ) );
111  owsContextElem.setAttribute( QStringLiteral( "xmlns:xal" ), QStringLiteral( "urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" ) );
112  owsContextElem.setAttribute( QStringLiteral( "xmlns:ins" ), QStringLiteral( "http://www.inspire.org" ) );
113  owsContextElem.setAttribute( QStringLiteral( "version" ), QStringLiteral( "0.3.1" ) );
114  doc.appendChild( owsContextElem );
115 
116  appendOwsGeneralAndResourceList( doc, owsContextElem, serverIface, project, request );
117 
118  return doc;
119  }
120  namespace
121  {
122  void appendOwsGeneralAndResourceList( QDomDocument &doc, QDomElement &parentElement,
123  QgsServerInterface *serverIface, const QgsProject *project,
124  const QgsWmsRequest &request )
125  {
126  parentElement.setAttribute( QStringLiteral( "id" ), "ows-context-" + project->baseName() );
127 
128  // OWSContext General element
129  QDomElement generalElem = doc.createElement( QStringLiteral( "General" ) );
130 
131  // OWSContext Window element
132  QDomElement windowElem = doc.createElement( QStringLiteral( "Window" ) );
133  windowElem.setAttribute( QStringLiteral( "height" ), QStringLiteral( "600" ) );
134  windowElem.setAttribute( QStringLiteral( "width" ), QStringLiteral( "800" ) );
135  generalElem.appendChild( windowElem );
136 
137  //OWS title
138  //why not use project title ?
139  const QString title = QgsServerProjectUtils::owsServiceTitle( *project );
140  if ( !title.isEmpty() )
141  {
142  QDomElement titleElem = doc.createElement( QStringLiteral( "ows:Title" ) );
143  const QDomText titleText = doc.createTextNode( title );
144  titleElem.appendChild( titleText );
145  generalElem.appendChild( titleElem );
146  }
147 
148  //OWS abstract
149  const QString abstract = QgsServerProjectUtils::owsServiceAbstract( *project );
150  if ( !abstract.isEmpty() )
151  {
152  QDomElement abstractElem = doc.createElement( QStringLiteral( "ows:Abstract" ) );
153  const QDomText abstractText = doc.createCDATASection( abstract );
154  abstractElem.appendChild( abstractText );
155  generalElem.appendChild( abstractElem );
156  }
157 
158  //OWS Keywords
159  const QStringList keywords = QgsServerProjectUtils::owsServiceKeywords( *project );
160  if ( !keywords.isEmpty() )
161  {
162  const bool sia2045 = QgsServerProjectUtils::wmsInfoFormatSia2045( *project );
163 
164  QDomElement keywordsElem = doc.createElement( QStringLiteral( "ows:Keywords" ) );
165 
166  for ( int i = 0; i < keywords.size(); ++i )
167  {
168  const QString keyword = keywords.at( i );
169  if ( !keyword.isEmpty() )
170  {
171  QDomElement keywordElem = doc.createElement( QStringLiteral( "ows:Keyword" ) );
172  const QDomText keywordText = doc.createTextNode( keyword );
173  keywordElem.appendChild( keywordText );
174  if ( sia2045 )
175  {
176  keywordElem.setAttribute( QStringLiteral( "vocabulary" ), QStringLiteral( "SIA_Geo405" ) );
177  }
178  keywordsElem.appendChild( keywordElem );
179  }
180  }
181  generalElem.appendChild( keywordsElem );
182  }
183 
184  // OWSContext General element is complete
185  parentElement.appendChild( generalElem );
186 
187  // OWSContext ResourceList element
188  QDomElement resourceListElem = doc.createElement( QStringLiteral( "ResourceList" ) );
189  const QgsLayerTree *projectLayerTreeRoot = project->layerTreeRoot();
190  QgsRectangle combinedBBox;
191  appendOwsLayersFromTreeGroup( doc, resourceListElem, serverIface, project, request, projectLayerTreeRoot, combinedBBox, QString() );
192  parentElement.appendChild( resourceListElem );
193 
194  // OWSContext BoundingBox
195  const QgsCoordinateReferenceSystem projectCrs = project->crs();
196  QgsRectangle mapRect = QgsServerProjectUtils::wmsExtent( *project );
197  if ( mapRect.isEmpty() )
198  {
199  mapRect = combinedBBox;
200  }
201  QDomElement bboxElem = doc.createElement( QStringLiteral( "ows:BoundingBox" ) );
202  bboxElem.setAttribute( QStringLiteral( "crs" ), projectCrs.authid() );
203  if ( projectCrs.hasAxisInverted() )
204  {
205  mapRect.invert();
206  }
207  QDomElement lowerCornerElem = doc.createElement( QStringLiteral( "ows:LowerCorner" ) );
208  const QDomText lowerCornerText = doc.createTextNode( QString::number( mapRect.xMinimum() ) + " " + QString::number( mapRect.yMinimum() ) );
209  lowerCornerElem.appendChild( lowerCornerText );
210  bboxElem.appendChild( lowerCornerElem );
211  QDomElement upperCornerElem = doc.createElement( QStringLiteral( "ows:UpperCorner" ) );
212  const QDomText upperCornerText = doc.createTextNode( QString::number( mapRect.xMaximum() ) + " " + QString::number( mapRect.yMaximum() ) );
213  upperCornerElem.appendChild( upperCornerText );
214  bboxElem.appendChild( upperCornerElem );
215  generalElem.appendChild( bboxElem );
216  }
217 
218  void appendOwsLayersFromTreeGroup( QDomDocument &doc,
219  QDomElement &parentLayer,
220  QgsServerInterface *serverIface,
221  const QgsProject *project,
222  const QgsWmsRequest &request,
223  const QgsLayerTreeGroup *layerTreeGroup,
224  QgsRectangle &combinedBBox,
225  const QString &strGroup )
226  {
227  const QStringList restrictedLayers = QgsServerProjectUtils::wmsRestrictedLayers( *project );
228 
229  const QList< QgsLayerTreeNode * > layerTreeGroupChildren = layerTreeGroup->children();
230  for ( int i = 0; i < layerTreeGroupChildren.size(); ++i )
231  {
232  QgsLayerTreeNode *treeNode = layerTreeGroupChildren.at( i );
233 
234  if ( treeNode->nodeType() == QgsLayerTreeNode::NodeGroup )
235  {
236  QgsLayerTreeGroup *treeGroupChild = static_cast<QgsLayerTreeGroup *>( treeNode );
237 
238  const QString name = treeGroupChild->name();
239  if ( restrictedLayers.contains( name ) ) //unpublished group
240  {
241  continue;
242  }
243 
244  QString group;
245  if ( strGroup.isEmpty() )
246  {
247  group = name;
248  }
249  else
250  {
251  group = strGroup + "/" + name;
252  }
253 
254  appendOwsLayersFromTreeGroup( doc, parentLayer, serverIface, project, request, treeGroupChild, combinedBBox, group );
255  }
256  else
257  {
258  QgsLayerTreeLayer *treeLayer = static_cast<QgsLayerTreeLayer *>( treeNode );
259  QgsMapLayer *l = treeLayer->layer();
260  if ( restrictedLayers.contains( l->name() ) ) //unpublished layer
261  {
262  continue;
263  }
264 #ifdef HAVE_SERVER_PYTHON_PLUGINS
265  QgsAccessControl *accessControl = serverIface->accessControls();
266  if ( accessControl && !accessControl->layerReadPermission( l ) )
267  {
268  continue;
269  }
270 #endif
271  QDomElement layerElem = doc.createElement( QStringLiteral( "Layer" ) );
272 
273  // queryable layer
274  if ( !l->flags().testFlag( QgsMapLayer::Identifiable ) )
275  {
276  layerElem.setAttribute( QStringLiteral( "queryable" ), QStringLiteral( "false" ) );
277  }
278  else
279  {
280  layerElem.setAttribute( QStringLiteral( "queryable" ), QStringLiteral( "true" ) );
281  }
282 
283  // visibility
284  if ( treeLayer->itemVisibilityChecked() )
285  {
286  layerElem.setAttribute( QStringLiteral( "hidden" ), QStringLiteral( "false" ) );
287  }
288  else
289  {
290  layerElem.setAttribute( QStringLiteral( "hidden" ), QStringLiteral( "true" ) );
291  }
292 
293  // layer group
294  if ( !strGroup.isEmpty() )
295  {
296  layerElem.setAttribute( QStringLiteral( "group" ), strGroup );
297  }
298 
299  // Because Layer transparency is used for the rendering
300  // OWSContext Layer opacity is set to 1
301  layerElem.setAttribute( QStringLiteral( "opacity" ), 1 );
302 
303  QString wmsName = l->name();
304  if ( QgsServerProjectUtils::wmsUseLayerIds( *project ) )
305  {
306  wmsName = l->id();
307  }
308  else if ( !l->shortName().isEmpty() )
309  {
310  wmsName = l->shortName();
311  }
312  // layer wms name
313  layerElem.setAttribute( QStringLiteral( "name" ), wmsName );
314  // define an id based on layer wms name
315  layerElem.setAttribute( QStringLiteral( "id" ), wmsName.replace( QRegExp( "[\\W]" ), QStringLiteral( "_" ) ) );
316 
317  // layer title
318  QDomElement titleElem = doc.createElement( QStringLiteral( "ows:Title" ) );
319  QString title = l->title();
320  if ( title.isEmpty() )
321  {
322  title = l->name();
323  }
324  const QDomText titleText = doc.createTextNode( title );
325  titleElem.appendChild( titleText );
326  layerElem.appendChild( titleElem );
327 
328  // WMS GetMap output format
329  QDomElement formatElem = doc.createElement( QStringLiteral( "ows:OutputFormat" ) );
330  const QDomText formatText = doc.createTextNode( QStringLiteral( "image/png" ) );
331  formatElem.appendChild( formatText );
332  layerElem.appendChild( formatElem );
333 
334  // Get WMS service URL for Server Element
335  const QUrl href = serviceUrl( request, project, *serverIface->serverSettings() );
336 
337  //href needs to be a prefix
338  QString hrefString = href.toString();
339  hrefString.append( href.hasQuery() ? "&" : "?" );
340 
341  // COntext Server Element with WMS service URL
342  QDomElement serverElem = doc.createElement( QStringLiteral( "Server" ) );
343  serverElem.setAttribute( QStringLiteral( "service" ), QStringLiteral( "urn:ogc:serviceType:WMS" ) );
344  serverElem.setAttribute( QStringLiteral( "version" ), QStringLiteral( "1.3.0" ) );
345  serverElem.setAttribute( QStringLiteral( "default" ), QStringLiteral( "true" ) );
346  QDomElement orServerElem = doc.createElement( QStringLiteral( "OnlineResource" ) );
347  orServerElem.setAttribute( QStringLiteral( "xlink:href" ), hrefString );
348  serverElem.appendChild( orServerElem );
349  layerElem.appendChild( serverElem );
350 
351  const QString abstract = l->abstract();
352  if ( !abstract.isEmpty() )
353  {
354  QDomElement abstractElem = doc.createElement( QStringLiteral( "ows:Abstract" ) );
355  const QDomText abstractText = doc.createTextNode( abstract );
356  abstractElem.appendChild( abstractText );
357  layerElem.appendChild( abstractElem );
358  }
359 
360  //min/max scale denominatorScaleBasedVisibility
361  if ( l->hasScaleBasedVisibility() )
362  {
363  const QString minScaleString = QString::number( l->maximumScale() );
364  const QString maxScaleString = QString::number( l->minimumScale() );
365  QDomElement minScaleElem = doc.createElement( QStringLiteral( "sld:MinScaleDenominator" ) );
366  const QDomText minScaleText = doc.createTextNode( minScaleString );
367  minScaleElem.appendChild( minScaleText );
368  layerElem.appendChild( minScaleElem );
369  QDomElement maxScaleElem = doc.createElement( QStringLiteral( "sld:MaxScaleDenominator" ) );
370  const QDomText maxScaleText = doc.createTextNode( maxScaleString );
371  maxScaleElem.appendChild( maxScaleText );
372  layerElem.appendChild( maxScaleElem );
373  }
374 
375  // Style list
376  appendOwsLayerStyles( doc, layerElem, l );
377 
378  //keyword list
379  if ( !l->keywordList().isEmpty() )
380  {
381  const QStringList keywordStringList = l->keywordList().split( ',' );
382  const bool sia2045 = QgsServerProjectUtils::wmsInfoFormatSia2045( *project );
383 
384  QDomElement keywordsElem = doc.createElement( QStringLiteral( "ows:Keywords" ) );
385  for ( int i = 0; i < keywordStringList.size(); ++i )
386  {
387  QDomElement keywordElem = doc.createElement( QStringLiteral( "ows:Keyword" ) );
388  const QDomText keywordText = doc.createTextNode( keywordStringList.at( i ).trimmed() );
389  keywordElem.appendChild( keywordText );
390  if ( sia2045 )
391  {
392  keywordElem.setAttribute( QStringLiteral( "vocabulary" ), QStringLiteral( "SIA_Geo405" ) );
393  }
394  keywordsElem.appendChild( keywordElem );
395  }
396  layerElem.appendChild( keywordsElem );
397  }
398 
399  // layer data URL
400  const QString dataUrl = l->dataUrl();
401  if ( !dataUrl.isEmpty() )
402  {
403  QDomElement dataUrlElem = doc.createElement( QStringLiteral( "DataURL" ) );
404  const QString dataUrlFormat = l->dataUrlFormat();
405  dataUrlElem.setAttribute( QStringLiteral( "format" ), dataUrlFormat );
406  QDomElement dataORElem = doc.createElement( QStringLiteral( "OnlineResource" ) );
407  dataORElem.setAttribute( QStringLiteral( "xmlns:xlink" ), QStringLiteral( "http://www.w3.org/1999/xlink" ) );
408  dataORElem.setAttribute( QStringLiteral( "xlink:type" ), QStringLiteral( "simple" ) );
409  dataORElem.setAttribute( QStringLiteral( "xlink:href" ), dataUrl );
410  dataUrlElem.appendChild( dataORElem );
411  layerElem.appendChild( dataUrlElem );
412  }
413 
414  // layer metadata URL
415  const QList<QgsMapLayerServerProperties::MetadataUrl> urls = l->serverProperties()->metadataUrls();
416  for ( const QgsMapLayerServerProperties::MetadataUrl &url : urls )
417  {
418  QDomElement metaUrlElem = doc.createElement( QStringLiteral( "MetadataURL" ) );
419  metaUrlElem.setAttribute( QStringLiteral( "format" ), url.format );
420  QDomElement metaUrlORElem = doc.createElement( QStringLiteral( "OnlineResource" ) );
421  metaUrlORElem.setAttribute( QStringLiteral( "xmlns:xlink" ), QStringLiteral( "http://www.w3.org/1999/xlink" ) );
422  metaUrlORElem.setAttribute( QStringLiteral( "xlink:type" ), QStringLiteral( "simple" ) );
423  metaUrlORElem.setAttribute( QStringLiteral( "xlink:href" ), url.url );
424  metaUrlElem.appendChild( metaUrlORElem );
425  layerElem.appendChild( metaUrlElem );
426  }
427 
428  // update combineBBox
429  try
430  {
431  const QgsCoordinateTransform t( l->crs(), project->crs(), project );
432  const QgsRectangle BBox = t.transformBoundingBox( l->extent() );
433  if ( combinedBBox.isEmpty() )
434  {
435  combinedBBox = BBox;
436  }
437  else
438  {
439  combinedBBox.combineExtentWith( BBox );
440  }
441  }
442  catch ( const QgsCsException &cse )
443  {
444  Q_UNUSED( cse )
445  }
446 
447  if ( parentLayer.hasChildNodes() )
448  {
449  parentLayer.insertBefore( layerElem, parentLayer.firstChild() );
450  }
451  else
452  {
453  parentLayer.appendChild( layerElem );
454  }
455  }// end of treeNode type
456  }// end of for
457  }
458 
459  void appendOwsLayerStyles( QDomDocument &doc, QDomElement &layerElem, QgsMapLayer *currentLayer )
460  {
461  for ( const QString &styleName : currentLayer->styleManager()->styles() )
462  {
463  QDomElement styleListElem = doc.createElement( QStringLiteral( "StyleList" ) );
464  //only one default style in project file mode
465  QDomElement styleElem = doc.createElement( QStringLiteral( "Style" ) );
466  styleElem.setAttribute( QStringLiteral( "current" ), QStringLiteral( "true" ) );
467  QDomElement styleNameElem = doc.createElement( QStringLiteral( "Name" ) );
468  const QDomText styleNameText = doc.createTextNode( styleName );
469  styleNameElem.appendChild( styleNameText );
470  QDomElement styleTitleElem = doc.createElement( QStringLiteral( "Title" ) );
471  const QDomText styleTitleText = doc.createTextNode( styleName );
472  styleTitleElem.appendChild( styleTitleText );
473  styleElem.appendChild( styleNameElem );
474  styleElem.appendChild( styleTitleElem );
475  styleListElem.appendChild( styleElem );
476  layerElem.appendChild( styleListElem );
477  }
478  }
479  }
480 
481 } // namespace QgsWms
A helper class that centralizes restrictions given by all the access control filter plugins.
bool layerReadPermission(const QgsMapLayer *layer) const
Returns the layer read right.
This class represents a coordinate reference system (CRS).
QString authid() const
Returns the authority identifier for the CRS.
bool hasAxisInverted() const
Returns whether axis is inverted (e.g., for WMS 1.3) for the CRS.
Class for doing transforms between two map coordinate systems.
Custom exception class for Coordinate Reference System related exceptions.
Definition: qgsexception.h:66
Layer tree group node serves as a container for layers and further groups.
QString name() const override
Returns the group's name.
Layer tree node points to a map layer.
QgsMapLayer * layer() const
Returns the map layer associated with this node.
This class is a base class for nodes in a layer tree.
@ NodeGroup
Container of other groups and layers.
NodeType nodeType() const
Find out about type of the node. It is usually shorter to use convenience functions from QgsLayerTree...
QList< QgsLayerTreeNode * > children()
Gets list of children of the node. Children are owned by the parent.
bool itemVisibilityChecked() const
Returns whether a node is checked (independently of its ancestors or children)
Namespace with helper functions for layer tree operations.
Definition: qgslayertree.h:33
QStringList styles() const
Returns list of all defined style names.
Base class for all map layer types.
Definition: qgsmaplayer.h:73
QString name
Definition: qgsmaplayer.h:76
virtual QgsRectangle extent() const
Returns the extent of the layer.
QgsMapLayer::LayerFlags flags() const
Returns the flags for this layer.
QgsCoordinateReferenceSystem crs
Definition: qgsmaplayer.h:79
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
QString abstract() const
Returns the abstract of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:323
QString dataUrlFormat() const
Returns the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:377
QgsMapLayerServerProperties * serverProperties()
Returns QGIS Server Properties for the map layer.
Definition: qgsmaplayer.h:423
QString shortName() const
Returns the short name of the layer used by QGIS Server to identify the layer.
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:307
QString dataUrl() const
Returns the DataUrl of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:359
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
@ Identifiable
If the layer is identifiable using the identify map tool and as a WMS layer.
Definition: qgsmaplayer.h:142
double minimumScale() const
Returns the minimum map scale (i.e.
QgsMapLayerStyleManager * styleManager() const
Gets access to the layer's style manager.
double maximumScale() const
Returns the maximum map scale (i.e.
QString keywordList() const
Returns the keyword list of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:339
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition: qgsproject.h:101
QString baseName() const
Returns the base name of the project file without the path and without extension - derived from fileN...
Definition: qgsproject.cpp:709
QgsLayerTree * layerTreeRoot() const
Returns pointer to the root (invisible) node of the project's layer tree.
QgsCoordinateReferenceSystem crs
Definition: qgsproject.h:106
A rectangle specified with double values.
Definition: qgsrectangle.h:42
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
Definition: qgsrectangle.h:193
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
Definition: qgsrectangle.h:183
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
Definition: qgsrectangle.h:188
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
Definition: qgsrectangle.h:198
void combineExtentWith(const QgsRectangle &rect)
Expands the rectangle so that it covers both the original rectangle and the given rectangle.
Definition: qgsrectangle.h:391
bool isEmpty() const
Returns true if the rectangle is empty.
Definition: qgsrectangle.h:469
void invert()
Swap x/y coordinates in the rectangle.
Definition: qgsrectangle.h:575
A helper class that centralizes caches accesses given by all the server cache filter plugins.
bool setCachedDocument(const QDomDocument *doc, const QgsProject *project, const QgsServerRequest &request, QgsAccessControl *accessControl) const
Updates or inserts the document in cache like capabilities.
bool getCachedDocument(QDomDocument *doc, const QgsProject *project, const QgsServerRequest &request, QgsAccessControl *accessControl) const
Returns cached document (or 0 if document not in cache) like capabilities.
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins.
virtual QgsAccessControl * accessControls() const =0
Gets the registered access control filters.
virtual QgsServerCacheManager * cacheManager() const =0
Gets the registered server cache filters.
virtual QgsServerSettings * serverSettings()=0
Returns the server settings.
QList< QgsServerMetadataUrlProperties::MetadataUrl > metadataUrls() const
Returns a list of metadataUrl resources associated for the layer.
QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() m...
virtual void write(const QString &data)
Write string This is a convenient method that will write directly to the underlying I/O device.
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...
Class defining request interface passed to WMS service.
Definition: qgswmsrequest.h:35
SERVER_EXPORT bool wmsInfoFormatSia2045(const QgsProject &project)
Returns if the info format is SIA20145.
SERVER_EXPORT QgsRectangle wmsExtent(const QgsProject &project)
Returns the WMS Extent restriction.
SERVER_EXPORT bool wmsUseLayerIds(const QgsProject &project)
Returns if layer ids are used as name in WMS.
SERVER_EXPORT QStringList owsServiceKeywords(const QgsProject &project)
Returns the owsService keywords defined in project.
SERVER_EXPORT QStringList wmsRestrictedLayers(const QgsProject &project)
Returns the restricted layer name list.
SERVER_EXPORT QString owsServiceTitle(const QgsProject &project)
Returns the owsService title defined in project.
SERVER_EXPORT QString owsServiceAbstract(const QgsProject &project)
Returns the owsService abstract defined in project.
Median cut implementation.
void writeGetContext(QgsServerInterface *serverIface, const QgsProject *project, const QgsWmsRequest &request, QgsServerResponse &response)
Output GetContext response.
QDomDocument getContext(QgsServerInterface *serverIface, const QgsProject *project, const QgsWmsRequest &request)
Returns XML document for the 'GetContext' request.
QUrl serviceUrl(const QgsServerRequest &request, const QgsProject *project, const QgsServerSettings &settings)
Returns WMS service URL.
Definition: qgswmsutils.cpp:33