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