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