32using namespace Qt::StringLiterals;
39 const QDomDocument doc =
describeLayer( serverIface, project, request );
40 response.
setHeader( u
"Content-Type"_s, u
"text/xml; charset=utf-8"_s );
41 response.
write( doc.toByteArray() );
49 if ( !parameters.contains( u
"SLD_VERSION"_s ) )
51 throw QgsServiceException( u
"MissingParameterValue"_s, u
"SLD_VERSION is mandatory for DescribeLayer operation"_s, 400 );
53 if ( parameters[u
"SLD_VERSION"_s] !=
"1.1.0"_L1 )
55 throw QgsServiceException( u
"InvalidParameterValue"_s, u
"SLD_VERSION = %1 is not supported"_s.arg( parameters[u
"SLD_VERSION"_s] ), 400 );
58 if ( !parameters.contains( u
"LAYERS"_s ) && !parameters.contains( u
"LAYER"_s ) )
60 throw QgsServiceException( u
"MissingParameterValue"_s, u
"LAYERS or LAYER is mandatory for DescribeLayer operation"_s, 400 );
63 QStringList layersList;
65 if ( parameters.contains( u
"LAYERS"_s ) )
67 layersList = parameters[u
"LAYERS"_s].split(
',', Qt::SkipEmptyParts );
71 layersList = parameters[u
"LAYER"_s].split(
',', Qt::SkipEmptyParts );
73 if ( layersList.isEmpty() )
77 QDomDocument myDocument = QDomDocument();
79 const QDomNode header = myDocument.createProcessingInstruction( u
"xml"_s, u
"version=\"1.0\" encoding=\"UTF-8\""_s );
80 myDocument.appendChild( header );
83 QDomElement root = myDocument.createElementNS( u
"http://www.opengis.net/sld"_s, u
"DescribeLayerResponse"_s );
84 root.setAttribute( u
"xsi:schemaLocation"_s, u
"http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/DescribeLayer.xsd"_s );
85 root.setAttribute( u
"xmlns:ows"_s, u
"http://www.opengis.net/ows"_s );
86 root.setAttribute( u
"xmlns:se"_s, u
"http://www.opengis.net/se"_s );
87 root.setAttribute( u
"xmlns:xlink"_s, u
"http://www.w3.org/1999/xlink"_s );
88 root.setAttribute( u
"xmlns:xsi"_s, u
"http://www.w3.org/2001/XMLSchema-instance"_s );
89 myDocument.appendChild( root );
92 QDomElement versionNode = myDocument.createElement( u
"Version"_s );
93 versionNode.appendChild( myDocument.createTextNode( u
"1.1.0"_s ) );
94 root.appendChild( versionNode );
103 if ( wfsHrefString.isEmpty() )
105 wfsHrefString = wmsHrefString;
111 if ( wcsHrefString.isEmpty() )
113 wcsHrefString = wmsHrefString;
117#ifdef HAVE_SERVER_PYTHON_PLUGINS
120 ( void ) serverIface;
133 QString name = layer->name();
136 else if ( !layer->serverProperties()->shortName().isEmpty() )
137 name = layer->serverProperties()->shortName();
139 if ( !layersList.contains( name ) )
145 if ( restrictedLayers.contains( layer->name() ) )
150#ifdef HAVE_SERVER_PYTHON_PLUGINS
158 QDomElement layerNode = myDocument.createElement( u
"LayerDescription"_s );
159 root.appendChild( layerNode );
162 QDomElement typeNode = myDocument.createElement( u
"owsType"_s );
164 QDomElement oResNode = myDocument.createElement( u
"se:OnlineResource"_s );
165 oResNode.setAttribute( u
"xlink:type"_s, u
"simple"_s );
167 QDomElement nameNode = myDocument.createElement( u
"TypeName"_s );
168 switch ( layer->type() )
172 typeNode.appendChild( myDocument.createTextNode( u
"wfs"_s ) );
174 if ( wfsLayerIds.indexOf( layer->id() ) != -1 )
176 oResNode.setAttribute( u
"xlink:href"_s, wfsHrefString );
180 QDomElement typeNameNode = myDocument.createElement( u
"se:FeatureTypeName"_s );
181 typeNameNode.appendChild( myDocument.createTextNode( name ) );
182 nameNode.appendChild( typeNameNode );
187 typeNode.appendChild( myDocument.createTextNode( u
"wcs"_s ) );
189 if ( wcsLayerIds.indexOf( layer->id() ) != -1 )
191 oResNode.setAttribute( u
"xlink:href"_s, wcsHrefString );
195 QDomElement typeNameNode = myDocument.createElement( u
"se:CoverageTypeName"_s );
196 typeNameNode.appendChild( myDocument.createTextNode( name ) );
197 nameNode.appendChild( typeNameNode );
210 layerNode.appendChild( typeNode );
211 layerNode.appendChild( oResNode );
212 layerNode.appendChild( nameNode );
@ Group
Composite group layer. Added in QGIS 3.24.
@ Plugin
Plugin based layer.
@ TiledScene
Tiled scene layer. Added in QGIS 3.34.
@ Annotation
Contains freeform, georeferenced annotations. Added in QGIS 3.16.
@ VectorTile
Vector tile layer. Added in QGIS 3.14.
@ Mesh
Mesh layer. Added in QGIS 3.2.
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
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.
Base class for all map layer types.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
QMap< QString, QgsMapLayer * > mapLayers(const bool validOnly=false) const
Returns a map of all registered layers by layer ID.
Defines interfaces exposed by QGIS Server and made available to plugins.
virtual QgsAccessControl * accessControls() const =0
Gets the registered access control filters.
virtual QgsServerSettings * serverSettings()=0
Returns the server settings.
static QString wcsServiceUrl(const QgsProject &project, const QgsServerRequest &request=QgsServerRequest(), const QgsServerSettings &settings=QgsServerSettings())
Returns the WCS service url.
static bool wmsUseLayerIds(const QgsProject &project)
Returns if layer ids are used as name in WMS.
static QStringList wfsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WFS.
static QStringList wmsRestrictedLayers(const QgsProject &project)
Returns the restricted layer name list.
static QString wfsServiceUrl(const QgsProject &project, const QgsServerRequest &request=QgsServerRequest(), const QgsServerSettings &settings=QgsServerSettings())
Returns the WFS service url.
static QStringList wcsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WCS.
QgsServerRequest::Parameters parameters() const
Returns a map of query parameters with keys converted to uppercase.
QMap< QString, QString > Parameters
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...
Exception thrown when data access violates access controls.
Exception class for WMS service exceptions.
Defines request interfaces passed to WMS service.
Median cut implementation.
QDomDocument describeLayer(QgsServerInterface *serverIface, const QgsProject *project, const QgsWmsRequest &request)
DescribeLayer is defined for WMS1.1.1/SLD1.0 and in WMS 1.3.0 SLD Extension.
void writeDescribeLayer(QgsServerInterface *serverIface, const QgsProject *project, const QgsWmsRequest &request, QgsServerResponse &response)
Output GetMap response in DXF format.
QUrl serviceUrl(const QgsServerRequest &request, const QgsProject *project, const QgsServerSettings &settings)
Returns WMS service URL.