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