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